From e249d1054762f7a3db4f04655dd662a221787a97 Mon Sep 17 00:00:00 2001 From: Andre Noll Date: Wed, 19 Jun 2013 20:33:43 +0200 Subject: [PATCH] Generate ggo dependencies automatically. Currently we maintain the dependency list of each ggo file manually in m4/gengetopt/makefile. This is tedious and error-prone, and missing dependencies result in build failures which are not repeatable and hard to locate. This changes the build system to keep track of these dependencies automatically. We now create one .m4d file for each executable. This file lists the dependencies of the corresponding ggo file, i.e. those m4 files which are included in order to make the ggo. All .m4d files are pulled in from the main Makefile via the -include directive, in the same way we include the object dependency files (.d) generated by gcc. --- Makefile.in | 5 ++++- m4/gengetopt/makefile | 36 +++++------------------------------- 2 files changed, 9 insertions(+), 32 deletions(-) diff --git a/Makefile.in b/Makefile.in index af9a20c9..487a9efe 100644 --- a/Makefile.in +++ b/Makefile.in @@ -34,6 +34,7 @@ object_dir := $(build_dir)/objects dep_dir := $(build_dir)/deps man_dir := $(build_dir)/man/man1 cmdline_dir := $(build_dir)/cmdline +m4depdir := $(build_dir)/m4deps DEBUG_CPPFLAGS += -g -Wunused -Wundef -W DEBUG_CPPFLAGS += -Wredundant-decls @@ -103,7 +104,7 @@ dep: $(deps) man: $(man_pages) tarball: $(tarball) -$(object_dir) $(man_dir) $(ggo_dir) $(cmdline_dir) $(dep_dir): +$(object_dir) $(man_dir) $(ggo_dir) $(cmdline_dir) $(dep_dir) $(m4depdir): $(Q) $(MKDIR_P) $@ -include $(m4_ggo_dir)/makefile @@ -230,6 +231,7 @@ all_objs := @recv_objs@ @filter_objs@ @client_objs@ @gui_objs@ \ @audiod_objs@ @audioc_objs@ @fade_objs@ @server_objs@ \ @write_objs@ @afh_objs@ @play_objs@ deps := $(addprefix $(dep_dir)/, $(all_objs:.o=.d)) +m4_deps := $(addprefix $(m4depdir)/, $(addsuffix .m4d, @executables@)) recv_objs := $(addprefix $(object_dir)/, @recv_objs@) filter_objs := $(addprefix $(object_dir)/, @filter_objs@) @@ -245,6 +247,7 @@ play_objs := $(addprefix $(object_dir)/, @play_objs@) ifeq ($(findstring clean, $(MAKECMDGOALS)),) -include $(deps) +-include $(m4_deps) endif para_recv: $(recv_objs) diff --git a/m4/gengetopt/makefile b/m4/gengetopt/makefile index 548a3d5d..035f44a5 100644 --- a/m4/gengetopt/makefile +++ b/m4/gengetopt/makefile @@ -16,37 +16,11 @@ ifeq ($(ggo_descriptions_declared),no) echo 'extern const char *$(*F)_args_info_description;' >> $(cmdline_dir)/$(*F).cmdline.h endif -$(ggo_dir)/server.ggo $(ggo_dir)/audiod.ggo: \ - $(m4_ggo_dir)/loglevel.m4 $(m4_ggo_dir)/color.m4 \ - $(m4_ggo_dir)/config_file.m4 $(m4_ggo_dir)/logfile.m4 \ - $(m4_ggo_dir)/daemon.m4 $(m4_ggo_dir)/user.m4 \ - $(m4_ggo_dir)/group.m4 $(m4_ggo_dir)/log_timing.m4 \ - $(m4_ggo_dir)/config_file.m4 - -$(ggo_dir)/afh.ggo: $(m4_ggo_dir)/loglevel.m4 -$(ggo_dir)/audioc.ggo: \ - $(m4_ggo_dir)/loglevel.m4 \ - $(m4_ggo_dir)/history_file.m4 \ - $(m4_ggo_dir)/complete.m4 -$(ggo_dir)/filter.ggo: $(m4_ggo_dir)/loglevel.m4 -$(ggo_dir)/fsck.ggo: $(m4_ggo_dir)/loglevel.m4 -$(ggo_dir)/gui.ggo: $(m4_ggo_dir)/loglevel.m4 $(m4_ggo_dir)/config_file.m4 -$(ggo_dir)/recv.ggo: $(m4_ggo_dir)/loglevel.m4 -$(ggo_dir)/write.ggo: $(m4_ggo_dir)/loglevel.m4 \ - $(m4_ggo_dir)/channels.m4 \ - $(m4_ggo_dir)/sample_rate.m4 \ - $(m4_ggo_dir)/sample_format.m4 -$(ggo_dir)/client.ggo: \ - $(m4_ggo_dir)/loglevel.m4 \ - $(m4_ggo_dir)/config_file.m4 \ - $(m4_ggo_dir)/history_file.m4 \ - $(m4_ggo_dir)/complete.m4 -$(ggo_dir)/fade.ggo: $(m4_ggo_dir)/loglevel.m4 $(m4_ggo_dir)/config_file.m4 -$(ggo_dir)/resample_filter.ggo: \ - $(m4_ggo_dir)/channels.m4 \ - $(m4_ggo_dir)/sample_rate.m4 \ - $(m4_ggo_dir)/sample_format.m4 -$(ggo_dir)/play.ggo: $(m4_ggo_dir)/loglevel.m4 $(m4_ggo_dir)/config_file.m4 +$(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}' > $@ $(ggo_dir)/%.ggo: $(m4_ggo_dir)/%.m4 $(m4_ggo_dir)/header.m4 | $(ggo_dir) @[ -z "$(Q)" ] || echo 'M4 $<' -- 2.39.5