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