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