[librsvgmm] Clean up and document generate-binding.am



commit a3d931df62185d3477e0e16c0357cc888ba3d0bf
Author: Daniel Elstner <danielk openismus com>
Date:   Tue Aug 4 16:46:29 2009 +0200

    Clean up and document generate-binding.am
    
    * build/generate-binding.am: Do not include codegen/m4/filelist.am
    from this file, because the include created an entirely unnecessary
    dependency on the module's directory layout.
    Add namespace prefix to most variable names to reduce the probability
    of clashes.  Make more variables overridable, and try to deduce from
    the parent directory name whether the module name includes the "lib"
    prefix.  Document all variables and rules.  Use MAINTAINERCLEANFILES
    variable instead of a custom maintainer-clean-local rule.
    * codegen/Makefile.am: Clean up a bit.
    * librsvg/src/Makefile.am: Include codegen/m4/filelist.m4 from here.

 build/generate-binding.am |   71 +++++++++++++++++++++++++++++---------------
 codegen/Makefile.am       |    9 +++--
 librsvg/src/Makefile.am   |    3 +-
 3 files changed, 54 insertions(+), 29 deletions(-)
---
diff --git a/build/generate-binding.am b/build/generate-binding.am
index 29329b3..e175796 100644
--- a/build/generate-binding.am
+++ b/build/generate-binding.am
@@ -15,39 +15,62 @@
 ## You should have received a copy of the GNU General Public License
 ## along with mm-autofu.  If not, see <http://www.gnu.org/licenses/>.
 
-## Parameter:   binding_name, wrap_init_flags
+## Parameters:  binding_name, wrap_init_flags
+## Overrides:   codegen_srcdir, codegen_m4_srcdir, binding_outputdir
 ## Files:       files_codegen_m4, files_defs, files_hg, files_ccg
-## Output:      dist_noinst_DATA
+## Output:      dist_noinst_DATA, gmmproc_dependencies, other_built_sources,
+##              MAINTAINERCLEANFILES
 
-include $(top_srcdir)/codegen/m4/filelist.am
+# Location of the module's gmmproc support files.
+codegen_srcdir ?= $(top_srcdir)/codegen
 
-dist_noinst_DATA = $(files_defs) $(files_hg) $(files_ccg)
+# Location of the module's gmmproc M4 files.
+codegen_m4_srcdir ?= $(codegen_srcdir)/m4
 
-codegen_dir	= $(top_srcdir)/codegen
-output_dir	= $(top_srcdir)/$(dir $(subdir))$(binding_name)
-stamp_dir	= $(srcdir)/.stamps
+# Destination directory of the generated source files.
+binding_outputdir ?= $(top_srcdir)/$(dir $(subdir))$(binding_name)
 
-path_codegen_m4	= $(files_codegen_m4:%.m4=$(codegen_dir)/m4/%.m4)
-path_files_hg	= $(files_hg:%.hg=$(srcdir)/%.hg)
-stamp_files	= $(files_hg:%.hg=$(stamp_dir)/stamp-%)
+# Additional built sources not generated by gmmproc.
+other_built_sources = $(binding_outputdir)/wrap_init.cc
 
-gmmproc		= $(GMMPROC_DIR)/gmmproc -I $(codegen_dir)/m4 --defs $(srcdir)
-gen_wrap_init	= $(PERL) $(GMMPROC_DIR)/generate_wrap_init.pl $(wrap_init_flags)
+# Where to put the stamp files for the gmmproc output.
+binding_stampdir = $(srcdir)/.stamps
 
-.DELETE_ON_ERROR:
-.PHONY: mkdir-stamps
+# Lists of qualified file names relative to the current directory.
+binding_relfiles_m4 = $(addprefix $(codegen_m4_srcdir)/,$(files_codegen_m4))
+binding_relfiles_hg = $(addprefix $(srcdir)/,$(files_hg))
+binding_stampfiles  = $(files_hg:%.hg=$(binding_stampdir)/%.stamp)
+
+# Distributed code generation source files.
+dist_noinst_DATA = $(files_defs) $(files_hg) $(files_ccg)
 
-all-local: $(stamp_files) $(output_dir)/wrap_init.cc
+# Delete stamps on make maintainer-clean.  The other generated source
+# files are deleted by the make rules for the output directory.
+MAINTAINERCLEANFILES = $(binding_stampdir)/*.stamp
 
-mkdir-stamps:
-	@$(MKDIR_P) "$(stamp_dir)"
+# Dependencies of the gmmproc code generator targets.
+gmmproc_dependencies = $(binding_relfiles_m4) $(files_defs)
 
-maintainer-clean-local:
-	-rm -rf "$(stamp_dir)"
+# Command lines to invoke the code generator tools.
+gmmproc_cmd = $(PERL) -- "$(GMMPROC_DIR)/gmmproc" -I $(codegen_m4_srcdir) --defs $(srcdir)
+gen_wrap_init_cmd = $(PERL) -- "$(GMMPROC_DIR)/generate_wrap_init.pl" $(wrap_init_flags)
 
-$(output_dir)/wrap_init.cc:: $(path_files_hg)
-	$(gen_wrap_init) $(path_files_hg) >'$@'
+# Declare the built sources main targets.
+all-local: $(binding_stampfiles) $(other_built_sources)
 
-$(stamp_dir)/stamp-%:: %.hg %.ccg $(path_codegen_m4) $(files_defs) | mkdir-stamps
-	@echo timestamp >'$@'
-	$(gmmproc) $(notdir $*) $(srcdir) $(output_dir)
+# Create the .stamps/ subdirectory if it does not exist already.
+$(binding_stampdir):
+	$(MKDIR_P) $@
+
+# Generate the wrap_init.cc file using generate_wrap_init.pl.
+$(binding_outputdir)/wrap_init.cc: $(binding_relfiles_hg)
+	$(gen_wrap_init_cmd) $(binding_relfiles_hg) >$@
+
+# Run the gmmproc code generator to produce the C++ binding code.
+$(binding_stampdir)/%.stamp: %.hg %.ccg $(gmmproc_dependencies) | $(binding_stampdir)
+	@: >$@
+	$(gmmproc_cmd) $(notdir $*) $(srcdir) $(binding_outputdir)
+
+# Instruct GNU make to delete the targets of a rule after it failed, in
+# order to avoid the complication of handling that situation manually.
+.DELETE_ON_ERROR:
diff --git a/codegen/Makefile.am b/codegen/Makefile.am
index bed3f18..d9f0185 100644
--- a/codegen/Makefile.am
+++ b/codegen/Makefile.am
@@ -19,14 +19,15 @@ AUTOMAKE_OPTIONS = subdir-objects
 
 include $(srcdir)/m4/filelist.am
 
-dist_noinst_DATA = $(files_codegen_m4:%.m4=m4/%.m4)
+dist_noinst_DATA = $(files_codegen_m4:%=m4/%)
+noinst_PROGRAMS  = extradefs/generate_extra_defs
 
-noinst_PROGRAMS = extradefs/generate_extra_defs
 extradefs_generate_extra_defs_SOURCES = extradefs/generate_extra_defs_librsvg.cc
+extradefs_generate_extra_defs_LDADD   = $(LIBRSVGMM_LIBS) -lglibmm_generate_extra_defs-2.4
 
 AM_CPPFLAGS = -I$(top_builddir) $(GTHREAD_CFLAGS) $(LIBRSVGMM_CFLAGS)
 AM_CXXFLAGS = $(LIBRSVGMM_WXXFLAGS)
 
-extradefs_generate_extra_defs_LDADD = $(LIBRSVGMM_LIBS) -lglibmm_generate_extra_defs-2.4
-
+# Instruct GNU make to delete the targets of a rule after it failed, in
+# order to avoid the complication of handling that situation manually.
 .DELETE_ON_ERROR:
diff --git a/librsvg/src/Makefile.am b/librsvg/src/Makefile.am
index 565bb80..b4d7ecc 100644
--- a/librsvg/src/Makefile.am
+++ b/librsvg/src/Makefile.am
@@ -15,8 +15,9 @@
 ## You should have received a copy of the GNU Lesser General Public License
 ## along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
-binding_name	= librsvgmm
+binding_name    = librsvgmm
 wrap_init_flags = --namespace=Rsvg --parent_dir=librsvgmm
 
 include $(srcdir)/filelist.am
+include $(top_srcdir)/codegen/m4/filelist.am
 include $(top_srcdir)/build/generate-binding.am



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]