]> git.ipfire.org Git - thirdparty/gcc.git/blob - gcc/m2/tools-src/makeSystem
Update copyright years.
[thirdparty/gcc.git] / gcc / m2 / tools-src / makeSystem
1 #!/bin/sh
2
3 # makeSystem creates a target SYSTEM.def using the appropriate dialect template.
4
5 # Copyright (C) 2008-2024 Free Software Foundation, Inc.
6 # Contributed by Gaius Mulley <gaius.mulley@southwales.ac.uk>.
7 #
8 # This file is part of GNU Modula-2.
9 #
10 # GNU Modula-2 is free software; you can redistribute it and/or modify it under
11 # the terms of the GNU General Public License as published by the Free
12 # Software Foundation; either version 3, or (at your option) any later
13 # version.
14 #
15 # GNU Modula-2 is distributed in the hope that it will be useful, but WITHOUT ANY
16 # WARRANTY; without even the implied warranty of MERCHANTABILITY or
17 # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
18 # for more details.
19 #
20 # You should have received a copy of the GNU General Public License along
21 # with gm2; see the file COPYING. If not, write to the Free Software
22 # Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *)
23
24
25 Usage () {
26 echo "Usage: makesystem dialectflag SYSTEM.def SYSTEM.mod { librarypath } compiler"
27 }
28
29 if [ $# -lt 6 ] ; then
30 Usage
31 exit 1
32 fi
33
34 DIALECT=$1
35 SYSTEMDEF=$2
36 SYSTEMMOD=$3
37 shift 3
38 LIBRARY=""
39 while [ $# -gt 2 ] ; do
40 if [ "$LIBRARY" = "" ] ; then
41 LIBRARY=$1
42 else
43 LIBRARY="${LIBRARY} $1"
44 fi
45 shift
46 done
47 COMPILER=$1
48 OUTPUTFILE=$2
49
50 if [ "$COMPILER" = "" ] ; then
51 echo "parameter 5 of makeSystem is incorrect, GM2_FOR_TARGET was unset"
52 exit 1
53 fi
54
55 if [ "$DIALECT" != "-fiso" -a "$DIALECT" != "-fpim" ] ; then
56 Usage
57 echo "dialect must be -fiso or -fpim"
58 exit 1
59 fi
60
61 displayExportedTypes () {
62 n=1
63 c=0
64 for i in ${types} ; do
65 if [ $n -eq 1 ] ; then
66 n=0
67 echo -n " " >> ${OUTPUTFILE}
68 fi
69 echo -n "$i, " >> ${OUTPUTFILE}
70 if [ $c -eq 4 ] ; then
71 echo " " >> ${OUTPUTFILE}
72 n=1
73 c=0
74 fi
75 c=`expr $c + 1`
76 done
77 echo " " >> ${OUTPUTFILE}
78 }
79
80 displayBuiltinTypes () {
81 for i in ${types} ; do
82 echo " $i ; " >> ${OUTPUTFILE}
83 done
84 }
85
86 displayStart () {
87 sed -e "1,/@SYSTEM_DATATYPES@/!d" < ${SYSTEMDEF} | \
88 sed -e "/@SYSTEM_DATATYPES@/d" >> ${OUTPUTFILE}
89 }
90
91 displayMiddle () {
92 sed -e "1,/@SYSTEM_DATATYPES@/d" < ${SYSTEMDEF} | \
93 sed -e "1,/@SYSTEM_TYPES@/!d" | \
94 sed -e "/@SYSTEM_TYPES@/d" >> ${OUTPUTFILE}
95 }
96
97 displayEnd () {
98 sed -e "1,/@SYSTEM_TYPES@/d" < ${SYSTEMDEF} >> ${OUTPUTFILE}
99 }
100
101 MINIMAL="-fno-scaffold-main -fno-scaffold-dynamic -fno-scaffold-static -fno-m2-plugin"
102
103 rm -f ${OUTPUTFILE}
104 if ${COMPILER} ${DIALECT} ${LIBRARY} ${MINIMAL} \
105 -S -fdump-system-exports ${SYSTEMMOD} -o /dev/null 2>&1 > /dev/null ; then
106 types=`${COMPILER} ${DIALECT} ${LIBRARY} ${MINIMAL} -fno-m2-plugin -S -fdump-system-exports ${SYSTEMMOD} -o /dev/null | cut -f5 -d' '`
107 touch ${OUTPUTFILE}
108 displayStart
109 displayExportedTypes
110 displayMiddle
111 displayBuiltinTypes
112 displayEnd
113 else
114 ${COMPILER} ${DIALECT} ${LIBRARY} ${MINIMAL} \
115 -S -fdump-system-exports ${SYSTEMMOD} -o /dev/null
116 exit $?
117 fi