Merge branch 'dfsg-orig'
[debian/gnuradio] / gr-howto-write-a-block / swig / Makefile.swig.gen
1 # -*- Makefile -*-
2 #
3 # Copyright 2009 Free Software Foundation, Inc.
4
5 # This file is part of GNU Radio
6
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)
10 # any later version.
11
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.
16
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.
21
22
23 # Makefile.swig.gen for howto.i
24
25 ## Default install locations for these files:
26 ##
27 ## Default location for the Python directory is:
28 ##  ${prefix}/lib/python${python_version}/site-packages/howto
29 ## Default location for the Python exec directory is:
30 ##  ${exec_prefix}/lib/python${python_version}/site-packages/howto
31 ##
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.
35
36 howto_pythondir = $(pythondir)/howto
37 howto_pylibdir = $(pyexecdir)/howto
38
39 ## SWIG headers are always installed into the same directory.
40
41 howto_swigincludedir = $(swigincludedir)
42
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
52 ## the SWIG .i file).
53 ##
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 >
57
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.
62
63 STAMPS += $(DEPDIR)/howto-generate-*
64
65 ## Other cleaned files: dependency files generated by SWIG or this Makefile
66
67 MOSTLYCLEANFILES += $(DEPDIR)/*.S*
68
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 .
72
73 swig_built_sources += howto_swig.py howto_swig.cc
74
75 ## Various SWIG variables.  These can be overloaded in the including
76 ## Makefile.am by setting the variable value there, then including
77 ## Makefile.swig .
78
79 howto_swiginclude_HEADERS =             \
80         howto.i                 \
81         $(howto_swiginclude_headers)
82
83 howto_pylib_LTLIBRARIES =               \
84         _howto_swig.la
85
86 _howto_swig_la_SOURCES =                \
87         howto_swig.cc                   \
88         $(howto_la_swig_sources)
89
90 _howto_swig_la_LIBADD =         \
91         $(STD_SWIG_LA_LIB_ADD)          \
92         $(howto_la_swig_libadd)
93
94 _howto_swig_la_LDFLAGS =                \
95         $(STD_SWIG_LA_LD_FLAGS)         \
96         $(howto_la_swig_ldflags)
97
98 _howto_swig_la_CXXFLAGS =               \
99         $(STD_SWIG_CXX_FLAGS)           \
100         $(howto_la_swig_cxxflags)
101
102 howto_python_PYTHON =                   \
103         howto_swig.py                   \
104         $(howto_python)
105
106 ## Entry rule for running SWIG
107
108 howto.h howto_swig.py howto_swig.cc: howto.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:
111 ##
112 ## * The .i file is newer than any or all of the generated files;
113 ##
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
116 ##   ignored); or
117 ##
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:
124 ##
125 ##      if test -f $@; then :; else
126 ##
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.
132 ##
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)/howto-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.
139 ##
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.
145 ##
146         trap 'rm -rf $(DEPDIR)/howto-generate-*' 1 2 13 15; \
147 ##
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.
152 ##
153         if mkdir $(DEPDIR)/howto-generate-lock 2>/dev/null; then \
154 ##
155 ## This code is being executed by the first process to succeed in
156 ## creating the directory lock.
157 ##
158 ## Remove the stamp associated with this filename.
159 ##
160                 rm -f $(DEPDIR)/howto-generate-stamp; \
161 ##
162 ## Tell MAKE to run the rule for creating this stamp.
163 ##
164                 $(MAKE) $(AM_MAKEFLAGS) $(DEPDIR)/howto-generate-stamp WHAT=$<; \
165 ##
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.
172 ##
173                 rmdir $(DEPDIR)/howto-generate-lock; \
174         else \
175 ##
176 ## This code is being executed by any follower processes while the
177 ## directory lock is in place.
178 ##
179 ## Wait until the first process is done, testing once per second.
180 ##
181                 while test -d $(DEPDIR)/howto-generate-lock; do \
182                         sleep 1; \
183                 done; \
184 ##
185 ## Succeed if and only if the first process succeeded; exit this
186 ## process returning the status of the generated stamp.
187 ##
188                 test -f $(DEPDIR)/howto-generate-stamp; \
189                 exit $$?; \
190         fi;
191
192 $(DEPDIR)/howto-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.
197 ##
198 ## Call SWIG to generate the various output files; special
199 ## post-processing on 'mingw32' host OS for the dependency file.
200 ##
201         if $(SWIG) $(STD_SWIG_PYTHON_ARGS) $(howto_swig_args) \
202                 -MD -MF $(DEPDIR)/howto.Std \
203                 -module howto_swig -o howto_swig.cc $(WHAT); then \
204             if test $(host_os) = mingw32; then \
205                 $(RM) $(DEPDIR)/howto.Sd; \
206                 $(SED) 's,\\\\,/,g' < $(DEPDIR)/howto.Std \
207                         > $(DEPDIR)/howto.Sd; \
208                 $(RM) $(DEPDIR)/howto.Std; \
209                 $(MV) $(DEPDIR)/howto.Sd $(DEPDIR)/howto.Std; \
210             fi; \
211         else \
212             $(RM) $(DEPDIR)/howto.S*; exit 1; \
213         fi;
214 ##
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
220 ## dependencies.
221 ##
222 ## (1) remove the current dependency file
223 ##
224         $(RM) $(DEPDIR)/howto.d
225 ##
226 ## (2) Copy the whole SWIG file:
227 ##
228         cp $(DEPDIR)/howto.Std $(DEPDIR)/howto.d
229 ##
230 ## (3) all a carriage return to the end of the dependency file.
231 ##
232         echo "" >> $(DEPDIR)/howto.d
233 ##
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.
238 ##
239         $(SED) -e '1d;s, \\,,g;s, ,,g' < $(DEPDIR)/howto.Std | \
240                 awk '{ printf "%s:\n\n", $$0 }' >> $(DEPDIR)/howto.d
241 ##
242 ## (5) remove the SWIG-generated file
243 ##
244         $(RM) $(DEPDIR)/howto.Std
245 ##
246 ## Create the stamp for this filename generation, to signal success in
247 ## executing this rule; allows other threads waiting on this process
248 ## to continue.
249 ##
250         touch $(DEPDIR)/howto-generate-stamp
251
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.
255
256 @am__include@ @am__quote@./$(DEPDIR)/howto.d@am__quote@
257