2014-11-28 23:44:41 +08:00
# This software is part of libcsdr, a set of simple DSP routines for
2014-11-29 08:20:44 +08:00
# Software Defined Radio.
2014-11-28 23:44:41 +08: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-29 03:07:00 +08:00
PARAMS_SIMD = $( shell ./detect_params.sh)
2014-11-28 23:44:41 +08:00
PARAMS_LOOPVECT = -O3 -ffast-math -fdump-tree-vect-details -dumpbase dumpvect
2015-08-17 05:40:42 +08:00
PARAMS_LIBS = -g -lm -lrt -lfftw3f -DUSE_FFTW -DLIBCSDR_GPL -DUSE_IMA_ADPCM
2014-11-28 23:44:41 +08:00
PARAMS_SO = -fpic
PARAMS_MISC = -Wno-unused-result
2017-01-11 17:48:25 +08: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-17 05:40:42 +08:00
FFTW_PACKAGE = fftw-3.3.3
2017-05-11 11:21:37 +08:00
PREFIX ?= /usr
2017-05-11 16:29:06 +08:00
SOVERSION = 0.15
2017-05-19 05:43:40 +08:00
PARSEVECT ?= yes
2014-11-28 23:44:41 +08:00
2017-07-07 01:17:58 +08:00
.PHONY : clean -vect clean codequality checkdocs v
2017-04-30 17:40:36 +08:00
all : codequality csdr nmux
2016-01-13 06:01:36 +08: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 23:44:41 +08: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 17:31:54 +08:00
rm -f dumpvect*.vect
2017-05-12 06:07:32 +08: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-19 05:43:40 +08:00
i f e q ( $( PARSEVECT ) , y e s )
2014-11-30 17:37:16 +08:00
-./parsevect dumpvect*.vect
2017-05-19 05:43:40 +08:00
e n d i f
2015-11-04 17:31:54 +08:00
csdr : csdr .c libcsdr .so
2015-09-30 21:52:43 +08:00
gcc -std= gnu99 $( PARAMS_LOOPVECT) $( PARAMS_SIMD) csdr.c $( PARAMS_LIBS) -L. -lcsdr $( PARAMS_MISC) -o csdr
2015-11-04 20:31:47 +08:00
ddcd : ddcd .cpp libcsdr .so ddcd .h
2015-12-03 18:22:25 +08:00
g++ $( PARAMS_LOOPVECT) $( PARAMS_SIMD) ddcd.cpp $( PARAMS_LIBS) -L. -lcsdr -lpthread $( PARAMS_MISC) -o ddcd
2017-01-11 17:48:25 +08: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 23:44:41 +08:00
arm-cross : clean -vect
#note: this doesn't work since having added FFTW
2015-09-30 21:52:43 +08: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 23:44:41 +08:00
clean-vect :
rm -f dumpvect*.vect
clean : clean -vect
2017-05-12 06:07:32 +08:00
rm -f libcsdr.so.$( SOVERSION) csdr ddcd nmux *.o *.so
2015-11-17 17:01:34 +08:00
install : all
2017-05-12 06:07:32 +08:00
install -m 0755 libcsdr.so.$( SOVERSION) $( PREFIX) /lib
2017-05-11 11:21:37 +08: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 16:16:00 +08:00
@ldconfig || echo please run ldconfig
2014-11-28 23:44:41 +08:00
uninstall :
2017-05-12 06:07:32 +08:00
rm $( PREFIX) /lib/libcsdr.so.$( SOVERSION) $( PREFIX) /bin/csdr $( PREFIX) /bin/csdr-fm
2014-11-28 23:44:41 +08:00
ldconfig
2015-09-30 21:52:43 +08:00
disasm :
2017-05-12 06:07:32 +08:00
objdump -S libcsdr.so.$( SOVERSION) > libcsdr.disasm
2015-08-17 05:40:42 +08: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 18:15:11 +08: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-17 05:40:42 +08: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 17:40:36 +08: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-07 01:17:58 +08: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-03 00:37:54 +08:00
v :
vim csdr.c libcsdr.c