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