Refactor gr-howto-write-a-block such that it no longer installs into
authorEric Blossom <eb@comsec.com>
Thu, 4 Mar 2010 15:02:42 +0000 (07:02 -0800)
committerEric Blossom <eb@comsec.com>
Thu, 4 Mar 2010 15:02:42 +0000 (07:02 -0800)
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
gr-howto-write-a-block/Makefile.swig.gen.t
gr-howto-write-a-block/apps/howto_square.py
gr-howto-write-a-block/grc/howto_square2_ff.xml
gr-howto-write-a-block/grc/howto_square_ff.xml
gr-howto-write-a-block/lib/Makefile.am
gr-howto-write-a-block/python/Makefile.am
gr-howto-write-a-block/swig/Makefile.am
gr-howto-write-a-block/swig/Makefile.swig.gen

index c81bc780dcf4efc2ed61a369ef0a562baa745439..e628d6b1606f2fb2cb9d62bcc5d52ea302f641db 100644 (file)
@@ -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
index c15a8172144f2ca15b629b3de98cc3d1c43f8c68..14e4f7c35d0d432899b0ef9ba46fd0b34619f19e 100644 (file)
 ## 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 \
index 8d3d870d8426c5b93f19a661f5b5c5209e8d9db1..f14e28325d9cb7b7687befde7b9630ebca710305 100755 (executable)
@@ -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
index 2b46106e819f64cbade9f2298e8c05f49cdad992..c58ef00478ccb3a132728ade67510f46c498d3bc 100644 (file)
@@ -3,7 +3,7 @@
   <name>Square2</name>
   <key>howto_square2_ff</key>
   <category>HOWTO</category>
-  <import>from gnuradio import howto</import>
+  <import>import howto</import>
   <make>howto.square2_ff()</make>
 
   <sink>
index ed318bfc6e6e830f2f7a63418698969143cda004..34a0b0a3f25aea18b6cee16af01cbc81ec246adb 100644 (file)
@@ -3,7 +3,7 @@
   <name>Square</name>
   <key>howto_square_ff</key>
   <category>HOWTO</category>
-  <import>from gnuradio import howto</import>
+  <import>import howto</import>
   <make>howto.square_ff()</make>
 
   <sink>
index 336cb8a203e3caf5b6ad0f73b0f79d86b2a203f8..2e76ee453c085228e3fac456fda95f2ee774568a 100644 (file)
@@ -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
 
 # ----------------------------------------------------------------
index 4ef5fc964d276fac3c858ab26dedf4d92878a9d2..ae36ea665f0588390c58f076a10d7cef80f23f64 100644 (file)
@@ -1,5 +1,5 @@
 #
-# Copyright 2004 Free Software Foundation, Inc.
+# Copyright 2004,2010 Free Software Foundation, Inc.
 # 
 # This file is part of GNU Radio
 # 
 
 include $(top_srcdir)/Makefile.common
 
-ourpythondir = $(grpythondir)/howto
-
 EXTRA_DIST = run_tests.in
 TESTS = run_tests
 
-ourpython_PYTHON = \
+modpython_PYTHON = \
        __init__.py
 
 noinst_PYTHON = \
index fc40109d0568e3cc061bdc334e8e7ed28fbd2423..140d54f807e54492d5200fd7e7daa3f1c4545b29 100644 (file)
@@ -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
 
index c62e5aa3e0a1beb9de01c71b5c61172a2bf06118..1809032d337f21b59974452f915b6b1f512863d3 100644 (file)
 ## 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)