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