diff options
Diffstat (limited to 'gr-howto-write-a-block')
-rw-r--r-- | gr-howto-write-a-block/Makefile.common | 10 | ||||
-rw-r--r-- | gr-howto-write-a-block/Makefile.swig | 72 | ||||
-rw-r--r-- | gr-howto-write-a-block/Makefile.swig.gen.t | 36 | ||||
-rw-r--r-- | gr-howto-write-a-block/swig/Makefile.am | 4 | ||||
-rw-r--r-- | gr-howto-write-a-block/swig/Makefile.swig.gen | 102 | ||||
-rw-r--r-- | gr-howto-write-a-block/swig/howto_swig.i (renamed from gr-howto-write-a-block/swig/howto.i) | 0 |
6 files changed, 151 insertions, 73 deletions
diff --git a/gr-howto-write-a-block/Makefile.common b/gr-howto-write-a-block/Makefile.common index 0787b4eec9..cfcbce9c8e 100644 --- a/gr-howto-write-a-block/Makefile.common +++ b/gr-howto-write-a-block/Makefile.common @@ -20,6 +20,16 @@ # Boston, MA 02110-1301, USA. # +# Every Makefile starts with common vars so we can +# consistently use += +BUILT_SOURCES = +MOSTLYCLEANFILES = $(BUILT_SOURCES) $(STAMPS) *.pyc *.pyo *~ *.tmp *.loT +CLEANFILES = guile.log +DISTCLEANFILES = +#EXTRA_DIST = +STAMPS = + + # The name of this "out-of-tree" module modname = howto diff --git a/gr-howto-write-a-block/Makefile.swig b/gr-howto-write-a-block/Makefile.swig index 231ae4ebe0..327b566e1e 100644 --- a/gr-howto-write-a-block/Makefile.swig +++ b/gr-howto-write-a-block/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 @@ -32,9 +37,6 @@ ## In some older autotools, $(builddir) is not defined, so ## just use '.' instead. -CLEANFILES = python/*.cc python/*.h python/*.lo python/*.o -CLEANFILES += guile/*.cc gnuradio/*.scm guile/*.lo guile/*.o - SWIG_PYTHON_FLAGS = \ -fvirtual \ -python \ @@ -68,8 +70,7 @@ STD_SWIG_GUILE_ARGS = \ $(SWIG_GUILE_FLAGS) \ $(STD_DEFINES_AND_INCLUDES) \ $(WITH_SWIG_INCLUDES) \ - $(WITH_INCLUDES) \ - -I$(GNURADIO_CORE_INCLUDEDIR)/swig/guile + $(WITH_INCLUDES) ## standard SWIG LD flags for library creation @@ -89,6 +90,57 @@ STD_SWIG_LA_LIB_ADD = -lstdc++ STD_SWIG_CXX_FLAGS = @swig_CXXFLAGS@ +# 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 in +# Makefile.common 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. + +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 + + +## ------------------------------------------------------------------------ +## 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 @@ -126,11 +178,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 - diff --git a/gr-howto-write-a-block/Makefile.swig.gen.t b/gr-howto-write-a-block/Makefile.swig.gen.t index 5be0ac4aaf..4d37e0e215 100644 --- a/gr-howto-write-a-block/Makefile.swig.gen.t +++ b/gr-howto-write-a-block/Makefile.swig.gen.t @@ -79,6 +79,7 @@ MOSTLYCLEANFILES += $(DEPDIR)/*.S* @NAME@.i \ $(@NAME@_swiginclude_headers) +if PYTHON @NAME@_pylib_LTLIBRARIES = \ _@NAME@.la @@ -86,6 +87,10 @@ _@NAME@_la_SOURCES = \ python/@NAME@.cc \ $(@NAME@_la_swig_sources) +@NAME@_python_PYTHON = \ + @NAME@.py \ + $(@NAME@_python) + _@NAME@_la_LIBADD = \ $(STD_SWIG_LA_LIB_ADD) \ $(@NAME@_la_swig_libadd) @@ -99,27 +104,34 @@ _@NAME@_la_CXXFLAGS = \ -I$(top_builddir) \ $(@NAME@_la_swig_cxxflags) -@NAME@_python_PYTHON = \ - @NAME@.py \ - $(@NAME@_python) - python/@NAME@.cc: @NAME@.py @NAME@.py: @NAME@.i # Include the python dependencies for this file -include python/@NAME@.d -# end of PYTHON + +endif # end of if python if GUILE -@NAME@_scmlib_LTLIBRARIES = libguile-@NAME@.la -libguile_@NAME@_la_SOURCES = \ + +@NAME@_scmlib_LTLIBRARIES = \ + libguile-gnuradio-@NAME@.la +libguile_gnuradio_@NAME@_la_SOURCES = \ guile/@NAME@.cc \ $(@NAME@_la_swig_sources) -nobase_@NAME@_scm_DATA = gnuradio/@NAME@.scm gnuradio/@NAME@-primitive.scm - -libguile_@NAME@_la_LIBADD = $(_@NAME@_la_LIBADD) -libguile_@NAME@_la_LDFLAGS = $(_@NAME@_la_LDFLAGS) -libguile_@NAME@_la_CXXFLAGS = $(_@NAME@_la_CXXFLAGS) +nobase_@NAME@_scm_DATA = \ + gnuradio/@NAME@.scm \ + gnuradio/@NAME@-primitive.scm +libguile_gnuradio_@NAME@_la_LIBADD = \ + $(STD_SWIG_LA_LIB_ADD) \ + $(@NAME@_la_swig_libadd) +libguile_gnuradio_@NAME@_la_LDFLAGS = \ + $(STD_SWIG_LA_LD_FLAGS) \ + $(@NAME@_la_swig_ldflags) +libguile_gnuradio_@NAME@_la_CXXFLAGS = \ + $(STD_SWIG_CXX_FLAGS) \ + -I$(top_builddir) \ + $(@NAME@_la_swig_cxxflags) guile/@NAME@.cc: gnuradio/@NAME@.scm gnuradio/@NAME@.scm: @NAME@.i diff --git a/gr-howto-write-a-block/swig/Makefile.am b/gr-howto-write-a-block/swig/Makefile.am index d55c8070d1..87134af93f 100644 --- a/gr-howto-write-a-block/swig/Makefile.am +++ b/gr-howto-write-a-block/swig/Makefile.am @@ -28,13 +28,13 @@ AM_CPPFLAGS += -I$(top_srcdir)/lib # SWIG interfaces and libraries TOP_SWIG_IFILES = \ - howto.i + howto_swig.i # Install so that they end up available as: # import howto # This ends up at: # ${prefix}/lib/python${python_version}/site-packages/$(modname) -howto_la_swig_libadd = \ +howto_swig_la_swig_libadd = \ $(top_builddir)/lib/libgnuradio-howto.la # additional SWIG files to be installed diff --git a/gr-howto-write-a-block/swig/Makefile.swig.gen b/gr-howto-write-a-block/swig/Makefile.swig.gen index 72d8a09aa6..310cfb8da7 100644 --- a/gr-howto-write-a-block/swig/Makefile.swig.gen +++ b/gr-howto-write-a-block/swig/Makefile.swig.gen @@ -20,37 +20,37 @@ # Boston, MA 02110-1301, USA. # -# Makefile.swig.gen for howto.i +# Makefile.swig.gen for howto_swig.i ## Default install locations for these files: ## ## Default location for the Python directory is: -## ${prefix}/lib/python${python_version}/site-packages/[category]/howto +## ${prefix}/lib/python${python_version}/site-packages/[category]/howto_swig ## Default location for the Python exec directory is: -## ${exec_prefix}/lib/python${python_version}/site-packages/[category]/howto +## ${exec_prefix}/lib/python${python_version}/site-packages/[category]/howto_swig ## ## The following can be overloaded to change the install location, but ## this has to be done in the including Makefile.am -before- ## Makefile.swig is included. -howto_pythondir_category ?= gnuradio/howto -howto_pylibdir_category ?= $(howto_pythondir_category) -howto_pythondir = $(pythondir)/$(howto_pythondir_category) -howto_pylibdir = $(pyexecdir)/$(howto_pylibdir_category) +howto_swig_pythondir_category ?= gnuradio/howto_swig +howto_swig_pylibdir_category ?= $(howto_swig_pythondir_category) +howto_swig_pythondir = $(pythondir)/$(howto_swig_pythondir_category) +howto_swig_pylibdir = $(pyexecdir)/$(howto_swig_pylibdir_category) # The .so libraries for the guile modules get installed whereever guile # is installed, usually /usr/lib/guile/gnuradio/ # FIXME: determince whether these should be installed with gnuradio. -howto_scmlibdir = $(libdir) +howto_swig_scmlibdir = $(libdir) # The scm files for the guile modules get installed where ever guile -# is installed, usually /usr/share/guile/site/howto +# is installed, usually /usr/share/guile/site/howto_swig # FIXME: determince whether these should be installed with gnuradio. -howto_scmdir = $(guiledir) +howto_swig_scmdir = $(guiledir) ## SWIG headers are always installed into the same directory. -howto_swigincludedir = $(swigincludedir) +howto_swig_swigincludedir = $(swigincludedir) ## This is a template file for a "generated" Makefile addition (in ## this case, "Makefile.swig.gen"). By including the top-level @@ -75,58 +75,70 @@ MOSTLYCLEANFILES += $(DEPDIR)/*.S* ## Makefile.am by setting the variable value there, then including ## Makefile.swig . -howto_swiginclude_HEADERS = \ - howto.i \ - $(howto_swiginclude_headers) +howto_swig_swiginclude_HEADERS = \ + howto_swig.i \ + $(howto_swig_swiginclude_headers) -howto_pylib_LTLIBRARIES = \ - _howto.la +if PYTHON +howto_swig_pylib_LTLIBRARIES = \ + _howto_swig.la -_howto_la_SOURCES = \ - python/howto.cc \ - $(howto_la_swig_sources) +_howto_swig_la_SOURCES = \ + python/howto_swig.cc \ + $(howto_swig_la_swig_sources) -_howto_la_LIBADD = \ +howto_swig_python_PYTHON = \ + howto_swig.py \ + $(howto_swig_python) + +_howto_swig_la_LIBADD = \ $(STD_SWIG_LA_LIB_ADD) \ - $(howto_la_swig_libadd) + $(howto_swig_la_swig_libadd) -_howto_la_LDFLAGS = \ +_howto_swig_la_LDFLAGS = \ $(STD_SWIG_LA_LD_FLAGS) \ - $(howto_la_swig_ldflags) + $(howto_swig_la_swig_ldflags) -_howto_la_CXXFLAGS = \ +_howto_swig_la_CXXFLAGS = \ $(STD_SWIG_CXX_FLAGS) \ -I$(top_builddir) \ - $(howto_la_swig_cxxflags) - -howto_python_PYTHON = \ - howto.py \ - $(howto_python) + $(howto_swig_la_swig_cxxflags) -python/howto.cc: howto.py -howto.py: howto.i +python/howto_swig.cc: howto_swig.py +howto_swig.py: howto_swig.i # Include the python dependencies for this file --include python/howto.d -# end of PYTHON +-include python/howto_swig.d + +endif # end of if python if GUILE -howto_scmlib_LTLIBRARIES = libguile-howto.la -libguile_howto_la_SOURCES = \ - guile/howto.cc \ - $(howto_la_swig_sources) -nobase_howto_scm_DATA = gnuradio/howto.scm gnuradio/howto-primitive.scm -libguile_howto_la_LIBADD = $(_howto_la_LIBADD) -libguile_howto_la_LDFLAGS = $(_howto_la_LDFLAGS) -libguile_howto_la_CXXFLAGS = $(_howto_la_CXXFLAGS) +howto_swig_scmlib_LTLIBRARIES = \ + libguile-gnuradio-howto_swig.la +libguile_gnuradio_howto_swig_la_SOURCES = \ + guile/howto_swig.cc \ + $(howto_swig_la_swig_sources) +nobase_howto_swig_scm_DATA = \ + gnuradio/howto_swig.scm \ + gnuradio/howto_swig-primitive.scm +libguile_gnuradio_howto_swig_la_LIBADD = \ + $(STD_SWIG_LA_LIB_ADD) \ + $(howto_swig_la_swig_libadd) +libguile_gnuradio_howto_swig_la_LDFLAGS = \ + $(STD_SWIG_LA_LD_FLAGS) \ + $(howto_swig_la_swig_ldflags) +libguile_gnuradio_howto_swig_la_CXXFLAGS = \ + $(STD_SWIG_CXX_FLAGS) \ + -I$(top_builddir) \ + $(howto_swig_la_swig_cxxflags) -guile/howto.cc: gnuradio/howto.scm -gnuradio/howto.scm: howto.i -gnuradio/howto-primitive.scm: gnuradio/howto.scm +guile/howto_swig.cc: gnuradio/howto_swig.scm +gnuradio/howto_swig.scm: howto_swig.i +gnuradio/howto_swig-primitive.scm: gnuradio/howto_swig.scm # Include the guile dependencies for this file --include guile/howto.d +-include guile/howto_swig.d endif # end of GUILE diff --git a/gr-howto-write-a-block/swig/howto.i b/gr-howto-write-a-block/swig/howto_swig.i index 868df57394..868df57394 100644 --- a/gr-howto-write-a-block/swig/howto.i +++ b/gr-howto-write-a-block/swig/howto_swig.i |