Convert para_fade to subcommands, rename it to para_mixer.
[paraslash.git] / Makefile.real
1 # Implicit rules are implemented in make as suffix rules. The following rule
2 # empties the suffix list to disable the predefined implicit rules. This
3 # increases performance and avoids hard-to-debug behaviour.
4 .SUFFIXES:
5 MAKEFLAGS += -Rr
6 ifeq ("$(origin CC)", "default")
7 CC := cc
8 endif
9
10 LOGLEVELS := LL_DEBUG,LL_INFO,LL_NOTICE,LL_WARNING,LL_ERROR,LL_CRIT,LL_EMERG
11 vardir := /var/paraslash
12 mandir := $(datarootdir)/man/man1
13 STRIP := $(CROSS_COMPILE)strip
14 MKDIR_P := mkdir -p
15 prefixed_executables := $(addprefix para_, $(executables))
16
17 build_date := $(shell date)
18 uname_s := $(shell uname -s 2>/dev/null || echo "UNKNOWN_OS")
19 uname_rs := $(shell uname -rs)
20 cc_version := $(shell $(CC) --version | head -n 1)
21 GIT_VERSION := $(shell ./GIT-VERSION-GEN git-version.h)
22 COPYRIGHT_YEAR := 2017
23
24 ifeq ("$(origin O)", "command line")
25 build_dir := $(O)
26 else
27 build_dir := build
28 endif
29 object_dir := $(build_dir)/objects
30 dep_dir := $(build_dir)/deps
31 man_dir := $(build_dir)/man/man1
32 m4depdir := $(build_dir)/m4deps
33 lls_suite_dir := $(build_dir)/lls
34 lls_m4_dir := m4/lls
35 test_dir := t
36
37 # sort removes duplicate words, which is all we need here
38 all_objs := $(sort $(recv_objs) $(filter_objs) $(client_objs) $(gui_objs) \
39 $(audiod_objs) $(audioc_objs) $(mixer_objs) $(server_objs) \
40 $(write_objs) $(afh_objs) $(play_objs))
41 deps := $(addprefix $(dep_dir)/, $(all_objs:.o=.d))
42
43 afh_objs += afh.lsg.o
44 audioc_objs += audioc.lsg.o
45 audiod_objs += $(addsuffix _cmd.lsg.o, recv filter audiod write) \
46 client.lsg.o audiod.lsg.o
47 client_objs += client.lsg.o
48 mixer_objs += mixer.lsg.o
49 filter_objs += filter_cmd.lsg.o filter.lsg.o
50 gui_objs += gui.lsg.o
51 play_objs += $(addsuffix _cmd.lsg.o, recv filter play write) play.lsg.o
52 recv_objs += recv_cmd.lsg.o recv.lsg.o
53 server_objs += server_cmd.lsg.o server.lsg.o
54 write_objs += write_cmd.lsg.o write.lsg.o
55
56 cmd_suites := $(addsuffix _cmd, audiod server play recv filter write)
57 suites := $(addprefix $(lls_suite_dir)/, $(cmd_suites) $(executables))
58 m4_lls_deps := $(addsuffix .m4d, $(suites))
59 lsg_h := $(addsuffix .lsg.h, $(suites))
60
61 # now prefix all objects with object dir
62 recv_objs := $(addprefix $(object_dir)/, $(recv_objs))
63 filter_objs := $(addprefix $(object_dir)/, $(filter_objs))
64 client_objs := $(addprefix $(object_dir)/, $(client_objs))
65 gui_objs := $(addprefix $(object_dir)/, $(gui_objs))
66 audiod_objs := $(addprefix $(object_dir)/, $(audiod_objs))
67 audioc_objs := $(addprefix $(object_dir)/, $(audioc_objs))
68 mixer_objs := $(addprefix $(object_dir)/, $(mixer_objs))
69 server_objs := $(addprefix $(object_dir)/, $(server_objs))
70 write_objs := $(addprefix $(object_dir)/, $(write_objs))
71 afh_objs := $(addprefix $(object_dir)/, $(afh_objs))
72 play_objs := $(addprefix $(object_dir)/, $(play_objs))
73
74 man_pages := $(patsubst %, $(man_dir)/%.1, $(prefixed_executables))
75
76 autocrap := config.h.in configure
77 tarball_pfx := $(PACKAGE_TARNAME)-$(GIT_VERSION)
78 tarball_delete := $(addprefix $(tarball_pfx)/, web .gitignore)
79 tarball := $(tarball_pfx).tar.bz2
80
81 .PHONY: all clean clean2 distclean maintainer-clean install man tarball
82 all: $(prefixed_executables) $(man_pages)
83 man: $(man_pages)
84 tarball: $(tarball)
85
86 include $(lls_m4_dir)/makefile
87 include $(test_dir)/makefile.test
88 ifeq ($(findstring clean, $(MAKECMDGOALS)),)
89 -include $(deps)
90 -include $(m4_lls_deps)
91 endif
92
93 $(object_dir) $(man_dir) $(dep_dir) $(m4depdir) $(lls_suite_dir):
94 $(Q) $(MKDIR_P) $@
95
96 CPPFLAGS += -DBINDIR='"$(bindir)"'
97 CPPFLAGS += -DCOPYRIGHT_YEAR='"$(COPYRIGHT_YEAR)"'
98 CPPFLAGS += -DBUILD_DATE='"$(build_date)"'
99 CPPFLAGS += -DLOGLEVELS='$(LOGLEVELS)'
100 CPPFLAGS += -DUNAME_RS='"$(uname_rs)"'
101 CPPFLAGS += -DCC_VERSION='"$(cc_version)"'
102 CPPFLAGS += -I/usr/local/include
103 CPPFLAGS += -I$(lls_suite_dir)
104 CPPFLAGS += $(lopsub_cppflags)
105
106 STRICT_CFLAGS += -fno-strict-aliasing
107 STRICT_CFLAGS += -g
108 STRICT_CFLAGS += -Os
109 STRICT_CFLAGS += -Wundef -W -Wuninitialized
110 STRICT_CFLAGS += -Wchar-subscripts
111 STRICT_CFLAGS += -Werror-implicit-function-declaration
112 STRICT_CFLAGS += -Wmissing-noreturn
113 STRICT_CFLAGS += -Wbad-function-cast
114 STRICT_CFLAGS += -Wredundant-decls
115 STRICT_CFLAGS += -Wno-sign-compare -Wno-unknown-pragmas
116 STRICT_CFLAGS += -Wdeclaration-after-statement
117 STRICT_CFLAGS += -Wformat -Wformat-security -Wmissing-format-attribute
118
119 LDFLAGS += $(clock_gettime_ldflags)
120
121 ifeq ($(uname_s),Linux)
122 # these cause warnings on *BSD
123 CPPFLAGS += -Wunused-macros
124 STRICT_CFLAGS += -fdata-sections -ffunction-sections
125 STRICT_CFLAGS += -Wstrict-prototypes
126 STRICT_CFLAGS += -Wshadow
127 STRICT_CFLAGS += -Wunused -Wall
128 LDFLAGS += -Wl,--gc-sections
129 endif
130
131 cc-option = $(shell \
132 $(CC) $(1) -Werror -c -x c /dev/null -o /dev/null > /dev/null 2>&1 \
133 && echo "$(1)" \
134 )
135
136 STRICT_CFLAGS += $(call cc-option, -Wformat-signedness)
137
138 # To put more focus on warnings, be less verbose as default
139 # Use 'make V=1' to see the full commands
140 ifeq ("$(origin V)", "command line")
141 Q :=
142 else
143 Q := @
144 endif
145
146 audiod_commands := $(addprefix $(lls_suite_dir)/, \
147 $(addsuffix _cmd.lsg.man, audiod recv filter write))
148 filter_commands := $(lls_suite_dir)/filter_cmd.lsg.man
149 play_commands := $(lls_suite_dir)/play_cmd.lsg.man
150 recv_commands := $(lls_suite_dir)/recv_cmd.lsg.man
151 server_commands := $(lls_suite_dir)/server_cmd.lsg.man
152 write_commands := $(lls_suite_dir)/write_cmd.lsg.man
153
154 $(man_dir)/para_audiod.1: $(audiod_commands)
155 $(man_dir)/para_filter.1: $(filter_commands)
156 $(man_dir)/para_play.1: $(play_commands)
157 $(man_dir)/para_recv.1: $(recv_commands)
158 $(man_dir)/para_server.1: $(server_commands)
159 $(man_dir)/para_write.1: $(write_commands)
160
161 $(man_dir)/para_audiod.1: all_commands := $(audiod_commands)
162 $(man_dir)/para_filter.1: all_commands := $(filter_commands)
163 $(man_dir)/para_play.1: all_commands := $(play_commands)
164 $(man_dir)/para_recv.1: all_commands := $(recv_commands)
165 $(man_dir)/para_server.1: all_commands := $(server_commands)
166 $(man_dir)/para_write.1: all_commands := $(write_commands)
167
168 $(man_dir)/para_%.1: $(lls_suite_dir)/%.lsg.man \
169 $(lls_m4_dir)/copyright.m4 | $(man_dir)
170 @[ -z "$(Q)" ] || echo 'LLSMAN $<'
171 $(Q) cat $< $(all_commands) > $@
172 $(Q) $(M4) -D COPYRIGHT_YEAR=$(COPYRIGHT_YEAR) $(lls_m4_dir)/copyright.m4 >> $@
173
174 $(object_dir)/%.o: %.c | $(object_dir)
175
176 $(object_dir)/opus%.o: CPPFLAGS += $(opus_cppflags)
177 $(object_dir)/gui.o $(object_dir)/gui%.o \
178 : CPPFLAGS += $(curses_cppflags)
179 $(object_dir)/spx%.o: CPPFLAGS += $(speex_cppflags)
180 $(object_dir)/flac%.o: CPPFLAGS += $(flac_cppflags)
181
182 $(object_dir)/mp3_afh.o: CPPFLAGS += $(id3tag_cppflags)
183 $(object_dir)/crypt.o: CPPFLAGS += $(openssl_cppflags)
184 $(object_dir)/gcrypt.o: CPPFLAGS += $(gcrypt_cppflags)
185 $(object_dir)/ao_write.o: CPPFLAGS += $(ao_cppflags)
186 $(object_dir)/aac_afh.o: CPPFLAGS += $(mp4v2_cppflags)
187 $(object_dir)/alsa%.o: CPPFLAGS += $(alsa_cppflags)
188
189 $(object_dir)/interactive.o \
190 : CPPFLAGS += $(readline_cppflags)
191
192 $(object_dir)/resample_filter.o \
193 : CPPFLAGS += $(samplerate_cppflags)
194
195 $(object_dir)/oss_write.o \
196 : CPPFLAGS += $(oss_cppflags)
197
198 $(object_dir)/ao_write.o \
199 : CPPFLAGS += $(ao_cppflags) $(pthread_cppflags)
200
201 $(object_dir)/mp3dec_filter.o \
202 : CPPFLAGS += $(mad_cppflags)
203
204 $(object_dir)/aacdec_filter.o \
205 $(object_dir)/aac_common.o \
206 $(object_dir)/aac_afh.o \
207 : CPPFLAGS += $(faad_cppflags)
208
209 $(object_dir)/ogg_afh.o \
210 $(object_dir)/oggdec_filter.o \
211 : CPPFLAGS += $(vorbis_cppflags)
212
213 $(object_dir)/spx_common.o \
214 $(object_dir)/spxdec_filter.o \
215 $(object_dir)/spx_afh.o \
216 $(object_dir)/oggdec_filter.o \
217 $(object_dir)/ogg_afh.o \
218 $(object_dir)/ogg_afh_common.o \
219 $(object_dir)/opus%.o \
220 : CPPFLAGS += $(ogg_cppflags)
221
222 $(object_dir)/afs.o \
223 $(object_dir)/aft.o \
224 $(object_dir)/attribute.o \
225 $(object_dir)/blob.o \
226 $(object_dir)/mood.o \
227 $(object_dir)/playlist.o \
228 $(object_dir)/score.o \
229 $(object_dir)/server.o \
230 $(object_dir)/vss.o \
231 $(object_dir)/command.o \
232 $(object_dir)/http_send.o \
233 $(object_dir)/dccp_send.o \
234 $(object_dir)/udp_send.o \
235 $(object_dir)/send_common.o \
236 $(object_dir)/mm.o \
237 : CPPFLAGS += $(osl_cppflags)
238
239 $(object_dir)/compress_filter.o: CFLAGS += -O3
240
241 $(object_dir)/%.o: %.c | $(object_dir) $(dep_dir) $(lsg_h)
242 @[ -z "$(Q)" ] || echo 'CC $<'
243 $(Q) $(CC) -c -o $@ -MMD -MF $(dep_dir)/$(*F).d -MT $@ $(CPPFLAGS) \
244 $(STRICT_CFLAGS) $(CFLAGS) $<
245
246 para_recv para_afh para_play para_server: LDFLAGS += $(id3tag_ldflags)
247 para_write para_play para_audiod \
248 : LDFLAGS += $(ao_ldflags) $(pthread_ldflags) $(core_audio_ldflags)
249 para_client para_audioc para_play : LDFLAGS += $(readline_ldflags)
250 para_server: LDFLAGS += $(osl_ldflags)
251 para_gui: LDFLAGS += $(curses_ldflags)
252 para_server \
253 para_client \
254 para_audiod \
255 :LDFLAGS += \
256 $(crypto_ldflags)
257
258 para_audiod \
259 para_filter \
260 para_play \
261 : LDFLAGS += \
262 $(mad_ldflags) \
263 $(faad_ldflags) \
264 $(samplerate_ldflags) \
265 -lm
266
267 para_write \
268 para_play \
269 para_audiod \
270 para_mixer \
271 : LDFLAGS += \
272 $(oss_ldflags) \
273 $(alsa_ldflags)
274
275 para_afh \
276 para_audioc \
277 para_audiod \
278 para_client \
279 para_mixer \
280 para_filter \
281 para_gui \
282 para_play \
283 para_recv \
284 para_server \
285 para_write \
286 : LDFLAGS += $(lopsub_ldflags)
287
288 para_server \
289 para_filter \
290 para_audiod \
291 para_play \
292 para_afh \
293 para_recv \
294 : LDFLAGS += \
295 $(ogg_ldflags) \
296 $(vorbis_ldflags) \
297 $(speex_ldflags) \
298 $(opus_ldflags) \
299 $(faad_ldflags) \
300 $(flac_ldflags)
301
302 para_server \
303 para_play \
304 para_afh \
305 para_recv \
306 : LDFLAGS += \
307 $(mp4v2_ldflags)
308
309 para_afh para_recv para_server para_play: LDFLAGS += $(iconv_ldflags)
310
311 $(foreach exe,$(executables),$(eval para_$(exe): $$($(exe)_objs)))
312 $(prefixed_executables):
313 @[ -z "$(Q)" ] || echo 'LD $@'
314 $(Q) $(CC) $^ -o $@ $(LDFLAGS)
315
316 clean:
317 @[ -z "$(Q)" ] || echo 'CLEAN'
318 $(Q) rm -f para_*
319 $(Q) rm -rf $(object_dir)
320
321 clean2: clean
322 @[ -z "$(Q)" ] || echo 'CLEAN2'
323 $(Q) rm -rf $(build_dir)
324 distclean: clean2 test-clean
325 @[ -z "$(Q)" ] || echo 'DISTCLEAN'
326 $(Q) rm -f Makefile autoscan.log config.status config.log
327 $(Q) rm -f GPATH GRTAGS GSYMS GTAGS
328
329 maintainer-clean: distclean
330 @[ -z "$(Q)" ] || echo 'MAINTAINER-CLEAN'
331 $(Q) rm -f *.tar.bz2 config.h configure config.h.in
332
333 install: all man
334 $(MKDIR_P) $(bindir) $(mandir)
335 $(INSTALL) -s --strip-program $(STRIP) -m 755 \
336 $(prefixed_executables) $(bindir)
337 $(INSTALL) -m 644 $(man_pages) $(mandir)
338 $(MKDIR_P) $(vardir) >/dev/null 2>&1 || true # not fatal, so don't complain
339
340 $(tarball):
341 $(Q) rm -rf $(tarball) $(tarball_pfx)
342 $(Q) git archive --format=tar --prefix=$(tarball_pfx)/ HEAD \
343 | tar --delete $(tarball_delete) > $(tarball_pfx).tar
344 $(Q) $(MKDIR_P) $(tarball_pfx)
345 $(Q) ./GIT-VERSION-GEN > $(tarball_pfx)/VERSION
346 $(Q) cp $(autocrap) $(tarball_pfx)
347 $(Q) tar rf $(tarball_pfx).tar $(tarball_pfx)/*
348 $(Q) bzip2 -9 $(tarball_pfx).tar
349 $(Q) ls -l $(tarball)
350 $(Q) ln -sf $(tarball) paraslash-git.tar.bz2
351 $(Q) rm -rf $(tarball_pfx)