1 2WARNINGS=-W -Wall -Wstrict-prototypes -Wmissing-prototypes -Waggregate-return \ 3 -Wcast-align -Wcast-qual -Wnested-externs -Wshadow -Wbad-function-cast \ 4 -Wwrite-strings 5 6CFLAGS=-O3 -I.. -I../tools $(WARNINGS) 7CFLAGS+=-ffast-math -fomit-frame-pointer 8#CFLAGS+=-funroll-loops 9#CFLAGS+=-march=prescott 10#CFLAGS+= -mtune=native 11# TIP: try adding -openmp or -fopenmp to enable OPENMP directives and use of multiple cores 12#CFLAGS+=-fopenmp 13CFLAGS+= $(CFLAGADD) 14 15 16ifeq "$(NFFT)" "" 17 NFFT=1800 18endif 19ifeq "$(NUMFFTS)" "" 20 NUMFFTS=10000 21endif 22 23ifeq "$(DATATYPE)" "" 24 DATATYPE=float 25endif 26 27BENCHKISS=bm_kiss_$(DATATYPE) 28BENCHFFTW=bm_fftw_$(DATATYPE) 29SELFTEST=st_$(DATATYPE) 30TESTREAL=tr_$(DATATYPE) 31TESTKFC=tkfc_$(DATATYPE) 32FASTFILTREAL=ffr_$(DATATYPE) 33SELFTESTSRC=twotonetest.c 34 35 36TYPEFLAGS=-Dkiss_fft_scalar=$(DATATYPE) 37 38ifeq "$(DATATYPE)" "int16_t" 39 TYPEFLAGS=-DFIXED_POINT=16 40endif 41 42ifeq "$(DATATYPE)" "int32_t" 43 TYPEFLAGS=-DFIXED_POINT=32 44endif 45 46ifeq "$(DATATYPE)" "simd" 47 TYPEFLAGS=-DUSE_SIMD=1 -msse 48endif 49 50 51ifeq "$(DATATYPE)" "float" 52 # fftw needs to be built with --enable-float to build this lib 53 FFTWLIB=-lfftw3f 54else 55 FFTWLIB=-lfftw3 56endif 57 58FFTWLIBDIR=-L/usr/local/lib/ 59 60SRCFILES=../kiss_fft.c ../tools/kiss_fftnd.c ../tools/kiss_fftr.c pstats.c ../tools/kfc.c ../tools/kiss_fftndr.c 61 62all: tools $(BENCHKISS) $(SELFTEST) $(BENCHFFTW) $(TESTREAL) $(TESTKFC) 63 64tools: 65 cd ../tools && make all 66 67 68$(SELFTEST): $(SELFTESTSRC) $(SRCFILES) 69 $(CC) -o $@ $(CFLAGS) $(TYPEFLAGS) $+ -lm 70 71$(TESTKFC): $(SRCFILES) 72 $(CC) -o $@ $(CFLAGS) -DKFC_TEST $(TYPEFLAGS) $+ -lm 73 74$(TESTREAL): test_real.c $(SRCFILES) 75 $(CC) -o $@ $(CFLAGS) $(TYPEFLAGS) $+ -lm 76 77$(BENCHKISS): benchkiss.c $(SRCFILES) 78 $(CC) -o $@ $(CFLAGS) $(TYPEFLAGS) $+ -lm 79 80$(BENCHFFTW): benchfftw.c pstats.c 81 @echo "======attempting to build FFTW benchmark" 82 @$(CC) -o $@ $(CFLAGS) -DDATATYPE$(DATATYPE) $+ $(FFTWLIB) $(FFTWLIBDIR) -lm || echo "FFTW not available for comparison" 83 84test: all 85 @./$(TESTKFC) 86 @echo "======1d & 2-d complex fft self test (type= $(DATATYPE) )" 87 @./$(SELFTEST) 88 @echo "======real FFT (type= $(DATATYPE) )" 89 @./$(TESTREAL) 90 @echo "======timing test (type=$(DATATYPE))" 91 @./$(BENCHKISS) -x $(NUMFFTS) -n $(NFFT) 92 @[ -x ./$(BENCHFFTW) ] && ./$(BENCHFFTW) -x $(NUMFFTS) -n $(NFFT) ||true 93 @echo "======higher dimensions type=$(DATATYPE))" 94 @./testkiss.py 95 96selftest.c: 97 ./mk_test.py 10 12 14 > selftest.c 98selftest_short.c: 99 ./mk_test.py -s 10 12 14 > selftest_short.c 100 101 102CXXFLAGS=-O3 -ffast-math -fomit-frame-pointer -I.. -I../tools -W -Wall 103testcpp: testcpp.cc ../kissfft.hh 104 $(CXX) -o $@ $(CXXFLAGS) testcpp.cc -lm 105 106 107clean: 108 rm -f *~ bm_* st_* tr_* kf_* tkfc_* ff_* ffr_* *.pyc *.pyo *.dat testcpp 109