From 2a00b317cbd7a05df7ca1408b16a9faaeea35de7 Mon Sep 17 00:00:00 2001 From: Andre Noll Date: Sat, 17 Oct 2015 16:47:01 +0200 Subject: [PATCH] build: Fix m4 dependencies for BSD m4. 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 | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/m4/gengetopt/makefile b/m4/gengetopt/makefile index af90d5bd..5130ddd1 100644 --- a/m4/gengetopt/makefile +++ b/m4/gengetopt/makefile @@ -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 $<' -- 2.39.5