build: Move relevant parts to audiod section.
[paraslash.git] / Makefile.in
1 prefix := @prefix@
2 exec_prefix := @exec_prefix@
3
4 BINDIR := @bindir@
5 VARDIR := /var/paraslash
6 PKGDATADIR := @datarootdir@/@PACKAGE_NAME@
7 MANDIR := @datarootdir@/man/man1
8 PACKAGE_VERSION := @PACKAGE_VERSION@
9 PACKAGE_STRING := @PACKAGE_STRING@
10 INSTALL := @install@
11 STRIP := $(CROSS_COMPILE)strip
12 HOSTCC ?= cc
13 executables := $(addprefix para_, @executables@)
14 ggo_descriptions_declared := @ggo_descriptions_declared@
15 object_executable_matrix := @object_executable_matrix@
16
17
18 GENGETOPT := @gengetopt@
19 HELP2MAN := @help2man@
20 MKDIR_P := mkdir -p
21
22 speex_cppflags := @speex_cppflags@
23 opus_cppflags := @opus_cppflags@
24
25 id3tag_ldflags := @id3tag_ldflags@
26 ogg_ldflags := @ogg_ldflags@
27 vorbis_ldflags := @vorbis_ldflags@
28 speex_ldflags := @speex_ldflags@
29 opus_ldflags := @opus_ldflags@
30 faad_ldflags := @faad_ldflags@
31 mad_ldflags := @mad_ldflags@
32 flac_ldflags := @flac_ldflags@
33 oss_ldflags := @oss_ldflags@
34 alsa_ldflags := @alsa_ldflags@
35 ao_ldflags := @ao_ldflags@
36 readline_ldflags := @readline_ldflags@
37 samplerate_ldflags := @samplerate_ldflags@
38 osl_ldflags := @osl_ldflags@
39 openssl_ldflags := @openssl_ldflags@
40 gcrypt_ldflags := @gcrypt_ldflags@
41 socket_ldflags := @socket_ldflags@
42 nsl_ldflags := @nsl_ldflags@
43 curses_ldflags := @curses_ldflags@
44 core_audio_ldflags := @core_audio_ldflags@
45
46 build_date := $(shell date)
47 uname_s := $(shell uname -s 2>/dev/null || echo "UNKNOWN_OS")
48 uname_rs := $(shell uname -rs)
49 cc_version := $(shell $(CC) --version | head -n 1)
50
51 GIT_VERSION := $(shell ./GIT-VERSION-GEN git-version.h)
52
53 m4_ggo_dir := m4/gengetopt
54 test_dir := t
55 ifeq ("$(origin O)", "command line")
56 build_dir := $(O)
57 else
58 build_dir := build
59 endif
60 ggo_dir := $(build_dir)/ggo
61 object_dir := $(build_dir)/objects
62 dep_dir := $(build_dir)/deps
63 man_dir := $(build_dir)/man/man1
64 cmdline_dir := $(build_dir)/cmdline
65 m4depdir := $(build_dir)/m4deps
66 help2man_dir := $(build_dir)/help2man
67 hostbin_dir := $(build_dir)/host/bin
68
69 DEBUG_CPPFLAGS += -g -Wunused -Wundef -W
70 DEBUG_CPPFLAGS += -Wredundant-decls
71 DEBUG_CPPFLAGS += -Wall -Wno-sign-compare -Wno-unknown-pragmas
72 DEBUG_CPPFLAGS += -Wformat-security
73 DEBUG_CPPFLAGS += -Wmissing-format-attribute
74
75 ifeq ($(uname_s),Linux)
76 CPPFLAGS += -fdata-sections -ffunction-sections
77 LDFLAGS += -Wl,--gc-sections
78 CPPFLAGS += -Wstrict-prototypes
79 CPPFLAGS += -Wshadow
80 # causes warnings on *BSD for the feature test macros
81 CPPFLAGS += -Wunused-macros
82 endif
83 CPPFLAGS += -Os
84 CPPFLAGS += -Wuninitialized
85 CPPFLAGS += -Wchar-subscripts
86 CPPFLAGS += -DBINDIR='"$(BINDIR)"'
87 CPPFLAGS += -DBUILD_DATE='"$(build_date)"'
88 CPPFLAGS += -DUNAME_RS='"$(uname_rs)"'
89 CPPFLAGS += -DCC_VERSION='"$(cc_version)"'
90 CPPFLAGS += -Werror-implicit-function-declaration
91 CPPFLAGS += -Wmissing-noreturn
92 CPPFLAGS += -Wbad-function-cast
93 CPPFLAGS += -fno-strict-aliasing
94 CPPFLAGS += -DMAIN_INPUT_FILE_IS_$(*F)
95 CPPFLAGS += @arch_cppflags@
96 CPPFLAGS += -I/usr/local/include
97 CPPFLAGS += -I$(cmdline_dir)
98 CPPFLAGS += @osl_cppflags@
99
100 LDFLAGS += @clock_gettime_ldflags@
101
102 man_pages := $(patsubst %, $(man_dir)/%.1, $(executables))
103
104 autocrap := config.h.in configure
105 tarball_pfx := @PACKAGE_TARNAME@-$(PACKAGE_VERSION)
106 tarball_delete := $(addprefix $(tarball_pfx)/,\
107 web .changelog_before_cvs .changelog_cvs .gitignore)
108 tarball := @PACKAGE_TARNAME@-$(PACKAGE_VERSION).tar.bz2
109
110 # To put more focus on warnings, be less verbose as default
111 # Use 'make V=1' to see the full commands
112 ifeq ("$(origin V)", "command line")
113 Q :=
114 else
115 Q := @
116 endif
117
118 .PHONY: dep all clean distclean maintainer-clean install man tarball
119 all: dep $(executables) $(man_pages)
120 dep: $(deps)
121 man: $(man_pages)
122 tarball: $(tarball)
123
124 $(object_dir) $(man_dir) $(ggo_dir) $(cmdline_dir) $(dep_dir) $(m4depdir) \
125 $(help2man_dir) $(hostbin_dir):
126 $(Q) $(MKDIR_P) $@
127
128 -include $(m4_ggo_dir)/makefile
129
130 # When in doubt, use brute force (Ken Thompson)
131 TOUPPER = \
132 $(subst a,A,$(subst b,B,$(subst c,C,$(subst d,D,$(subst e,E,\
133 $(subst f,F,$(subst g,G,$(subst h,H,$(subst i,I,$(subst j,J,\
134 $(subst k,K,$(subst l,L,$(subst m,M,$(subst n,N,$(subst o,O,\
135 $(subst p,P,$(subst q,Q,$(subst r,R,$(subst s,S,$(subst t,T,\
136 $(subst u,U,$(subst v,V,$(subst w,W,$(subst x,X,$(subst y,Y,\
137 $(subst z,Z,$1))))))))))))))))))))))))))
138
139 %_command_list.h: %.cmd %.c
140 @[ -z "$(Q)" ] || echo 'GEN $@'
141 $(Q) ./command_util.sh h < $< >$@
142 %_command_list.man: %.cmd %.c
143 @[ -z "$(Q)" ] || echo 'GEN $@'
144 $(Q) ./command_util.sh man < $< > $@
145 %_completion.h: %.cmd %.c
146 @[ -z "$(Q)" ] || echo 'GEN $@'
147 $(Q) ./command_util.sh compl $(strip $(call TOUPPER,$(*F)))_COMPLETERS \
148 $(strip $(call TOUPPER,$(*F)))_COMMANDS < $< > $@
149
150 server_command_list.h server_command_list.man server_completion.h: command.c
151 afs_command_list.h afs_command_list.man afs_completion.h: afs.c aft.c attribute.c
152 audiod_command_list.h audiod_command_list.man audiod_completion.h: audiod_command.c
153
154 server_command_lists_man = server_command_list.man afs_command_list.man
155 $(man_dir)/para_server.1: $(help2man_dir)/para_server $(server_command_lists_man) | $(man_dir)
156 @[ -z "$(Q)" ] || echo 'MAN $<'
157 $(Q) opts="`for i in $(server_command_lists_man); do printf "%s\n" "-i $$i"; done`"; \
158 $(HELP2MAN) $$opts ./$< > $@
159
160 $(man_dir)/para_audiod.1: $(help2man_dir)/para_audiod audiod_command_list.man | $(man_dir)
161 @[ -z "$(Q)" ] || echo 'MAN $<'
162 $(Q) $(HELP2MAN) -N -i audiod_command_list.man ./$< > $@
163
164 $(man_dir)/para_play.1: $(help2man_dir)/para_play play_command_list.man | $(man_dir)
165 @[ -z "$(Q)" ] || echo 'MAN $<'
166 $(Q) $(HELP2MAN) -N -i play_command_list.man ./$< > $@
167
168 $(man_dir)/%.1: $(help2man_dir)/% | $(man_dir)
169 @[ -z "$(Q)" ] || echo 'MAN $<'
170 $(Q) $(HELP2MAN) -N ./$< > $@
171
172 $(hostbin_dir)/error2: error2.c | $(hostbin_dir)
173 @[ -z "$(Q)" ] || echo 'HCC $<'
174 $(Q) $(HOSTCC) -o $@ $<
175 error2.h: $(hostbin_dir)/error2
176 @[ -z "$(Q)" ] || echo 'ER2 $<'
177 @echo "$(object_executable_matrix)" | $< > $@
178 $(object_dir)/crypt.o: crypt.c | $(object_dir)
179 @[ -z "$(Q)" ] || echo 'CC $<'
180 $(Q) $(CC) -c -o $@ $(CPPFLAGS) $(DEBUG_CPPFLAGS) @openssl_cppflags@ $<
181 $(object_dir)/spx_common.o: spx_common.c | $(object_dir)
182 @[ -z "$(Q)" ] || echo 'CC $<'
183 $(Q) $(CC) -c -o $@ $(CPPFLAGS) $(DEBUG_CPPFLAGS) $(speex_cppflags) @ogg_cppflags@ $<
184
185 $(object_dir)/spxdec_filter.o: spxdec_filter.c | $(object_dir)
186 @[ -z "$(Q)" ] || echo 'CC $<'
187 $(Q) $(CC) -c -o $@ $(CPPFLAGS) $(DEBUG_CPPFLAGS) $(speex_cppflags) @ogg_cppflags@ $<
188
189 $(object_dir)/spx_afh.o: spx_afh.c | $(object_dir)
190 @[ -z "$(Q)" ] || echo 'CC $<'
191 $(Q) $(CC) -c -o $@ $(CPPFLAGS) $(DEBUG_CPPFLAGS) $(speex_cppflags) @ogg_cppflags@ $<
192
193 $(object_dir)/oggdec_filter.o: oggdec_filter.c | $(object_dir)
194 @[ -z "$(Q)" ] || echo 'CC $<'
195 $(Q) $(CC) -c -o $@ $(CPPFLAGS) $(DEBUG_CPPFLAGS) @ogg_cppflags@ $<
196
197 $(object_dir)/ogg_afh.o: ogg_afh.c | $(object_dir)
198 @[ -z "$(Q)" ] || echo 'CC $<'
199 $(Q) $(CC) -c -o $@ $(CPPFLAGS) $(DEBUG_CPPFLAGS) @ogg_cppflags@ $<
200
201 $(object_dir)/ogg_afh_common.o: ogg_afh_common.c | $(object_dir)
202 @[ -z "$(Q)" ] || echo 'CC $<'
203 $(Q) $(CC) -c -o $@ $(CPPFLAGS) $(DEBUG_CPPFLAGS) @ogg_cppflags@ $<
204
205 $(object_dir)/mp3dec_filter.o: mp3dec_filter.c | $(object_dir)
206 @[ -z "$(Q)" ] || echo 'CC $<'
207 $(Q) $(CC) -c -o $@ $(CPPFLAGS) $(DEBUG_CPPFLAGS) @mad_cppflags@ $<
208
209 $(object_dir)/compress_filter.o: compress_filter.c | $(object_dir)
210 @[ -z "$(Q)" ] || echo 'CC $<'
211 $(Q) $(CC) -c -o $@ $(CPPFLAGS) $(DEBUG_CPPFLAGS) -O3 $<
212
213 $(object_dir)/aacdec_filter.o: aacdec_filter.c | $(object_dir)
214 @[ -z "$(Q)" ] || echo 'CC $<'
215 $(Q) $(CC) -c -o $@ $(CPPFLAGS) $(DEBUG_CPPFLAGS) @faad_cppflags@ $<
216
217 $(object_dir)/aac_common.o: aac_common.c | $(object_dir)
218 @[ -z "$(Q)" ] || echo 'CC $<'
219 $(Q) $(CC) -c -o $@ $(CPPFLAGS) $(DEBUG_CPPFLAGS) @faad_cppflags@ $<
220
221 $(object_dir)/aac_afh.o: aac_afh.c | $(object_dir)
222 @[ -z "$(Q)" ] || echo 'CC $<'
223 $(Q) $(CC) -c -o $@ $(CPPFLAGS) $(DEBUG_CPPFLAGS) @faad_cppflags@ $<
224
225 $(object_dir)/opus%.o: CPPFLAGS += $(opus_cppflags)
226 $(object_dir)/mp3_afh.o: CPPFLAGS += @id3tag_cppflags@
227 $(object_dir)/mp3_afh.o: mp3_afh.c | $(object_dir)
228
229 $(object_dir)/gui%.o: gui%.c | $(object_dir)
230 @[ -z "$(Q)" ] || echo 'CC $<'
231 $(Q) $(CC) -c -o $@ $(CPPFLAGS) $(DEBUG_CPPFLAGS) @curses_cppflags@ $<
232 $(object_dir)/ao_write.o: ao_write.c | $(object_dir)
233 @[ -z "$(Q)" ] || echo 'CC $<'
234 $(Q) $(CC) -c -o $@ $(CPPFLAGS) $(DEBUG_CPPFLAGS) @ao_cppflags@ $<
235
236 $(object_dir)/%.cmdline.o: $(cmdline_dir)/%.cmdline.c $(cmdline_dir)/%.cmdline.h | $(object_dir)
237 @[ -z "$(Q)" ] || echo 'CC $<'
238 $(Q) $(CC) -c $(CPPFLAGS) -Wno-unused-function -o $@ $<
239
240 $(object_dir)/%.o: %.c | $(object_dir)
241 @[ -z "$(Q)" ] || echo 'CC $<'
242 $(Q) $(CC) -c -o $@ $(CPPFLAGS) $(DEBUG_CPPFLAGS) $<
243
244 $(dep_dir)/%.cmdline.d: $(cmdline_dir)/%.cmdline.c | $(dep_dir)
245 @[ -z "$(Q)" ] || echo 'DEP $<'
246 $(Q) ./depend.sh $(dep_dir) $(object_dir) $(cmdline_dir) \
247 $(CPPFLAGS) $< > $@
248
249 $(dep_dir)/%.d: %.c | $(dep_dir)
250 @[ -z "$(Q)" ] || echo 'DEP $<'
251 $(Q) ./depend.sh $(dep_dir) $(object_dir) $(cmdline_dir) \
252 $(CPPFLAGS) $< > $@
253
254 # sort removes duplicate words, which is all we need here
255 all_objs := $(sort @recv_objs@ @filter_objs@ @client_objs@ @gui_objs@ \
256 @audiod_objs@ @audioc_objs@ @fade_objs@ @server_objs@ \
257 @write_objs@ @afh_objs@ @play_objs@)
258 deps := $(addprefix $(dep_dir)/, $(all_objs:.o=.d))
259 m4_deps := $(addprefix $(m4depdir)/, $(addsuffix .m4d, @executables@))
260
261 recv_objs := $(addprefix $(object_dir)/, @recv_objs@)
262 filter_objs := $(addprefix $(object_dir)/, @filter_objs@)
263 client_objs := $(addprefix $(object_dir)/, @client_objs@)
264 gui_objs := $(addprefix $(object_dir)/, @gui_objs@)
265 audiod_objs := $(addprefix $(object_dir)/, @audiod_objs@)
266 audioc_objs := $(addprefix $(object_dir)/, @audioc_objs@)
267 fade_objs := $(addprefix $(object_dir)/, @fade_objs@)
268 server_objs := $(addprefix $(object_dir)/, @server_objs@)
269 write_objs := $(addprefix $(object_dir)/, @write_objs@)
270 afh_objs := $(addprefix $(object_dir)/, @afh_objs@)
271 play_objs := $(addprefix $(object_dir)/, @play_objs@)
272
273 ifeq ($(findstring clean, $(MAKECMDGOALS)),)
274 -include $(deps)
275 -include $(m4_deps)
276 endif
277
278 para_recv para_afh para_play para_server: LDFLAGS += $(id3tag_ldflags)
279 para_write para_play para_audiod: LDFLAGS += $(ao_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 $(openssl_ldflags) \
288 $(gcrypt_ldflags)
289
290 para_audiod \
291 para_filter \
292 para_play \
293 : LDFLAGS += \
294 $(mad_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_server \
307 para_filter \
308 para_audiod \
309 para_play \
310 para_afh \
311 para_recv \
312 : LDFLAGS += \
313 $(ogg_ldflags) \
314 $(vorbis_ldflags) \
315 $(speex_ldflags) \
316 $(opus_ldflags) \
317 $(faad_ldflags) \
318 $(flac_ldflags)
319
320 para_server \
321 para_client \
322 para_audioc \
323 para_audiod \
324 para_recv \
325 : LDFLAGS += \
326 $(socket_ldflags) $(nsl_ldflags)
327
328 para_recv: $(recv_objs)
329 @[ -z "$(Q)" ] || echo 'LD $@'
330 $(Q) $(CC) $(recv_objs) -o $@ $(LDFLAGS)
331
332 para_filter: $(filter_objs)
333 @[ -z "$(Q)" ] || echo 'LD $@'
334 $(Q) $(CC) $(filter_objs) -o $@ $(LDFLAGS)
335
336 para_client: $(client_objs)
337 @[ -z "$(Q)" ] || echo 'LD $@'
338 $(Q) $(CC) -o $@ $(client_objs) $(LDFLAGS)
339
340 para_gui: $(gui_objs)
341 @[ -z "$(Q)" ] || echo 'LD $@'
342 $(Q) $(CC) -o $@ $(gui_objs) $(LDFLAGS)
343
344 para_audiod: $(audiod_objs)
345 @[ -z "$(Q)" ] || echo 'LD $@'
346 $(Q) $(CC) -o $@ $(audiod_objs) $(LDFLAGS)
347
348 para_audioc: $(audioc_objs)
349 @[ -z "$(Q)" ] || echo 'LD $@'
350 $(Q) $(CC) -o $@ $(audioc_objs) $(LDFLAGS)
351
352 para_fade: $(fade_objs)
353 @[ -z "$(Q)" ] || echo 'LD $@'
354 $(Q) $(CC) -o $@ $(fade_objs) @fade_ldflags@ $(LDFLAGS)
355
356 para_server: $(server_objs)
357 @[ -z "$(Q)" ] || echo 'LD $@'
358 $(Q) $(CC) -o $@ $(server_objs) $(LDFLAGS)
359
360 para_write: $(write_objs)
361 @[ -z "$(Q)" ] || echo 'LD $@'
362 $(Q) $(CC) -o $@ $(write_objs) $(LDFLAGS)
363
364 para_afh: $(afh_objs)
365 @[ -z "$(Q)" ] || echo 'LD $@'
366 $(Q) $(CC) -o $@ $(afh_objs) $(LDFLAGS)
367
368 para_play: $(play_objs)
369 @[ -z "$(Q)" ] || echo 'LD $@'
370 $(Q) $(CC) -o $@ $(play_objs) $(LDFLAGS)
371
372 clean:
373 @[ -z "$(Q)" ] || echo 'CLEAN'
374 $(Q) rm -f $(executables)
375 $(Q) rm -rf $(object_dir)
376
377 clean2: clean
378 @[ -z "$(Q)" ] || echo 'CLEAN2'
379 $(Q) rm -f *_command_list.* *_completion.h
380 $(Q) rm -rf $(build_dir)
381 distclean: clean2 test-clean
382 @[ -z "$(Q)" ] || echo 'DISTCLEAN'
383 $(Q) rm -f Makefile autoscan.log config.status config.log
384 $(Q) rm -rf autom4te.cache
385 $(Q) rm -f GPATH GRTAGS GSYMS GTAGS
386
387 maintainer-clean: distclean
388 rm -f *.tar.bz2 config.h configure config.h.in
389 rm -rf web_sync
390
391 install: all man
392 $(MKDIR_P) $(BINDIR) $(MANDIR)
393 $(INSTALL) -s --strip-program $(STRIP) -m 755 $(executables) $(BINDIR)
394 $(INSTALL) -m 644 $(man_pages) $(MANDIR)
395 $(MKDIR_P) $(VARDIR) >/dev/null 2>&1 || true # not fatal, so don't complain
396
397 $(tarball):
398 rm -rf $(tarball_pfx).tar.bz2 $(tarball_pfx)
399 git archive --format=tar --prefix=$(tarball_pfx)/ HEAD \
400 | tar --delete $(tarball_delete) > $(tarball_pfx).tar
401 $(MKDIR_P) $(tarball_pfx)
402 ./GIT-VERSION-GEN > $(tarball_pfx)/VERSION
403 cp -r $(autocrap) $(tarball_pfx)
404 tar rf $(tarball_pfx).tar $(tarball_pfx)/*
405 bzip2 -9 $(tarball_pfx).tar
406 ls -l $(tarball_pfx).tar.bz2
407 rm -rf $(tarball_pfx)
408 include $(test_dir)/makefile.test