forked from ralph-irving/squeezelite
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
187 lines (167 loc) · 4.63 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
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
#Cross compile support - create a Makefile which defines these three variables and then includes this Makefile...
CFLAGS ?= -Wall -fPIC -O2
CFLAGS += -fcommon -std=gnu99
LDADD ?= -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_NO_MAD = -DNO_MAD
OPT_NO_MPG123 = -DNO_MPG123
OPT_SSL = -DUSE_SSL
OPT_NOSSLSYM = -DNO_SSLSYM
OPT_OPUS = -DOPUS
OPT_PORTAUDIO = -DPORTAUDIO
OPT_PULSEAUDIO = -DPULSEAUDIO
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 output_pulse.c decode.c \
flac.c pcm.c vorbis.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_FAAD = faad.c
SOURCES_SSL = sslsym.c
SOURCES_OPUS = opus.c
SOURCES_MAD = mad.c
SOURCES_MPG123 = mpg.c
LINK_LINUX = -ldl
LINK_ALSA = -lasound
LINK_PORTAUDIO = -lportaudio
LINK_PULSEAUDIO = -lpulse
LINK_RPI = -lgpiod
LINK_SSL = -lssl -lcrypto
LINK_ALAC = -lalac
LINKALL = -lFLAC -lvorbisfile -lvorbis -logg
LINKALL_FF = -lavformat -lavcodec -lavutil
LINKALL_RESAMPLE = -lsoxr
LINKALL_IR = -llirc_client
LINKALL_FAAD = -lfaad
LINKALL_OPUS = -lopusfile -lopus
LINKALL_MAD = -lmad
LINKALL_MPG123 = -lmpg123
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
# ensure GPIO is enabled with RPI
ifneq (,$(findstring $(OPT_RPI), $(OPTS)))
ifeq (,$(findstring $(SOURCES_GPIO), $(SOURCES)))
OPTS += $(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
ifeq (,$(findstring $(OPT_NO_MAD), $(OPTS)))
SOURCES += $(SOURCES_MAD)
endif
ifeq (,$(findstring $(OPT_NO_MPG123), $(OPTS)))
SOURCES += $(SOURCES_MPG123)
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
ifeq (,$(findstring $(OPT_NO_MAD), $(OPTS)))
LDADD += $(LINKALL_MAD)
endif
ifeq (,$(findstring $(OPT_NO_MPG123), $(OPTS)))
LDADD += $(LINKALL_MPG123)
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_PULSEAUDIO), $(OPTS)))
LDADD += $(LINK_PULSEAUDIO)
else ifneq (,$(findstring $(OPT_PORTAUDIO), $(OPTS)))
LDADD += $(LINK_PORTAUDIO)
else
LDADD += $(LINK_ALSA)
endif
ifneq (,$(findstring $(OPT_ALAC), $(OPTS)))
LDADD += $(LINK_ALAC)
endif
ifneq (,$(findstring $(OPT_RPI), $(OPTS)))
LDADD += $(LINK_RPI)
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 $* = $($*)