source: trunk/minix/lib/generate.sh@ 12

Last change on this file since 12 was 9, checked in by Mattia Monga, 14 years ago

Minix 3.1.2a

File size: 5.3 KB
RevLine 
[9]1#!/bin/sh
2# called with parameters: 1:dir 2:ackbase 3:gnubase
3
4exec >Makefile
5exec 3>Makedepend-ack
6exec 4>Makedepend-gnu
7touch .depend-ack
8touch .depend-gnu
9
10echo "#Generated from $1/Makefile.in"
11
12ACKBASE=$2
13GNUBASE=$3
14OBJDIR=$1
15
16RECURSIVE_TARGETS="clean depend depend-ack depend-gnu"
17
18if [ -z $ACKBASE ]; then echo ACKBASE is not set!; exit 1; fi
19if [ -z $GNUBASE ]; then echo GNUBASE is not set!; exit 1; fi
20
21. Makefile.in
22
23#to enable library debugging, enable the next line
24#CFLAGS=$CFLAGS" -g"
25
26echo "all: all-ack"
27echo
28echo "all-ack:"
29echo "all-gnu:"
30echo
31echo "makefiles: Makefile"
32echo "Makedepend-ack Makedepend-gnu: "
33echo " sh $0 $OBJDIR $ACKBASE $GNUBASE"
34echo
35echo "Makefile: Makefile.in Makedepend-ack Makedepend-gnu"
36echo " sh $0 $OBJDIR $ACKBASE $GNUBASE"
37echo " @echo"
38echo " @echo *Attention*"
39echo " @echo Makefile is regenerated... rerun command to see changes"
40echo " @echo *Attention*"
41echo " @echo"
42echo
43if [ ! -z "$SUBDIRS" ]; then
44 echo "all-ack: makefiles"
45 for dir in $SUBDIRS
46 {
47 if [ $TYPE = "both" -o $TYPE = "ack" ]; then
48 echo " mkdir -p $ACKBASE/$OBJDIR/$dir"
49 fi
50 echo " cd $dir && \$(MAKE) \$@"
51 }
52 echo
53 echo "all-gnu: makefiles"
54 for dir in $SUBDIRS
55 {
56 if [ $TYPE = "both" -o $TYPE = "gnu" ]; then
57 echo " mkdir -p $GNUBASE/$OBJDIR/$dir"
58 fi
59
60 echo " cd $dir && \$(MAKE) \$@"
61 }
62 echo
63 echo "$RECURSIVE_TARGETS:: makefiles"
64 for dir in $SUBDIRS
65 {
66 #if [ $TYPE = "both" -o $TYPE = "ack" ]; then
67 #echo " mkdir -p $ACKBASE/$OBJDIR/$dir"
68 #fi
69 #if [ $TYPE = "both" -o $TYPE = "gnu" ]; then
70 #echo " mkdir -p $GNUBASE/$OBJDIR/$dir"
71 #fi
72
73 echo " cd $dir && \$(MAKE) \$@"
74 }
75 echo
76 for dir in $SUBDIRS
77 {
78 echo "makefiles: $dir/Makefile"
79 }
80 echo
81 for dir in $SUBDIRS
82 {
83 echo "$dir/Makefile: $dir/Makefile.in"
84 echo " cd $dir && sh ../$0 $OBJDIR/$dir ../$ACKBASE ../$GNUBASE && \$(MAKE) makefiles"
85 }
86else
87
88echo "depend: depend-ack"
89
90echo "depend-ack:" >&3
91echo " rm .depend-ack" >&3
92echo " touch .depend-ack" >&3
93
94echo "depend-gnu:" >&4
95echo " rm .depend-gnu" >&4
96echo " touch .depend-gnu" >&4
97
98ackCommands()
99{
100 dstfile=$1
101 srcfile=$2
102 dstdir=`dirname $dstfile`
103
104 case $srcfile in
105 *.s | *.c | *.e )
106 echo " cc $CFLAGS -c -o $dstfile $srcfile"
107
108 echo " mkdep 'cc $CFLAGS -E' $srcfile | sed -e 's:^\(.\):$dstdir/\1:' >> .depend-ack" >&3
109 ;;
110 *.mod )
111 echo " m2 $M2FLAGS -c -o $dstfile $srcfile"
112
113 echo " mkdep 'm2 $M2FLAGS -E' $srcfile | sed -e 's:^\(.\):$dstdir/\1:' >> .depend-ack" >&3
114 ;;
115 *.fc )
116 echo " sh ./FP.compile $dstfile $srcfile"
117
118 echo " mkdep 'cc -E' $srcfile | sed -e 's:^\(.\):$dstdir/\1:' >> .depend-ack" >&3
119 ;;
120 esac
121}
122
123gnuCommands()
124{
125 dstfile=$1
126 srcfile=$2
127 dstdir=`dirname $dstfile`
128 sedcmd="sed -e '/<built-in>/d' -e '/<command line>/d' -e 's:^\(.\):$dstdir/\1:'"
129
130 case $srcfile in
131 *.s )
132 echo " gcc $CFLAGS -E -x assembler-with-cpp -I. $srcfile | asmconv -mi386 ack gnu > $GNUBASE/$OBJDIR/$srcfile.gnu || true"
133 echo " gas -o $dstfile $GNUBASE/$OBJDIR/$srcfile.gnu"
134
135 echo " mkdep 'gcc $CFLAGS -E -x assembler-with-cpp -I.' $srcfile | $sedcmd >> .depend-gnu" >&4
136 ;;
137 *.gs )
138 echo " gas -o $dstfile $srcfile"
139
140 echo " mkdep 'gcc $CFLAGS -E -x assembler-with-cpp -I.' $srcfile | $sedcmd >> .depend-gnu" >&4
141 ;;
142 *.c )
143 echo " gcc $CFLAGS -c -o $dstfile $srcfile"
144
145 echo " mkdep 'gcc $CFLAGS -E' $srcfile | $sedcmd >> .depend-gnu" >&4
146 ;;
147 #*.mod )
148 # echo " \$(M2C) -o $dstfile $srcfile"
149 # ;;
150 #*.fc )
151 # echo " sh ./FP.COMPILE $srcfile"
152 # ;;
153 esac
154 echo
155}
156
157#libraries
158for lib in $LIBRARIES
159{
160 if [ $TYPE = "both" -o $TYPE = "ack" ]; then
161 echo "all-ack: $ACKBASE/$lib.a"
162 eval "FILES=\$${lib}_FILES"
163 echo
164 for f in $FILES
165 {
166 o=`echo $f | sed -e 's/\\..*\$/\.o/'`
167 echo "$ACKBASE/$lib.a: $ACKBASE/$lib.a($o)"
168 }
169 echo
170 echo "$ACKBASE/$lib.a:"
171 echo " ar cr $ACKBASE/$lib.a $ACKBASE/$OBJDIR/*.o"
172 echo " rm $ACKBASE/$OBJDIR/*.o"
173 echo
174 for f in $FILES
175 {
176 o=`echo $f | sed -e 's/\\..*\$/\.o/'`
177 echo "$ACKBASE/$lib.a($o): $f"
178
179 ackCommands $ACKBASE/$OBJDIR/$o $f
180 }
181 echo
182 fi
183
184 if [ $TYPE = "both" -o $TYPE = "gnu" ]; then
185 echo "all-gnu: $GNUBASE/$lib.a"
186 eval "FILES=\$${lib}_FILES"
187 echo
188 for f in $FILES
189 {
190 o=`echo $f | sed -e 's/\\..*\$/\.o/'`
191 echo "$GNUBASE/$lib.a: $GNUBASE/$OBJDIR/$o"
192 }
193 echo
194 echo "$GNUBASE/$lib.a:"
195 echo " gar cr $GNUBASE/$lib.a \$?"
196 echo
197 for f in $FILES
198 {
199 o=`echo $f | sed -e 's/\\..*\$/\.o/'`
200
201 echo "$GNUBASE/$OBJDIR/$o: $f"
202
203 gnuCommands $GNUBASE/$OBJDIR/$o $f
204 }
205 echo
206 fi
207}
208echo
209
210#start files
211for f in $STARTFILES
212{
213 o=`echo $f | sed -e 's/\\..*\$/\.o/'`
214
215 if [ $TYPE = "both" -o $TYPE = "ack" ]; then
216 echo "all-ack: $ACKBASE/$o"
217 echo
218 echo "$ACKBASE/$o: $f"
219 ackCommands $ACKBASE/$o $f
220 echo
221 fi
222 if [ $TYPE = "both" -o $TYPE = "gnu" ]; then
223 echo "all-gnu: $GNUBASE/$o"
224 echo
225 echo "$GNUBASE/$o: $f"
226 gnuCommands $GNUBASE/$o $f
227 echo
228 fi
229}
230
231fi # elif of if [ -n "$SUBDIRS" ]
232echo
233echo "clean::"
234if [ $TYPE = "both" -o $TYPE = "ack" ]; then
235 echo " rm -f $ACKBASE/$OBJDIR/*"
236fi
237if [ $TYPE = "both" -o $TYPE = "gnu" ]; then
238 echo " rm -f $GNUBASE/$OBJDIR/*"
239fi
240
241if [ $OBJDIR = "." ]; then
242 echo
243 echo "install: install-ack"
244 echo
245 echo "install-ack: all-ack"
246 echo " cp $ACKBASE/*.[ao] /usr/lib/i386"
247 echo
248 echo "install-gnu: all-gnu"
249 echo " cp $GNUBASE/*.[ao] /usr/gnu/lib"
250fi
251
252echo
253echo "include Makedepend-ack"
254echo "include .depend-ack"
255echo
256echo "include Makedepend-gnu"
257echo "include .depend-gnu"
Note: See TracBrowser for help on using the repository browser.