3 # Copyright 2009 Free Software Foundation, Inc.
5 # This file is part of GNU Radio
7 # GNU Radio is free software; you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License as published by
9 # the Free Software Foundation; either version 3, or (at your option)
12 # GNU Radio is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
17 # You should have received a copy of the GNU General Public License
18 # along with GNU Radio; see the file COPYING. If not, write to
19 # the Free Software Foundation, Inc., 51 Franklin Street,
20 # Boston, MA 02110-1301, USA.
23 # Makefile.swig.gen for @NAME@.i
25 ## Default install locations for these files:
27 ## Default location for the Python directory is:
28 ## ${prefix}/lib/python${python_version}/site-packages/@NAME@
29 ## Default location for the Python exec directory is:
30 ## ${exec_prefix}/lib/python${python_version}/site-packages/@NAME@
32 ## The following can be overloaded to change the install location, but
33 ## this has to be done in the including Makefile.am -before-
34 ## Makefile.swig is included.
36 @NAME@_pythondir = $(pythondir)/@NAME@
37 @NAME@_pylibdir = $(pyexecdir)/@NAME@
39 ## SWIG headers are always installed into the same directory.
41 @NAME@_swigincludedir = $(swigincludedir)
43 ## This is a template file for a "generated" Makefile addition (in
44 ## this case, "Makefile.swig.gen"). By including the top-level
45 ## Makefile.swig, this file will be used to generate the SWIG
46 ## dependencies. Assign the variable TOP_SWIG_FILES to be the list of
47 ## SWIG .i files to generated wrappings for; there can be more than 1
48 ## so long as the names are unique (no sorting is done on the
49 ## TOP_SWIG_FILES list). This file explicitly assumes that a SWIG .i
50 ## file will generate .cc, .py, and possibly .h files -- meaning that
51 ## all of these files will have the same base name (that provided for
54 ## This code is setup to ensure parallel MAKE ("-j" or "-jN") does the
55 ## right thing. For more info, see <
56 ## http://sources.redhat.com/automake/automake.html#Multiple-Outputs >
58 ## Stamps used to ensure parallel make does the right thing. These
59 ## are removed by "make clean", but otherwise unused except during the
60 ## parallel built. These will not be included in a tarball, because
61 ## the SWIG-generated files will be removed from the distribution.
63 STAMPS += $(DEPDIR)/@NAME@-generate-*
65 ## Other cleaned files: dependency files generated by SWIG or this Makefile
67 MOSTLYCLEANFILES += $(DEPDIR)/*.S*
69 ## Add the .py and .cc files to the list of SWIG built sources. The
70 ## .h file is sometimes built, but not always ... so that one has to
71 ## be added manually by the including Makefile.am .
73 swig_built_sources += @NAME@_swig.py @NAME@_swig.cc
75 ## Various SWIG variables. These can be overloaded in the including
76 ## Makefile.am by setting the variable value there, then including
79 @NAME@_swiginclude_HEADERS = \
81 $(@NAME@_swiginclude_headers)
83 @NAME@_pylib_LTLIBRARIES = \
86 _@NAME@_swig_la_SOURCES = \
88 $(@NAME@_la_swig_sources)
90 _@NAME@_swig_la_LIBADD = \
91 $(STD_SWIG_LA_LIB_ADD) \
92 $(@NAME@_la_swig_libadd)
94 _@NAME@_swig_la_LDFLAGS = \
95 $(STD_SWIG_LA_LD_FLAGS) \
96 $(@NAME@_la_swig_ldflags)
98 _@NAME@_swig_la_CXXFLAGS = \
99 $(STD_SWIG_CXX_FLAGS) \
100 $(@NAME@_la_swig_cxxflags)
102 @NAME@_python_PYTHON = \
106 ## Entry rule for running SWIG
108 @NAME@.h @NAME@_swig.py @NAME@_swig.cc: @NAME@.i
109 ## This rule will get called only when MAKE decides that one of the
110 ## targets needs to be created or re-created, because:
112 ## * The .i file is newer than any or all of the generated files;
114 ## * Any or all of the .cc, .h, or .py files does not exist and is
115 ## needed (in the case this file is not needed, the rule for it is
118 ## * Some SWIG-based dependecy of the .cc file isn't met and hence the
119 ## .cc file needs be be regenerated. Explanation: Because MAKE
120 ## knows how to handle dependencies for .cc files (regardless of
121 ## their name or extension), then the .cc file is used as a target
122 ## instead of the .i file -- but with the dependencies of the .i
123 ## file. It is this last reason why the line:
125 ## if test -f $@; then :; else
127 ## cannot be used in this case: If a .i file dependecy is not met,
128 ## then the .cc file needs to be rebuilt. But if the stamp is newer
129 ## than the .cc file, and the .cc file exists, then in the original
130 ## version (with the 'test' above) the internal MAKE call will not
131 ## be issued and hence the .cc file will not be rebuilt.
133 ## Once execution gets to here, it should always proceed no matter the
134 ## state of a stamp (as discussed in link above). The
135 ## $(DEPDIR)/@NAME@-generate stuff is used to allow for parallel
136 ## builds to "do the right thing". The stamp has no relationship with
137 ## either the target files or dependency file; it is used solely for
138 ## the protection of multiple builds during a given call to MAKE.
140 ## Catch signals SIGHUP (1), SIGINT (2), SIGPIPE (13), and SIGTERM
141 ## (15). At a caught signal, the quoted command will be issued before
142 ## exiting. In this case, remove any stamp, whether temporary of not.
143 ## The trap is valid until the process exits; the process includes all
144 ## commands appended via "\"s.
146 trap 'rm -rf $(DEPDIR)/@NAME@-generate-*' 1 2 13 15; \
148 ## Create a temporary directory, which acts as a lock. The first
149 ## process to create the directory will succeed and issue the MAKE
150 ## command to do the actual work, while all subsequent processes will
151 ## fail -- leading them to wait for the first process to finish.
153 if mkdir $(DEPDIR)/@NAME@-generate-lock 2>/dev/null; then \
155 ## This code is being executed by the first process to succeed in
156 ## creating the directory lock.
158 ## Remove the stamp associated with this filename.
160 rm -f $(DEPDIR)/@NAME@-generate-stamp; \
162 ## Tell MAKE to run the rule for creating this stamp.
164 $(MAKE) $(AM_MAKEFLAGS) $(DEPDIR)/@NAME@-generate-stamp WHAT=$<; \
166 ## Now that the .cc, .h, and .py files have been (re)created from the
167 ## .i file, future checking of this rule during the same MAKE
168 ## execution will come back that the rule doesn't need to be executed
169 ## because none of the conditions mentioned at the start of this rule
170 ## will be positive. Remove the the directory lock, which frees up
171 ## any waiting process(es) to continue.
173 rmdir $(DEPDIR)/@NAME@-generate-lock; \
176 ## This code is being executed by any follower processes while the
177 ## directory lock is in place.
179 ## Wait until the first process is done, testing once per second.
181 while test -d $(DEPDIR)/@NAME@-generate-lock; do \
185 ## Succeed if and only if the first process succeeded; exit this
186 ## process returning the status of the generated stamp.
188 test -f $(DEPDIR)/@NAME@-generate-stamp; \
192 $(DEPDIR)/@NAME@-generate-stamp:
193 ## This rule will be called only by the first process issuing the
194 ## above rule to succeed in creating the lock directory, after
195 ## removing the actual stamp file in order to guarantee that MAKE will
196 ## execute this rule.
198 ## Call SWIG to generate the various output files; special
199 ## post-processing on 'mingw32' host OS for the dependency file.
201 if $(SWIG) $(STD_SWIG_PYTHON_ARGS) $(@NAME@_swig_args) \
202 -MD -MF $(DEPDIR)/@NAME@.Std \
203 -module @NAME@_swig -o @NAME@_swig.cc $(WHAT); then \
204 if test $(host_os) = mingw32; then \
205 $(RM) $(DEPDIR)/@NAME@.Sd; \
206 $(SED) 's,\\\\,/,g' < $(DEPDIR)/@NAME@.Std \
207 > $(DEPDIR)/@NAME@.Sd; \
208 $(RM) $(DEPDIR)/@NAME@.Std; \
209 $(MV) $(DEPDIR)/@NAME@.Sd $(DEPDIR)/@NAME@.Std; \
212 $(RM) $(DEPDIR)/@NAME@.S*; exit 1; \
215 ## Mess with the SWIG output .Std dependency file, to create a
216 ## dependecy file valid for the input .i file: Basically, simulate the
217 ## dependency file created for libraries by GNU's libtool for C++,
218 ## where all of the dependencies for the target are first listed, then
219 ## each individual dependency is listed as a target with no further
222 ## (1) remove the current dependency file
224 $(RM) $(DEPDIR)/@NAME@.d
226 ## (2) Copy the whole SWIG file:
228 cp $(DEPDIR)/@NAME@.Std $(DEPDIR)/@NAME@.d
230 ## (3) all a carriage return to the end of the dependency file.
232 echo "" >> $(DEPDIR)/@NAME@.d
234 ## (4) from the SWIG file, remove the first line (the target); remove
235 ## trailing " \" and " " from each line. Append ":" to each line,
236 ## followed by 2 carriage returns, then append this to the end of
237 ## the dependency file.
239 $(SED) -e '1d;s, \\,,g;s, ,,g' < $(DEPDIR)/@NAME@.Std | \
240 awk '{ printf "%s:\n\n", $$0 }' >> $(DEPDIR)/@NAME@.d
242 ## (5) remove the SWIG-generated file
244 $(RM) $(DEPDIR)/@NAME@.Std
246 ## Create the stamp for this filename generation, to signal success in
247 ## executing this rule; allows other threads waiting on this process
250 touch $(DEPDIR)/@NAME@-generate-stamp
252 # KLUDGE: Force runtime include of a SWIG dependency file. This is
253 # not guaranteed to be portable, but will probably work. If it works,
254 # we have accurate dependencies for our swig stuff, which is good.
256 @am__include@ @am__quote@./$(DEPDIR)/@NAME@.d@am__quote@