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