forked from Sleepwalking/ciglet
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
101 lines (84 loc) · 2.8 KB
/
Makefile
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
PREFIX = /usr
CC ?= gcc
AR ?= ar
FP_TYPE = float
CONFIG = Debug
CFLAGS_PLAT =
CFLAGS_COMMON = -Iexternal -D_POSIX_C_SOURCE=2 -DFP_TYPE=$(FP_TYPE) \
-std=c99 -Wall -fPIC $(CFLAGS_PLAT)
ifeq ($(CXX), emcc)
CFLAGS_DBG = $(CFLAGS_COMMON) -O1 -g -D_DEBUG
CFLAGS_REL = $(CFLAGS_COMMON) -O3
else
CFLAGS_DBG = $(CFLAGS_COMMON) -Og -g -D_DEBUG
CFLAGS_REL = $(CFLAGS_COMMON) -Ofast
endif
ifeq ($(CONFIG), Debug)
CFLAGS = $(CFLAGS_DBG)
else
CFLAGS = $(CFLAGS_REL)
endif
ARFLAGS = -rv
OBJS = ciglet.o fftsg.o fastmedian.o wavfile.o
default: libciglet.a
ifeq ($(CXX), emcc)
test: ciglet-test.html
emrun ./ciglet-test.html noplot
test-fft: ciglet-test-fft.js
node ./ciglet-test-fft.js
else
test: ciglet-test
./ciglet-test noplot
test-fft: ciglet-test-fft
./ciglet-test-fft
endif
single-file: single-file/ciglet.c single-file/ciglet.h
$(CC) $(CFLAGS) -o single-file/ciglet.o -c single-file/ciglet.c -Wno-unused-result
ciglet-test: libciglet.a test/test.c
$(CC) $(CFLAGS) test/test.c libciglet.a -o ciglet-test -lm
ciglet-test-fft: libciglet.a test/test-fft.c
$(CC) $(CFLAGS) test/test-fft.c libciglet.a -o ciglet-test-fft -lm
ciglet-test.html: libciglet.a test/test.c
$(CC) $(CFLAGS) test/test.c libciglet.a -o ciglet-test.html -lm \
--preload-file test/ --emrun -s TOTAL_MEMORY=64MB
ciglet-test-fft.js: libciglet.a test/test-fft.c
$(CC) $(CFLAGS) test/test-fft.c libciglet.a -o ciglet-test-fft.js -lm
libciglet.a: $(OBJS)
$(AR) $(ARFLAGS) libciglet.a $(OBJS)
@echo Done.
install: libciglet.a ciglet.h
mkdir -p $(PREFIX)/lib/ $(PREFIX)/include/ciglet/external
cp libciglet.a $(PREFIX)/lib
cp ciglet.h $(PREFIX)/include/ciglet
cp external/fastapprox-all.h $(PREFIX)/include/ciglet/external
cp external/fastapprox-all-nosimd.h $(PREFIX)/include/ciglet/external
ciglet.o: ciglet.c ciglet.h
fftsg.o: external/fftsg_h.c
$(CC) $(CFLAGS) -o fftsg.o -c external/fftsg_h.c
fastmedian.o: external/fast_median.c
$(CC) $(CFLAGS) -o fastmedian.o -c external/fast_median.c
wavfile.o: external/wavfile.c
$(CC) $(CFLAGS) -o wavfile.o -c external/wavfile.c -Wno-unused-result
%.o: %.c
$(CC) $(CFLAGS) -o $*.o -c $*.c
single-file/ciglet.c: ciglet.c
mkdir -p single-file
cat external/fftsg_h.c > single-file/ciglet.c
cat external/fast_median.c >> single-file/ciglet.c
cat external/wavfile.c >> single-file/ciglet.c
cat ciglet.c >> single-file/ciglet.c
single-file/ciglet.h: ciglet.h
mkdir -p single-file
cat external/fastapprox-all.h > single-file/ciglet.h
echo "" >> single-file/ciglet.h
echo "#define CIGLET_SINGLE_FILE" >> single-file/ciglet.h
echo "" >> single-file/ciglet.h
cat ciglet.h >> single-file/ciglet.h
clean:
@echo 'Removing all temporary binaries... '
@rm -rf *.o *.a *.html *.data *.js *.wasm
@echo Done.
clear:
@echo 'Removing all temporary binaries... '
@rm -rf *.o *.a *.html *.data *.js *.wasm
@echo Done.