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