Convert para_play to lopsub.
[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 ggo_dir := $(build_dir)/ggo
30 object_dir := $(build_dir)/objects
31 dep_dir := $(build_dir)/deps
32 man_dir := $(build_dir)/man/man1
33 cmdline_dir := $(build_dir)/cmdline
34 m4depdir := $(build_dir)/m4deps
35 help2man_dir := $(build_dir)/help2man
36 lls_suite_dir := $(build_dir)/lls
37 lls_m4_dir := m4/lls
38 m4_ggo_dir := m4/gengetopt
39 test_dir := t
40
41 # sort removes duplicate words, which is all we need here
42 all_objs := $(sort $(recv_objs) $(filter_objs) $(client_objs) $(gui_objs) \
43 $(audiod_objs) $(audioc_objs) $(fade_objs) $(server_objs) \
44 $(write_objs) $(afh_objs) $(play_objs))
45 deps := $(addprefix $(dep_dir)/, $(filter-out %.cmdline.d, $(all_objs:.o=.d)))
46 converted_executables := audioc client fade play
47 unconverted_executables := $(filter-out $(converted_executables), $(executables))
48
49 audioc_objs += audioc.lsg.o
50 audiod_objs += audiod_cmd.lsg.o recv_cmd.lsg.o client.lsg.o
51 fade_objs += fade.lsg.o
52 server_objs += server_cmd.lsg.o
53 play_objs += play_cmd.lsg.o recv_cmd.lsg.o play.lsg.o
54 recv_objs += recv_cmd.lsg.o
55 client_objs += client.lsg.o
56
57 m4_deps := $(addprefix $(m4depdir)/, $(addsuffix .m4d, $(unconverted_executables)))
58 m4_lls_deps := audiod_cmd server_cmd play_cmd recv_cmd $(converted_executables)
59 m4_lls_deps := $(addprefix $(lls_suite_dir)/, $(addsuffix .m4d, $(m4_lls_deps)))
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 fade_objs := $(addprefix $(object_dir)/, $(fade_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 $(m4_ggo_dir)/makefile
88 include $(test_dir)/makefile.test
89 ifeq ($(findstring clean, $(MAKECMDGOALS)),)
90 -include $(deps)
91 -include $(m4_deps)
92 -include $(m4_lls_deps)
93 endif
94
95 $(object_dir) $(man_dir) $(ggo_dir) $(cmdline_dir) $(dep_dir) $(m4depdir) \
96 $(help2man_dir) $(lls_suite_dir):
97 $(Q) $(MKDIR_P) $@
98
99 CPPFLAGS += -DBINDIR='"$(bindir)"'
100 CPPFLAGS += -DCOPYRIGHT_YEAR='"$(COPYRIGHT_YEAR)"'
101 CPPFLAGS += -DBUILD_DATE='"$(build_date)"'
102 CPPFLAGS += -DLOGLEVELS='$(LOGLEVELS)'
103 CPPFLAGS += -DUNAME_RS='"$(uname_rs)"'
104 CPPFLAGS += -DCC_VERSION='"$(cc_version)"'
105 CPPFLAGS += -I/usr/local/include
106 CPPFLAGS += -I$(cmdline_dir)
107 CPPFLAGS += -I$(lls_suite_dir)
108 CPPFLAGS += $(lopsub_cppflags)
109
110 CFLAGS += -Os
111 CFLAGS += -Wuninitialized
112 CFLAGS += -Wchar-subscripts
113 CFLAGS += -Werror-implicit-function-declaration
114 CFLAGS += -Wmissing-noreturn
115 CFLAGS += -Wbad-function-cast
116 CFLAGS += -fno-strict-aliasing
117
118 STRICT_CFLAGS = $(CFLAGS)
119 STRICT_CFLAGS += -g -Wundef -W
120 STRICT_CFLAGS += -Wredundant-decls
121 STRICT_CFLAGS += -Wno-sign-compare -Wno-unknown-pragmas
122 STRICT_CFLAGS += -Wformat -Wformat-security
123 STRICT_CFLAGS += -Wmissing-format-attribute
124 STRICT_CFLAGS += -Wdeclaration-after-statement
125
126 LDFLAGS += $(clock_gettime_ldflags)
127
128 ifeq ($(uname_s),Linux)
129 # these cause warnings on *BSD
130 CPPFLAGS += -Wunused-macros
131 STRICT_CFLAGS += -fdata-sections -ffunction-sections
132 STRICT_CFLAGS += -Wstrict-prototypes
133 STRICT_CFLAGS += -Wshadow
134 STRICT_CFLAGS += -Wunused -Wall
135 LDFLAGS += -Wl,--gc-sections
136 endif
137
138 cc-option = $(shell \
139 $(CC) $(1) -Werror -c -x c /dev/null -o /dev/null > /dev/null 2>&1 \
140 && echo "$(1)" \
141 )
142
143 STRICT_CFLAGS += $(call cc-option, -Wformat-signedness)
144
145 # To put more focus on warnings, be less verbose as default
146 # Use 'make V=1' to see the full commands
147 ifeq ("$(origin V)", "command line")
148 Q :=
149 else
150 Q := @
151 endif
152
153 server_command_lists := $(lls_suite_dir)/server_cmd.lsg.man
154 audiod_command_lists := \
155 $(lls_suite_dir)/audiod_cmd.lsg.man \
156 $(lls_suite_dir)/recv_cmd.lsg.man
157 play_command_lists := $(lls_suite_dir)/play_cmd.lsg.man
158 recv_command_lists := $(lls_suite_dir)/recv_cmd.lsg.man
159
160 $(man_dir)/para_server.1: $(server_command_lists)
161 $(man_dir)/para_audiod.1: $(audiod_command_lists)
162 $(man_dir)/para_play.1: $(play_command_lists)
163 $(man_dir)/para_recv.1: $(recv_command_lists)
164
165 $(man_dir)/para_server.1: man_util_command_lists := $(server_command_lists)
166 $(man_dir)/para_audiod.1: man_util_command_lists := $(audiod_command_lists)
167 $(man_dir)/para_play.1: man_util_command_lists := $(play_command_lists)
168 $(man_dir)/para_recv.1: man_util_command_lists := $(recv_command_lists)
169
170 $(man_dir)/para_%.1: $(lls_suite_dir)/%.lsg.man $(man_util_command_lists) \
171 $(lls_m4_dir)/copyright.m4 | $(man_dir)
172 @[ -z "$(Q)" ] || echo 'LLSMAN $<'
173 $(Q) cat $< $(man_util_command_lists) > $@
174 $(Q) $(M4) -D COPYRIGHT_YEAR=$(COPYRIGHT_YEAR) $(lls_m4_dir)/copyright.m4 >> $@
175
176 $(man_dir)/para_%.1: $(man_util_command_lists) \
177 $(ggo_dir)/%.ggo man_util.bash \
178 | $(man_dir) $(help2man_dir)
179 @[ -z "$(Q)" ] || echo 'MAN $<'
180 $(Q) \
181 COMMAND_LISTS="$(man_util_command_lists)" \
182 FILTERS="$(filters)" \
183 GENGETOPT=$(GENGETOPT) \
184 GGO_DIR=$(ggo_dir) \
185 HELP2MAN=$(HELP2MAN) \
186 HELP2MAN_DIR=$(help2man_dir) \
187 RECEIVERS="$(receivers)" \
188 VERSION="$(GIT_VERSION)" \
189 WRITERS="$(writers)" \
190 ./man_util.bash $@
191
192 $(object_dir)/%.o: %.c | $(object_dir)
193
194 $(object_dir)/opus%.o $(dep_dir)/opus%.d: CPPFLAGS += $(opus_cppflags)
195 $(object_dir)/gui.o $(object_dir)/gui%.o $(dep_dir)/gui%.d \
196 : CPPFLAGS += $(curses_cppflags)
197 $(object_dir)/spx%.o $(dep_dir)/spx%.d: CPPFLAGS += $(speex_cppflags)
198 $(object_dir)/flac%.o $(dep_dir)/flac%.d: CPPFLAGS += $(flac_cppflags)
199
200 $(object_dir)/mp3_afh.o $(dep_dir)/mp3_afh.d: CPPFLAGS += $(id3tag_cppflags)
201 $(object_dir)/crypt.o $(dep_dir)/crypt.d: CPPFLAGS += $(openssl_cppflags)
202 $(object_dir)/gcrypt.o $(dep_dir)/gcrypt.d: CPPFLAGS += $(gcrypt_cppflags)
203 $(object_dir)/ao_write.o $(dep_dir)/ao_write.d: CPPFLAGS += $(ao_cppflags)
204 $(object_dir)/aac_afh.o $(dep_dir)/aac_afh.d: CPPFLAGS += $(mp4v2_cppflags)
205 $(object_dir)/alsa%.o $(dep_dir)/alsa%.d: CPPFLAGS += $(alsa_cppflags)
206
207 $(object_dir)/interactive.o $(dep_dir)/interactive.d \
208 : CPPFLAGS += $(readline_cppflags)
209
210 $(object_dir)/resample_filter.o $(dep_dir)/resample_filter.d \
211 : CPPFLAGS += $(samplerate_cppflags)
212
213 $(object_dir)/oss_write.o $(dep_dir)/oss_write.d \
214 : CPPFLAGS += $(oss_cppflags)
215
216 $(object_dir)/ao_write.o $(dep_dir)/ao_write.d \
217 : CPPFLAGS += $(ao_cppflags) $(pthread_cppflags)
218
219 $(object_dir)/mp3dec_filter.o $(dep_dir)/mp3dec_filter.d \
220 : CPPFLAGS += $(mad_cppflags)
221
222 $(object_dir)/aacdec_filter.o $(dep_dir)/aacdec_filter.d \
223 $(object_dir)/aac_common.o $(dep_dir)/aac_common.d \
224 $(object_dir)/aac_afh.o $(dep_dir)/aac_afh.d \
225 : CPPFLAGS += $(faad_cppflags)
226
227 $(object_dir)/ogg_afh.o $(dep_dir)/ogg_afh.d \
228 $(object_dir)/oggdec_filter.o $(dep_dir)/oggdec_filter.d \
229 : CPPFLAGS += $(vorbis_cppflags)
230
231 $(object_dir)/spx_common.o $(dep_dir)/spx_common.d \
232 $(object_dir)/spxdec_filter.o $(dep_dir)/spxdec_filter.d \
233 $(object_dir)/spx_afh.o $(dep_dir)/spx_afh.d \
234 $(object_dir)/oggdec_filter.o $(dep_dir)/oggdec_filter.d \
235 $(object_dir)/ogg_afh.o $(dep_dir)/ogg_afh.d \
236 $(object_dir)/ogg_afh_common.o $(dep_dir)/ogg_afh_common.d \
237 $(object_dir)/opus%.o $(dep_dir)/opus%.d \
238 : CPPFLAGS += $(ogg_cppflags)
239
240 $(object_dir)/afs.o $(dep_dir)/afs.d \
241 $(object_dir)/aft.o $(dep_dir)/aft.d \
242 $(object_dir)/attribute.o $(dep_dir)/attribute.d \
243 $(object_dir)/blob.o $(dep_dir)/blob.d \
244 $(object_dir)/mood.o $(dep_dir)/mood.d \
245 $(object_dir)/playlist.o $(dep_dir)/playlist.d \
246 $(object_dir)/score.o $(dep_dir)/score.d \
247 $(object_dir)/server.o $(dep_dir)/server.d \
248 $(object_dir)/vss.o $(dep_dir)/vss.d \
249 $(object_dir)/command.o $(dep_dir)/command.d \
250 $(object_dir)/http_send.o $(dep_dir)/http_send.d \
251 $(object_dir)/dccp_send.o $(dep_dir)/dccp_send.d \
252 $(object_dir)/udp_send.o $(dep_dir)/udp_send.d \
253 $(object_dir)/send_common.o $(dep_dir)/send_common.d \
254 $(object_dir)/mm.o $(dep_dir)/mm.d \
255 : CPPFLAGS += $(osl_cppflags)
256
257 $(object_dir)/%.cmdline.o: CFLAGS += -Wno-unused-function
258 $(object_dir)/compress_filter.o: CFLAGS += -O3
259
260 $(object_dir)/%.o: %.c | $(object_dir)
261 @[ -z "$(Q)" ] || echo 'CC $<'
262 $(Q) $(CC) -c -o $@ $(CPPFLAGS) $(STRICT_CFLAGS) $<
263
264 $(object_dir)/%.cmdline.o: $(cmdline_dir)/%.cmdline.c $(cmdline_dir)/%.cmdline.h | $(object_dir)
265 @[ -z "$(Q)" ] || echo 'CC $<'
266 $(Q) $(CC) -c -o $@ $(CPPFLAGS) $(CFLAGS) $<
267
268 # The compiler outputs dependencies either as foo.h or as some_directory/foo.h,
269 # depending on whether the latter file exists. Since make needs the directory
270 # part we prefix the dependency as appropriate.
271 $(dep_dir)/%.d: %.c | $(dep_dir)
272 @[ -z "$(Q)" ] || echo 'DEP $<'
273 $(Q) $(CC) $(CPPFLAGS) -MM -MG -MP -MT $@ -MT $(object_dir)/$(*F).o $< \
274 | sed -e "s@ \([a-zA-Z0-9_]\{1,\}\.cmdline.h\)@ $(cmdline_dir)/\1@g" \
275 -e "s@ \([a-zA-Z0-9_]\{1,\}.lsg.h\)@ $(lls_suite_dir)/\1@g" > $@
276
277 para_recv para_afh para_play para_server: LDFLAGS += $(id3tag_ldflags)
278 para_write para_play para_audiod \
279 : LDFLAGS += $(ao_ldflags) $(pthread_ldflags) $(core_audio_ldflags)
280 para_client para_audioc para_play : LDFLAGS += $(readline_ldflags)
281 para_server: LDFLAGS += $(osl_ldflags)
282 para_gui: LDFLAGS += $(curses_ldflags)
283 para_server \
284 para_client \
285 para_audiod \
286 :LDFLAGS += \
287 $(crypto_ldflags)
288
289 para_audiod \
290 para_filter \
291 para_play \
292 : LDFLAGS += \
293 $(mad_ldflags) \
294 $(faad_ldflags) \
295 $(samplerate_ldflags) \
296 -lm
297
298 para_write \
299 para_play \
300 para_audiod \
301 para_fade \
302 : LDFLAGS += \
303 $(oss_ldflags) \
304 $(alsa_ldflags)
305
306 para_audioc \
307 para_audiod \
308 para_client \
309 para_fade \
310 para_play \
311 para_recv \
312 para_server \
313 : LDFLAGS += $(lopsub_ldflags)
314
315 para_server \
316 para_filter \
317 para_audiod \
318 para_play \
319 para_afh \
320 para_recv \
321 : LDFLAGS += \
322 $(ogg_ldflags) \
323 $(vorbis_ldflags) \
324 $(speex_ldflags) \
325 $(opus_ldflags) \
326 $(faad_ldflags) \
327 $(flac_ldflags)
328
329 para_server \
330 para_play \
331 para_afh \
332 para_recv \
333 : LDFLAGS += \
334 $(mp4v2_ldflags)
335
336 para_afh para_recv para_server para_play: LDFLAGS += $(iconv_ldflags)
337
338 $(foreach exe,$(executables),$(eval para_$(exe): $$($(exe)_objs)))
339 $(prefixed_executables):
340 @[ -z "$(Q)" ] || echo 'LD $@'
341 $(Q) $(CC) $^ -o $@ $(LDFLAGS)
342
343 clean:
344 @[ -z "$(Q)" ] || echo 'CLEAN'
345 $(Q) rm -f para_*
346 $(Q) rm -rf $(object_dir)
347
348 clean2: clean
349 @[ -z "$(Q)" ] || echo 'CLEAN2'
350 $(Q) rm -rf $(build_dir)
351 distclean: clean2 test-clean
352 @[ -z "$(Q)" ] || echo 'DISTCLEAN'
353 $(Q) rm -f Makefile autoscan.log config.status config.log
354 $(Q) rm -f GPATH GRTAGS GSYMS GTAGS
355
356 maintainer-clean: distclean
357 @[ -z "$(Q)" ] || echo 'MAINTAINER-CLEAN'
358 $(Q) rm -f *.tar.bz2 config.h configure config.h.in
359
360 install: all man
361 $(MKDIR_P) $(bindir) $(mandir)
362 $(INSTALL) -s --strip-program $(STRIP) -m 755 \
363 $(prefixed_executables) $(bindir)
364 $(INSTALL) -m 644 $(man_pages) $(mandir)
365 $(MKDIR_P) $(vardir) >/dev/null 2>&1 || true # not fatal, so don't complain
366
367 $(tarball):
368 $(Q) rm -rf $(tarball) $(tarball_pfx)
369 $(Q) git archive --format=tar --prefix=$(tarball_pfx)/ HEAD \
370 | tar --delete $(tarball_delete) > $(tarball_pfx).tar
371 $(Q) $(MKDIR_P) $(tarball_pfx)
372 $(Q) ./GIT-VERSION-GEN > $(tarball_pfx)/VERSION
373 $(Q) cp $(autocrap) $(tarball_pfx)
374 $(Q) tar rf $(tarball_pfx).tar $(tarball_pfx)/*
375 $(Q) bzip2 -9 $(tarball_pfx).tar
376 $(Q) ls -l $(tarball)
377 $(Q) ln -sf $(tarball) paraslash-git.tar.bz2
378 $(Q) rm -rf $(tarball_pfx)