|
| 1 | +# This software is part of libcsdr, a set of simple DSP routines for |
| 2 | +# Software Defined Radio under BSD license. |
| 3 | +# |
| 4 | +# Copyright (c) 2014, Andras Retzler <[email protected]> |
| 5 | +# All rights reserved. |
| 6 | +# |
| 7 | +# Redistribution and use in source and binary forms, with or without |
| 8 | +# modification, are permitted provided that the following conditions are met: |
| 9 | +# * Redistributions of source code must retain the above copyright |
| 10 | +# notice, this list of conditions and the following disclaimer. |
| 11 | +# * Redistributions in binary form must reproduce the above copyright |
| 12 | +# notice, this list of conditions and the following disclaimer in the |
| 13 | +# documentation and/or other materials provided with the distribution. |
| 14 | +# * Neither the name of the copyright holder nor the |
| 15 | +# names of its contributors may be used to endorse or promote products |
| 16 | +# derived from this software without specific prior written permission. |
| 17 | +# |
| 18 | +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND |
| 19 | +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
| 20 | +# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
| 21 | +# DISCLAIMED. IN NO EVENT SHALL ANDRAS RETZLER BE LIABLE FOR ANY |
| 22 | +# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
| 23 | +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
| 24 | +# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
| 25 | +# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 26 | +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
| 27 | +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 28 | + |
| 29 | + |
| 30 | + |
| 31 | +LIBSOURCES = fft_fftw.c libcsdr_wrapper.c |
| 32 | +#SOURCES = csdr.c $(LIBSOURCES) |
| 33 | +cpufeature = $(if $(findstring $(1),$(shell cat /proc/cpuinfo)),$(2)) |
| 34 | +PARAMS_SSE = $(call cpufeature,sse,-msse) $(call cpufeature,sse2,-msse2) $(call cpufeature,sse3,-msse3) $(call cpufeature,sse4,-msse4) $(call cpufeature,sse4_1,-msse4.1) $(call cpufeature,sse4_2,-msse4.2) -mfpmath=sse |
| 35 | +PARAMS_NEON = -fshort-double -mfloat-abi=softfp -march=armv7-a -mtune=cortex-a8 -mfpu=neon -mvectorize-with-neon-quad -Wformat=0 |
| 36 | +PARAMS_SIMD = $(if $(call cpufeature,sse,dummy-text),$(PARAMS_SSE),$(PARAMS_NEON)) |
| 37 | +PARAMS_LOOPVECT = -O3 -ffast-math -fdump-tree-vect-details -dumpbase dumpvect |
| 38 | +PARAMS_LIBS = -g -lm -lfftw3f -DUSE_FFTW -DLIBCSDR_GPL |
| 39 | +PARAMS_SO = -fpic |
| 40 | +PARAMS_MISC = -Wno-unused-result |
| 41 | + |
| 42 | +all: clean-vect |
| 43 | + @echo NOTE: you may have to manually edit Makefile to optimize for your CPU \(especially if you compile on ARM, please edit PARAMS_NEON\). |
| 44 | + @echo Auto-detected optimization parameters: $(PARAMS_SIMD) |
| 45 | + @echo |
| 46 | + c99 $(PARAMS_LOOPVECT) $(PARAMS_SIMD) $(LIBSOURCES) $(PARAMS_LIBS) $(PARAMS_MISC) -fpic -shared -o libcsdr.so |
| 47 | + ./parsevect dumpvect*.vect libcsdr.c |
| 48 | + c99 $(PARAMS_LOOPVECT) $(PARAMS_SIMD) csdr.c $(PARAMS_LIBS) -L. -lcsdr $(PARAMS_MISC) -o csdr |
| 49 | +arm-cross: clean-vect |
| 50 | + #note: this doesn't work since having added FFTW |
| 51 | + arm-linux-gnueabihf-gcc -std=c99 -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 |
| 52 | +clean-vect: |
| 53 | + rm -f dumpvect*.vect |
| 54 | +clean: clean-vect |
| 55 | + rm libcsdr.so csdr |
| 56 | +install: |
| 57 | + install -m 0755 libcsdr.so /usr/lib |
| 58 | + install -m 0755 csdr /usr/bin |
| 59 | + install -m 0755 csdr-fm /usr/bin |
| 60 | + ldconfig |
| 61 | +uninstall: |
| 62 | + rm /usr/lib/libcsdr.so /usr/bin/csdr /usr/bin/csdr-fm |
| 63 | + ldconfig |
| 64 | + |
| 65 | + |
| 66 | + |
0 commit comments