[9] | 1 | #!/bin/sh
|
---|
| 2 | # called with parameters: 1:dir 2:ackbase 3:gnubase
|
---|
| 3 |
|
---|
| 4 | exec >Makefile
|
---|
| 5 | exec 3>Makedepend-ack
|
---|
| 6 | exec 4>Makedepend-gnu
|
---|
| 7 | touch .depend-ack
|
---|
| 8 | touch .depend-gnu
|
---|
| 9 |
|
---|
| 10 | echo "#Generated from $1/Makefile.in"
|
---|
| 11 |
|
---|
| 12 | ACKBASE=$2
|
---|
| 13 | GNUBASE=$3
|
---|
| 14 | OBJDIR=$1
|
---|
| 15 |
|
---|
| 16 | RECURSIVE_TARGETS="clean depend depend-ack depend-gnu"
|
---|
| 17 |
|
---|
| 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
|
---|
| 20 |
|
---|
| 21 | . Makefile.in
|
---|
| 22 |
|
---|
| 23 | #to enable library debugging, enable the next line
|
---|
| 24 | #CFLAGS=$CFLAGS" -g"
|
---|
| 25 |
|
---|
| 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
|
---|
| 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 | }
|
---|
| 86 | else
|
---|
| 87 |
|
---|
| 88 | echo "depend: depend-ack"
|
---|
| 89 |
|
---|
| 90 | echo "depend-ack:" >&3
|
---|
| 91 | echo " rm .depend-ack" >&3
|
---|
| 92 | echo " touch .depend-ack" >&3
|
---|
| 93 |
|
---|
| 94 | echo "depend-gnu:" >&4
|
---|
| 95 | echo " rm .depend-gnu" >&4
|
---|
| 96 | echo " touch .depend-gnu" >&4
|
---|
| 97 |
|
---|
| 98 | ackCommands()
|
---|
| 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 |
|
---|
| 123 | gnuCommands()
|
---|
| 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
|
---|
| 158 | for 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 | }
|
---|
| 208 | echo
|
---|
| 209 |
|
---|
| 210 | #start files
|
---|
| 211 | for 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 |
|
---|
| 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/*"
|
---|
| 236 | fi
|
---|
| 237 | if [ $TYPE = "both" -o $TYPE = "gnu" ]; then
|
---|
| 238 | echo " rm -f $GNUBASE/$OBJDIR/*"
|
---|
| 239 | fi
|
---|
| 240 |
|
---|
| 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"
|
---|
| 250 | fi
|
---|
| 251 |
|
---|
| 252 | echo
|
---|
| 253 | echo "include Makedepend-ack"
|
---|
| 254 | echo "include .depend-ack"
|
---|
| 255 | echo
|
---|
| 256 | echo "include Makedepend-gnu"
|
---|
| 257 | echo "include .depend-gnu"
|
---|