-
Notifications
You must be signed in to change notification settings - Fork 10
/
Makefile
67 lines (50 loc) · 2.03 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
SRC := ./src/resamplerate.c ./src/log/log.c
INI_SRC := ./src/iniparser/iniparser.c ./src/iniparser/dictionary.c
RESAM_SRC := ./src/resamplerate/samplerate.c ./src/resamplerate/src_sinc.c ./src/resamplerate/src_zoh.c ./src/resamplerate/src_linear.c
WAVEH_SRC := ./src/waveHeader/handle_wave.c
All_SRC = $(SRC) $(INI_SRC) $(RESAM_SRC) $(WAVEH_SRC)
OBJS := $(SRC:.c=.o)
INI_OBJS := $(INI_SRC:.c=.o)
RESAM_OBJS := $(RESAM_SRC:.c=.o)
WAVEH_OBJS := $(WAVEH_SRC:.c=.o)
All_OBJS := $(OBJS) $(INI_OBJS) $(RESAM_OBJS) $(WAVEH_OBJS)
TARGET := ./resamplerate
INI_TARGET := ./lib/libiniparser.so
RESAM_TARGET := ./lib/libresamplerate.so
WAVEH_TARGET := ./lib/libwaveheader.so
AUDIO := ./audio/result.pcm ./audio/result.wav
CC := gcc
PLUS := g++
RM := -rm -rf
CFLAGS := -Wall -O2 -m64 -D_GUN_SOURCE
LDFLAGS = -Llib -liniparser -lresamplerate -lwaveheader
LDSHFLAGS = -fPIC -shared
CPPFLAGS = -I./include/log -I ./include/iniparser/ -I ./include/resamplerate/ -I ./include/waveHeader/ -I ./include/
rely := $(All_SRC:.c=.d) # 生成.d文件
tmp := ./src/*.d.*
#############################
.PHONY: iniparser resamplerate waveheader clean cleanall cleanso
$(TARGET): $(OBJS)
$(PLUS) $(CFLAGS) $(LDFLAGS) $(CPPFLAGS) $^ -o $@
iniparser : $(INI_TARGET)
$(INI_TARGET): $(INI_SRC)
$(CC) $(LDSHFLAGS) $(CFLAGS) $(CPPFLAGS) $^ -o $@
resamplerate : $(RESAM_TARGET)
$(RESAM_TARGET): $(RESAM_SRC)
$(CC) $(LDSHFLAGS) $(CFLAGS) $(CPPFLAGS) $^ -o $@
waveheader : $(WAVEH_TARGET)
$(WAVEH_TARGET): $(WAVEH_SRC)
$(CC) $(LDSHFLAGS) $(CFLAGS) $(CPPFLAGS) $^ -o $@
# 自动生成依赖
$(rely): $(All_SRC)
@set -e; rm -f $@ &> /dev/null; # 设置错误检查,若下面有语句执行错误则直接退出, 删除旧的.d文件\
$(CC) -MM $(CPPFLAGS) $< > $@.$$$$; # 生成依赖文件 \
sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' < $@.$$$$ > $@; # 替换临时文件 \
rm -f $@.$$$$ &> /dev/null # 删除临时文件
# 替换
-include $(rely)
cleanall : clean cleanso
clean:
$(RM) $(All_OBJS) $(rely) $(tmp) $(TARGET) $(AUDIO)
cleanso:
$(RM) $(INI_TARGET) $(RESAM_TARGET) $(WAVEH_TARGET)