root / Makefile.swig @ 44ad2b33
History | View | Annotate | Download (7.6 kB)
| 1 | c3f962a1 | jcorgan | # -*- Makefile -*- |
|---|---|---|---|
| 2 | c3f962a1 | jcorgan | # |
| 3 | e4eb47f0 | Eric Blossom | # Copyright 2009,2010 Free Software Foundation, Inc. |
| 4 | c3f962a1 | jcorgan | # |
| 5 | c3f962a1 | jcorgan | # This file is part of GNU Radio |
| 6 | c3f962a1 | jcorgan | # |
| 7 | c3f962a1 | jcorgan | # GNU Radio is free software; you can redistribute it and/or modify |
| 8 | c3f962a1 | jcorgan | # it under the terms of the GNU General Public License as published by |
| 9 | c3f962a1 | jcorgan | # the Free Software Foundation; either version 3, or (at your option) |
| 10 | c3f962a1 | jcorgan | # any later version. |
| 11 | c3f962a1 | jcorgan | # |
| 12 | c3f962a1 | jcorgan | # GNU Radio is distributed in the hope that it will be useful, |
| 13 | c3f962a1 | jcorgan | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 | c3f962a1 | jcorgan | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 15 | c3f962a1 | jcorgan | # GNU General Public License for more details. |
| 16 | c3f962a1 | jcorgan | # |
| 17 | c3f962a1 | jcorgan | # You should have received a copy of the GNU General Public License |
| 18 | c3f962a1 | jcorgan | # along with GNU Radio; see the file COPYING. If not, write to |
| 19 | c3f962a1 | jcorgan | # the Free Software Foundation, Inc., 51 Franklin Street, |
| 20 | c3f962a1 | jcorgan | # Boston, MA 02110-1301, USA. |
| 21 | c3f962a1 | jcorgan | # |
| 22 | c3f962a1 | jcorgan | |
| 23 | c3f962a1 | jcorgan | ## This makefile should be included using |
| 24 | c3f962a1 | jcorgan | ## include $(top_srcdir)/Makefile.swig |
| 25 | c3f962a1 | jcorgan | ## in Makefile.am's which require SWIG wrapping / compilation. |
| 26 | c3f962a1 | jcorgan | ## For just installing .i files, this Makefile is not required. |
| 27 | c3f962a1 | jcorgan | |
| 28 | 6b5643a7 | Eric Blossom | |
| 29 | 6b5643a7 | Eric Blossom | ## include the built Makefile.swig.gen, always the one from the srcdir |
| 30 | 6b5643a7 | Eric Blossom | include $(srcdir)/Makefile.swig.gen |
| 31 | 6b5643a7 | Eric Blossom | |
| 32 | 6b5643a7 | Eric Blossom | |
| 33 | c3f962a1 | jcorgan | ## swig flags |
| 34 | c3f962a1 | jcorgan | ## -w511 turns off keyword argument warning |
| 35 | c3f962a1 | jcorgan | ## "-outdir $(builddir)" writes all generated output files to |
| 36 | c3f962a1 | jcorgan | ## the local builddir (which should always be '.') |
| 37 | c3f962a1 | jcorgan | ## In some older autotools, $(builddir) is not defined, so |
| 38 | c3f962a1 | jcorgan | ## just use '.' instead. |
| 39 | c3f962a1 | jcorgan | |
| 40 | c3f962a1 | jcorgan | SWIG_PYTHON_FLAGS = \ |
| 41 | c3f962a1 | jcorgan | -fvirtual \ |
| 42 | c3f962a1 | jcorgan | -python \ |
| 43 | c3f962a1 | jcorgan | -modern \ |
| 44 | c3f962a1 | jcorgan | -keyword \ |
| 45 | c3f962a1 | jcorgan | -w511 \ |
| 46 | c3f962a1 | jcorgan | -outdir . |
| 47 | c3f962a1 | jcorgan | |
| 48 | c3f962a1 | jcorgan | STD_SWIG_PYTHON_ARGS = \ |
| 49 | c3f962a1 | jcorgan | $(SWIG_PYTHON_FLAGS) \ |
| 50 | c3f962a1 | jcorgan | $(STD_DEFINES_AND_INCLUDES) \ |
| 51 | c3f962a1 | jcorgan | $(WITH_SWIG_INCLUDES) \ |
| 52 | c3f962a1 | jcorgan | $(WITH_INCLUDES) |
| 53 | c3f962a1 | jcorgan | |
| 54 | 52b42834 | Rob Savoye | # NOTE: -Linkage passive and -Linkage module don't define SWIG_init() |
| 55 | 3e970ae2 | Rob Savoye | SWIG_GUILE_FLAGS = \ |
| 56 | 3e970ae2 | Rob Savoye | -guile \ |
| 57 | f04b7c4b | Rob Savoye | -scm \ |
| 58 | 52b42834 | Rob Savoye | -scmstub \ |
| 59 | 299aba57 | Eric Blossom | -package gnuradio \ |
| 60 | 299aba57 | Eric Blossom | -Linkage module \ |
| 61 | 299aba57 | Eric Blossom | -proxy \ |
| 62 | 299aba57 | Eric Blossom | -goopsprefix gr: \ |
| 63 | 299aba57 | Eric Blossom | -emit-slot-accessors \ |
| 64 | 299aba57 | Eric Blossom | -emit-setters \ |
| 65 | c41cb174 | Rob Savoye | -outdir . |
| 66 | 3e970ae2 | Rob Savoye | |
| 67 | 3e970ae2 | Rob Savoye | ## standard swig flags used by most components |
| 68 | 3e970ae2 | Rob Savoye | |
| 69 | 3e970ae2 | Rob Savoye | STD_SWIG_GUILE_ARGS = \ |
| 70 | 3e970ae2 | Rob Savoye | $(SWIG_GUILE_FLAGS) \ |
| 71 | 3e970ae2 | Rob Savoye | $(STD_DEFINES_AND_INCLUDES) \ |
| 72 | 3e970ae2 | Rob Savoye | $(WITH_SWIG_INCLUDES) \ |
| 73 | 3e970ae2 | Rob Savoye | $(WITH_INCLUDES) |
| 74 | 3e970ae2 | Rob Savoye | |
| 75 | c3f962a1 | jcorgan | ## standard SWIG LD flags for library creation |
| 76 | c3f962a1 | jcorgan | |
| 77 | c3f962a1 | jcorgan | STD_SWIG_LA_LD_FLAGS = \ |
| 78 | c3f962a1 | jcorgan | $(PYTHON_LDFLAGS) \ |
| 79 | c3f962a1 | jcorgan | -module \ |
| 80 | c3f962a1 | jcorgan | -avoid-version \ |
| 81 | c3f962a1 | jcorgan | $(NO_UNDEFINED) |
| 82 | c3f962a1 | jcorgan | |
| 83 | c3f962a1 | jcorgan | ## standard SWIG library additions for library creation |
| 84 | c3f962a1 | jcorgan | |
| 85 | 52b42834 | Rob Savoye | STD_SWIG_LA_LIB_ADD = -lstdc++ |
| 86 | c3f962a1 | jcorgan | |
| 87 | c3f962a1 | jcorgan | ## standard SWIG CXXFLAGS |
| 88 | c3f962a1 | jcorgan | ## This allows for code to be compiled with "-O1" instead of "-g -O2" |
| 89 | c3f962a1 | jcorgan | ## for some systems, avoiding some optimization issues. |
| 90 | c3f962a1 | jcorgan | |
| 91 | c3f962a1 | jcorgan | STD_SWIG_CXX_FLAGS = @swig_CXXFLAGS@ |
| 92 | c3f962a1 | jcorgan | |
| 93 | 6b5643a7 | Eric Blossom | # We drive the dependencies off of swig_built_sources. This variable |
| 94 | 6b5643a7 | Eric Blossom | # ends up containing only the generated .py and/or .scm files, not the .h |
| 95 | 95254c28 | Eric Blossom | # or .cc files. This allows us to use the pattern rules defined |
| 96 | 95254c28 | Eric Blossom | # below to generate all the pieces without the parallel make |
| 97 | 6b5643a7 | Eric Blossom | # problems that occur when both the .py's and .cc's are in swig_built_sources. |
| 98 | c3f962a1 | jcorgan | |
| 99 | 5d03065c | Eric Blossom | swig_built_sources = |
| 100 | c3f962a1 | jcorgan | |
| 101 | a20c127a | Ben Reynwar | ## Create the swig interface file swig_doc.i containing docstring information. |
| 102 | a20c127a | Ben Reynwar | |
| 103 | a20c127a | Ben Reynwar | $(top_srcdir)/gnuradio-core/src/lib/swig/swig_doc.i: $(top_srcdir)/docs/doxygen/html/index.html |
| 104 | a20c127a | Ben Reynwar | $(PYTHON) $(top_srcdir)/gnuradio-core/src/lib/swig/swig_doc.py $(top_srcdir)/docs/doxygen/xml/ $(top_srcdir)/gnuradio-core/src/lib/swig/swig_doc.i |
| 105 | a20c127a | Ben Reynwar | |
| 106 | a20c127a | Ben Reynwar | ## Make sure the doxygen docs are generated |
| 107 | a20c127a | Ben Reynwar | |
| 108 | a20c127a | Ben Reynwar | $(top_srcdir)/docs/doxygen/html/index.html: |
| 109 | 31c8002c | Ben Reynwar | $(MKDIR_P) $(top_srcdir)/docs/doxygen/html |
| 110 | 31c8002c | Ben Reynwar | $(MKDIR_P) $(top_srcdir)/docs/doxygen/xml |
| 111 | 31c8002c | Ben Reynwar | cd $(top_srcdir)/docs/doxygen; @DOXYGEN@ |
| 112 | a20c127a | Ben Reynwar | |
| 113 | 6b5643a7 | Eric Blossom | # swig_all_built_sources contains swig_built_sources plus the .cc and .h files. |
| 114 | 6b5643a7 | Eric Blossom | # It contains the files to remove from the distribution and the files to |
| 115 | 6b5643a7 | Eric Blossom | # remove for make clean. |
| 116 | 5d03065c | Eric Blossom | |
| 117 | 6b5643a7 | Eric Blossom | swig_all_built_sources = |
| 118 | 5d03065c | Eric Blossom | |
| 119 | 5d03065c | Eric Blossom | if PYTHON |
| 120 | 5d03065c | Eric Blossom | # Create a list of .py files based on the top level .i files. |
| 121 | 5d03065c | Eric Blossom | PYTHON_GEN = $(foreach IFILE,$(TOP_SWIG_IFILES), $(subst .i,.py,$(IFILE))) |
| 122 | 5d03065c | Eric Blossom | swig_built_sources += $(PYTHON_GEN) |
| 123 | 6b5643a7 | Eric Blossom | swig_all_built_sources += $(PYTHON_GEN) |
| 124 | 6b5643a7 | Eric Blossom | |
| 125 | 6b5643a7 | Eric Blossom | # Now add .h, .cc to _all_ |
| 126 | 6b5643a7 | Eric Blossom | swig_all_built_sources += $(foreach IFILE,$(TOP_SWIG_IFILES), $(patsubst %.i,python/%.h,$(IFILE))) |
| 127 | 6b5643a7 | Eric Blossom | swig_all_built_sources += $(foreach IFILE,$(TOP_SWIG_IFILES), $(patsubst %.i,python/%.cc,$(IFILE))) |
| 128 | 5d03065c | Eric Blossom | endif |
| 129 | 5d03065c | Eric Blossom | |
| 130 | 5d03065c | Eric Blossom | if GUILE |
| 131 | 5d03065c | Eric Blossom | # Create a list of .scm files based on the top level .i files. |
| 132 | 5d03065c | Eric Blossom | GUILE_GEN = $(foreach IFILE,$(TOP_SWIG_IFILES), $(patsubst %.i,gnuradio/%.scm,$(IFILE))) |
| 133 | 5d03065c | Eric Blossom | swig_built_sources += $(GUILE_GEN) |
| 134 | 6b5643a7 | Eric Blossom | swig_all_built_sources += $(GUILE_GEN) |
| 135 | 6b5643a7 | Eric Blossom | |
| 136 | 6b5643a7 | Eric Blossom | # Now add -primitive.scm, .cc to _all_ |
| 137 | 6b5643a7 | Eric Blossom | swig_all_built_sources += $(foreach IFILE,$(TOP_SWIG_IFILES), $(patsubst %.i,gnuradio/%-primitive.scm,$(IFILE))) |
| 138 | 6b5643a7 | Eric Blossom | swig_all_built_sources += $(foreach IFILE,$(TOP_SWIG_IFILES), $(patsubst %.i,guile/%.cc,$(IFILE))) |
| 139 | 5d03065c | Eric Blossom | endif |
| 140 | 5d03065c | Eric Blossom | |
| 141 | 6b5643a7 | Eric Blossom | # N.B. Only $(swig_built_sources), not $(swig_all_built_sources) |
| 142 | 5d03065c | Eric Blossom | BUILT_SOURCES += $(swig_built_sources) |
| 143 | 5d03065c | Eric Blossom | |
| 144 | 6b5643a7 | Eric Blossom | # Don't distribute any of the swig generated files |
| 145 | 6b5643a7 | Eric Blossom | no_dist_files = $(swig_all_built_sources) |
| 146 | 5d03065c | Eric Blossom | |
| 147 | 6b5643a7 | Eric Blossom | CLEANFILES += $(swig_all_built_sources) |
| 148 | 6b5643a7 | Eric Blossom | CLEANFILES += python/*.lo python/*.o python/*.d |
| 149 | 6b5643a7 | Eric Blossom | CLEANFILES += guile/*.lo guile/*.o guile/*.d |
| 150 | 5d03065c | Eric Blossom | |
| 151 | 5d03065c | Eric Blossom | |
| 152 | 95254c28 | Eric Blossom | ## SWIG suffixes for automake to know about |
| 153 | 95254c28 | Eric Blossom | SUFFIXES = .i .scm .py |
| 154 | 95254c28 | Eric Blossom | |
| 155 | 95254c28 | Eric Blossom | # Compile a .i to what guile needs. We use -o to set the output file name, |
| 156 | 95254c28 | Eric Blossom | # or even with -outdir guile in SWIG_GUILE_ARGS, swig keeps putting a |
| 157 | 95254c28 | Eric Blossom | # gnuradio_core_*_wrap.cxx in the source directory. |
| 158 | 95254c28 | Eric Blossom | gnuradio/%.scm : %.i |
| 159 | 95254c28 | Eric Blossom | @echo "Compile .i to .scm" |
| 160 | 95254c28 | Eric Blossom | @test -d "guile" || $(mkinstalldirs) "guile" |
| 161 | 95254c28 | Eric Blossom | @test -d "gnuradio" || $(mkinstalldirs) "gnuradio" |
| 162 | 95254c28 | Eric Blossom | $(SWIG) $(STD_SWIG_GUILE_ARGS) $($*_swig_args) \ |
| 163 | 95254c28 | Eric Blossom | -MD -MF guile/$*.Std \ |
| 164 | 95254c28 | Eric Blossom | -module $* -o guile/$*.cc $< |
| 165 | 95254c28 | Eric Blossom | $(SED) -e 's|guile/\(.*\)\.cc:|gnuradio/\1.scm:|' guile/$*.Std > guile/$*.d |
| 166 | 95254c28 | Eric Blossom | $(SED) -i -e 's/<--dummy-[0-9]\+-->/<top>/g' gnuradio/$*.scm |
| 167 | 95254c28 | Eric Blossom | $(SED) -i -e 's/^(export /(export-safely /' gnuradio/$*.scm |
| 168 | 95254c28 | Eric Blossom | $(RM) guile/$*.Std |
| 169 | 95254c28 | Eric Blossom | |
| 170 | 95254c28 | Eric Blossom | # Compile a .i file to what python needs |
| 171 | 95254c28 | Eric Blossom | .i.py: |
| 172 | 95254c28 | Eric Blossom | @echo "Compile .i to .py" |
| 173 | 95254c28 | Eric Blossom | @test -d "python" || $(mkinstalldirs) "python" |
| 174 | 95254c28 | Eric Blossom | $(SWIG) $(STD_SWIG_PYTHON_ARGS) $($*_swig_args) \ |
| 175 | 95254c28 | Eric Blossom | -MD -MF python/$*.Std \ |
| 176 | 95254c28 | Eric Blossom | -module $* -o python/$*.cc -oh python/$*.h $< |
| 177 | 95254c28 | Eric Blossom | $(SED) -e 's|python/\(.*\)\.cc:|\1.py:|' python/$*.Std > python/$*.d |
| 178 | 95254c28 | Eric Blossom | $(RM) python/$*.Std |
| 179 | 95254c28 | Eric Blossom | |
| 180 | 5d03065c | Eric Blossom | ## ------------------------------------------------------------------------ |
| 181 | 5d03065c | Eric Blossom | ## Rule that (re)generates Makefile.swig.gen using TOP_SWIG_IFILES and |
| 182 | 5d03065c | Eric Blossom | ## Makefile.swig.gen.t |
| 183 | 5d03065c | Eric Blossom | ## |
| 184 | d1d4c8fd | Ben Reynwar | |
| 185 | c3f962a1 | jcorgan | ## Create $(srcdir)/Makefile.swig.gen, containing all of the rules |
| 186 | c3f962a1 | jcorgan | ## for running SWIG to generate or re-generate outputs. SWIG file |
| 187 | c3f962a1 | jcorgan | ## names are to be defined in TOP_SWIG_IFILES, and must include the |
| 188 | c3f962a1 | jcorgan | ## full path to the file and full filename including extension. This |
| 189 | c3f962a1 | jcorgan | ## Makefile addition will be made only if either it does not exist or |
| 190 | c3f962a1 | jcorgan | ## if the top-level template has been modified. |
| 191 | c3f962a1 | jcorgan | |
| 192 | c3f962a1 | jcorgan | generate-makefile-swig $(srcdir)/Makefile.swig.gen: $(top_srcdir)/Makefile.swig.gen.t |
| 193 | c3f962a1 | jcorgan | ## recreate $(srcdir)/Makefile.swig.gen only if ... |
| 194 | c3f962a1 | jcorgan | @do_recreate=0; \ |
| 195 | c3f962a1 | jcorgan | if test -f $(srcdir)/Makefile.swig.gen; then \ |
| 196 | c3f962a1 | jcorgan | ## the file exists and can be removed; or ... |
| 197 | c3f962a1 | jcorgan | if $(RM) $(srcdir)/Makefile.swig.gen 2>/dev/null; then \ |
| 198 | c3f962a1 | jcorgan | if touch $(srcdir)/Makefile.swig.gen 2>/dev/null; then \ |
| 199 | c3f962a1 | jcorgan | do_recreate=1; \ |
| 200 | c3f962a1 | jcorgan | fi; \ |
| 201 | c3f962a1 | jcorgan | fi; \ |
| 202 | c3f962a1 | jcorgan | else \ |
| 203 | c3f962a1 | jcorgan | ## the file doesn't exist, but can be created (e.g., by touching it). |
| 204 | c3f962a1 | jcorgan | if touch $(srcdir)/Makefile.swig.gen 2>/dev/null; then \ |
| 205 | c3f962a1 | jcorgan | do_recreate=1; \ |
| 206 | c3f962a1 | jcorgan | fi; \ |
| 207 | c3f962a1 | jcorgan | fi; \ |
| 208 | c3f962a1 | jcorgan | if test "$$do_recreate" == "1"; then \ |
| 209 | c3f962a1 | jcorgan | echo "Regenerating $(srcdir)/Makefile.swig.gen"; \ |
| 210 | c3f962a1 | jcorgan | for TFILE in $(TOP_SWIG_IFILES); do \ |
| 211 | c3f962a1 | jcorgan | ## retrieve just the filename, without path or extension |
| 212 | c3f962a1 | jcorgan | TNAME=`python -c "import os.path as op; (dN, fN) = op.split ('$$TFILE'); (fbN, fE) = op.splitext (fN); print fbN;"`; \
|
| 213 | c3f962a1 | jcorgan | ## Replace the @-named strings in the template Makefile for SWIG. |
| 214 | c3f962a1 | jcorgan | $(SED) -e 's|@NAME@|'$$TNAME'|g;' < $(top_srcdir)/Makefile.swig.gen.t >> $(srcdir)/Makefile.swig.gen; \ |
| 215 | c3f962a1 | jcorgan | echo "" >> $(srcdir)/Makefile.swig.gen; \ |
| 216 | c3f962a1 | jcorgan | done; \ |
| 217 | c3f962a1 | jcorgan | else \ |
| 218 | c3f962a1 | jcorgan | echo "Cannot recreate $(srcdir)/Makefile.swig.gen because the directory or file is write-protected."; \ |
| 219 | c3f962a1 | jcorgan | exit -1; \ |
| 220 | c3f962a1 | jcorgan | fi; |