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 pager_swig.i
25 ## Default install locations for these files:
27 ## Default location for the Python directory is:
28 ## ${prefix}/lib/python${python_version}/site-packages/[category]/pager_swig
29 ## Default location for the Python exec directory is:
30 ## ${exec_prefix}/lib/python${python_version}/site-packages/[category]/pager_swig
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 pager_swig_pythondir_category ?= gnuradio/pager_swig
37 pager_swig_pylibdir_category ?= $(pager_swig_pythondir_category)
38 pager_swig_pythondir = $(pythondir)/$(pager_swig_pythondir_category)
39 pager_swig_pylibdir = $(pyexecdir)/$(pager_swig_pylibdir_category)
41 ## SWIG headers are always installed into the same directory.
43 pager_swig_swigincludedir = $(swigincludedir)
45 ## This is a template file for a "generated" Makefile addition (in
46 ## this case, "Makefile.swig.gen"). By including the top-level
47 ## Makefile.swig, this file will be used to generate the SWIG
48 ## dependencies. Assign the variable TOP_SWIG_FILES to be the list of
49 ## SWIG .i files to generated wrappings for; there can be more than 1
50 ## so long as the names are unique (no sorting is done on the
51 ## TOP_SWIG_FILES list). This file explicitly assumes that a SWIG .i
52 ## file will generate .cc, .py, and possibly .h files -- meaning that
53 ## all of these files will have the same base name (that provided for
56 ## This code is setup to ensure parallel MAKE ("-j" or "-jN") does the
57 ## right thing. For more info, see <
58 ## http://sources.redhat.com/automake/automake.html#Multiple-Outputs >
60 ## Stamps used to ensure parallel make does the right thing. These
61 ## are removed by "make clean", but otherwise unused except during the
62 ## parallel built. These will not be included in a tarball, because
63 ## the SWIG-generated files will be removed from the distribution.
65 STAMPS += $(DEPDIR)/pager_swig-generate-*
67 ## Other cleaned files: dependency files generated by SWIG or this Makefile
69 MOSTLYCLEANFILES += $(DEPDIR)/*.S*
71 ## Add the .py and .cc files to the list of SWIG built sources. The
72 ## .h file is sometimes built, but not always ... so that one has to
73 ## be added manually by the including Makefile.am .
75 swig_built_sources += pager_swig.py pager_swig.cc
77 ## Various SWIG variables. These can be overloaded in the including
78 ## Makefile.am by setting the variable value there, then including
81 pager_swig_swiginclude_HEADERS = \
83 $(pager_swig_swiginclude_headers)
85 pager_swig_pylib_LTLIBRARIES = \
88 _pager_swig_la_SOURCES = \
90 $(pager_swig_la_swig_sources)
92 _pager_swig_la_LIBADD = \
93 $(STD_SWIG_LA_LIB_ADD) \
94 $(pager_swig_la_swig_libadd)
96 _pager_swig_la_LDFLAGS = \
97 $(STD_SWIG_LA_LD_FLAGS) \
98 $(pager_swig_la_swig_ldflags)
100 _pager_swig_la_CXXFLAGS = \
101 $(STD_SWIG_CXX_FLAGS) \
102 $(pager_swig_la_swig_cxxflags)
104 pager_swig_python_PYTHON = \
108 ## Entry rule for running SWIG
110 pager_swig.h pager_swig.py pager_swig.cc: pager_swig.i
111 ## This rule will get called only when MAKE decides that one of the
112 ## targets needs to be created or re-created, because:
114 ## * The .i file is newer than any or all of the generated files;
116 ## * Any or all of the .cc, .h, or .py files does not exist and is
117 ## needed (in the case this file is not needed, the rule for it is
120 ## * Some SWIG-based dependecy of the .cc file isn't met and hence the
121 ## .cc file needs be be regenerated. Explanation: Because MAKE
122 ## knows how to handle dependencies for .cc files (regardless of
123 ## their name or extension), then the .cc file is used as a target
124 ## instead of the .i file -- but with the dependencies of the .i
125 ## file. It is this last reason why the line:
127 ## if test -f $@; then :; else
129 ## cannot be used in this case: If a .i file dependecy is not met,
130 ## then the .cc file needs to be rebuilt. But if the stamp is newer
131 ## than the .cc file, and the .cc file exists, then in the original
132 ## version (with the 'test' above) the internal MAKE call will not
133 ## be issued and hence the .cc file will not be rebuilt.
135 ## Once execution gets to here, it should always proceed no matter the
136 ## state of a stamp (as discussed in link above). The
137 ## $(DEPDIR)/pager_swig-generate stuff is used to allow for parallel
138 ## builds to "do the right thing". The stamp has no relationship with
139 ## either the target files or dependency file; it is used solely for
140 ## the protection of multiple builds during a given call to MAKE.
142 ## Catch signals SIGHUP (1), SIGINT (2), SIGPIPE (13), and SIGTERM
143 ## (15). At a caught signal, the quoted command will be issued before
144 ## exiting. In this case, remove any stamp, whether temporary of not.
145 ## The trap is valid until the process exits; the process includes all
146 ## commands appended via "\"s.
148 trap 'rm -rf $(DEPDIR)/pager_swig-generate-*' 1 2 13 15; \
150 ## Create a temporary directory, which acts as a lock. The first
151 ## process to create the directory will succeed and issue the MAKE
152 ## command to do the actual work, while all subsequent processes will
153 ## fail -- leading them to wait for the first process to finish.
155 if mkdir $(DEPDIR)/pager_swig-generate-lock 2>/dev/null; then \
157 ## This code is being executed by the first process to succeed in
158 ## creating the directory lock.
160 ## Remove the stamp associated with this filename.
162 rm -f $(DEPDIR)/pager_swig-generate-stamp; \
164 ## Tell MAKE to run the rule for creating this stamp.
166 $(MAKE) $(AM_MAKEFLAGS) $(DEPDIR)/pager_swig-generate-stamp WHAT=$<; \
168 ## Now that the .cc, .h, and .py files have been (re)created from the
169 ## .i file, future checking of this rule during the same MAKE
170 ## execution will come back that the rule doesn't need to be executed
171 ## because none of the conditions mentioned at the start of this rule
172 ## will be positive. Remove the the directory lock, which frees up
173 ## any waiting process(es) to continue.
175 rmdir $(DEPDIR)/pager_swig-generate-lock; \
178 ## This code is being executed by any follower processes while the
179 ## directory lock is in place.
181 ## Wait until the first process is done, testing once per second.
183 while test -d $(DEPDIR)/pager_swig-generate-lock; do \
187 ## Succeed if and only if the first process succeeded; exit this
188 ## process returning the status of the generated stamp.
190 test -f $(DEPDIR)/pager_swig-generate-stamp; \
194 $(DEPDIR)/pager_swig-generate-stamp:
195 ## This rule will be called only by the first process issuing the
196 ## above rule to succeed in creating the lock directory, after
197 ## removing the actual stamp file in order to guarantee that MAKE will
198 ## execute this rule.
200 ## Call SWIG to generate the various output files; special
201 ## post-processing on 'mingw32' host OS for the dependency file.
203 if $(SWIG) $(STD_SWIG_PYTHON_ARGS) $(pager_swig_swig_args) \
204 -MD -MF $(DEPDIR)/pager_swig.Std \
205 -module pager_swig -o pager_swig.cc $(WHAT); then \
206 if test $(host_os) = mingw32; then \
207 $(RM) $(DEPDIR)/pager_swig.Sd; \
208 $(SED) 's,\\\\,/,g' < $(DEPDIR)/pager_swig.Std \
209 > $(DEPDIR)/pager_swig.Sd; \
210 $(RM) $(DEPDIR)/pager_swig.Std; \
211 $(MV) $(DEPDIR)/pager_swig.Sd $(DEPDIR)/pager_swig.Std; \
214 $(RM) $(DEPDIR)/pager_swig.S*; exit 1; \
217 ## Mess with the SWIG output .Std dependency file, to create a
218 ## dependecy file valid for the input .i file: Basically, simulate the
219 ## dependency file created for libraries by GNU's libtool for C++,
220 ## where all of the dependencies for the target are first listed, then
221 ## each individual dependency is listed as a target with no further
224 ## (1) remove the current dependency file
226 $(RM) $(DEPDIR)/pager_swig.d
228 ## (2) Copy the whole SWIG file:
230 cp $(DEPDIR)/pager_swig.Std $(DEPDIR)/pager_swig.d
232 ## (3) all a carriage return to the end of the dependency file.
234 echo "" >> $(DEPDIR)/pager_swig.d
236 ## (4) from the SWIG file, remove the first line (the target); remove
237 ## trailing " \" and " " from each line. Append ":" to each line,
238 ## followed by 2 carriage returns, then append this to the end of
239 ## the dependency file.
241 $(SED) -e '1d;s, \\,,g;s, ,,g' < $(DEPDIR)/pager_swig.Std | \
242 awk '{ printf "%s:\n\n", $$0 }' >> $(DEPDIR)/pager_swig.d
244 ## (5) remove the SWIG-generated file
246 $(RM) $(DEPDIR)/pager_swig.Std
248 ## Create the stamp for this filename generation, to signal success in
249 ## executing this rule; allows other threads waiting on this process
252 touch $(DEPDIR)/pager_swig-generate-stamp
254 # KLUDGE: Force runtime include of a SWIG dependency file. This is
255 # not guaranteed to be portable, but will probably work. If it works,
256 # we have accurate dependencies for our swig stuff, which is good.
258 @am__include@ @am__quote@./$(DEPDIR)/pager_swig.d@am__quote@