summaryrefslogtreecommitdiffhomepage
path: root/Makefile
blob: bba1d165ec0793d89ac809d99d99f36d445aa0fc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
PORTAUDIOCFLAGS=$(shell pkg-config --cflags portaudiocpp)
PORTAUDIOLIBS=$(shell pkg-config --libs portaudiocpp)

CXX=clang++-11

ifeq ($(CXXFLAGS),)
#CXXFLAGS=-O0 -g -D_DEBUG
CXXFLAGS=-O2 -DNDEBUG
endif
CXXFLAGS+=-stdlib=libc++
CXXFLAGS+=-Wall
CXXFLAGS+=-std=c++17 -fexceptions -Iexternal
#-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

all: tunerdemo testsuite

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

clean:
	rm -f tunerdemo testsuite *.o external/*.o

.PHONY: clean install all test