From 6c3b6396bc420228215072b2fc1b83c82eaeb291 Mon Sep 17 00:00:00 2001 From: Eric Blossom Date: Thu, 4 Mar 2010 07:02:42 -0800 Subject: Refactor gr-howto-write-a-block such that it no longer installs into the gnuradio python namespace, but rather in the howto namespace. This allows it to be installed under a separate --prefix in the common case where the user doing the "out of tree build" is going to be installing their new and/or modified code somewhere other than the system installation directories. Any code that uses these blocks should now import them using: import howto instead of from gnuradio import howto --- gr-howto-write-a-block/Makefile.common | 16 ++++++++----- gr-howto-write-a-block/Makefile.swig.gen.t | 26 ++++++++++---------- gr-howto-write-a-block/apps/howto_square.py | 2 +- gr-howto-write-a-block/grc/howto_square2_ff.xml | 2 +- gr-howto-write-a-block/grc/howto_square_ff.xml | 2 +- gr-howto-write-a-block/lib/Makefile.am | 32 ++++++++++++------------- gr-howto-write-a-block/python/Makefile.am | 6 ++--- gr-howto-write-a-block/swig/Makefile.am | 11 ++++----- gr-howto-write-a-block/swig/Makefile.swig.gen | 10 ++++---- 9 files changed, 52 insertions(+), 55 deletions(-) (limited to 'gr-howto-write-a-block') diff --git a/gr-howto-write-a-block/Makefile.common b/gr-howto-write-a-block/Makefile.common index c81bc780d..e628d6b16 100644 --- a/gr-howto-write-a-block/Makefile.common +++ b/gr-howto-write-a-block/Makefile.common @@ -1,6 +1,6 @@ # -*- Makefile -*- # -# Copyright 2004,2006,2009 Free Software Foundation, Inc. +# Copyright 2004,2006,2009,2010 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -20,6 +20,9 @@ # Boston, MA 02110-1301, USA. # +# The name of this "out-of-tree" module +modname = howto + # these flags are used when compiling non-SWIG-wrapper files # when going in to non-SWIG libraries AM_CXXFLAGS = @autoconf_default_CXXFLAGS@ @@ -34,21 +37,22 @@ AM_CPPFLAGS = \ # these are used by both SWIG and CXX STD_DEFINES_AND_INCLUDES = \ $(DEFINES) \ + -I$(abs_top_srcdir)/include \ -I$(GNURADIO_CORE_INCLUDEDIR) \ -I$(GNURADIO_CORE_INCLUDEDIR)/swig # includes -grincludedir = $(includedir)/gnuradio +modincludedir = $(includedir)/$(modname) # swig includes -swigincludedir = $(grincludedir)/swig +swigincludedir = $(modincludedir)/swig # Install this stuff in the appropriate subdirectory # This usually ends up at: -# ${prefix}/lib/python${python_version}/site-packages/gnuradio +# ${prefix}/lib/python${python_version}/site-packages/$(modname) -grpythondir = $(pythondir)/gnuradio -grpyexecdir = $(pyexecdir)/gnuradio +modpythondir = $(pythondir)/$(modname) +modpyexecdir = $(pyexecdir)/$(modname) # Data directory for grc block wrappers grc_blocksdir = $(prefix)/share/gnuradio/grc/blocks diff --git a/gr-howto-write-a-block/Makefile.swig.gen.t b/gr-howto-write-a-block/Makefile.swig.gen.t index c15a81721..14e4f7c35 100644 --- a/gr-howto-write-a-block/Makefile.swig.gen.t +++ b/gr-howto-write-a-block/Makefile.swig.gen.t @@ -33,10 +33,8 @@ ## this has to be done in the including Makefile.am -before- ## Makefile.swig is included. -@NAME@_pythondir_category ?= gnuradio/@NAME@ -@NAME@_pylibdir_category ?= $(@NAME@_pythondir_category) -@NAME@_pythondir = $(pythondir)/$(@NAME@_pythondir_category) -@NAME@_pylibdir = $(pyexecdir)/$(@NAME@_pylibdir_category) +@NAME@_pythondir = $(pythondir)/@NAME@ +@NAME@_pylibdir = $(pyexecdir)/@NAME@ ## SWIG headers are always installed into the same directory. @@ -72,7 +70,7 @@ MOSTLYCLEANFILES += $(DEPDIR)/*.S* ## .h file is sometimes built, but not always ... so that one has to ## be added manually by the including Makefile.am . -swig_built_sources += @NAME@.py @NAME@.cc +swig_built_sources += @NAME@_swig.py @NAME@_swig.cc ## Various SWIG variables. These can be overloaded in the including ## Makefile.am by setting the variable value there, then including @@ -83,31 +81,31 @@ swig_built_sources += @NAME@.py @NAME@.cc $(@NAME@_swiginclude_headers) @NAME@_pylib_LTLIBRARIES = \ - _@NAME@.la + _@NAME@_swig.la -_@NAME@_la_SOURCES = \ - @NAME@.cc \ +_@NAME@_swig_la_SOURCES = \ + @NAME@_swig.cc \ $(@NAME@_la_swig_sources) -_@NAME@_la_LIBADD = \ +_@NAME@_swig_la_LIBADD = \ $(STD_SWIG_LA_LIB_ADD) \ $(@NAME@_la_swig_libadd) -_@NAME@_la_LDFLAGS = \ +_@NAME@_swig_la_LDFLAGS = \ $(STD_SWIG_LA_LD_FLAGS) \ $(@NAME@_la_swig_ldflags) -_@NAME@_la_CXXFLAGS = \ +_@NAME@_swig_la_CXXFLAGS = \ $(STD_SWIG_CXX_FLAGS) \ $(@NAME@_la_swig_cxxflags) @NAME@_python_PYTHON = \ - @NAME@.py \ + @NAME@_swig.py \ $(@NAME@_python) ## Entry rule for running SWIG -@NAME@.h @NAME@.py @NAME@.cc: @NAME@.i +@NAME@.h @NAME@_swig.py @NAME@_swig.cc: @NAME@.i ## This rule will get called only when MAKE decides that one of the ## targets needs to be created or re-created, because: ## @@ -202,7 +200,7 @@ $(DEPDIR)/@NAME@-generate-stamp: ## if $(SWIG) $(STD_SWIG_PYTHON_ARGS) $(@NAME@_swig_args) \ -MD -MF $(DEPDIR)/@NAME@.Std \ - -module @NAME@ -o @NAME@.cc $(WHAT); then \ + -module @NAME@_swig -o @NAME@_swig.cc $(WHAT); then \ if test $(host_os) = mingw32; then \ $(RM) $(DEPDIR)/@NAME@.Sd; \ $(SED) 's,\\\\,/,g' < $(DEPDIR)/@NAME@.Std \ diff --git a/gr-howto-write-a-block/apps/howto_square.py b/gr-howto-write-a-block/apps/howto_square.py index 8d3d870d8..f14e28325 100755 --- a/gr-howto-write-a-block/apps/howto_square.py +++ b/gr-howto-write-a-block/apps/howto_square.py @@ -5,9 +5,9 @@ # Generated: Thu Nov 12 11:26:07 2009 ################################################## +import howto from gnuradio import eng_notation from gnuradio import gr -from gnuradio import howto from gnuradio.eng_option import eng_option from gnuradio.gr import firdes from gnuradio.wxgui import scopesink2 diff --git a/gr-howto-write-a-block/grc/howto_square2_ff.xml b/gr-howto-write-a-block/grc/howto_square2_ff.xml index 2b46106e8..c58ef0047 100644 --- a/gr-howto-write-a-block/grc/howto_square2_ff.xml +++ b/gr-howto-write-a-block/grc/howto_square2_ff.xml @@ -3,7 +3,7 @@ Square2 howto_square2_ff HOWTO - from gnuradio import howto + import howto howto.square2_ff() diff --git a/gr-howto-write-a-block/grc/howto_square_ff.xml b/gr-howto-write-a-block/grc/howto_square_ff.xml index ed318bfc6..34a0b0a3f 100644 --- a/gr-howto-write-a-block/grc/howto_square_ff.xml +++ b/gr-howto-write-a-block/grc/howto_square_ff.xml @@ -3,7 +3,7 @@ Square howto_square_ff HOWTO - from gnuradio import howto + import howto howto.square_ff() diff --git a/gr-howto-write-a-block/lib/Makefile.am b/gr-howto-write-a-block/lib/Makefile.am index 336cb8a20..2e76ee453 100644 --- a/gr-howto-write-a-block/lib/Makefile.am +++ b/gr-howto-write-a-block/lib/Makefile.am @@ -1,5 +1,5 @@ # -# Copyright 2004,2005,2006,2008,2009 Free Software Foundation, Inc. +# Copyright 2004,2005,2006,2008,2009,2010 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -28,21 +28,21 @@ TESTS = test_all # howto C++ library: libgnuradio-howto.so # ---------------------------------------------------------------- -# C/C++ headers get installed in ${prefix}/include/gnuradio -grinclude_HEADERS = \ - howto_square_ff.h \ +# C/C++ headers get installed in ${prefix}/include/$(modname) +modinclude_HEADERS = \ + howto_square_ff.h \ howto_square2_ff.h lib_LTLIBRARIES = libgnuradio-howto.la -libgnuradio_howto_la_SOURCES = \ - howto_square_ff.cc \ +libgnuradio_howto_la_SOURCES = \ + howto_square_ff.cc \ howto_square2_ff.cc -libgnuradio_howto_la_LIBADD = \ +libgnuradio_howto_la_LIBADD = \ $(GNURADIO_CORE_LA) -libgnuradio_howto_la_LDFLAGS = \ +libgnuradio_howto_la_LDFLAGS = \ $(NO_UNDEFINED) # ---------------------------------------------------------------- @@ -51,23 +51,23 @@ libgnuradio_howto_la_LDFLAGS = \ noinst_LTLIBRARIES = libgnuradio-howto-qa.la -libgnuradio_howto_qa_la_SOURCES = \ - qa_howto.cc \ - qa_howto_square_ff.cc \ +libgnuradio_howto_qa_la_SOURCES = \ + qa_howto.cc \ + qa_howto_square_ff.cc \ qa_howto_square2_ff.cc libgnuradio_howto_qa_la_LDFLAGS = $(NO_UNDEFINED) -version-info 0:0:0 -libgnuradio_howto_qa_la_LIBADD = \ - libgnuradio-howto.la \ +libgnuradio_howto_qa_la_LIBADD = \ + libgnuradio-howto.la \ $(CPPUNIT_LIBS) # ---------------------------------------------------------------- # headers that don't get installed # ---------------------------------------------------------------- -noinst_HEADERS = \ - qa_howto.h \ - qa_howto_square_ff.h \ +noinst_HEADERS = \ + qa_howto.h \ + qa_howto_square_ff.h \ qa_howto_square2_ff.h # ---------------------------------------------------------------- diff --git a/gr-howto-write-a-block/python/Makefile.am b/gr-howto-write-a-block/python/Makefile.am index 4ef5fc964..ae36ea665 100644 --- a/gr-howto-write-a-block/python/Makefile.am +++ b/gr-howto-write-a-block/python/Makefile.am @@ -1,5 +1,5 @@ # -# Copyright 2004 Free Software Foundation, Inc. +# Copyright 2004,2010 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -21,12 +21,10 @@ include $(top_srcdir)/Makefile.common -ourpythondir = $(grpythondir)/howto - EXTRA_DIST = run_tests.in TESTS = run_tests -ourpython_PYTHON = \ +modpython_PYTHON = \ __init__.py noinst_PYTHON = \ diff --git a/gr-howto-write-a-block/swig/Makefile.am b/gr-howto-write-a-block/swig/Makefile.am index fc40109d0..140d54f80 100644 --- a/gr-howto-write-a-block/swig/Makefile.am +++ b/gr-howto-write-a-block/swig/Makefile.am @@ -1,5 +1,5 @@ # -# Copyright 2004,2005,2006,2008,2009 Free Software Foundation, Inc. +# Copyright 2004,2005,2006,2008,2009,2010 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -27,14 +27,13 @@ if PYTHON ################################### # SWIG Python interface and library -TOP_SWIG_IFILES = \ +TOP_SWIG_IFILES = \ howto.i # Install so that they end up available as: -# import gnuradio.howto +# import howto # This ends up at: -# ${prefix}/lib/python${python_version}/site-packages/gnuradio -howto_pythondir_category = gnuradio/howto +# ${prefix}/lib/python${python_version}/site-packages/$(modname) howto_la_swig_libadd = \ $(top_builddir)/lib/libgnuradio-howto.la @@ -48,7 +47,7 @@ BUILT_SOURCES = $(swig_built_sources) no_dist_files = $(swig_built_sources) # additional SWIG files to be installed -howto_swiginclude_headers = \ +swiginclude_headers = \ howto_square_ff.i \ howto_square2_ff.i diff --git a/gr-howto-write-a-block/swig/Makefile.swig.gen b/gr-howto-write-a-block/swig/Makefile.swig.gen index c62e5aa3e..1809032d3 100644 --- a/gr-howto-write-a-block/swig/Makefile.swig.gen +++ b/gr-howto-write-a-block/swig/Makefile.swig.gen @@ -33,10 +33,8 @@ ## 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_pythondir = $(pythondir)/howto +howto_pylibdir = $(pyexecdir)/howto ## SWIG headers are always installed into the same directory. @@ -79,7 +77,7 @@ swig_built_sources += howto_swig.py howto_swig.cc ## Makefile.swig . howto_swiginclude_HEADERS = \ - howto.i \ + howto.i \ $(howto_swiginclude_headers) howto_pylib_LTLIBRARIES = \ @@ -89,7 +87,7 @@ _howto_swig_la_SOURCES = \ howto_swig.cc \ $(howto_la_swig_sources) -_howto_swig_la_LIBADD = \ +_howto_swig_la_LIBADD = \ $(STD_SWIG_LA_LIB_ADD) \ $(howto_la_swig_libadd) -- cgit