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