Don't install progressbar suid.
[minix3.git] / lib / generate.sh
blob0d74f20f538b45fc475fbd7d0d2be320de2329cf
1 #!/bin/sh
2 # called with parameters: 1:dir 2:ackbase 3:gnubase
4 exec >Makefile
5 exec 3>Makedepend-ack
6 exec 4>Makedepend-gnu
7 touch .depend-ack
8 touch .depend-gnu
10 echo "#Generated from $1/Makefile.in"
12 ACKBASE=$2
13 GNUBASE=$3
14 OBJDIR=$1
16 RECURSIVE_TARGETS="clean depend depend-ack depend-gnu"
18 if [ -z $ACKBASE ]; then echo ACKBASE is not set!; exit 1; fi
19 if [ -z $GNUBASE ]; then echo GNUBASE is not set!; exit 1; fi
21 . Makefile.in
23 #to enable library debugging, enable the next line
24 #CFLAGS=$CFLAGS" -g"
26 echo "all: all-ack"
27 echo
28 echo "all-ack:"
29 echo "all-gnu:"
30 echo
31 echo "makefiles: Makefile"
32 echo "Makedepend-ack Makedepend-gnu: "
33 echo " sh $0 $OBJDIR $ACKBASE $GNUBASE"
34 echo
35 echo "Makefile: Makefile.in Makedepend-ack Makedepend-gnu"
36 echo " sh $0 $OBJDIR $ACKBASE $GNUBASE"
37 echo " @echo"
38 echo " @echo *Attention*"
39 echo " @echo Makefile is regenerated... rerun command to see changes"
40 echo " @echo *Attention*"
41 echo " @echo"
42 echo
43 if [ ! -z "$SUBDIRS" ]; then
44 echo "all-ack: makefiles"
45 for dir in $SUBDIRS
47 if [ $TYPE = "both" -o $TYPE = "ack" ]; then
48 echo " mkdir -p $ACKBASE/$OBJDIR/$dir"
50 echo " cd $dir && \$(MAKE) \$@"
52 echo
53 echo "all-gnu: makefiles"
54 for dir in $SUBDIRS
56 if [ $TYPE = "both" -o $TYPE = "gnu" ]; then
57 echo " mkdir -p $GNUBASE/$OBJDIR/$dir"
60 echo " cd $dir && \$(MAKE) \$@"
62 echo
63 echo "$RECURSIVE_TARGETS:: makefiles"
64 for dir in $SUBDIRS
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
73 echo " cd $dir && \$(MAKE) \$@"
75 echo
76 for dir in $SUBDIRS
78 echo "makefiles: $dir/Makefile"
80 echo
81 for dir in $SUBDIRS
83 echo "$dir/Makefile: $dir/Makefile.in"
84 echo " cd $dir && sh ../$0 $OBJDIR/$dir ../$ACKBASE ../$GNUBASE && \$(MAKE) makefiles"
86 else
88 echo "depend: depend-ack"
90 echo "depend-ack:" >&3
91 echo " rm .depend-ack" >&3
92 echo " touch .depend-ack" >&3
94 echo "depend-gnu:" >&4
95 echo " rm .depend-gnu" >&4
96 echo " touch .depend-gnu" >&4
98 ackCommands()
100 dstfile=$1
101 srcfile=$2
102 dstdir=`dirname $dstfile`
104 case $srcfile in
105 *.s | *.c | *.e )
106 echo " cc $CFLAGS -c -o $dstfile $srcfile"
108 echo " mkdep 'cc $CFLAGS -E' $srcfile | sed -e 's:^\(.\):$dstdir/\1:' >> .depend-ack" >&3
110 *.mod )
111 echo " m2 $M2FLAGS -c -o $dstfile $srcfile"
113 echo " mkdep 'm2 $M2FLAGS -E' $srcfile | sed -e 's:^\(.\):$dstdir/\1:' >> .depend-ack" >&3
115 *.fc )
116 echo " sh ./FP.compile $dstfile $srcfile"
118 echo " mkdep 'cc -E' $srcfile | sed -e 's:^\(.\):$dstdir/\1:' >> .depend-ack" >&3
120 esac
123 gnuCommands()
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:'"
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"
135 echo " mkdep 'gcc $CFLAGS -E -x assembler-with-cpp -I.' $srcfile | $sedcmd >> .depend-gnu" >&4
137 *.gs )
138 echo " gas -o $dstfile $srcfile"
140 echo " mkdep 'gcc $CFLAGS -E -x assembler-with-cpp -I.' $srcfile | $sedcmd >> .depend-gnu" >&4
142 *.c )
143 echo " gcc $CFLAGS -c -o $dstfile $srcfile"
145 echo " mkdep 'gcc $CFLAGS -E' $srcfile | $sedcmd >> .depend-gnu" >&4
147 #*.mod )
148 # echo " \$(M2C) -o $dstfile $srcfile"
149 # ;;
150 #*.fc )
151 # echo " sh ./FP.COMPILE $srcfile"
152 # ;;
153 esac
154 echo
157 #libraries
158 for lib in $LIBRARIES
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
166 o=`echo $f | sed -e 's/\\..*\$/\.o/'`
167 echo "$ACKBASE/$lib.a: $ACKBASE/$lib.a($o)"
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
176 o=`echo $f | sed -e 's/\\..*\$/\.o/'`
177 echo "$ACKBASE/$lib.a($o): $f"
179 ackCommands $ACKBASE/$OBJDIR/$o $f
181 echo
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
190 o=`echo $f | sed -e 's/\\..*\$/\.o/'`
191 echo "$GNUBASE/$lib.a: $GNUBASE/$OBJDIR/$o"
193 echo
194 echo "$GNUBASE/$lib.a:"
195 echo " gar cr $GNUBASE/$lib.a \$?"
196 echo
197 for f in $FILES
199 o=`echo $f | sed -e 's/\\..*\$/\.o/'`
201 echo "$GNUBASE/$OBJDIR/$o: $f"
203 gnuCommands $GNUBASE/$OBJDIR/$o $f
205 echo
208 echo
210 #start files
211 for f in $STARTFILES
213 o=`echo $f | sed -e 's/\\..*\$/\.o/'`
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
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
231 fi # elif of if [ -n "$SUBDIRS" ]
232 echo
233 echo "clean::"
234 if [ $TYPE = "both" -o $TYPE = "ack" ]; then
235 echo " rm -f $ACKBASE/$OBJDIR/*"
237 if [ $TYPE = "both" -o $TYPE = "gnu" ]; then
238 echo " rm -f $GNUBASE/$OBJDIR/*"
241 if [ $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"
252 echo
253 echo "include Makedepend-ack"
254 echo "include .depend-ack"
255 echo
256 echo "include Makedepend-gnu"
257 echo "include .depend-gnu"