]> git.tuebingen.mpg.de Git - paraslash.git/blob - Makefile.real
build: Construct audioc object list in Makefile.
[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 .ONESHELL:
10 .SHELLFLAGS := -ec
11
12 LOGLEVELS := LL_DEBUG,LL_INFO,LL_NOTICE,LL_WARNING,LL_ERROR,LL_CRIT,LL_EMERG
13 SEVERITIES := \"debug\",\"info\",\"notice\",\"warning\",\"error\",\"crit\",\"emerg\"
14 vardir := /var/paraslash
15 mandir := $(datarootdir)/man/man1
16 MKDIR_P := mkdir -p
17 prefixed_executables := $(addprefix para_, $(executables))
18
19 build_date := $(shell date)
20 uname_s := $(shell uname -s 2>/dev/null || echo "UNKNOWN_OS")
21 uname_rs := $(shell uname -rs)
22 cc_version := $(shell $(CC) --version | head -n 1)
23 GIT_VERSION := $(shell ./GIT-VERSION-GEN git-version.h)
24 COPYRIGHT_YEAR := 2024
25
26 ifeq ("$(origin O)", "command line")
27         build_dir := $(O)
28 else
29         build_dir := build
30 endif
31 object_dir := $(build_dir)/objects
32 dep_dir := $(build_dir)/deps
33 man_dir := $(build_dir)/man/man1
34 m4depdir := $(build_dir)/m4deps
35 lls_suite_dir := $(build_dir)/lls
36 lls_m4_dir := m4/lls
37 test_dir := t
38 yy_src_dir := yy
39 yy_build_dir := $(build_dir)/yy
40
41 ifneq ($(CRYPTOLIB),)
42         ifeq ($(HAVE_OSL),yes)
43                 server_objs := $(addsuffix .o, \
44                         server afh_common mp3_afh vss command net string \
45                         signal time daemon http_send close_on_fork \
46                         crypt_common base64 ipc dccp_send fd user_list \
47                         chunk_queue afs aft mood mp score attribute blob \
48                         playlist sched acl send_common udp_send color fec \
49                         wma_afh wma_common sideband version lsu \
50                 )
51                 ifeq ($(CRYPTOLIB),openssl)
52                         server_objs += openssl.o
53                 else
54                         server_objs += gcrypt.o
55                 endif
56                 ifeq ($(NEED_OGG_OBJECTS),yes)
57                         server_objs += ogg_afh_common.o
58                 endif
59                 ifeq ($(NEED_VORBIS_OBJECTS),yes)
60                         server_objs += ogg_afh.o
61                 endif
62                 ifeq ($(NEED_SPEEX_OBJECTS),yes)
63                         server_objs += spx_afh.o spx_common.o
64                 endif
65                 ifeq ($(NEED_OPUS_OBJECTS),yes)
66                         server_objs += opus_afh.o opus_common.o
67                 endif
68                 ifeq ($(NEED_FLAC_OBJECTS),yes)
69                         server_objs += flac_afh.o
70                 endif
71                 ifeq ($(HAVE_FAAD),yes)
72                         server_objs += aac_afh.o mp4.o
73                 endif
74                 upgrade_db_objs := $(addsuffix .o, crypt_common exec fd string \
75                         upgrade_db version base64)
76         endif
77 endif
78 ifneq ($(CRYPTOLIB),)
79         client_objs := $(addsuffix .o, \
80                 client net string fd lsu sched stdin stdout time sideband client_common \
81                 buffer_tree crypt_common base64 version $(CRYPTOLIB) \
82         )
83         ifeq ($(HAVE_READLINE),yes)
84                 client_objs += interactive.o
85         endif
86         audiod_objs := $(addsuffix .o, \
87                 audiod signal string daemon stat net crypt_common base64 sideband \
88                 time grab_client filter_common wav_filter compress_filter amp_filter \
89                 http_recv dccp_recv recv_common fd sched write_common file_write \
90                 audiod_command fecdec_filter client_common udp_recv color fec \
91                 prebuffer_filter version bitstream imdct wma_common wmadec_filter \
92                 buffer_tree sync_filter lsu $(CRYPTOLIB) \
93         )
94         audiod_audio_formats := "wma"
95         ifeq ($(NEED_VORBIS_OBJECTS),yes)
96                 audiod_objs += oggdec_filter.o
97                 audiod_audio_formats += ,"ogg"
98         endif
99         ifeq ($(NEED_SPEEX_OBJECTS),yes)
100                 audiod_objs += spxdec_filter.o spx_common.o
101                 audiod_audio_formats += ,"spx"
102         endif
103         ifeq ($(NEED_OPUS_OBJECTS),yes)
104                 audiod_objs += opusdec_filter.o opus_common.o
105                 audiod_audio_formats += ,"opus"
106         endif
107         ifeq ($(NEED_FLAC_OBJECTS),yes)
108                 audiod_objs += flacdec_filter.o
109                 audiod_audio_formats += ,"flac"
110         endif
111         ifeq ($(HAVE_FAAD),yes)
112                 audiod_objs += aacdec_filter.o
113                 audiod_audio_formats += ,"aac"
114         endif
115         ifeq ($(HAVE_MAD),yes)
116                 audiod_objs += mp3dec_filter.o
117                 audiod_audio_formats += ,"mp3"
118         endif
119         ifeq ($(HAVE_OSS),yes)
120                 audiod_objs += oss_write.o
121         endif
122         ifeq ($(HAVE_ALSA),yes)
123                 audiod_objs += alsa_write.o
124         endif
125         ifeq ($(NEED_AO_OBJECTS),yes)
126                 audiod_objs += ao_write.o
127         endif
128         ifeq ($(HAVE_SAMPLERATE),yes)
129                 audiod_objs += resample_filter.o check_wav.o
130         endif
131 endif
132 ifneq ($(HAVE_OSS)-$(HAVE_ALSA),no-no)
133         mixer_objs := $(addsuffix .o, mixer exec string fd time lsu version)
134         ifeq ($(HAVE_OSS),yes)
135                 mixer_objs += oss_mix.o
136         endif
137         ifeq ($(HAVE_ALSA),yes)
138                 mixer_objs += alsa_mix.o
139         endif
140 endif
141 ifeq ($(HAVE_CURSES),yes)
142         gui_objs := $(addsuffix .o, exec signal string stat ringbuffer fd \
143                 gui gui_theme lsu time sched version)
144 endif
145 filter_objs := $(addsuffix .o, \
146         filter_common wav_filter compress_filter filter string stdin stdout \
147         sched fd amp_filter fecdec_filter fec lsu version prebuffer_filter \
148         time bitstream imdct wma_common wmadec_filter buffer_tree net \
149         sync_filter \
150 )
151 ifeq ($(NEED_VORBIS_OBJECTS),yes)
152         filter_objs += oggdec_filter.o
153 endif
154 ifeq ($(NEED_SPEEX_OBJECTS),yes)
155         filter_objs += spxdec_filter.o spx_common.o
156 endif
157 ifeq ($(NEED_OPUS_OBJECTS),yes)
158         filter_objs += opusdec_filter.o opus_common.o
159 endif
160 ifeq ($(NEED_FLAC_OBJECTS),yes)
161         filter_objs += flacdec_filter.o
162 endif
163 ifeq ($(HAVE_FAAD),yes)
164         filter_objs += aacdec_filter.o
165 endif
166 ifeq ($(HAVE_MAD),yes)
167         filter_objs += mp3dec_filter.o
168 endif
169 ifeq ($(HAVE_SAMPLERATE),yes)
170         filter_objs += resample_filter.o check_wav.o
171 endif
172
173 recv_objs := $(addsuffix .o, \
174         http_recv recv_common recv time string net dccp_recv fd sched stdout \
175         udp_recv buffer_tree afh_recv afh_common wma_afh wma_common mp3_afh \
176         version \
177 )
178 ifeq ($(NEED_OGG_OBJECTS),yes)
179         recv_objs += ogg_afh_common.o
180 endif
181 ifeq ($(NEED_VORBIS_OBJECTS),yes)
182         recv_objs += ogg_afh.o
183 endif
184 ifeq ($(NEED_SPEEX_OBJECTS),yes)
185         recv_objs += spx_afh.o spx_common.o
186 endif
187 ifeq ($(NEED_OPUS_OBJECTS),yes)
188         recv_objs += opus_afh.o opus_common.o
189 endif
190 ifeq ($(NEED_FLAC_OBJECTS),yes)
191         recv_objs += flac_afh.o
192 endif
193 ifeq ($(HAVE_FAAD),yes)
194         recv_objs += aac_afh.o mp4.o
195 endif
196
197 audio_format_handlers := mp3 wma
198 afh_objs := $(addsuffix .o, afh string fd mp3_afh afh_common time wma_afh \
199         wma_common version)
200 ifeq ($(NEED_OGG_OBJECTS),yes)
201         afh_objs += ogg_afh_common.o
202 endif
203 ifeq ($(NEED_VORBIS_OBJECTS),yes)
204         afh_objs += ogg_afh.o
205         audio_format_handlers += ogg
206 endif
207 ifeq ($(NEED_SPEEX_OBJECTS),yes)
208         afh_objs += spx_common.o
209         audio_format_handlers += spx
210 endif
211 ifeq ($(NEED_OPUS_OBJECTS),yes)
212         afh_objs += opus_afh.o opus_common.o
213         audio_format_handlers += opus
214 endif
215 ifeq ($(NEED_FLAC_OBJECTS),yes)
216         afh_objs += flac_afh.o
217         audio_format_handlers += flac
218 endif
219 ifeq ($(HAVE_FAAD),yes)
220         afh_objs += aac_afh.o mp4.o
221         audio_format_handlers += aac
222 endif
223
224 play_objs := $(addsuffix .o, \
225         play fd sched buffer_tree time string net afh_recv afh_common \
226         wma_afh wma_common mp3_afh recv_common udp_recv http_recv dccp_recv \
227         filter_common fec bitstream imdct wav_filter compress_filter \
228         amp_filter prebuffer_filter fecdec_filter wmadec_filter write_common \
229         file_write version sync_filter lsu \
230 )
231 ifeq ($(NEED_OGG_OBJECTS),yes)
232         play_objs += ogg_afh_common.o
233 endif
234 ifeq ($(NEED_VORBIS_OBJECTS),yes)
235         play_objs += oggdec_filter.o ogg_afh.o
236 endif
237 ifeq ($(NEED_SPEEX_OBJECTS),yes)
238         play_objs += spxdec_filter.o spx_afh.o spx_common.o
239 endif
240 ifeq ($(NEED_OPUS_OBJECTS),yes)
241         play_objs += opusdec_filter.o opus_afh.o opus_common.o
242 endif
243 ifeq ($(NEED_FLAC_OBJECTS),yes)
244         play_objs += flacdec_filter.o flac_afh.o
245 endif
246 ifeq ($(HAVE_FAAD),yes)
247         play_objs += aac_afh.o aacdec_filter.o mp4.o
248 endif
249 ifeq ($(HAVE_MAD),yes)
250         play_objs += mp3dec_filter.o
251 endif
252 ifeq ($(HAVE_OSS),yes)
253         play_objs += oss_write.o
254 endif
255 ifeq ($(HAVE_ALSA),yes)
256         play_objs += alsa_write.o
257 endif
258 ifeq ($(NEED_AO_OBJECTS),yes)
259         play_objs += ao_write.o
260 endif
261 ifeq ($(HAVE_READLINE),yes)
262         play_objs += interactive.o
263 endif
264 ifeq ($(HAVE_SAMPLERATE),yes)
265         play_objs += resample_filter.o check_wav.o
266 endif
267
268 write_objs := $(addsuffix .o, write write_common file_write time fd \
269         string sched stdin buffer_tree check_wav version)
270 ifeq ($(NEED_AO_OBJECTS),yes)
271         write_objs += ao_write.o
272 endif
273 ifeq ($(HAVE_OSS),yes)
274         write_objs += oss_write.o
275 endif
276 ifeq ($(HAVE_ALSA),yes)
277         write_objs += alsa_write.o
278 endif
279
280 audioc_objs := $(addsuffix .o, audioc string lsu net fd time version)
281 ifeq ($(HAVE_READLINE),yes)
282         audioc_objs += buffer_tree.o interactive.o sched.o
283 endif
284
285 # sort removes duplicate words, which is all we need here
286 all_objs := $(sort $(recv_objs) $(filter_objs) $(client_objs) $(gui_objs) \
287         $(audiod_objs) $(audioc_objs) $(mixer_objs) $(server_objs) \
288         $(write_objs) $(afh_objs) $(play_objs))
289 deps := $(addprefix $(dep_dir)/, $(all_objs:.o=.d))
290 deps += $(addprefix $(dep_dir)/, mp.bison.d mp.flex.d)
291
292 afh_objs += afh.lsg.o
293 audioc_objs += audioc.lsg.o
294 audiod_objs += $(addsuffix _cmd.lsg.o, recv filter audiod write) \
295         client.lsg.o audiod.lsg.o
296 client_objs += client.lsg.o
297 mixer_objs += mixer.lsg.o
298 filter_objs += filter_cmd.lsg.o filter.lsg.o
299 gui_objs += gui.lsg.o
300 play_objs += $(addsuffix _cmd.lsg.o, recv filter play write) play.lsg.o
301 recv_objs += recv_cmd.lsg.o recv.lsg.o
302 server_objs += server_cmd.lsg.o server.lsg.o
303 upgrade_db_objs += upgrade_db.lsg.o
304 write_objs += write_cmd.lsg.o write.lsg.o
305
306 cmd_suites := $(addsuffix _cmd, audiod server play recv filter write)
307 suites := $(addprefix $(lls_suite_dir)/, $(cmd_suites) $(executables))
308 m4_lls_deps := $(addsuffix .m4d, $(suites))
309 lsg_h := $(addsuffix .lsg.h, $(suites))
310
311 # flex/bison objects and headers are only needed if para_server is built
312 ifeq ("$(findstring server, $(executables))", "server")
313         server_objs += mp.flex.o mp.bison.o
314         yy_h := $(yy_build_dir)/mp.bison.h
315 endif
316
317 # now prefix all objects with object dir
318 recv_objs := $(addprefix $(object_dir)/, $(recv_objs))
319 filter_objs := $(addprefix $(object_dir)/, $(filter_objs))
320 client_objs := $(addprefix $(object_dir)/, $(client_objs))
321 gui_objs := $(addprefix $(object_dir)/, $(gui_objs))
322 audiod_objs := $(addprefix $(object_dir)/, $(audiod_objs))
323 audioc_objs := $(addprefix $(object_dir)/, $(audioc_objs))
324 mixer_objs := $(addprefix $(object_dir)/, $(mixer_objs))
325 server_objs := $(addprefix $(object_dir)/, $(server_objs))
326 upgrade_db_objs := $(addprefix $(object_dir)/, $(upgrade_db_objs))
327 write_objs := $(addprefix $(object_dir)/, $(write_objs))
328 afh_objs := $(addprefix $(object_dir)/, $(afh_objs))
329 play_objs := $(addprefix $(object_dir)/, $(play_objs))
330
331 man_pages := $(patsubst %, $(man_dir)/%.1, $(prefixed_executables))
332
333 autocrap := config.h.in configure
334 tarball_pfx := $(PACKAGE_TARNAME)-$(GIT_VERSION)
335 tarball_delete := $(addprefix $(tarball_pfx)/, web .gitignore)
336 tarball := $(tarball_pfx).tar.xz
337
338 all: $(prefixed_executables) $(man_pages)
339 .PHONY: all mostlyclean clean distclean maintainer-clean install \
340         install-strip man dist tarball
341
342 man: $(man_pages)
343
344 include $(lls_m4_dir)/makefile
345 include $(test_dir)/makefile.test
346 include $(yy_src_dir)/makefile
347 ifeq ($(findstring clean, $(MAKECMDGOALS)),)
348 -include $(deps)
349 -include $(m4_lls_deps)
350 endif
351
352 $(object_dir) $(man_dir) $(dep_dir) $(m4depdir) $(lls_suite_dir) \
353         $(yy_build_dir):
354         @$(MKDIR_P) $@
355
356 CPPFLAGS += -DBINDIR='"$(bindir)"'
357 CPPFLAGS += -DCOPYRIGHT_YEAR='"$(COPYRIGHT_YEAR)"'
358 CPPFLAGS += -DBUILD_DATE='"$(build_date)"'
359 CPPFLAGS += -DLOGLEVELS='$(LOGLEVELS)'
360 CPPFLAGS += -DSEVERITIES=$(SEVERITIES)
361 CPPFLAGS += -DUNAME_RS='"$(uname_rs)"'
362 CPPFLAGS += -DCC_VERSION='"$(cc_version)"'
363 CPPFLAGS += -I$(lls_suite_dir)
364 CPPFLAGS += -I$(yy_build_dir)
365 CPPFLAGS += $(lopsub_cppflags)
366 CPPFLAGS += -Wunused-macros
367
368 STRICT_CFLAGS += -fno-strict-aliasing
369 STRICT_CFLAGS += -ftrapv
370 STRICT_CFLAGS += -g
371 STRICT_CFLAGS += -Os
372 STRICT_CFLAGS += -Wundef -W -Wuninitialized
373 STRICT_CFLAGS += -Wchar-subscripts
374 STRICT_CFLAGS += -Werror-implicit-function-declaration
375 STRICT_CFLAGS += -Wmissing-noreturn
376 STRICT_CFLAGS += -Wbad-function-cast
377 STRICT_CFLAGS += -Wredundant-decls
378 STRICT_CFLAGS += -Wno-sign-compare -Wno-unknown-pragmas
379 STRICT_CFLAGS += -Wdeclaration-after-statement
380 STRICT_CFLAGS += -Wformat -Wformat-security -Wmissing-format-attribute
381 STRICT_CFLAGS += -fdata-sections -ffunction-sections
382 STRICT_CFLAGS += -Wstrict-prototypes
383 STRICT_CFLAGS += -Wshadow
384
385 LDFLAGS += -Wl,--gc-sections
386
387 ifeq ($(ENABLE_UBSAN), yes)
388         STRICT_CFLAGS += -fsanitize=undefined
389         LDFLAGS += -lubsan
390 endif
391
392 ifeq ($(uname_s),Linux)
393         # these cause warnings on *BSD
394         STRICT_CFLAGS += -Wunused -Wall
395 endif
396
397 cc-option = $(shell \
398         $(CC) $(1) -Werror -c -x c /dev/null -o /dev/null > /dev/null 2>&1 \
399         && echo "$(1)" \
400 )
401
402 STRICT_CFLAGS += $(call cc-option, -Wformat-signedness)
403 STRICT_CFLAGS += $(call cc-option, -Wdiscarded-qualifiers)
404 STRICT_CFLAGS += $(call cc-option, -Wsuggest-attribute=malloc)
405
406 # To put more focus on warnings, be less verbose as default
407 # Use 'make V=1' to see the full commands
408 ifeq ("$(origin V)", "command line")
409         SAY =
410 else
411         SAY = @echo '$(strip $(1))'
412 endif
413
414 audiod_commands := $(addprefix $(lls_suite_dir)/, \
415         $(addsuffix _cmd.lsg.man, audiod recv filter write))
416 filter_commands := $(lls_suite_dir)/filter_cmd.lsg.man
417 play_commands := $(lls_suite_dir)/play_cmd.lsg.man
418 recv_commands := $(lls_suite_dir)/recv_cmd.lsg.man
419 server_commands := $(lls_suite_dir)/server_cmd.lsg.man
420 write_commands := $(lls_suite_dir)/write_cmd.lsg.man
421
422 $(man_dir)/para_audiod.1: $(audiod_commands)
423 $(man_dir)/para_filter.1: $(filter_commands)
424 $(man_dir)/para_play.1: $(play_commands)
425 $(man_dir)/para_recv.1: $(recv_commands)
426 $(man_dir)/para_server.1: $(server_commands)
427 $(man_dir)/para_write.1: $(write_commands)
428
429 $(man_dir)/para_audiod.1: all_commands := $(audiod_commands)
430 $(man_dir)/para_filter.1: all_commands := $(filter_commands)
431 $(man_dir)/para_play.1: all_commands := $(play_commands)
432 $(man_dir)/para_recv.1: all_commands := $(recv_commands)
433 $(man_dir)/para_server.1: all_commands := $(server_commands)
434 $(man_dir)/para_write.1: all_commands := $(write_commands)
435
436 $(man_dir)/para_%.1: $(lls_suite_dir)/%.lsg.man \
437                 $(lls_m4_dir)/copyright.m4 | $(man_dir)
438         $(call SAY, LLSMAN $<)
439         cat $< $(all_commands) > $@
440         $(M4) -D COPYRIGHT_YEAR=$(COPYRIGHT_YEAR) $(lls_m4_dir)/copyright.m4 >> $@
441
442 $(object_dir)/%.o: %.c | $(object_dir)
443
444 OD = $(addsuffix .d, $(addprefix $(dep_dir)/, $(1))) \
445         $(addsuffix .o, $(addprefix $(object_dir)/, $(1)))
446
447 $(call OD, audiod): \
448         CPPFLAGS += -DAUDIOD_AUDIO_FORMAT_ARRAY='$(audiod_audio_formats)'
449 $(call OD, afh command): \
450         CPPFLAGS += -DAUDIO_FORMAT_HANDLERS='"$(audio_format_handlers)"'
451 $(call OD, opus%): CPPFLAGS += $(opus_cppflags)
452 $(call OD, gui gui%): CPPFLAGS += $(curses_cppflags)
453 $(call OD, spx%): CPPFLAGS += $(speex_cppflags)
454 $(call OD, flac%): CPPFLAGS += $(flac_cppflags)
455 $(call OD, mp3_afh): CPPFLAGS += $(id3tag_cppflags)
456 $(call OD, openssl): CPPFLAGS += $(openssl_cppflags)
457 $(call OD, gcrypt): CPPFLAGS += $(gcrypt_cppflags)
458 $(call OD, ao_write): CPPFLAGS += $(ao_cppflags)
459 $(call OD, alsa%): CPPFLAGS += $(alsa_cppflags)
460 $(call OD, interactive): CPPFLAGS += $(readline_cppflags)
461 $(call OD, resample_filter): CPPFLAGS += $(samplerate_cppflags)
462 $(call OD, oss_write): CPPFLAGS += $(oss_cppflags)
463 $(call OD, ao_write): CPPFLAGS += $(ao_cppflags) $(pthread_cppflags)
464 $(call OD, mp3dec_filter): CPPFLAGS += $(mad_cppflags)
465 $(call OD, aacdec_filter aac_afh): CPPFLAGS += $(faad_cppflags)
466 $(call OD, ogg_afh oggdec_filter): CPPFLAGS += $(vorbis_cppflags)
467 $(call OD, spx_common spxdec_filter spx_afh oggdec_filter ogg_afh \
468         ogg_afh_common opus%): CPPFLAGS += $(ogg_cppflags)
469 $(call OD, afs aft attribute blob mood playlist score server vss command \
470         http_send dccp_send udp_send send_common mm.o): \
471         CPPFLAGS += $(osl_cppflags)
472
473 $(call OD, compress_filter): CFLAGS += -O3
474 $(call OD, openssl): CFLAGS += -Wno-deprecated-declarations
475
476 $(object_dir)/%.o: %.c | $(object_dir) $(dep_dir) $(lsg_h) $(yy_h)
477 define CC_CMD
478         $(call SAY, CC $<)
479         $(CC) -c -o $(object_dir)/$(*F).o -MMD -MF \
480                 $(dep_dir)/$(*F).d -MT $(object_dir)/$(*F).o \
481                 $(CPPFLAGS) $(STRICT_CFLAGS) $(CFLAGS) $<
482 endef
483 CC_PREREQUISITES := %.c | $(object_dir) $(dep_dir) $(lsg_h) $(yy_h)
484 # These two have the same prerequisites and the same recipe. There should be a
485 # better way to write this.
486 $(object_dir)/%.o: $(CC_PREREQUISITES)
487         $(CC_CMD)
488 $(dep_dir)/%.d: $(CC_PREREQUISITES)
489         $(CC_CMD)
490
491 para_recv para_afh para_play para_server: LDFLAGS += $(id3tag_ldflags)
492 para_write para_play para_audiod \
493 : LDFLAGS += $(ao_ldflags) $(pthread_ldflags)
494 para_client para_audioc para_play : LDFLAGS += $(readline_ldflags)
495 para_server para_upgrade_db: LDFLAGS += $(osl_ldflags)
496 para_gui: LDFLAGS += $(curses_ldflags)
497 para_server \
498 para_client \
499 para_audiod \
500 :LDFLAGS += \
501         $(crypto_ldflags)
502
503 para_audiod \
504 para_filter \
505 para_play \
506 : LDFLAGS += \
507         $(mad_ldflags) \
508         $(faad_ldflags) \
509         $(samplerate_ldflags) \
510         -lm
511
512 para_mixer: LDFLAGS += -lm
513
514 para_write \
515 para_play \
516 para_audiod \
517 para_mixer \
518 : LDFLAGS += \
519         $(oss_ldflags) \
520         $(alsa_ldflags)
521
522 para_afh \
523 para_audioc \
524 para_audiod \
525 para_client \
526 para_mixer \
527 para_filter \
528 para_gui \
529 para_play \
530 para_recv \
531 para_server \
532 para_upgrade_db \
533 para_write \
534 : LDFLAGS += $(lopsub_ldflags)
535
536 para_server \
537 para_filter \
538 para_audiod \
539 para_play \
540 para_afh \
541 para_recv \
542 : LDFLAGS += \
543         $(ogg_ldflags) \
544         $(vorbis_ldflags) \
545         $(speex_ldflags) \
546         $(opus_ldflags) \
547         $(faad_ldflags) \
548         $(flac_ldflags)
549
550 para_afh para_recv para_server para_play: LDFLAGS += $(iconv_ldflags)
551
552 $(foreach exe,$(executables),$(eval para_$(exe): $$($(exe)_objs)))
553 $(prefixed_executables):
554         $(call SAY, LD $@)
555         $(CC) $^ -o $@ $(LDFLAGS)
556
557 mostlyclean:
558         $(call SAY, MOSTLYCLEAN)
559         rm -f para_*
560         rm -rf $(object_dir)
561 clean: mostlyclean
562         $(call SAY, CLEAN)
563         rm -rf $(build_dir)
564 distclean: clean
565         $(call SAY, DISTCLEAN)
566         rm -f Makefile autoscan.log config.status config.log
567         rm -f config.h configure config.h.in
568 maintainer-clean: distclean test-clean
569         $(call SAY, MAINTAINER-CLEAN)
570         rm -f *.tar.bz2 *.tar.xz
571         rm -f GPATH GRTAGS GSYMS GTAGS
572
573 INSTALL ?= install
574 INSTALL_PROGRAM ?= $(INSTALL)
575 INSTALL_DATA ?= $(INSTALL) -m 644
576 ifneq ($(findstring strip, $(MAKECMDGOALS)),)
577         strip_option := -s
578 endif
579
580 install install-strip: all man
581         $(MKDIR_P) $(DESTDIR)$(bindir) $(DESTDIR)$(mandir)
582         $(INSTALL) $(strip_option) $(prefixed_executables) $(DESTDIR)$(bindir)
583         $(INSTALL_DATA) $(man_pages) $(DESTDIR)$(mandir)
584         $(MKDIR_P) $(DESTDIR)$(vardir) >/dev/null 2>&1 || true # not fatal, so don't complain
585
586 $(tarball) dist tarball:
587         $(call SAY, DIST)
588         rm -rf $(tarball) $(tarball_pfx)
589         git archive --format=tar --prefix=$(tarball_pfx)/ HEAD \
590            | tar --delete $(tarball_delete) > $(tarball_pfx).tar
591         $(MKDIR_P) $(tarball_pfx)
592         ./GIT-VERSION-GEN > $(tarball_pfx)/VERSION
593         cp $(autocrap) $(tarball_pfx)
594         tar rf $(tarball_pfx).tar $(tarball_pfx)/*
595         xz -9 $(tarball_pfx).tar
596         ls -l $(tarball)
597         ln -sf $(tarball) paraslash-git.tar.xz
598         rm -rf $(tarball_pfx)