PORTAUDIOCFLAGS=$(shell pkg-config --cflags portaudiocpp) PORTAUDIOLIBS=$(shell pkg-config --libs portaudiocpp) CXX=clang++-14 ifeq ($(CXXFLAGS),) #CXXFLAGS=-O0 -g -D_DEBUG CXXFLAGS=-O2 -DNDEBUG endif CXXFLAGS+=-stdlib=libc++ CXXFLAGS+=-Wall -Wpedantic -gdwarf-4 CXXFLAGS+=-std=c++17 -fexceptions -Iexternal -fPIC #-march=native -mtune=native # is not better for llvm CC=clang CFLAGS=-Wall -O2 -Iexternal # libstdc++-8 doesn't have transform_reduce #CXX=g++-8 #CXXFLAGS=-Wall -O2 -std=c++17 -nostdinc++ -I/usr/lib/llvm-7/include/c++/v1 -nodefaultlibs -lc++ -lc++abi -lm -lc -lgcc_s -lgcc # -march=native -mtune=native # doesn't help for gcc DESTDIR=/ PREFIX=/usr/bin SONAME1=libfft.so SONAME2=libfft.so.0 SONAME3=libfft.so.0.0.0 all: staticlib sharedlib tunerdemo testsuite staticlib: fft.a fft.a: fft.o util.o ar rcs $@ $^ sharedlib: $(SONAME3) $(SONAME3): fft.o util.o $(CXX) $(CXXFLAGS) -shared -Wl,-soname,$(SONAME2) -o $@ $^ tunerdemo: audioio.o external/pa_ringbuffer.o util.o fft.o autocorrelation.o tuner.o tunerdemo.o $(CXX) $(CXXFLAGS) $(PORTAUDIOLIBS) -o $@ $^ testsuite: util.o fft.o autocorrelation.o tuner.o testsuite.o $(CXX) $(CXXFLAGS) -o $@ $^ fft.o: fft.cpp fft.h $(CXX) $(CXXFLAGS) -c -o $@ $< autocorrelation.o: autocorrelation.cpp autocorrelation.h $(CXX) $(CXXFLAGS) -c -o $@ $< tuner.o: tuner.cpp tuner.h $(CXX) $(CXXFLAGS) -c -o $@ $< util.o: util.cpp util.h $(CXX) $(CXXFLAGS) -c -o $@ $< audioio.o: audioio.cpp audioio.h $(CXX) $(CXXFLAGS) $(PORTAUDIOCFLAGS) -c -o $@ $< external/pa_ringbuffer.o: external/pa_ringbuffer.c external/pa_ringbuffer.h $(CC) $(CFLAGS) -c -o $@ $< testsuite.o: testsuite.cpp fft.h autocorrelation.h tuner.h $(CXX) $(CXXFLAGS) -c -o $@ $< tunerdemo.o: tunerdemo.cpp fft.h autocorrelation.h tuner.h $(CXX) $(CXXFLAGS) -c -o $@ $< test: testsuite ./testsuite install: mkdir -p $(DESTDIR)/$(PREFIX) install tunerdemo $(DESTDIR)/$(PREFIX)/tunerdemo mkdir -p $(DESTDIR)/usr/include install fft.h $(DESTDIR)/usr/include/fft.h mkdir -p $(DESTDIR)/usr/lib install $(SONAME3) $(DESTDIR)/usr/lib/$(SONAME3) ln -sf $(SONAME3) $(DESTDIR)/usr/lib/$(SONAME2) ln -sf $(SONAME2) $(DESTDIR)/usr/lib/$(SONAME1) deb: dpkg-buildpackage -us -uc clean: rm -f tunerdemo testsuite *.o external/*.o $(SONAME1) $(SONAME2) $(SONAME3) *.a .PHONY: clean install all test staticlib sharedlib