]> git.tuebingen.mpg.de Git - paraslash.git/commitdiff
Generate ggo dependencies automatically.
authorAndre Noll <maan@systemlinux.org>
Wed, 19 Jun 2013 18:33:43 +0000 (20:33 +0200)
committerAndre Noll <maan@systemlinux.org>
Wed, 31 Jul 2013 21:56:15 +0000 (23:56 +0200)
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
m4/gengetopt/makefile

index af9a20c9419aa56b9b79949f89bf0379049a5f80..487a9efe2bb6f51f9b3d5ad279aeae2cc5a2c469 100644 (file)
@@ -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)
index 548a3d5d83bcb406a66dc26a77c0a840745d868f..035f44a5df4360e0a68eabe55dd6598a589141e1 100644 (file)
@@ -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 $<'