vfs/mount/rs/service changes:
[minix3.git] / lib / generate.sh
blobf520a32e78afd1c17490ab14a85bf083e7bcc331
1 #!/bin/sh
2 # called with parameters: 1:dir 2:ackbase 3:gnubase
4 set -e
6 . /etc/make.conf
8 exec >Makefile
9 exec 3>Makedepend-ack
10 exec 4>Makedepend-gnu
11 touch .depend-ack
12 touch .depend-gnu
14 echo "#Generated from $1/Makefile.in"
16 ACKBASE=$2
17 GNUBASE=$3
18 OBJDIR=$1
20 RECURSIVE_TARGETS="clean depend depend-ack depend-gnu"
22 if [ -z $ACKBASE ]; then echo ACKBASE is not set!; exit 1; fi
23 if [ -z $GNUBASE ]; then echo GNUBASE is not set!; exit 1; fi
25 . Makefile.in
27 #to enable library debugging, enable the next line
28 #CFLAGS=$CFLAGS" -g"
30 echo "all: all-ack"
31 echo
32 echo "all-ack:"
33 echo "all-gnu:"
34 echo
35 echo "makefiles: Makefile"
36 echo "Makedepend-ack Makedepend-gnu: "
37 echo " sh $0 $OBJDIR $ACKBASE $GNUBASE"
38 echo
39 echo "Makefile: Makefile.in Makedepend-ack Makedepend-gnu"
40 echo " sh $0 $OBJDIR $ACKBASE $GNUBASE"
41 echo " @echo"
42 echo " @echo *Attention*"
43 echo " @echo Makefile is regenerated... rerun command to see changes"
44 echo " @echo *Attention*"
45 echo " @echo"
46 echo
47 if [ ! -z "$SUBDIRS" ]; then
48 echo "all-ack: makefiles"
49 for dir in $SUBDIRS
51 if [ $TYPE = "both" -o $TYPE = "ack" ]; then
52 echo " mkdir -p $ACKBASE/$OBJDIR/$dir"
54 echo " cd $dir && \$(MAKE) \$@"
56 echo
57 echo "all-gnu: makefiles"
58 for dir in $SUBDIRS
60 if [ $TYPE = "both" -o $TYPE = "gnu" ]; then
61 echo " mkdir -p $GNUBASE/$OBJDIR/$dir"
64 echo " cd $dir && \$(MAKE) \$@"
66 echo
67 echo "$RECURSIVE_TARGETS:: makefiles"
68 for dir in $SUBDIRS
70 #if [ $TYPE = "both" -o $TYPE = "ack" ]; then
71 #echo " mkdir -p $ACKBASE/$OBJDIR/$dir"
72 #fi
73 #if [ $TYPE = "both" -o $TYPE = "gnu" ]; then
74 #echo " mkdir -p $GNUBASE/$OBJDIR/$dir"
75 #fi
77 echo " cd $dir && \$(MAKE) \$@"
79 echo
80 for dir in $SUBDIRS
82 echo "makefiles: $dir/Makefile"
84 echo
85 for dir in $SUBDIRS
87 echo "$dir/Makefile: $dir/Makefile.in"
88 echo " cd $dir && sh ../$0 $OBJDIR/$dir ../$ACKBASE ../$GNUBASE && \$(MAKE) makefiles"
90 else
92 echo "depend: depend-ack"
94 echo "depend-ack:" >&3
95 echo " rm .depend-ack" >&3
96 echo " touch .depend-ack" >&3
98 echo "depend-gnu:" >&4
99 echo " rm .depend-gnu" >&4
100 echo " touch .depend-gnu" >&4
102 ackCommands()
104 dstfile=$1
105 srcfile=$2
106 dstdir=`dirname $dstfile`
108 case $srcfile in
109 *.s | *.c | *.e )
110 echo " cc $CFLAGS -c -o $dstfile $srcfile"
112 echo " mkdep 'cc $CFLAGS -E' $srcfile | sed -e 's:^\(.\):$dstdir/\1:' >> .depend-ack" >&3
114 *.mod )
115 echo " m2 $M2FLAGS -c -o $dstfile $srcfile"
117 echo " mkdep 'm2 $M2FLAGS -E' $srcfile | sed -e 's:^\(.\):$dstdir/\1:' >> .depend-ack" >&3
119 *.fc )
120 echo " sh ./FP.compile $dstfile $srcfile"
122 echo " mkdep 'cc -E' $srcfile | sed -e 's:^\(.\):$dstdir/\1:' >> .depend-ack" >&3
124 esac
127 gnuCommands()
129 dstfile=$1
130 srcfile=$2
131 dstdir=`dirname $dstfile`
132 sedcmd="sed -e '/<built-in>/d' -e '/<command line>/d' -e 's:^\(.\):$dstdir/\1:'"
134 case $srcfile in
135 *.s )
136 echo " gcc $CFLAGS -E -x assembler-with-cpp -I. $srcfile | asmconv -mi386 ack gnu > $GNUBASE/$OBJDIR/$srcfile.gnu || true"
137 echo " gas -o $dstfile $GNUBASE/$OBJDIR/$srcfile.gnu"
139 echo " mkdep 'gcc $CFLAGS -E -x assembler-with-cpp -I.' $srcfile | $sedcmd >> .depend-gnu" >&4
141 *.gs )
142 echo " gas -o $dstfile $srcfile"
144 echo " mkdep 'gcc $CFLAGS -E -x assembler-with-cpp -I.' $srcfile | $sedcmd >> .depend-gnu" >&4
146 *.c )
147 echo " gcc $CFLAGS -c -o $dstfile $srcfile"
149 echo " mkdep 'gcc $CFLAGS -E' $srcfile | $sedcmd >> .depend-gnu" >&4
151 #*.mod )
152 # echo " \$(M2C) -o $dstfile $srcfile"
153 # ;;
154 #*.fc )
155 # echo " sh ./FP.COMPILE $srcfile"
156 # ;;
157 esac
158 echo
161 #libraries
162 for lib in $LIBRARIES
164 if [ $TYPE = "both" -o $TYPE = "ack" ]; then
165 echo "all-ack: $ACKBASE/$lib.a"
166 eval "FILES=\$${lib}_FILES"
167 echo
168 for f in $FILES
170 o=`echo $f | sed -e 's/\\..*\$/\.o/'`
171 echo "$ACKBASE/$lib.a: $ACKBASE/$lib.a($o)"
173 echo
174 echo "$ACKBASE/$lib.a:"
175 echo " ar cr $ACKBASE/$lib.a $ACKBASE/$OBJDIR/*.o"
176 echo " rm $ACKBASE/$OBJDIR/*.o"
177 echo
178 for f in $FILES
180 o=`echo $f | sed -e 's/\\..*\$/\.o/'`
181 echo "$ACKBASE/$lib.a($o): $f"
183 ackCommands $ACKBASE/$OBJDIR/$o $f
185 echo
188 if [ $TYPE = "both" -o $TYPE = "gnu" ]; then
189 echo "all-gnu: $GNUBASE/$lib.a"
190 eval "FILES=\$${lib}_FILES"
191 echo
192 for f in $FILES
194 o=`echo $f | sed -e 's/\\..*\$/\.o/'`
195 echo "$GNUBASE/$lib.a: $GNUBASE/$OBJDIR/$o"
197 echo
198 echo "$GNUBASE/$lib.a:"
199 echo " gar cr $GNUBASE/$lib.a \$?"
200 echo
201 for f in $FILES
203 o=`echo $f | sed -e 's/\\..*\$/\.o/'`
205 echo "$GNUBASE/$OBJDIR/$o: $f"
207 gnuCommands $GNUBASE/$OBJDIR/$o $f
209 echo
212 echo
214 #start files
215 for f in $STARTFILES
217 o=`echo $f | sed -e 's/\\..*\$/\.o/'`
219 if [ $TYPE = "both" -o $TYPE = "ack" ]; then
220 echo "all-ack: $ACKBASE/$o"
221 echo
222 echo "$ACKBASE/$o: $f"
223 ackCommands $ACKBASE/$o $f
224 echo
226 if [ $TYPE = "both" -o $TYPE = "gnu" ]; then
227 echo "all-gnu: $GNUBASE/$o"
228 echo
229 echo "$GNUBASE/$o: $f"
230 gnuCommands $GNUBASE/$o $f
231 echo
235 fi # elif of if [ -n "$SUBDIRS" ]
236 echo
237 echo "clean::"
238 if [ $TYPE = "both" -o $TYPE = "ack" ]; then
239 echo " rm -f $ACKBASE/$OBJDIR/*"
241 if [ $TYPE = "both" -o $TYPE = "gnu" ]; then
242 echo " rm -f $GNUBASE/$OBJDIR/*"
245 if [ $OBJDIR = "." ]; then
246 echo
247 echo "install: install-ack"
248 echo
249 echo "install-ack: all-ack"
250 # $ARCH is from /etc/make.conf
251 echo " cp $ACKBASE/*.[ao] /usr/lib/$ARCH"
252 echo
253 echo "install-gnu: all-gnu"
254 echo " cp $GNUBASE/*.[ao] /usr/gnu/lib"
257 echo
258 echo "include Makedepend-ack"
259 echo "include .depend-ack"
260 echo
261 echo "include Makedepend-gnu"
262 echo "include .depend-gnu"