diff --git a/CMakeLists.txt b/CMakeLists.txt index aa013a34..c136433c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,7 +1,85 @@ +######################################################################## +# Project setup +######################################################################## cmake_minimum_required(VERSION 2.6) project(gr-op25 CXX C) +enable_testing() + +#select the release build type by default to get optimization flags +if(NOT CMAKE_BUILD_TYPE) + set(CMAKE_BUILD_TYPE "Release") + message(STATUS "Build type not specified: defaulting to release.") +endif(NOT CMAKE_BUILD_TYPE) +set(CMAKE_BUILD_TYPE ${CMAKE_BUILD_TYPE} CACHE STRING "") + +######################################################################## +# Compiler specific setup +######################################################################## +if(CMAKE_COMPILER_IS_GNUCXX AND NOT WIN32) + #http://gcc.gnu.org/wiki/Visibility + add_definitions(-fvisibility=hidden) +endif() +######################################################################## +# Find boost +######################################################################## +if(UNIX AND EXISTS "/usr/lib64") + list(APPEND BOOST_LIBRARYDIR "/usr/lib64") #fedora 64-bit fix +endif(UNIX AND EXISTS "/usr/lib64") +set(Boost_ADDITIONAL_VERSIONS + "1.35.0" "1.35" "1.36.0" "1.36" "1.37.0" "1.37" "1.38.0" "1.38" "1.39.0" "1.39" + "1.40.0" "1.40" "1.41.0" "1.41" "1.42.0" "1.42" "1.43.0" "1.43" "1.44.0" "1.44" + "1.45.0" "1.45" "1.46.0" "1.46" "1.47.0" "1.47" "1.48.0" "1.48" "1.49.0" "1.49" + "1.50.0" "1.50" "1.51.0" "1.51" "1.52.0" "1.52" "1.53.0" "1.53" "1.54.0" "1.54" + "1.55.0" "1.55" "1.56.0" "1.56" "1.57.0" "1.57" "1.58.0" "1.58" "1.59.0" "1.59" + "1.60.0" "1.60" "1.61.0" "1.61" "1.62.0" "1.62" "1.63.0" "1.63" "1.64.0" "1.64" + "1.65.0" "1.65" "1.66.0" "1.66" "1.67.0" "1.67" "1.68.0" "1.68" "1.69.0" "1.69" +) +find_package(Boost "1.35" COMPONENTS filesystem system) + +if(NOT Boost_FOUND) + message(FATAL_ERROR "Boost required to compile op25") +endif() + +######################################################################## +# Find gnuradio build dependencies +######################################################################## +list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/Modules) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") +find_package(CppUnit) +if(NOT CPPUNIT_FOUND) + message(FATAL_ERROR "CppUnit required to compile op25") +endif() +set(GR_REQUIRED_COMPONENTS RUNTIME BLOCKS FILTER PMT) +find_package(GnuradioRuntime) +find_package(Gnuradio REQUIRED) +MESSAGE(STATUS "GnuRadio version ${Gnuradio_VERSION}") +if ("${Gnuradio_VERSION}" VERSION_LESS "2.7.0") + MESSAGE(FATAL_ERROR "OP25 Required Gnuradio minimum version 2.7.0") +elseif ("${Gnuradio_VERSION}" VERSION_LESS "3.8.0") + set(OP25_PYTHON_VER 2) +else() + set(OP25_PYTHON_VER 3) +endif() +MESSAGE(STATUS "Configuring for Python ${OP25_PYTHON_VER}") + +execute_process(COMMAND python${OP25_PYTHON_VER} -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-gr3.8.patch b/README-gr3.8.patch deleted file mode 100644 index a35d0bb4..00000000 --- a/README-gr3.8.patch +++ /dev/null @@ -1,16 +0,0 @@ - -Dec. 2020 - -The op25 install.sh script attempts to determine whether you are -building for gnuradio-3.7 with python2 or gnuradio-3.8 with python3 - -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 file gr3.8.patch - -When you run the install.sh script the patch will be applied -automatically if needed. Re-running the install.sh script will -result in warning messages that patches are being skipped. These -may be safely ignored. - diff --git a/README-installation b/README-installation index 5dbdb7e0..117dca0e 100644 --- a/README-installation +++ b/README-installation @@ -4,7 +4,8 @@ These high level instructions will lead you through installing op25 on Debian based Linux systems such as Ubuntu, Linux Mint and similar. Note 1: op25 is currently tested against gnuradio-3.7/python2 with Ubuntu 16.04 -and gnuradio-3.8/python3 with Ubuntu 20.04. +and gnuradio-3.8/python3 with Ubuntu 20.04. Build environment automatically figures +out which version of gnuradio you have and therefore which version of python to use. Note 2: versions of cmake later than 3.10.3 have been known to cause dependency issues while building the swig libraries on pyhton2. At the current time if you diff --git a/cmake/Modules/GrSwig.cmake b/cmake/Modules/GrSwig.cmake index 569667b0..1609b531 100644 --- a/cmake/Modules/GrSwig.cmake +++ b/cmake/Modules/GrSwig.cmake @@ -114,7 +114,7 @@ macro(GR_SWIG_MAKE name) endif() #append additional include directories - find_package(PythonLibs 2) + find_package(PythonLibs ${OP25_PYTHON_VER}) list(APPEND GR_SWIG_INCLUDE_DIRS ${PYTHON_INCLUDE_PATH}) #deprecated name (now dirs) list(APPEND GR_SWIG_INCLUDE_DIRS ${PYTHON_INCLUDE_DIRS}) list(APPEND GR_SWIG_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}) diff --git a/gr3.8.patch b/gr3.8.patch deleted file mode 100644 index 3da662cd..00000000 --- a/gr3.8.patch +++ /dev/null @@ -1,224 +0,0 @@ -diff --git a/install.sh b/install.sh -index cf50de5..e1d934f 100755 ---- a/install.sh -+++ b/install.sh -@@ -10,9 +10,16 @@ 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 gnuplot-x11 -+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 gnuplot-x11 -+ -+if [ ! -x /usr/bin/python ]; then -+ echo ====== installing python-is-python3 -+ sudo apt-get install python-is-python3 -+fi - - if [ ! -f /etc/modprobe.d/blacklist-rtl.conf ]; then - echo ====== installing blacklist-rtl.conf -diff --git a/CMakeLists.txt b/CMakeLists.txt -index aa013a3..23d273d 100644 ---- a/CMakeLists.txt -+++ b/CMakeLists.txt -@@ -3,6 +3,24 @@ project(gr-op25 CXX C) - - set(CMAKE_CXX_FLAGS "${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/cmake/Modules/GrSwig.cmake b/cmake/Modules/GrSwig.cmake -index 569667b..f175cc5 100644 ---- a/cmake/Modules/GrSwig.cmake -+++ b/cmake/Modules/GrSwig.cmake -@@ -114,7 +114,7 @@ macro(GR_SWIG_MAKE name) - endif() - - #append additional include directories -- find_package(PythonLibs 2) -+ find_package(PythonLibs 3) - list(APPEND GR_SWIG_INCLUDE_DIRS ${PYTHON_INCLUDE_PATH}) #deprecated name (now dirs) - list(APPEND GR_SWIG_INCLUDE_DIRS ${PYTHON_INCLUDE_DIRS}) - list(APPEND GR_SWIG_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}) -diff --git a/op25/gr-op25/CMakeLists.txt b/op25/gr-op25/CMakeLists.txt -index 3ab2a79..3c79adf 100644 ---- a/op25/gr-op25/CMakeLists.txt -+++ b/op25/gr-op25/CMakeLists.txt -@@ -94,11 +94,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 255ef93..51b4154 100644 ---- a/op25/gr-op25/lib/CMakeLists.txt -+++ b/op25/gr-op25/lib/CMakeLists.txt -@@ -56,7 +56,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 68d51e8..4aa697f 100644 ---- a/op25/gr-op25_repeater/CMakeLists.txt -+++ b/op25/gr-op25_repeater/CMakeLists.txt -@@ -94,11 +94,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_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/lib/CMakeLists.txt b/op25/gr-op25_repeater/lib/CMakeLists.txt -index 8d3ae9e..6b0003d 100755 ---- a/op25/gr-op25_repeater/lib/CMakeLists.txt -+++ b/op25/gr-op25_repeater/lib/CMakeLists.txt -@@ -85,7 +85,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 diff --git a/install.sh b/install.sh index 377d16fb..ec86e05f 100755 --- a/install.sh +++ b/install.sh @@ -16,7 +16,6 @@ sudo apt-get update GR_VER=$(apt list gnuradio 2>/dev/null | grep -m 1 gnuradio | cut -d' ' -f2 | cut -d'.' -f1,2) if [ ${GR_VER} = "3.8" ]; then echo "Installing for GNURadio 3.8" - cat gr3.8.patch | patch -N -p1 -r - sudo sed -i -- 's/^# *deb-src/deb-src/' /etc/apt/sources.list 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 python3-numpy python3-waitress python3-requests gnuplot-x11 @@ -30,7 +29,7 @@ else 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 gnuplot-x11 # Tell op25 to use python2 - echo "/usr/bin/python" > op25/gr-op25_repeater/apps/op25_python + echo "/usr/bin/python2" > op25/gr-op25_repeater/apps/op25_python fi diff --git a/op25/gr-op25/CMakeLists.txt b/op25/gr-op25/CMakeLists.txt index 3ab2a798..d6024e08 100644 --- a/op25/gr-op25/CMakeLists.txt +++ b/op25/gr-op25/CMakeLists.txt @@ -21,47 +21,7 @@ ######################################################################## # Project setup ######################################################################## -cmake_minimum_required(VERSION 2.6) project(gr-op25 CXX C) -enable_testing() - -#select the release build type by default to get optimization flags -if(NOT CMAKE_BUILD_TYPE) - set(CMAKE_BUILD_TYPE "Release") - message(STATUS "Build type not specified: defaulting to release.") -endif(NOT CMAKE_BUILD_TYPE) -set(CMAKE_BUILD_TYPE ${CMAKE_BUILD_TYPE} CACHE STRING "") - -list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/Modules) - -######################################################################## -# Compiler specific setup -######################################################################## -if(CMAKE_COMPILER_IS_GNUCXX AND NOT WIN32) - #http://gcc.gnu.org/wiki/Visibility - add_definitions(-fvisibility=hidden) -endif() - -######################################################################## -# Find boost -######################################################################## -if(UNIX AND EXISTS "/usr/lib64") - list(APPEND BOOST_LIBRARYDIR "/usr/lib64") #fedora 64-bit fix -endif(UNIX AND EXISTS "/usr/lib64") -set(Boost_ADDITIONAL_VERSIONS - "1.35.0" "1.35" "1.36.0" "1.36" "1.37.0" "1.37" "1.38.0" "1.38" "1.39.0" "1.39" - "1.40.0" "1.40" "1.41.0" "1.41" "1.42.0" "1.42" "1.43.0" "1.43" "1.44.0" "1.44" - "1.45.0" "1.45" "1.46.0" "1.46" "1.47.0" "1.47" "1.48.0" "1.48" "1.49.0" "1.49" - "1.50.0" "1.50" "1.51.0" "1.51" "1.52.0" "1.52" "1.53.0" "1.53" "1.54.0" "1.54" - "1.55.0" "1.55" "1.56.0" "1.56" "1.57.0" "1.57" "1.58.0" "1.58" "1.59.0" "1.59" - "1.60.0" "1.60" "1.61.0" "1.61" "1.62.0" "1.62" "1.63.0" "1.63" "1.64.0" "1.64" - "1.65.0" "1.65" "1.66.0" "1.66" "1.67.0" "1.67" "1.68.0" "1.68" "1.69.0" "1.69" -) -find_package(Boost "1.35" COMPONENTS filesystem system) - -if(NOT Boost_FOUND) - message(FATAL_ERROR "Boost required to compile op25") -endif() ######################################################################## # Install directories @@ -80,29 +40,6 @@ set(GR_LIBEXEC_DIR libexec) set(GR_PKG_LIBEXEC_DIR ${GR_LIBEXEC_DIR}/${CMAKE_PROJECT_NAME}) set(GRC_BLOCKS_DIR ${GR_PKG_DATA_DIR}/grc/blocks) -######################################################################## -# Find gnuradio build dependencies -######################################################################## -find_package(GnuradioRuntime) -find_package(CppUnit) - -# 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 -# minimum API compatible version required. -# -# 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") -endif() -if(NOT CPPUNIT_FOUND) - message(FATAL_ERROR "CppUnit required to compile op25") -endif() - ######################################################################## # Setup the include and linker paths ######################################################################## diff --git a/op25/gr-op25/lib/CMakeLists.txt b/op25/gr-op25/lib/CMakeLists.txt index 255ef936..8cbc4528 100644 --- a/op25/gr-op25/lib/CMakeLists.txt +++ b/op25/gr-op25/lib/CMakeLists.txt @@ -56,7 +56,11 @@ list(APPEND op25_sources ) add_library(gnuradio-op25 SHARED ${op25_sources}) -target_link_libraries(gnuradio-op25 ${Boost_LIBRARIES} ${GNURADIO_RUNTIME_LIBRARIES} itpp pcap) +if ("${Gnuradio_VERSION}" VERSION_LESS "3.8.0") + target_link_libraries(gnuradio-op25 ${Boost_LIBRARIES} ${GNURADIO_RUNTIME_LIBRARIES} itpp pcap) +else() + target_link_libraries(gnuradio-op25 ${Boost_LIBRARIES} gnuradio::gnuradio-runtime itpp pcap) +endif() 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 03361a2b..e497faae 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 e99226fd..17366b7c 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 ${OP25_PYTHON_VER}) if(NOT SWIG_FOUND OR NOT PYTHONLIBS_FOUND) return() endif() @@ -31,9 +31,13 @@ include(GrPython) ######################################################################## # Setup swig generation ######################################################################## -foreach(incdir ${GNURADIO_RUNTIME_INCLUDE_DIRS}) - list(APPEND GR_SWIG_INCLUDE_DIRS ${incdir}/gnuradio/swig) -endforeach(incdir) +if ("${Gnuradio_VERSION}" VERSION_LESS "3.8.0") + foreach(incdir ${GNURADIO_RUNTIME_INCLUDE_DIRS}) + list(APPEND GR_SWIG_INCLUDE_DIRS ${incdir}/gnuradio/swig) + endforeach(incdir) +else() + set(GR_SWIG_INCLUDE_DIRS $) +endif() set(GR_SWIG_LIBRARIES gnuradio-op25) set(GR_SWIG_DOC_FILE ${CMAKE_CURRENT_BINARY_DIR}/op25_swig_doc.i) @@ -44,7 +48,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 68d51e85..d6c91f6e 100644 --- a/op25/gr-op25_repeater/CMakeLists.txt +++ b/op25/gr-op25_repeater/CMakeLists.txt @@ -17,51 +17,10 @@ # the Free Software Foundation, Inc., 51 Franklin Street, # Boston, MA 02110-1301, USA. - ######################################################################## # Project setup ######################################################################## -cmake_minimum_required(VERSION 2.6) project(gr-op25_repeater CXX C) -enable_testing() - -#select the release build type by default to get optimization flags -if(NOT CMAKE_BUILD_TYPE) - set(CMAKE_BUILD_TYPE "Release") - message(STATUS "Build type not specified: defaulting to release.") -endif(NOT CMAKE_BUILD_TYPE) -set(CMAKE_BUILD_TYPE ${CMAKE_BUILD_TYPE} CACHE STRING "") - -list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/Modules) - -######################################################################## -# Compiler specific setup -######################################################################## -if(CMAKE_COMPILER_IS_GNUCXX AND NOT WIN32) - #http://gcc.gnu.org/wiki/Visibility - add_definitions(-fvisibility=hidden) -endif() - -######################################################################## -# Find boost -######################################################################## -if(UNIX AND EXISTS "/usr/lib64") - list(APPEND BOOST_LIBRARYDIR "/usr/lib64") #fedora 64-bit fix -endif(UNIX AND EXISTS "/usr/lib64") -set(Boost_ADDITIONAL_VERSIONS - "1.35.0" "1.35" "1.36.0" "1.36" "1.37.0" "1.37" "1.38.0" "1.38" "1.39.0" "1.39" - "1.40.0" "1.40" "1.41.0" "1.41" "1.42.0" "1.42" "1.43.0" "1.43" "1.44.0" "1.44" - "1.45.0" "1.45" "1.46.0" "1.46" "1.47.0" "1.47" "1.48.0" "1.48" "1.49.0" "1.49" - "1.50.0" "1.50" "1.51.0" "1.51" "1.52.0" "1.52" "1.53.0" "1.53" "1.54.0" "1.54" - "1.55.0" "1.55" "1.56.0" "1.56" "1.57.0" "1.57" "1.58.0" "1.58" "1.59.0" "1.59" - "1.60.0" "1.60" "1.61.0" "1.61" "1.62.0" "1.62" "1.63.0" "1.63" "1.64.0" "1.64" - "1.65.0" "1.65" "1.66.0" "1.66" "1.67.0" "1.67" "1.68.0" "1.68" "1.69.0" "1.69" -) -find_package(Boost "1.35" COMPONENTS filesystem system) - -if(NOT Boost_FOUND) - message(FATAL_ERROR "Boost required to compile op25_repeater") -endif() ######################################################################## # Install directories @@ -80,29 +39,6 @@ set(GR_LIBEXEC_DIR libexec) set(GR_PKG_LIBEXEC_DIR ${GR_LIBEXEC_DIR}/${CMAKE_PROJECT_NAME}) set(GRC_BLOCKS_DIR ${GR_PKG_DATA_DIR}/grc/blocks) -######################################################################## -# Find gnuradio build dependencies -######################################################################## -find_package(GnuradioRuntime) -find_package(CppUnit) - -# 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 -# minimum API compatible version required. -# -# 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_repeater") -endif() -if(NOT CPPUNIT_FOUND) - message(FATAL_ERROR "CppUnit required to compile op25_repeater") -endif() - ######################################################################## # Setup the include and linker paths ######################################################################## diff --git a/op25/gr-op25_repeater/apps/.gitignore b/op25/gr-op25_repeater/apps/.gitignore index a0488c36..314f8a73 100644 --- a/op25/gr-op25_repeater/apps/.gitignore +++ b/op25/gr-op25_repeater/apps/.gitignore @@ -9,6 +9,7 @@ stderr* *.txt *.liq *.bin +op25_python # Tracked files that would otherwise be excluded !op25.sh diff --git a/op25/gr-op25_repeater/apps/multi_rx.py b/op25/gr-op25_repeater/apps/multi_rx.py index 488f34e7..d8fbd6cf 100755 --- a/op25/gr-op25_repeater/apps/multi_rx.py +++ b/op25/gr-op25_repeater/apps/multi_rx.py @@ -725,6 +725,8 @@ def nbfm_control(self, msgq_id, action): def process_qmsg(self, msg): # Handle UI requests RX_COMMANDS = 'skip lockout hold whitelist reload'.split() + if msg is None: + return True s = msg.to_string() if type(s) is not str and isinstance(s, bytes): # should only get here if python3 @@ -812,6 +814,10 @@ def kill(self): if self.audio_instances[instance] is not None: self.audio_instances[instance].stop() + for meta_s in self.meta_streams: + if self.meta_streams[meta_s] is not None: + self.meta_streams[meta_s][0].stop() + if self.terminal is not None: self.terminal.end_terminal() @@ -832,9 +838,15 @@ def __init__(self, msgq, callback, **kwds): self.start() def run(self): - while(self.keep_running): - msg = self.msgq.delete_head() - self.callback(msg) + try: + while(self.keep_running): + msg = self.msgq.delete_head() + if msg is not None: + self.callback(msg) + else: + self.keep_running = False + except: + self.keep_running = False def kill(self): self.keep_running = False @@ -866,7 +878,10 @@ def byteify(input): # thx so # wait for gdb if options.pause: sys.stdout.write("Ready for GDB to attach (pid = %d)\n" % (os.getpid(),)) - input("Press 'Enter' to continue...") + if sys.version[0] > '2': + input("Press 'Enter' to continue...") + else: + raw_input("Press 'Enter' to continue...") if options.config_file == '-': config = json.loads(sys.stdin.read()) @@ -880,7 +895,7 @@ def byteify(input): # thx so sys.stderr.write('python version detected: %s\n' % sys.version) def process_qmsg(self, msg): - if self.tb.process_qmsg(msg): + if msg is None or self.tb.process_qmsg(msg): self.tb.stop() self.keep_running = False diff --git a/op25/gr-op25_repeater/apps/rx.py b/op25/gr-op25_repeater/apps/rx.py index 2b7cd30f..e1bd5f11 100755 --- a/op25/gr-op25_repeater/apps/rx.py +++ b/op25/gr-op25_repeater/apps/rx.py @@ -222,7 +222,10 @@ def __init__(self, options): # wait for gdb if options.pause: sys.stdout.write("Ready for GDB to attach (pid = %d)\n" % (os.getpid(),)) - input("Press 'Enter' to continue...") + if sys.version[0] > '2': + input("Press 'Enter' to continue...") + else: + raw_input("Press 'Enter' to continue...") self.input_q = gr.msg_queue(10) self.output_q = gr.msg_queue(10) diff --git a/op25/gr-op25_repeater/apps/sockaudio.py b/op25/gr-op25_repeater/apps/sockaudio.py index fce2d928..81e053b9 100644 --- a/op25/gr-op25_repeater/apps/sockaudio.py +++ b/op25/gr-op25_repeater/apps/sockaudio.py @@ -297,6 +297,7 @@ def open(self, hwdevice): def close(self): self.libpa.pa_simple_free(self.out) + self.out = None def setup(self, pcm_format, pcm_channels, pcm_rate, pcm_buffer_size): self.ss.format = PA_SAMPLE_S16LE # fixed format @@ -382,9 +383,11 @@ def __init__(self, udp_host, udp_port, pcm_device, two_channels = False, audio_g else: if pcm_device.lower() == "pulse": try: - self.pcm = pa_sound() # first try to use PulseAudio + self.pcm = pa_sound() # first try to open PulseAudio + self.pcm.drain() # and make sure it actually works sys.stderr.write("using PulseAudio sound system\n") except: + self.pcm = None sys.stderr.write("unable to load PulseAudio library\n") pcm_device = "default" diff --git a/op25/gr-op25_repeater/lib/CMakeLists.txt b/op25/gr-op25_repeater/lib/CMakeLists.txt index 8d3ae9ee..bffd71db 100755 --- a/op25/gr-op25_repeater/lib/CMakeLists.txt +++ b/op25/gr-op25_repeater/lib/CMakeLists.txt @@ -85,7 +85,11 @@ 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) +if ("${Gnuradio_VERSION}" VERSION_LESS "3.8.0") + target_link_libraries(gnuradio-op25_repeater ${Boost_LIBRARIES} ${GNURADIO_RUNTIME_LIBRARIES} ${GR_FILTER_LIBRARIES} imbe_vocoder) +else() + target_link_libraries(gnuradio-op25_repeater ${Boost_LIBRARIES} gnuradio::gnuradio-runtime ${GR_FILTER_LIBRARIES} imbe_vocoder) +endif() 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 99585775..bb117a05 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 1d88bbd1..069ed9d4 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 ${OP25_PYTHOM_VER}) if(NOT SWIG_FOUND OR NOT PYTHONLIBS_FOUND) return() endif() @@ -31,9 +31,13 @@ include(GrPython) ######################################################################## # Setup swig generation ######################################################################## -foreach(incdir ${GNURADIO_RUNTIME_INCLUDE_DIRS}) - list(APPEND GR_SWIG_INCLUDE_DIRS ${incdir}/gnuradio/swig) -endforeach(incdir) +if ("${Gnuradio_VERSION}" VERSION_LESS "3.8.0") + foreach(incdir ${GNURADIO_RUNTIME_INCLUDE_DIRS}) + list(APPEND GR_SWIG_INCLUDE_DIRS ${incdir}/gnuradio/swig) + endforeach(incdir) +else() + set(GR_SWIG_INCLUDE_DIRS $) +endif() set(GR_SWIG_LIBRARIES gnuradio-op25_repeater) set(GR_SWIG_DOC_FILE ${CMAKE_CURRENT_BINARY_DIR}/op25_repeater_swig_doc.i) @@ -44,7 +48,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