summaryrefslogtreecommitdiff
path: root/Makefile.swig
diff options
context:
space:
mode:
authorBen Reynwar2011-01-30 09:50:36 -0700
committerBen Reynwar2011-01-30 09:50:36 -0700
commitd1d4c8fd9dcf852cef9c274363182209c6761145 (patch)
tree54ddbd617c5ffffbbfc4e766f2d2281669919a73 /Makefile.swig
parentf6547e103e6cae44ff2a81b0f83675ccc897f2e9 (diff)
parent023167ca8a85ab597f9e59302733f71809a8afbd (diff)
downloadgnuradio-d1d4c8fd9dcf852cef9c274363182209c6761145.tar.gz
gnuradio-d1d4c8fd9dcf852cef9c274363182209c6761145.tar.bz2
gnuradio-d1d4c8fd9dcf852cef9c274363182209c6761145.zip
Merged upstream from next
Diffstat (limited to 'Makefile.swig')
-rw-r--r--Makefile.swig120
1 files changed, 106 insertions, 14 deletions
diff --git a/Makefile.swig b/Makefile.swig
index ef1b2126d..e659aea5c 100644
--- a/Makefile.swig
+++ b/Makefile.swig
@@ -1,6 +1,6 @@
# -*- Makefile -*-
#
-# Copyright 2009 Free Software Foundation, Inc.
+# Copyright 2009,2010 Free Software Foundation, Inc.
#
# This file is part of GNU Radio
#
@@ -25,6 +25,11 @@
## in Makefile.am's which require SWIG wrapping / compilation.
## For just installing .i files, this Makefile is not required.
+
+## include the built Makefile.swig.gen, always the one from the srcdir
+include $(srcdir)/Makefile.swig.gen
+
+
## swig flags
## -w511 turns off keyword argument warning
## "-outdir $(builddir)" writes all generated output files to
@@ -40,14 +45,33 @@ SWIG_PYTHON_FLAGS = \
-w511 \
-outdir .
-## standard swig flags used by most components
-
STD_SWIG_PYTHON_ARGS = \
$(SWIG_PYTHON_FLAGS) \
$(STD_DEFINES_AND_INCLUDES) \
$(WITH_SWIG_INCLUDES) \
$(WITH_INCLUDES)
+# NOTE: -Linkage passive and -Linkage module don't define SWIG_init()
+SWIG_GUILE_FLAGS = \
+ -guile \
+ -scm \
+ -scmstub \
+ -package gnuradio \
+ -Linkage module \
+ -proxy \
+ -goopsprefix gr: \
+ -emit-slot-accessors \
+ -emit-setters \
+ -outdir .
+
+## standard swig flags used by most components
+
+STD_SWIG_GUILE_ARGS = \
+ $(SWIG_GUILE_FLAGS) \
+ $(STD_DEFINES_AND_INCLUDES) \
+ $(WITH_SWIG_INCLUDES) \
+ $(WITH_INCLUDES)
+
## standard SWIG LD flags for library creation
STD_SWIG_LA_LD_FLAGS = \
@@ -58,8 +82,7 @@ STD_SWIG_LA_LD_FLAGS = \
## standard SWIG library additions for library creation
-STD_SWIG_LA_LIB_ADD = \
- -lstdc++
+STD_SWIG_LA_LIB_ADD = -lstdc++
## standard SWIG CXXFLAGS
## This allows for code to be compiled with "-O1" instead of "-g -O2"
@@ -67,9 +90,13 @@ STD_SWIG_LA_LIB_ADD = \
STD_SWIG_CXX_FLAGS = @swig_CXXFLAGS@
-## SWIG suffix for automake to know about
+# We drive the dependencies off of swig_built_sources. This variable
+# ends up containing only the generated .py and/or .scm files, not the .h
+# or .cc files. This allows us to use the pattern rules defined
+# below to generate all the pieces without the parallel make
+# problems that occur when both the .py's and .cc's are in swig_built_sources.
-SUFFIXES = .i
+swig_built_sources =
## Create the swig interface file swig_doc.i containing docstring information.
@@ -83,6 +110,78 @@ $(top_srcdir)/docs/doxygen/html/index.html:
$(MKDIR_P) $(top_srcdir)/docs/doxygen/xml
cd $(top_srcdir)/docs/doxygen; @DOXYGEN@
+# swig_all_built_sources contains swig_built_sources plus the .cc and .h files.
+# It contains the files to remove from the distribution and the files to
+# remove for make clean.
+
+swig_all_built_sources =
+
+if PYTHON
+# Create a list of .py files based on the top level .i files.
+PYTHON_GEN = $(foreach IFILE,$(TOP_SWIG_IFILES), $(subst .i,.py,$(IFILE)))
+swig_built_sources += $(PYTHON_GEN)
+swig_all_built_sources += $(PYTHON_GEN)
+
+# Now add .h, .cc to _all_
+swig_all_built_sources += $(foreach IFILE,$(TOP_SWIG_IFILES), $(patsubst %.i,python/%.h,$(IFILE)))
+swig_all_built_sources += $(foreach IFILE,$(TOP_SWIG_IFILES), $(patsubst %.i,python/%.cc,$(IFILE)))
+endif
+
+if GUILE
+# Create a list of .scm files based on the top level .i files.
+GUILE_GEN = $(foreach IFILE,$(TOP_SWIG_IFILES), $(patsubst %.i,gnuradio/%.scm,$(IFILE)))
+swig_built_sources += $(GUILE_GEN)
+swig_all_built_sources += $(GUILE_GEN)
+
+# Now add -primitive.scm, .cc to _all_
+swig_all_built_sources += $(foreach IFILE,$(TOP_SWIG_IFILES), $(patsubst %.i,gnuradio/%-primitive.scm,$(IFILE)))
+swig_all_built_sources += $(foreach IFILE,$(TOP_SWIG_IFILES), $(patsubst %.i,guile/%.cc,$(IFILE)))
+endif
+
+# N.B. Only $(swig_built_sources), not $(swig_all_built_sources)
+BUILT_SOURCES += $(swig_built_sources)
+
+# Don't distribute any of the swig generated files
+no_dist_files = $(swig_all_built_sources)
+
+CLEANFILES += $(swig_all_built_sources)
+CLEANFILES += python/*.lo python/*.o python/*.d
+CLEANFILES += guile/*.lo guile/*.o guile/*.d
+
+
+## SWIG suffixes for automake to know about
+SUFFIXES = .i .scm .py
+
+# Compile a .i to what guile needs. We use -o to set the output file name,
+# or even with -outdir guile in SWIG_GUILE_ARGS, swig keeps putting a
+# gnuradio_core_*_wrap.cxx in the source directory.
+gnuradio/%.scm : %.i
+ @echo "Compile .i to .scm"
+ @test -d "guile" || $(mkinstalldirs) "guile"
+ @test -d "gnuradio" || $(mkinstalldirs) "gnuradio"
+ $(SWIG) $(STD_SWIG_GUILE_ARGS) $($*_swig_args) \
+ -MD -MF guile/$*.Std \
+ -module $* -o guile/$*.cc $<
+ $(SED) -e 's|guile/\(.*\)\.cc:|gnuradio/\1.scm:|' guile/$*.Std > guile/$*.d
+ $(SED) -i -e 's/<--dummy-[0-9]\+-->/<top>/g' gnuradio/$*.scm
+ $(SED) -i -e 's/^(export /(export-safely /' gnuradio/$*.scm
+ $(RM) guile/$*.Std
+
+# Compile a .i file to what python needs
+.i.py:
+ @echo "Compile .i to .py"
+ @test -d "python" || $(mkinstalldirs) "python"
+ $(SWIG) $(STD_SWIG_PYTHON_ARGS) $($*_swig_args) \
+ -MD -MF python/$*.Std \
+ -module $* -o python/$*.cc -oh python/$*.h $<
+ $(SED) -e 's|python/\(.*\)\.cc:|\1.py:|' python/$*.Std > python/$*.d
+ $(RM) python/$*.Std
+
+## ------------------------------------------------------------------------
+## Rule that (re)generates Makefile.swig.gen using TOP_SWIG_IFILES and
+## Makefile.swig.gen.t
+##
+
## Create $(srcdir)/Makefile.swig.gen, containing all of the rules
## for running SWIG to generate or re-generate outputs. SWIG file
## names are to be defined in TOP_SWIG_IFILES, and must include the
@@ -120,10 +219,3 @@ generate-makefile-swig $(srcdir)/Makefile.swig.gen: $(top_srcdir)/Makefile.swig.
exit -1; \
fi;
-swig_built_sources =
-
-## include the built Makefile.swig.gen, always the one from the
-## srcdir; this must be included as the last item, because it depends
-## on variables defined above.
-
-include $(srcdir)/Makefile.swig.gen