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