From d90ecd7c89cd51eb4c06247ede0eb52337cce5d2 Mon Sep 17 00:00:00 2001 From: Max Date: Sun, 25 Sep 2022 18:53:44 -0400 Subject: [PATCH] gr3.8 build --- CMakeLists.txt | 18 +++++++++++++ README | 23 ++++++++++++++++ README-gr3.8.patch | 26 +++++-------------- README-gr3.9 | 3 +-- install.sh | 5 +++- op25/gr-op25/CMakeLists.txt | 12 ++++++--- op25/gr-op25/lib/CMakeLists.txt | 2 +- op25/gr-op25/python/CMakeLists.txt | 2 +- op25/gr-op25/swig/CMakeLists.txt | 8 +++--- op25/gr-op25_repeater/CMakeLists.txt | 12 ++++++--- op25/gr-op25_repeater/apps/audio.py | 2 +- op25/gr-op25_repeater/apps/http_server.py | 2 +- op25/gr-op25_repeater/apps/multi_rx.py | 2 +- op25/gr-op25_repeater/apps/rx.py | 2 +- op25/gr-op25_repeater/apps/sockaudio.py | 2 +- op25/gr-op25_repeater/apps/terminal.py | 2 +- op25/gr-op25_repeater/apps/tx/dv_tx.py | 2 +- .../apps/tx/generate-tsbks.py | 2 +- op25/gr-op25_repeater/apps/tx/multi_tx.py | 2 +- op25/gr-op25_repeater/apps/tx/op25_tx.py | 2 +- op25/gr-op25_repeater/apps/tx/p25craft.py | 2 +- op25/gr-op25_repeater/apps/tx/unpack.py | 2 +- .../apps/util/arb-resample.py | 2 +- .../apps/util/cqpsk-demod-file.py | 2 +- op25/gr-op25_repeater/lib/CMakeLists.txt | 2 +- op25/gr-op25_repeater/python/CMakeLists.txt | 2 +- op25/gr-op25_repeater/swig/CMakeLists.txt | 8 +++--- 27 files changed, 93 insertions(+), 58 deletions(-) create mode 100644 README diff --git a/CMakeLists.txt b/CMakeLists.txt index 56f95f4..c43483a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,6 +4,24 @@ project(gr-op25 CXX C) set(CMAKE_BUILD_TYPE Debug) set(CMAKE_CXX_FLAGS "-std=c++11") +execute_process(COMMAND python3 -c " +import os +import sys +from distutils import sysconfig +pfx = '/usr/local' +m1 = os.path.join('lib', 'python' + sys.version[:3], 'dist-packages') +m2 = sysconfig.get_python_lib(plat_specific=True, prefix='') +f1 = os.path.join(pfx, m1) +f2 = os.path.join(pfx, m2) +ok2 = f2 in sys.path +if ok2: + print(m2) +else: + print(m1) +" OUTPUT_VARIABLE OP25_PYTHON_DIR OUTPUT_STRIP_TRAILING_WHITESPACE +) +MESSAGE(STATUS "OP25_PYTHON_DIR has been set to \"${OP25_PYTHON_DIR}\".") + add_subdirectory(op25/gr-op25) add_subdirectory(op25/gr-op25_repeater) diff --git a/README b/README new file mode 100644 index 0000000..335b2a1 --- /dev/null +++ b/README @@ -0,0 +1,23 @@ + +As of this writing (Sept. 2022) OP25 builds for python3 and GNU Radio 3.8. + +The full list of supported versions is as follows: + +PYTHON 2 AND GNU RADIO 3.7 +========================== +It should still be possible to use the file gr3.8.patch (in reverse) to +downgrade the source tree to build against Python 2 and GNU Radio 3.7, +although this has not been tested. + $ cat gr3.8.patch | patch -p1 -R +Once this has been done, proceed by running the install.sh script. + +PYTHON 3 AND GNU RADIO 3.8 +========================== +It is no longer necessary to apply the gr3.8 patch to the op25 source tree, +as Python3/GNU Radio 3.8 is now the default. You can proceed directly to +running the install.sh script. + +PYTHON 3 AND GNU RADIO 3.9 / 3.10 +================================= +It is no longer necessary to apply the gr3.8 patch to the op25 source tree, +See the file README-gr3.9 for procedures for both GNU Radio 3.9 and 3.10. diff --git a/README-gr3.8.patch b/README-gr3.8.patch index b0e4bea..5efdca7 100644 --- a/README-gr3.8.patch +++ b/README-gr3.8.patch @@ -1,22 +1,10 @@ -Feb. 2020 +Updated Sept. 2022 -By default, OP25 builds for python2 and gnuradio3.7. - -Rather than branching the repo source tree and until such time as -gnuradio3.8 should become standard, it was decided to distribute -the necessary mods to build OP25 for gnuradio3.8 / python3 in -the form of a patch (in file gr3.8.patch). - -To apply -# first, if necessary "sudo make uninstall" from your build dir -# (if op25 already installed) -# then, cd to the top level op25 directory -cat gr3.8.patch | patch -p1 -# finally, run "install.sh" as usual - -NOTE: This patch only affects the cmake (build) process; the -python apps (.py files) have been rewritten to be compatible with -either version (2 or 3) of python. It's possible there may be -leftover bugs from that process - please report if so. +By default, OP25 now builds for Python3 and GNU Radio3.8. +Accordingly, it is no longer necessary to apply the op25 patch +for gr3.8. +It should be possible to use the gr3.8.patch in reverse to downgrade +the source tree to build for Python 2 and GNU Radio 3.7. See the +file README in this directory for details. diff --git a/README-gr3.9 b/README-gr3.9 index b37ef71..0991be4 100644 --- a/README-gr3.9 +++ b/README-gr3.9 @@ -9,8 +9,7 @@ Installation cd ...path-to-existing/op25/build sudo make uninstall -1. Apply the patch for gr3.8 as described in file README-gr3.8.patch - in this directory. +1. Step 1 is removed. 2. Run the command ./install-gr3.9.sh diff --git a/install.sh b/install.sh index 651b8ce..771de20 100755 --- a/install.sh +++ b/install.sh @@ -10,9 +10,12 @@ if [ ! -d op25/gr-op25 ]; then exit fi +sudo sed -i -- 's/^# *deb-src/deb-src/' /etc/apt/sources.list + sudo apt-get update sudo apt-get build-dep gnuradio -sudo apt-get install gnuradio gnuradio-dev gr-osmosdr librtlsdr-dev libuhd-dev libhackrf-dev libitpp-dev libpcap-dev cmake git swig build-essential pkg-config doxygen python-numpy python-waitress python-requests +sudo apt-get install gnuradio gnuradio-dev gr-osmosdr librtlsdr-dev libuhd-dev libhackrf-dev libitpp-dev libpcap-dev cmake git swig build-essential pkg-config doxygen python3-numpy python3-waitress python3-requests +sudo apt-get install liborc-dev mkdir build cd build diff --git a/op25/gr-op25/CMakeLists.txt b/op25/gr-op25/CMakeLists.txt index 6c05df5..1c6fa23 100644 --- a/op25/gr-op25/CMakeLists.txt +++ b/op25/gr-op25/CMakeLists.txt @@ -68,6 +68,9 @@ endif() ######################################################################## find_package(CppUnit) +set(ENABLE_PYTHON "TRUE" CACHE BOOL "enable python") +cmake_policy(SET CMP0012 NEW) + # To run a more advanced search for GNU Radio and it's components and # versions, use the following. Add any components required to the list # of GR_REQUIRED_COMPONENTS (in all caps) and change "version" to the @@ -76,11 +79,12 @@ find_package(CppUnit) # set(GR_REQUIRED_COMPONENTS RUNTIME BLOCKS FILTER ...) # find_package(Gnuradio "version") set(GR_REQUIRED_COMPONENTS RUNTIME BLOCKS FILTER PMT) -find_package(Gnuradio) - -if(NOT GNURADIO_RUNTIME_FOUND) - message(FATAL_ERROR "GnuRadio Runtime required to compile op25") +SET(MIN_GR_VERSION "3.8.0") +find_package(Gnuradio REQUIRED) +if("${Gnuradio_VERSION}" VERSION_LESS MIN_GR_VERSION) + MESSAGE(FATAL_ERROR "GnuRadio version required: >=\"" ${MIN_GR_VERSION} "\" found: \"" ${Gnuradio_VERSION} "\"") endif() + if(NOT CPPUNIT_FOUND) message(FATAL_ERROR "CppUnit required to compile op25") endif() diff --git a/op25/gr-op25/lib/CMakeLists.txt b/op25/gr-op25/lib/CMakeLists.txt index 1befdd9..609fa84 100644 --- a/op25/gr-op25/lib/CMakeLists.txt +++ b/op25/gr-op25/lib/CMakeLists.txt @@ -63,7 +63,7 @@ list(APPEND op25_sources ) add_library(gnuradio-op25 SHARED ${op25_sources}) -target_link_libraries(gnuradio-op25 ${Boost_LIBRARIES} ${GNURADIO_RUNTIME_LIBRARIES} itpp pcap) +target_link_libraries(gnuradio-op25 ${Boost_LIBRARIES} gnuradio::gnuradio-runtime itpp pcap) set_target_properties(gnuradio-op25 PROPERTIES DEFINE_SYMBOL "gnuradio_op25_EXPORTS") ######################################################################## diff --git a/op25/gr-op25/python/CMakeLists.txt b/op25/gr-op25/python/CMakeLists.txt index 03361a2..e497faa 100644 --- a/op25/gr-op25/python/CMakeLists.txt +++ b/op25/gr-op25/python/CMakeLists.txt @@ -31,7 +31,7 @@ endif() GR_PYTHON_INSTALL( FILES __init__.py - DESTINATION ${GR_PYTHON_DIR}/op25 + DESTINATION ${OP25_PYTHON_DIR}/op25 ) ######################################################################## diff --git a/op25/gr-op25/swig/CMakeLists.txt b/op25/gr-op25/swig/CMakeLists.txt index e99226f..fd7bd85 100644 --- a/op25/gr-op25/swig/CMakeLists.txt +++ b/op25/gr-op25/swig/CMakeLists.txt @@ -21,7 +21,7 @@ # Include swig generation macros ######################################################################## find_package(SWIG) -find_package(PythonLibs 2) +find_package(PythonLibs 3) if(NOT SWIG_FOUND OR NOT PYTHONLIBS_FOUND) return() endif() @@ -31,9 +31,7 @@ include(GrPython) ######################################################################## # Setup swig generation ######################################################################## -foreach(incdir ${GNURADIO_RUNTIME_INCLUDE_DIRS}) - list(APPEND GR_SWIG_INCLUDE_DIRS ${incdir}/gnuradio/swig) -endforeach(incdir) +set(GR_SWIG_INCLUDE_DIRS $) set(GR_SWIG_LIBRARIES gnuradio-op25) set(GR_SWIG_DOC_FILE ${CMAKE_CURRENT_BINARY_DIR}/op25_swig_doc.i) @@ -44,7 +42,7 @@ GR_SWIG_MAKE(op25_swig op25_swig.i) ######################################################################## # Install the build swig module ######################################################################## -GR_SWIG_INSTALL(TARGETS op25_swig DESTINATION ${GR_PYTHON_DIR}/op25) +GR_SWIG_INSTALL(TARGETS op25_swig DESTINATION ${OP25_PYTHON_DIR}/op25) ######################################################################## # Install swig .i files for development diff --git a/op25/gr-op25_repeater/CMakeLists.txt b/op25/gr-op25_repeater/CMakeLists.txt index fa29b9e..dc1d8e7 100644 --- a/op25/gr-op25_repeater/CMakeLists.txt +++ b/op25/gr-op25_repeater/CMakeLists.txt @@ -68,6 +68,9 @@ endif() ######################################################################## find_package(CppUnit) +set(ENABLE_PYTHON "TRUE" CACHE BOOL "enable python") +cmake_policy(SET CMP0012 NEW) + # To run a more advanced search for GNU Radio and it's components and # versions, use the following. Add any components required to the list # of GR_REQUIRED_COMPONENTS (in all caps) and change "version" to the @@ -75,11 +78,12 @@ find_package(CppUnit) # set(GR_REQUIRED_COMPONENTS RUNTIME BLOCKS FILTER PMT) # find_package(Gnuradio "version") -find_package(Gnuradio) - -if(NOT GNURADIO_RUNTIME_FOUND) - message(FATAL_ERROR "GnuRadio Runtime required to compile op25_repeater") +set(MIN_GR_VERSION "3.8.0") +find_package(Gnuradio REQUIRED) +if("${Gnuradio_VERSION}" VERSION_LESS MIN_GR_VERSION) + MESSAGE(FATAL_ERROR "GnuRadio version required: >=\"" ${MIN_GR_VERSION} "\" found: \"" ${Gnuradio_VERSION} "\"") endif() + if(NOT CPPUNIT_FOUND) message(FATAL_ERROR "CppUnit required to compile op25_repeater") endif() diff --git a/op25/gr-op25_repeater/apps/audio.py b/op25/gr-op25_repeater/apps/audio.py index 26cbe4f..255812f 100755 --- a/op25/gr-op25_repeater/apps/audio.py +++ b/op25/gr-op25_repeater/apps/audio.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # Copyright 2017, 2018 Graham Norbury # diff --git a/op25/gr-op25_repeater/apps/http_server.py b/op25/gr-op25_repeater/apps/http_server.py index 9bf748a..1d10795 100755 --- a/op25/gr-op25_repeater/apps/http_server.py +++ b/op25/gr-op25_repeater/apps/http_server.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # Copyright 2017, 2018, 2019, 2020 Max H. Parke KA1RBI # diff --git a/op25/gr-op25_repeater/apps/multi_rx.py b/op25/gr-op25_repeater/apps/multi_rx.py index 5674acc..ddd7537 100755 --- a/op25/gr-op25_repeater/apps/multi_rx.py +++ b/op25/gr-op25_repeater/apps/multi_rx.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # Copyright 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020 Max H. Parke KA1RBI # diff --git a/op25/gr-op25_repeater/apps/rx.py b/op25/gr-op25_repeater/apps/rx.py index 2e30380..56e4ac0 100755 --- a/op25/gr-op25_repeater/apps/rx.py +++ b/op25/gr-op25_repeater/apps/rx.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # Copyright 2008-2011 Steve Glass # diff --git a/op25/gr-op25_repeater/apps/sockaudio.py b/op25/gr-op25_repeater/apps/sockaudio.py index 76282ac..68c6adb 100755 --- a/op25/gr-op25_repeater/apps/sockaudio.py +++ b/op25/gr-op25_repeater/apps/sockaudio.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # Copyright 2017, 2018 Graham Norbury # diff --git a/op25/gr-op25_repeater/apps/terminal.py b/op25/gr-op25_repeater/apps/terminal.py index 9afbb7c..fb4b7f8 100755 --- a/op25/gr-op25_repeater/apps/terminal.py +++ b/op25/gr-op25_repeater/apps/terminal.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # Copyright 2008-2011 Steve Glass # diff --git a/op25/gr-op25_repeater/apps/tx/dv_tx.py b/op25/gr-op25_repeater/apps/tx/dv_tx.py index a687127..c841176 100755 --- a/op25/gr-op25_repeater/apps/tx/dv_tx.py +++ b/op25/gr-op25_repeater/apps/tx/dv_tx.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 ################################################################################# # diff --git a/op25/gr-op25_repeater/apps/tx/generate-tsbks.py b/op25/gr-op25_repeater/apps/tx/generate-tsbks.py index a823b0d..fa1eb01 100755 --- a/op25/gr-op25_repeater/apps/tx/generate-tsbks.py +++ b/op25/gr-op25_repeater/apps/tx/generate-tsbks.py @@ -1,4 +1,4 @@ -#! /usr/bin/python +#! /usr/bin/python3 from p25craft import make_fakecc_tsdu diff --git a/op25/gr-op25_repeater/apps/tx/multi_tx.py b/op25/gr-op25_repeater/apps/tx/multi_tx.py index f0e4ba8..6c5c6dc 100755 --- a/op25/gr-op25_repeater/apps/tx/multi_tx.py +++ b/op25/gr-op25_repeater/apps/tx/multi_tx.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 ################################################################################# # diff --git a/op25/gr-op25_repeater/apps/tx/op25_tx.py b/op25/gr-op25_repeater/apps/tx/op25_tx.py index 4f07e9e..8d67a47 100755 --- a/op25/gr-op25_repeater/apps/tx/op25_tx.py +++ b/op25/gr-op25_repeater/apps/tx/op25_tx.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # # Copyright 2005,2006,2007 Free Software Foundation, Inc. # diff --git a/op25/gr-op25_repeater/apps/tx/p25craft.py b/op25/gr-op25_repeater/apps/tx/p25craft.py index 9b42e06..68ae214 100755 --- a/op25/gr-op25_repeater/apps/tx/p25craft.py +++ b/op25/gr-op25_repeater/apps/tx/p25craft.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/python3 # # p25craft.py - utility for crafting APCO P25 packets # diff --git a/op25/gr-op25_repeater/apps/tx/unpack.py b/op25/gr-op25_repeater/apps/tx/unpack.py index 5e0e84e..0a8f0ad 100755 --- a/op25/gr-op25_repeater/apps/tx/unpack.py +++ b/op25/gr-op25_repeater/apps/tx/unpack.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 from gnuradio import gr, audio, eng_notation, blocks from gnuradio.eng_option import eng_option from optparse import OptionParser diff --git a/op25/gr-op25_repeater/apps/util/arb-resample.py b/op25/gr-op25_repeater/apps/util/arb-resample.py index 7f99561..a0fccbe 100755 --- a/op25/gr-op25_repeater/apps/util/arb-resample.py +++ b/op25/gr-op25_repeater/apps/util/arb-resample.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 import sys import math diff --git a/op25/gr-op25_repeater/apps/util/cqpsk-demod-file.py b/op25/gr-op25_repeater/apps/util/cqpsk-demod-file.py index b26a870..65ccec6 100755 --- a/op25/gr-op25_repeater/apps/util/cqpsk-demod-file.py +++ b/op25/gr-op25_repeater/apps/util/cqpsk-demod-file.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # # (C) Copyright 2010, 2014 Max H. Parke, KA1RBI diff --git a/op25/gr-op25_repeater/lib/CMakeLists.txt b/op25/gr-op25_repeater/lib/CMakeLists.txt index da84e14..1464230 100644 --- a/op25/gr-op25_repeater/lib/CMakeLists.txt +++ b/op25/gr-op25_repeater/lib/CMakeLists.txt @@ -68,7 +68,7 @@ else(CMAKE_SYSTEM_NAME STREQUAL "Darwin") find_library(GR_FILTER_LIBRARY libgnuradio-filter.so ) endif(CMAKE_SYSTEM_NAME STREQUAL "Darwin") set(GR_FILTER_LIBRARIES ${GR_FILTER_LIBRARY}) -target_link_libraries(gnuradio-op25_repeater ${Boost_LIBRARIES} ${GNURADIO_RUNTIME_LIBRARIES} ${GR_FILTER_LIBRARIES} imbe_vocoder) +target_link_libraries(gnuradio-op25_repeater ${Boost_LIBRARIES} gnuradio::gnuradio-runtime ${GR_FILTER_LIBRARIES} imbe_vocoder) set_target_properties(gnuradio-op25_repeater PROPERTIES DEFINE_SYMBOL "gnuradio_op25_repeater_EXPORTS") ######################################################################## diff --git a/op25/gr-op25_repeater/python/CMakeLists.txt b/op25/gr-op25_repeater/python/CMakeLists.txt index 9958577..bb117a0 100644 --- a/op25/gr-op25_repeater/python/CMakeLists.txt +++ b/op25/gr-op25_repeater/python/CMakeLists.txt @@ -31,7 +31,7 @@ endif() GR_PYTHON_INSTALL( FILES __init__.py - DESTINATION ${GR_PYTHON_DIR}/op25_repeater + DESTINATION ${OP25_PYTHON_DIR}/op25_repeater ) ######################################################################## diff --git a/op25/gr-op25_repeater/swig/CMakeLists.txt b/op25/gr-op25_repeater/swig/CMakeLists.txt index 1d88bbd..50819d7 100644 --- a/op25/gr-op25_repeater/swig/CMakeLists.txt +++ b/op25/gr-op25_repeater/swig/CMakeLists.txt @@ -21,7 +21,7 @@ # Include swig generation macros ######################################################################## find_package(SWIG) -find_package(PythonLibs 2) +find_package(PythonLibs 3) if(NOT SWIG_FOUND OR NOT PYTHONLIBS_FOUND) return() endif() @@ -31,9 +31,7 @@ include(GrPython) ######################################################################## # Setup swig generation ######################################################################## -foreach(incdir ${GNURADIO_RUNTIME_INCLUDE_DIRS}) - list(APPEND GR_SWIG_INCLUDE_DIRS ${incdir}/gnuradio/swig) -endforeach(incdir) +set(GR_SWIG_INCLUDE_DIRS $) set(GR_SWIG_LIBRARIES gnuradio-op25_repeater) set(GR_SWIG_DOC_FILE ${CMAKE_CURRENT_BINARY_DIR}/op25_repeater_swig_doc.i) @@ -44,7 +42,7 @@ GR_SWIG_MAKE(op25_repeater_swig op25_repeater_swig.i) ######################################################################## # Install the build swig module ######################################################################## -GR_SWIG_INSTALL(TARGETS op25_repeater_swig DESTINATION ${GR_PYTHON_DIR}/op25_repeater) +GR_SWIG_INSTALL(TARGETS op25_repeater_swig DESTINATION ${OP25_PYTHON_DIR}/op25_repeater) ######################################################################## # Install swig .i files for development