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