forked from ralph-irving/squeezelite
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
155 lines (137 loc) · 3.81 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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
#Cross compile support - create a Makefile which defines these three variables and then includes this Makefile...
CFLAGS ?= -Wall -fPIC -O2
CFLAGS += -fcommon
LDADD ?= -lasound -lpthread -lm -lrt
EXECUTABLE ?= squeezelite
# passing one or more of these in $(OPTS) enables optional feature inclusion
OPT_DSD = -DDSD
OPT_FF = -DFFMPEG
OPT_ALAC = -DALAC
OPT_LINKALL = -DLINKALL
OPT_RESAMPLE= -DRESAMPLE
OPT_VIS = -DVISEXPORT
OPT_IR = -DIR
OPT_GPIO = -DGPIO
OPT_RPI = -DRPI
OPT_NO_FAAD = -DNO_FAAD
OPT_SSL = -DUSE_SSL
OPT_NOSSLSYM= -DNO_SSLSYM
OPT_OPUS = -DOPUS
SOURCES = \
main.c slimproto.c buffer.c stream.c utils.c \
output.c output_alsa.c output_pa.c output_stdout.c output_pack.c decode.c \
flac.c pcm.c mad.c vorbis.c mpg.c
SOURCES_DSD = dsd.c dop.c dsd2pcm/dsd2pcm.c
SOURCES_FF = ffmpeg.c
SOURCES_ALAC = alac.c alac_wrapper.cpp
SOURCES_RESAMPLE = process.c resample.c
SOURCES_VIS = output_vis.c
SOURCES_IR = ir.c
SOURCES_GPIO = gpio.c
SOURCES_RPI = minimal_gpio.c
SOURCES_FAAD = faad.c
SOURCES_SSL = sslsym.c
SOURCES_OPUS = opus.c
LINK_LINUX = -ldl
LINK_SSL = -lssl -lcrypto
LINK_ALAC = -lalac
LINKALL = -lmad -lmpg123 -lFLAC -lvorbisfile -lvorbis -logg
LINKALL_FF = -lavformat -lavcodec -lavutil
LINKALL_RESAMPLE = -lsoxr
LINKALL_IR = -llirc_client
LINKALL_FAAD = -lfaad
LINKALL_OPUS = -lopusfile -lopus
DEPS = squeezelite.h slimproto.h
UNAME = $(shell uname -s)
# add optional sources
ifneq (,$(findstring $(OPT_DSD), $(OPTS)))
SOURCES += $(SOURCES_DSD)
endif
ifneq (,$(findstring $(OPT_FF), $(OPTS)))
SOURCES += $(SOURCES_FF)
endif
ifneq (,$(findstring $(OPT_ALAC), $(OPTS)))
SOURCES += $(SOURCES_ALAC)
DEPS += alac_wrapper.h
endif
ifneq (,$(findstring $(OPT_OPUS), $(OPTS)))
SOURCES += $(SOURCES_OPUS)
endif
ifneq (,$(findstring $(OPT_RESAMPLE), $(OPTS)))
SOURCES += $(SOURCES_RESAMPLE)
endif
ifneq (,$(findstring $(OPT_VIS), $(OPTS)))
SOURCES += $(SOURCES_VIS)
endif
ifneq (,$(findstring $(OPT_IR), $(OPTS)))
SOURCES += $(SOURCES_IR)
endif
ifneq (,$(findstring $(OPT_GPIO), $(OPTS)))
SOURCES += $(SOURCES_GPIO)
endif
ifneq (,$(findstring $(OPT_RPI), $(OPTS)))
SOURCES += $(SOURCES_RPI)
endif
# ensure GPIO is enabled with RPI
ifneq (,$(findstring $(OPT_RPI), $(OPTS)))
ifeq (,$(findstring $(SOURCES_GPIO), $(SOURCES)))
CFLAGS += $(OPT_GPIO)
SOURCES += $(SOURCES_GPIO)
endif
endif
ifeq (,$(findstring $(OPT_NO_FAAD), $(OPTS)))
SOURCES += $(SOURCES_FAAD)
endif
ifneq (,$(findstring $(OPT_SSL), $(OPTS)))
SOURCES += $(SOURCES_SSL)
endif
# add optional link options
ifneq (,$(findstring $(OPT_LINKALL), $(OPTS)))
LDADD += $(LINKALL)
ifneq (,$(findstring $(OPT_FF), $(OPTS)))
LDADD += $(LINKALL_FF)
endif
ifneq (,$(findstring $(OPT_OPUS), $(OPTS)))
LDADD += $(LINKALL_OPUS)
endif
ifneq (,$(findstring $(OPT_RESAMPLE), $(OPTS)))
LDADD += $(LINKALL_RESAMPLE)
endif
ifneq (,$(findstring $(OPT_IR), $(OPTS)))
LDADD += $(LINKALL_IR)
endif
ifeq (,$(findstring $(OPT_NO_FAAD), $(OPTS)))
LDADD += $(LINKALL_FAAD)
endif
ifneq (,$(findstring $(OPT_SSL), $(OPTS)))
LDADD += $(LINK_SSL)
endif
else
# if not LINKALL and linux add LINK_LINUX
ifeq ($(UNAME), Linux)
LDADD += $(LINK_LINUX)
endif
ifneq (,$(findstring $(OPT_NOSSLSYM), $(OPTS)))
LDADD += $(LINK_SSL)
endif
endif
ifneq (,$(findstring $(OPT_ALAC), $(OPTS)))
LDADD += $(LINK_ALAC)
endif
OBJECTS = $(addsuffix .o,$(basename $(SOURCES)))
all: $(EXECUTABLE)
$(EXECUTABLE): $(OBJECTS)
ifneq (,$(findstring $(OPT_ALAC), $(OPTS)))
$(CXX) $(OBJECTS) $(LDFLAGS) $(LDADD) -o $@
else
$(CC) $(OBJECTS) $(LDFLAGS) $(LDADD) -o $@
endif
$(OBJECTS): $(DEPS)
.cpp.o:
$(CXX) $(CXXFLAGS) $(CFLAGS) $(CPPFLAGS) $(OPTS) -Wno-multichar $< -c -o $@
.c.o:
$(CC) $(CFLAGS) $(CPPFLAGS) $(OPTS) $< -c -o $@
clean:
rm -f $(OBJECTS) $(EXECUTABLE)
print-%:
@echo $* = $($*)