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