summaryrefslogtreecommitdiff
path: root/Makefile.swig
diff options
context:
space:
mode:
Diffstat (limited to 'Makefile.swig')
-rw-r--r--Makefile.swig119
1 files changed, 105 insertions, 14 deletions
diff --git a/Makefile.swig b/Makefile.swig
index 9e14835e5..2ed69c6c7 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,10 +90,85 @@ 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 =
+# 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
@@ -108,10 +206,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