From c8835c285c6abbc334701238f53f87f93e6f125a Mon Sep 17 00:00:00 2001 From: Rob Savoye Date: Mon, 15 Nov 2010 19:08:28 -0700 Subject: make howto build the new way --- gr-howto-write-a-block/Makefile.swig | 35 +++++++++++++++++++++++++++-------- 1 file changed, 27 insertions(+), 8 deletions(-) (limited to 'gr-howto-write-a-block/Makefile.swig') diff --git a/gr-howto-write-a-block/Makefile.swig b/gr-howto-write-a-block/Makefile.swig index 9e14835e5..231ae4ebe 100644 --- a/gr-howto-write-a-block/Makefile.swig +++ b/gr-howto-write-a-block/Makefile.swig @@ -32,6 +32,9 @@ ## 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 \ @@ -40,14 +43,34 @@ 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) \ + -I$(GNURADIO_CORE_INCLUDEDIR)/swig/guile + ## standard SWIG LD flags for library creation STD_SWIG_LA_LD_FLAGS = \ @@ -58,8 +81,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 +89,6 @@ STD_SWIG_LA_LIB_ADD = \ STD_SWIG_CXX_FLAGS = @swig_CXXFLAGS@ -## SWIG suffix for automake to know about - -SUFFIXES = .i - ## 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 @@ -115,3 +133,4 @@ swig_built_sources = ## on variables defined above. include $(srcdir)/Makefile.swig.gen + -- cgit From ea8a60ad9c2e0f9bdc57f77f5506c5906f8d1d6f Mon Sep 17 00:00:00 2001 From: Eric Blossom Date: Fri, 3 Dec 2010 23:58:48 -0800 Subject: Make gr-howto-write-a-block work again... Copied Makefile.swig, Mkefile.swig.gen.t from .. Renamed howto.i to howto_swig.i Regenerated Makefile.swig.gen --- gr-howto-write-a-block/Makefile.swig | 72 +++++++++++++++++++++++++++++------- 1 file changed, 58 insertions(+), 14 deletions(-) (limited to 'gr-howto-write-a-block/Makefile.swig') diff --git a/gr-howto-write-a-block/Makefile.swig b/gr-howto-write-a-block/Makefile.swig index 231ae4ebe..327b566e1 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 - -- cgit From 95254c28c18277012907354ae9fa5aef295271b8 Mon Sep 17 00:00:00 2001 From: Eric Blossom Date: Sat, 4 Dec 2010 00:49:17 -0800 Subject: Move swig related suffix/pattern rules from Makefile.common to Makefile.swig. --- gr-howto-write-a-block/Makefile.swig | 32 ++++++++++++++++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) (limited to 'gr-howto-write-a-block/Makefile.swig') diff --git a/gr-howto-write-a-block/Makefile.swig b/gr-howto-write-a-block/Makefile.swig index 327b566e1..2ed69c6c7 100644 --- a/gr-howto-write-a-block/Makefile.swig +++ b/gr-howto-write-a-block/Makefile.swig @@ -92,8 +92,8 @@ 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 +# 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. swig_built_sources = @@ -137,6 +137,34 @@ 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]\+-->//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 -- cgit