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