udp: transition to use sender_client 'name' field
[paraslash.git] / depend.sh
1 #!/bin/sh
2
3 # Call gcc to output a rule suitable for make describing the dependencies of
4 # the given input file and parse the output to add a *.d target with the same
5 # dependencies.
6
7 # The first two arguments to that script are special: $1 is the object
8 # directory. This string is prefixed to both the .o and the .d target. $2 is
9 # the directory that contains the *.cmdline.h files generated by gengetopt.
10
11 # As gcc outputs the dependencies on the *.cmdline.h files either as either
12 # foo.cmdline.h or as $cmdline_dir/foo,cmdline.h, depending on whether the
13 # latter file exists, we prefix the former with $2/
14
15 object_dir="$1"
16 cmdline_dir="$2"
17 shift
18 shift
19
20 LC_ALL=C gcc -MM -MG "$@" \
21         | sed -e "s@^\(.*\)\.o:@$object_dir/\1.d $object_dir/\1.o:@" \
22         -e "s@[         ^]\([a-zA-Z0-9_]\+\.cmdline.h\)@ $cmdline_dir/\1@g"