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