2014-11-28 15:44:41 +00:00
# This software is part of libcsdr, a set of simple DSP routines for
2014-11-29 00:20:44 +00:00
# Software Defined Radio.
2014-11-28 15:44:41 +00:00
#
# Copyright (c) 2014, Andras Retzler <randras@sdr.hu>
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# * Neither the name of the copyright holder nor the
# names of its contributors may be used to endorse or promote products
# derived from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL ANDRAS RETZLER BE LIABLE FOR ANY
# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
LIBSOURCES = fft_fftw.c libcsdr_wrapper.c
#SOURCES = csdr.c $(LIBSOURCES)
2019-05-28 19:07:00 +00:00
PARAMS_SIMD = $( shell ./detect_params.sh)
2014-11-28 15:44:41 +00:00
PARAMS_LOOPVECT = -O3 -ffast-math -fdump-tree-vect-details -dumpbase dumpvect
2015-08-16 21:40:42 +00:00
PARAMS_LIBS = -g -lm -lrt -lfftw3f -DUSE_FFTW -DLIBCSDR_GPL -DUSE_IMA_ADPCM
2014-11-28 15:44:41 +00:00
PARAMS_SO = -fpic
PARAMS_MISC = -Wno-unused-result
2017-01-11 09:48:25 +00:00
#DEBUG_ON = 0 #debug is always on by now (anyway it could be compiled with `make DEBUG_ON=1`)
#PARAMS_DEBUG = $(if $(DEBUG_ON),-g,)
2015-08-16 21:40:42 +00:00
FFTW_PACKAGE = fftw-3.3.3
2017-05-11 03:21:37 +00:00
PREFIX ?= /usr
2017-05-11 08:29:06 +00:00
SOVERSION = 0.15
2017-05-18 21:43:40 +00:00
PARSEVECT ?= yes
2014-11-28 15:44:41 +00:00
2017-07-06 17:17:58 +00:00
.PHONY : clean -vect clean codequality checkdocs v
2017-04-30 09:40:36 +00:00
all : codequality csdr nmux
2016-01-12 22:01:36 +00:00
libcsdr.so : fft_fftw .c fft_rpi .c libcsdr_wrapper .c libcsdr .c libcsdr_gpl .c fastddc .c fastddc .h fft_fftw .h fft_rpi .h ima_adpcm .h libcsdr_gpl .h libcsdr .h predefined .h
2014-11-28 15:44:41 +00:00
@echo NOTE: you may have to manually edit Makefile to optimize for your CPU \( especially if you compile on ARM, please edit PARAMS_NEON\) .
@echo Auto-detected optimization parameters: $( PARAMS_SIMD)
@echo
2015-11-04 09:31:54 +00:00
rm -f dumpvect*.vect
2017-05-11 22:07:32 +00:00
gcc -std= gnu99 $( PARAMS_LOOPVECT) $( PARAMS_SIMD) $( LIBSOURCES) $( PARAMS_LIBS) $( PARAMS_MISC) -fpic -shared -Wl,-soname,libcsdr.so.$( SOVERSION) -o libcsdr.so.$( SOVERSION)
@ln -fs libcsdr.so.$( SOVERSION) libcsdr.so
2017-05-18 21:43:40 +00:00
i f e q ( $( PARSEVECT ) , y e s )
2014-11-30 09:37:16 +00:00
-./parsevect dumpvect*.vect
2017-05-18 21:43:40 +00:00
e n d i f
2015-11-04 09:31:54 +00:00
csdr : csdr .c libcsdr .so
2015-09-30 13:52:43 +00:00
gcc -std= gnu99 $( PARAMS_LOOPVECT) $( PARAMS_SIMD) csdr.c $( PARAMS_LIBS) -L. -lcsdr $( PARAMS_MISC) -o csdr
2015-11-04 12:31:47 +00:00
ddcd : ddcd .cpp libcsdr .so ddcd .h
2015-12-03 10:22:25 +00:00
g++ $( PARAMS_LOOPVECT) $( PARAMS_SIMD) ddcd.cpp $( PARAMS_LIBS) -L. -lcsdr -lpthread $( PARAMS_MISC) -o ddcd
2017-01-11 09:48:25 +00:00
nmux : nmux .cpp libcsdr .so nmux .h tsmpool .cpp tsmpool .h
g++ $( PARAMS_LOOPVECT) $( PARAMS_SIMD) nmux.cpp tsmpool.cpp $( PARAMS_LIBS) -L. -lcsdr -lpthread $( PARAMS_MISC) -o nmux
2014-11-28 15:44:41 +00:00
arm-cross : clean -vect
#note: this doesn't work since having added FFTW
2015-09-30 13:52:43 +00:00
arm-linux-gnueabihf-gcc -std= gnu99 -O3 -fshort-double -ffast-math -dumpbase dumpvect-arm -fdump-tree-vect-details -mfloat-abi= softfp -march= armv7-a -mtune= cortex-a9 -mfpu= neon -mvectorize-with-neon-quad -Wno-unused-result -Wformat= 0 $( SOURCES) -lm -o ./csdr
2014-11-28 15:44:41 +00:00
clean-vect :
rm -f dumpvect*.vect
clean : clean -vect
2017-05-11 22:07:32 +00:00
rm -f libcsdr.so.$( SOVERSION) csdr ddcd nmux *.o *.so
2015-11-17 09:01:34 +00:00
install : all
2017-05-11 22:07:32 +00:00
install -m 0755 libcsdr.so.$( SOVERSION) $( PREFIX) /lib
2017-05-11 03:21:37 +00:00
install -m 0755 csdr $( PREFIX) /bin
install -m 0755 csdr-fm $( PREFIX) /bin
install -m 0755 nmux $( PREFIX) /bin
#-install -m 0755 ddcd $(PREFIX)/bin
2017-05-11 08:16:00 +00:00
@ldconfig || echo please run ldconfig
2014-11-28 15:44:41 +00:00
uninstall :
2017-05-11 22:07:32 +00:00
rm $( PREFIX) /lib/libcsdr.so.$( SOVERSION) $( PREFIX) /bin/csdr $( PREFIX) /bin/csdr-fm
2014-11-28 15:44:41 +00:00
ldconfig
2015-09-30 13:52:43 +00:00
disasm :
2017-05-11 22:07:32 +00:00
objdump -S libcsdr.so.$( SOVERSION) > libcsdr.disasm
2015-08-16 21:40:42 +00:00
emcc-clean :
-rm sdr.js/sdr.js
-rm sdr.js/sdrjs-compiled.js
-rm -rf sdr.js/$( FFTW_PACKAGE)
emcc-get-deps :
echo "getting and compiling fftw3 with emscripten..."
cd sdr.js; \
wget http://fftw.org/$( FFTW_PACKAGE) .tar.gz; \
tar -xvf $( FFTW_PACKAGE) .tar.gz; \
rm $( FFTW_PACKAGE) .tar.gz; \
cd $( FFTW_PACKAGE) ; \
emconfigure ./configure --enable-float --disable-fortran --prefix= ` pwd ` /emscripten-install --libdir= ` pwd ` /emscripten-lib; \
emmake make; \
emmake make install
emcc :
2016-07-24 10:15:11 +00:00
emcc -O3 -Isdr.js/$( FFTW_PACKAGE) /api -Lsdr.js/$( FFTW_PACKAGE) /emscripten-lib -o sdr.js/sdrjs-compiled.js fft_fftw.c libcsdr_wrapper.c -s TOTAL_MEMORY = 67108864 -DLIBCSDR_GPL -DUSE_IMA_ADPCM -DUSE_FFTW -lfftw3f -s EXPORTED_FUNCTIONS = "`python sdr.js/exported_functions.py`"
2015-08-16 21:40:42 +00:00
cat sdr.js/sdrjs-header.js sdr.js/sdrjs-compiled.js sdr.js/sdrjs-footer.js > sdr.js/sdr.js
emcc-beautify :
bash -c 'type js-beautify >/dev/null 2>&1; if [ $$? -eq 0 ]; then js-beautify sdr.js/sdr.js >sdr.js/sdr.js.beautiful; mv sdr.js/sdr.js.beautiful sdr.js/sdr.js; fi'
2017-04-30 09:40:36 +00:00
codequality :
@bash -c 'if [ `cat csdr.c | grep badsyntax | grep -v return | wc -l` -ne 1 ]; then echo "error at code quality check: badsyntax() used in csdr.c without return."; exit 1; else exit 0; fi'
2017-07-06 17:17:58 +00:00
checkdocs :
@cat csdr.c | grep strcmp | egrep 'argv\[1\]' | awk -F'"' '$$0=$$2' > /tmp/csdr-list-of-functions
@cat /tmp/csdr-list-of-functions | xargs -I{ } bash -c 'if ! cat csdr.c | grep \"\ \ \ \ {} >/dev/null ; then echo "warning: \"{}\" is in csdr.c code, but not in usage string"; fi'
@cat /tmp/csdr-list-of-functions | xargs -I{ } bash -c 'if ! cat README.md | grep {} >/dev/null ; then echo "warning: \"{}\" is in csdr.c code, but not in README.md"; fi'
@rm /tmp/csdr-list-of-functions
2017-05-02 16:37:54 +00:00
v :
vim csdr.c libcsdr.c