]> git.tuebingen.mpg.de Git - paraslash.git/blob - depend.sh
build: Introduce cmdlist_dir.
[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 four arguments to that script are special: $1 is the
8 # dependency directory and $2 is the object directory. These are used
9 # to prefix the .d and .o targets respectively. $3 is the directory
10 # that contains the *.cmdline.h files generated by gengetopt. Similarly,
11 # $4 is the command list directory which contains all files generated by
12 # the command_util script.
13
14 # As gcc outputs the dependencies on the *.cmdline.h files either as
15 # foo.cmdline.h or as $cmdline_dir/foo.cmdline.h, depending on whether the
16 # latter file exists, we prefix the former with $2/
17
18 dep_dir="$1"
19 object_dir="$2"
20 cmdline_dir="$3"
21 cmdlist_dir="$4"
22 shift
23 shift
24 shift
25 shift
26
27 LC_ALL=C cc -MM -MG "$@" \
28         | sed -e "s@^\(.*\)\.o:@$dep_dir/\1.d $object_dir/\1.o:@" \
29         -e "s@[         ^]\([a-zA-Z0-9_]\{1,\}\.cmdline.h\)@ $cmdline_dir/\1@g" \
30         -e "s@[         ^]\([a-zA-Z0-9_]\{1,\}\.command_list.h\)@ $cmdlist_dir/\1@g" \
31         -e "s@[         ^]\([a-zA-Z0-9_]\{1,\}\.completion.h\)@ $cmdlist_dir/\1@g"