Statistics
| Branch: | Tag: | Revision:

root / gr-usrp2 / src / Makefile.swig.gen @ b47b9ca4

History | View | Annotate | Download (9.9 kB)

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 usrp2.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/[category]/usrp2
29
## Default location for the Python exec directory is:
30
##  ${exec_prefix}/lib/python${python_version}/site-packages/[category]/usrp2
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
usrp2_pythondir_category ?= gnuradio/usrp2
37
usrp2_pylibdir_category ?= $(usrp2_pythondir_category)
38
usrp2_pythondir = $(pythondir)/$(usrp2_pythondir_category)
39
usrp2_pylibdir = $(pyexecdir)/$(usrp2_pylibdir_category)
40
41
## SWIG headers are always installed into the same directory.
42
43
usrp2_swigincludedir = $(swigincludedir)
44
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
54
## the SWIG .i file).
55
##
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 >
59
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.
64
65
STAMPS += $(DEPDIR)/usrp2-generate-*
66
67
## Other cleaned files: dependency files generated by SWIG or this Makefile
68
69
MOSTLYCLEANFILES += $(DEPDIR)/*.S*
70
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 .
74
75
swig_built_sources += usrp2.py usrp2-python.cc
76
77
## Various SWIG variables.  These can be overloaded in the including
78
## Makefile.am by setting the variable value there, then including
79
## Makefile.swig .
80
81
usrp2_swiginclude_HEADERS =		\
82
	usrp2.i			\
83
	$(usrp2_swiginclude_headers)
84
85
usrp2_pylib_LTLIBRARIES =		\
86
	_usrp2.la
87
88
_usrp2_la_SOURCES = 			\
89
	usrp2-python.cc			\
90
	$(usrp2_la_swig_sources)
91
92
_usrp2_la_LIBADD =			\
93
	$(STD_SWIG_LA_LIB_ADD)		\
94
	$(usrp2_la_swig_libadd)
95
96
_usrp2_la_LDFLAGS =			\
97
	$(STD_SWIG_LA_LD_FLAGS)		\
98
	$(usrp2_la_swig_ldflags)
99
100
_usrp2_la_CXXFLAGS =			\
101
	$(STD_SWIG_CXX_FLAGS)		\
102
	$(usrp2_la_swig_cxxflags)
103
104
usrp2_python_PYTHON =			\
105
	usrp2.py			\
106
	$(usrp2_python)
107
108
## Entry rule for running SWIG
109
110
usrp2.h usrp2.py usrp2-python.cc: usrp2.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:
113
##
114
## * The .i file is newer than any or all of the generated files;
115
##
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
118
##   ignored); or
119
##
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:
126
##
127
##     	if test -f $@; then :; else
128
##
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.
134
##
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)/usrp2-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.
141
##
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.
147
##
148
	trap 'rm -rf $(DEPDIR)/usrp2-generate-*' 1 2 13 15; \
149
##
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.
154
##
155
	if mkdir $(DEPDIR)/usrp2-generate-lock 2>/dev/null; then \
156
##
157
## This code is being executed by the first process to succeed in
158
## creating the directory lock.
159
##
160
## Remove the stamp associated with this filename.
161
##
162
		rm -f $(DEPDIR)/usrp2-generate-*stamp; \
163
##
164
## Tell MAKE to run the rule for creating this stamp.
165
##
166
		$(MAKE) $(AM_MAKEFLAGS) $(DEPDIR)/usrp2-generate-python-stamp WHAT=$<; \
167
		$(MAKE) $(AM_MAKEFLAGS) $(DEPDIR)/usrp2-generate-guile-stamp WHAT=$<; \
168
##
169
## Now that the .cc, .h, and .py files have been (re)created from the
170
## .i file, future checking of this rule during the same MAKE
171
## execution will come back that the rule doesn't need to be executed
172
## because none of the conditions mentioned at the start of this rule
173
## will be positive.  Remove the the directory lock, which frees up
174
## any waiting process(es) to continue.
175
##
176
		rmdir $(DEPDIR)/usrp2-generate-lock; \
177
	else \
178
##
179
## This code is being executed by any follower processes while the
180
## directory lock is in place.
181
##
182
## Wait until the first process is done, testing once per second.
183
##
184
		while test -d $(DEPDIR)/usrp2-generate-lock; do \
185
			sleep 1; \
186
		done; \
187
##
188
## Succeed if and only if the first process succeeded; exit this
189
## process returning the status of the generated stamp.
190
##
191
		test -f $(DEPDIR)/usrp2-generate-python-stamp; \
192
		exit $$?; \
193
	fi;
194
195
$(DEPDIR)/usrp2-generate-guile-stamp:
196
	if $(SWIG) $(STD_SWIG_GUILE_ARGS) $(usrp2_swig_args) \
197
		-MD -MF $(DEPDIR)/usrp2.Std \
198
		-module usrp2 -o usrp2-guile.cc $(WHAT); then \
199
	    if test $(host_os) = mingw32; then \
200
		$(RM) $(DEPDIR)/usrp2.Sd; \
201
		$(SED) 's,\\\\,/,g' < $(DEPDIR)/usrp2.Std \
202
			> $(DEPDIR)/usrp2.Sd; \
203
		$(RM) $(DEPDIR)/usrp2.Std; \
204
		$(MV) $(DEPDIR)/usrp2.Sd $(DEPDIR)/usrp2.Std; \
205
	    fi; \
206
	else \
207
	    $(RM) $(DEPDIR)/usrp2.S*; exit 1; \
208
	fi;
209
	touch $(DEPDIR)/usrp2-generate-guile-stamp
210
211
$(DEPDIR)/usrp2-generate-python-stamp:
212
## This rule will be called only by the first process issuing the
213
## above rule to succeed in creating the lock directory, after
214
## removing the actual stamp file in order to guarantee that MAKE will
215
## execute this rule.
216
##
217
## Call SWIG to generate the various output files; special
218
## post-processing on 'mingw32' host OS for the dependency file.
219
##
220
	if $(SWIG) $(STD_SWIG_PYTHON_ARGS) $(usrp2_swig_args) \
221
		-MD -MF $(DEPDIR)/usrp2.Std \
222
		-module usrp2 -o usrp2-python.cc $(WHAT); then \
223
	    if test $(host_os) = mingw32; then \
224
		$(RM) $(DEPDIR)/usrp2.Sd; \
225
		$(SED) 's,\\\\,/,g' < $(DEPDIR)/usrp2.Std \
226
			> $(DEPDIR)/usrp2.Sd; \
227
		$(RM) $(DEPDIR)/usrp2.Std; \
228
		$(MV) $(DEPDIR)/usrp2.Sd $(DEPDIR)/usrp2.Std; \
229
	    fi; \
230
	else \
231
	    $(RM) $(DEPDIR)/usrp2.S*; exit 1; \
232
	fi;
233
##
234
## Mess with the SWIG output .Std dependency file, to create a
235
## dependecy file valid for the input .i file: Basically, simulate the
236
## dependency file created for libraries by GNU's libtool for C++,
237
## where all of the dependencies for the target are first listed, then
238
## each individual dependency is listed as a target with no further
239
## dependencies.
240
##
241
## (1) remove the current dependency file
242
##
243
	$(RM) $(DEPDIR)/usrp2.d
244
##
245
## (2) Copy the whole SWIG file:
246
##
247
	cp $(DEPDIR)/usrp2.Std $(DEPDIR)/usrp2.d
248
##
249
## (3) all a carriage return to the end of the dependency file.
250
##
251
	echo "" >> $(DEPDIR)/usrp2.d
252
##
253
## (4) from the SWIG file, remove the first line (the target); remove
254
##     trailing " \" and " " from each line.  Append ":" to each line,
255
##     followed by 2 carriage returns, then append this to the end of
256
##     the dependency file.
257
##
258
	$(SED) -e '1d;s, \\,,g;s, ,,g' < $(DEPDIR)/usrp2.Std | \
259
		awk '{ printf "%s:\n\n", $$0 }' >> $(DEPDIR)/usrp2.d
260
##
261
## (5) remove the SWIG-generated file
262
##
263
	$(RM) $(DEPDIR)/usrp2.Std
264
##
265
## Create the stamp for this filename generation, to signal success in
266
## executing this rule; allows other threads waiting on this process
267
## to continue.
268
##
269
	touch $(DEPDIR)/usrp2-generate-python-stamp
270
271
# KLUDGE: Force runtime include of a SWIG dependency file.  This is
272
# not guaranteed to be portable, but will probably work.  If it works,
273
# we have accurate dependencies for our swig stuff, which is good.
274
275
@am__include@ @am__quote@./$(DEPDIR)/usrp2.d@am__quote@
276