]> git.tuebingen.mpg.de Git - paraslash.git/commitdiff
build: Fix m4 dependencies for BSD m4.
authorAndre Noll <maan@tuebingen.mpg.de>
Sat, 17 Oct 2015 14:47:01 +0000 (16:47 +0200)
committerAndre Noll <maan@tuebingen.mpg.de>
Sat, 24 Oct 2015 08:35:16 +0000 (10:35 +0200)
FreeBSD and NetBSD ship an m4 version which does not understand
the --debug=i option which we use to generate the .m4d dependency
files. This results in empty dependency files on those systems.

This was broken since m4 dependencies were introduced two years ago
in commit e249d105 (Generate ggo dependencies automatically). The
bug went unnoticed for so long because the problematic m4 command
is the first command of a pipeline (hence the exit code is lost),
and because the command redirects stderr, so the error message is
not printed to the terminal.

This commit fixes the bug by using the  (portable) -s option of
m4 rather than --debug. The -s option outputs line synchronization
directives which include the file name, so it is equally well suited
for generating the dependency files.

m4/gengetopt/makefile

index af90d5bd68cc70d520dbb87fb331ac0ba3f7e317..5130ddd1d7779790250ac52eb2e263503a1002c7 100644 (file)
@@ -18,9 +18,9 @@ endif
 
 $(m4depdir)/%.m4d: $(m4_ggo_dir)/%.m4 | $(m4depdir)
        @[ -z "$(Q)" ] || echo 'M4D $<'
-       $(Q) m4 -I $(m4_ggo_dir) --debug=i $< 3>&1 1>/dev/null 2>&3 \
-               | awk '{if ($$0 ~ "^m4debug: input read from ") \
-               print "$(ggo_dir)/$(*F).ggo: " $$NF}' > $@
+       $(Q) m4 -I $(m4_ggo_dir) -s $< \
+       | awk '{if ($$1 ~ /#line/) {gsub(/"/, "", $$3); if ($$3 != "$<") \
+       print "$(ggo_dir)/$(*F).ggo: " $$3}}' | sort | uniq > $@
 
 $(ggo_dir)/%.ggo: $(m4_ggo_dir)/%.m4 $(m4_ggo_dir)/header.m4 | $(ggo_dir)
        @[ -z "$(Q)" ] || echo 'M4 $<'