chiark / gitweb /
New --managed option for use when running under a daemon supervisor.
[secnet.git] / depend.sh
1 #!/bin/sh
2
3 # For more information see "Recursive Make Considered Harmful" at
4 # http://www.canb.auug.org.au/~millerp/rmch/recu-make-cons-harm.html
5
6 set -e
7 set -u
8
9 cutout="$1"
10 shift
11
12 # cutout may contain the character '.' which means a special thing to sed
13 # Escape all '.'s (i.e. '..' -> '\.\.')
14 cutout2="`echo ${cutout} | sed -e 's@\.@\\\.@g'`"
15
16 # We don't bother depending on system header files (which have names
17 # starting with '/'). We arrange for both the .o and the .d file to depend
18 # on the appropriate header files. We're using VPATH, so we turn pathnames
19 # of the form "${srcdir}/foo" into just "foo" (we expect srcdir to be
20 # passed as our first command line argument)
21 gcc -M -MG "$@" |
22 sed -e 's@ /[^ ]*@@g' -e 's@^\(.*\)\.o:@\1.d \1.o:@' -e "s@${cutout2}/@@g"