Debian Codegraph @

build/generate-binding.am

raw
1 ## Copyright (c) 2009 Openismus GmbH <http://www.openismus.com/>
2 ##
3 ## This file is part of mm-common.
4 ##
5 ## mm-common is free software: you can redistribute it and/or modify
6 ## it under the terms of the GNU General Public License as published
7 ## by the Free Software Foundation, either version 2 of the License,
8 ## or (at your option) any later version.
9 ##
10 ## mm-common is distributed in the hope that it will be useful,
11 ## but WITHOUT ANY WARRANTY; without even the implied warranty of
12 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 ## GNU General Public License for more details.
14 ##
15 ## You should have received a copy of the GNU General Public License
16 ## along with mm-common. If not, see <http://www.gnu.org/licenses/>.
17
18 ## Parameters: binding_name, wrap_init_flags
19 ## Overrides: codegen_srcdir, codegen_m4_srcdir, binding_outputdir,
20 ## gmmproc, gen_wrap_init, gmmproc_flags
21 ## Files: files_codegen_m4, files_defs, files_hg, files_ccg
22 ## Output: dist_noinst_DATA, gmmproc_dependencies, other_built_sources,
23 ## MAINTAINERCLEANFILES
24
25 # Location of the module's gmmproc support files.
26 codegen_srcdir ?= $(top_srcdir)/codegen
27
28 # Location of the module's gmmproc M4 files,
29 # and of any extra m4 files from installed modules,
30 # such as from gtkmm rather than just glibmm.
31 # Use, for instance, this in configure.ac:
32 # MM_PKG_CONFIG_SUBST([GMMPROC_EXTRA_M4_DIR], [--variable=gmmprocm4dir gtkmm-3.0])
33 codegen_m4_srcdir ?= $(codegen_srcdir)/m4
34
35 # Destination directory of the generated source files.
36 binding_outputdir ?= $(if $(srcdir:.=),$(dir $(top_srcdir)/$(subdir)),../)$(binding_name)
37
38 # Additional built sources not generated by gmmproc.
39 other_built_sources = $(binding_outputdir)/wrap_init.cc
40
41 # Where to put the stamp files for the gmmproc output.
42 binding_stampdir = $(srcdir)/.stamps
43
44 # Lists of qualified file names relative to the current directory.
45 binding_relfiles_m4 = $(addprefix $(codegen_m4_srcdir)/,$(files_codegen_m4))
46 binding_relfiles_hg = $(addprefix $(srcdir)/,$(files_hg))
47 binding_stampfiles = $(patsubst %.hg,$(binding_stampdir)/%.stamp,$(files_hg))
48
49 # Distributed code generation source files.
50 dist_noinst_DATA = $(files_defs) $(files_hg) $(files_ccg)
51
52 # Delete stamps on make maintainer-clean. The other generated source
53 # files are deleted by the make rules for the output directory.
54 MAINTAINERCLEANFILES = $(binding_stampdir)/*.stamp
55
56 # Dependencies of the gmmproc code generator targets.
57 gmmproc_dependencies = $(binding_relfiles_m4) $(files_defs)
58
59 # Default command lines for running the code generators.
60 gmmproc ?= $(PERL) -I"$(GMMPROC_DIR)/pm" -- "$(GMMPROC_DIR)/gmmproc"
61 gen_wrap_init ?= $(PERL) -- "$(GMMPROC_DIR)/generate_wrap_init.pl"
62 codegen_m4_flags = $(addprefix -I , $(codegen_m4_srcdir) $(GMMPROC_EXTRA_M4_DIR))
63 gmmproc_flags ?= $(codegen_m4_flags) --defs $(srcdir)
64
65 # Automatically created output directories.
66 binding_mkdirs = $(binding_stampdir) $(binding_outputdir)/private
67
68 # Show names of generated files in silent rules output.
69 mm_0_gen = @echo ' GEN $(binding_outputdir)/{$*.cc,$*.h,private/$*_p.h}';
70 mm_v_gen = $(if $(filter 0,$(or $(V),$(AM_DEFAULT_VERBOSITY))),$(mm_0_gen))
71
72 # Declare the built sources main targets.
73 all-local: $(binding_stampfiles) $(other_built_sources)
74
75 # Create the output directories if they do not exist already.
76 $(binding_mkdirs):
77 $(AM_V_at)$(MKDIR_P) $@
78
79 # Generate the wrap_init.cc file using generate_wrap_init.pl.
80 $(binding_outputdir)/wrap_init.cc: $(binding_relfiles_hg) $(srcdir)/Makefile.in
81 $(AM_V_GEN)$(gen_wrap_init) $(wrap_init_flags) $(binding_relfiles_hg) >$@
82
83 # Run the gmmproc code generator to produce the C++ binding code.
84 $(binding_stampdir)/%.stamp: %.hg %.ccg $(gmmproc_dependencies) | $(binding_mkdirs)
85 @: >$@
86 $(mm_v_gen)$(gmmproc) $(gmmproc_flags) $* $(srcdir) $(binding_outputdir)
87
88 # Instruct GNU make to delete the targets of a rule after it failed, in
89 # order to avoid the complication of handling that situation manually.
90 .DELETE_ON_ERROR: