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