]> git.tuebingen.mpg.de Git - paraslash.git/commitdiff
Avoid unnecessary regeneration of dependencies.
authorAndre Noll <maan@systemlinux.org>
Sat, 19 Dec 2009 00:19:18 +0000 (01:19 +0100)
committerAndre Noll <maan@systemlinux.org>
Sat, 19 Dec 2009 00:19:18 +0000 (01:19 +0100)
Change depend.sh so that it can handles foo.cmdline.h and cmdline/foo.cmdline.h
dependencies correctly. This way we no longer need to depend on $(cmdline_generated).

Makefile.in
depend.sh

index 72f59eaedc98df0d973a4ae81cd92e5af2fdc05b..e4a3dd3f068f72bf2ff8655e5c8a482f87c68dc7 100644 (file)
@@ -188,16 +188,13 @@ $(object_dir)/%.o: %.c | $(object_dir)
        @[ -z "$(Q)" ] || echo 'CC $<'
        $(Q) $(CC) -c -o $@ $(CPPFLAGS) $(DEBUG_CPPFLAGS) $<
 
-# We depend on the *.cmdline.[ch] files as these must be present for depend.sh
-# to work. The first dependency is explititly given as it is used by $<.
-
-$(object_dir)/%.cmdline.d: %.cmdline.c $(cmdline_generated) | $(object_dir)
+$(object_dir)/%.cmdline.d: $(cmdline_dir)/%.cmdline.c | $(object_dir)
        @[ -z "$(Q)" ] || echo 'DEP $<'
-       $(Q) ./depend.sh $(object_dir) $(CPPFLAGS) $< > $@
+       $(Q) ./depend.sh $(object_dir) $(cmdline_dir) $(CPPFLAGS) $< > $@
 
-$(object_dir)/%.d: %.c $(cmdline_generated) | $(object_dir)
+$(object_dir)/%.d: %.c | $(object_dir)
        @[ -z "$(Q)" ] || echo 'DEP $<'
-       $(Q) ./depend.sh  $(object_dir) $(CPPFLAGS) $< > $@
+       $(Q) ./depend.sh $(object_dir) $(cmdline_dir) $(CPPFLAGS) $< > $@
 
 recv_objs := $(addprefix $(object_dir)/, @recv_objs@)
 filter_objs := $(addprefix $(object_dir)/, @filter_objs@)
index db32f6c6ab834c88dceba94cdc2dd37fd6cfcb87..aad45a3c8d4ff8f6882893683fd8763ac4970c9f 100755 (executable)
--- a/depend.sh
+++ b/depend.sh
@@ -1,4 +1,22 @@
 #!/bin/sh
-dir="$1"
+
+# Call gcc to output a rule suitable for make describing the dependencies of
+# the given input file and parse the output to add a *.d target with the same
+# dependencies.
+
+# The first two arguments to that script are special: $1 is the object
+# directory. This string is prefixed to both the .o and the .d target. $2 is
+# the directory that contains the *.cmdline.h files generated by gengetopt.
+
+# As gcc outputs the dependencies on the *.cmdline.h files either as either
+# foo.cmdline.h or as $cmdline_dir/foo,cmdline.h, depending on whether the
+# latter file exists, we prefix the former with $2/
+
+object_dir="$1"
+cmdline_dir="$2"
 shift
-gcc -MM -MG "$@" | sed -e "s@^\(.*\)\.o:@$dir/\1.d $dir/\1.o:@"
+shift
+
+LC_ALL=C gcc -MM -MG "$@" \
+       | sed -e "s@^\(.*\)\.o:@$object_dir/\1.d $object_dir/\1.o:@" \
+       -e "s@[         ^]\([a-zA-Z0-9_]\+\.cmdline.h\)@ $cmdline_dir/\1@g"