X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=depend.sh;fp=depend.sh;h=72fde4ba7e05ac9cee7c9c4b24a8856aebda8fb8;hb=d3fe100dfc120244d316e083ce87b1eb130fe4fd;hp=0000000000000000000000000000000000000000;hpb=794f2398b8fe84bf398bb10d6eeca6fe6737f65f;p=secnet.git diff --git a/depend.sh b/depend.sh new file mode 100755 index 0000000..72fde4b --- /dev/null +++ b/depend.sh @@ -0,0 +1,22 @@ +#!/bin/sh + +# For more information see "Recursive Make Considered Harmful" at +# http://www.canb.auug.org.au/~millerp/rmch/recu-make-cons-harm.html + +set -e +set -u + +cutout="$1" +shift + +# cutout may contain the character '.' which means a special thing to sed +# Escape all '.'s (i.e. '..' -> '\.\.') +cutout2="`echo ${cutout} | sed -e 's@\.@\\\.@g'`" + +# We don't bother depending on system header files (which have names +# starting with '/'). We arrange for both the .o and the .d file to depend +# on the appropriate header files. We're using VPATH, so we turn pathnames +# of the form "${srcdir}/foo" into just "foo" (we expect srcdir to be +# passed as our first command line argument) +gcc -M -MG "$@" | +sed -e 's@ /[^ ]*@@g' -e 's@^\(.*\)\.o:@\1.d \1.o:@' -e "s@${cutout2}/@@g"