1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68
|
#!/bin/sh
#require cc
#require cflags
#phase library
#phase init
#after init_cflags
case $PHASE in
library)
disp "Loading dependency helper function"
rm -f dependencies.log
customdeplist() {
for DEP in $1; do
JUNK=`$ECHO "$BUILTDEPS" | grep "$DEP"`
if test "$?" != "0"; then
# haven't built this one yet
BUILTDEPS="$BUILTDEPS $DEP"
CNAME=`echo "$DEP" | sed 's/\\.o\$/.c/'`
customdeps "$CNAME" "$DEP"
fi
done
}
customdeps() {
if test "$CC_DEPENDENCY" = "n"; then
return
fi
dispn "Generating customized build rule for $1..."
$ECHO "Generating dependencies with \"$CC $FM_CFLAGS -M $1\" (errors print below):" >> dependencies.log
$CC $FM_CFLAGS -M $1 2>>dependencies.log
if test "$?" != "0"; then
disp "unable to generate dependencies; this file probably won't build. Aborting (check dependencies.log for details)"
exit 1
fi
$ECHO >> dependencies.log
$ECHO " $CC $FM_CFLAGS -DCONFDIR=\"\\\"\$(CONFDIR)\\\"\" -DBINDIR=\"\\\"\$(BINDIR)\\\"\" -DSBINDIR=\"\\\"\$(SBINDIR)\\\"\" -DLIBDIR=\"\\\"\$(LIBDIR)\\\"\" -DMANDIR=\"\\\"\$(MANDIR)\\\"\" -c -o $2 $1"
$ECHO
disp "done"
}
;;
init)
dispn "Checking for compiler dependency support..."
$ECHO "#include <stdio.h>
int main() {
return 0;
}" > deptest.c
$ECHO "Testing \"$CC $FM_CFLAGS -M deptest.c\":" >> dependencies.log
DEPOUTPUT=`$CC $FM_CFLAGS -M deptest.c`
RESULT="$?"
$ECHO "Result is $RESULT" >> dependencies.log
$ECHO "Output is:
$DEPOUTPUT
" >> dependencies.log
if test "$RESULT" = "0"; then
JUNK=`$ECHO "$DEPOUTPUT" | grep stdio`
if test "$?" = "0"; then
disp "found"
CC_DEPENDENCY="y"
else
disp "found but broken, skipping"
CC_DEPENDENCY="n"
fi
else
disp "not found, skipping"
CC_DEPENDENCY="n"
fi
rm -f deptest.c
;;
esac
|