2 exec_prefix := @exec_prefix@
5 VARDIR := /var/paraslash
6 PKGDATADIR := @datarootdir@/@PACKAGE_NAME@
7 MANDIR := @datarootdir@/man/man1
8 PACKAGE_VERSION := @PACKAGE_VERSION@
9 PACKAGE_STRING := @PACKAGE_STRING@
11 STRIP := $(CROSS_COMPILE)strip
13 executables := $(addprefix para_, @executables@)
14 ggo_descriptions_declared := @ggo_descriptions_declared@
15 object_executable_matrix := @object_executable_matrix@
18 GENGETOPT := @gengetopt@
19 HELP2MAN := @help2man@
22 speex_cppflags := @speex_cppflags@
23 opus_cppflags := @opus_cppflags@
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@
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)
50 GIT_VERSION := $(shell ./GIT-VERSION-GEN git-version.h)
52 m4_ggo_dir := m4/gengetopt
54 ifeq ("$(origin O)", "command line")
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
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
74 ifeq ($(uname_s),Linux)
75 CPPFLAGS += -fdata-sections -ffunction-sections
76 LDFLAGS += -Wl,--gc-sections
77 CPPFLAGS += -Wstrict-prototypes
79 # causes warnings on *BSD for the feature test macros
80 CPPFLAGS += -Wunused-macros
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@
99 LDFLAGS += @clock_gettime_ldflags@
101 man_pages := $(patsubst %, $(man_dir)/%.1, $(executables))
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
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")
117 .PHONY: dep all clean distclean maintainer-clean install man tarball
118 all: dep $(executables) $(man_pages)
123 $(object_dir) $(man_dir) $(ggo_dir) $(cmdline_dir) $(dep_dir) $(m4depdir) \
124 $(help2man_dir) $(hostbin_dir):
127 -include $(m4_ggo_dir)/makefile
129 # When in doubt, use brute force (Ken Thompson)
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))))))))))))))))))))))))))
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 < $< > $@
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
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 ./$< > $@
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 ./$< > $@
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 ./$< > $@
167 $(man_dir)/%.1: $(help2man_dir)/% | $(man_dir)
168 @[ -z "$(Q)" ] || echo 'MAN $<'
169 $(Q) $(HELP2MAN) -N ./$< > $@
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@ $<
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@ $<
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@ $<
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@ $<
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@ $<
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@ $<
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@ $<
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 $<
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@ $<
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@ $<
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@ $<
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)
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@ $<
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 $@ $<
239 $(object_dir)/%.o: %.c | $(object_dir)
240 @[ -z "$(Q)" ] || echo 'CC $<'
241 $(Q) $(CC) -c -o $@ $(CPPFLAGS) $(DEBUG_CPPFLAGS) $<
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) \
248 $(dep_dir)/%.d: %.c | $(dep_dir)
249 @[ -z "$(Q)" ] || echo 'DEP $<'
250 $(Q) ./depend.sh $(dep_dir) $(object_dir) $(cmdline_dir) \
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@))
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@)
272 ifeq ($(findstring clean, $(MAKECMDGOALS)),)
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)
294 $(samplerate_ldflags)
324 $(socket_ldflags) $(nsl_ldflags)
326 para_recv: $(recv_objs)
327 @[ -z "$(Q)" ] || echo 'LD $@'
328 $(Q) $(CC) $(recv_objs) -o $@ @recv_ldflags@ $(LDFLAGS)
330 para_filter: $(filter_objs)
331 @[ -z "$(Q)" ] || echo 'LD $@'
332 $(Q) $(CC) $(filter_objs) -o $@ @filter_ldflags@ $(LDFLAGS)
334 para_client: $(client_objs)
335 @[ -z "$(Q)" ] || echo 'LD $@'
336 $(Q) $(CC) -o $@ $(client_objs) @client_ldflags@ $(LDFLAGS)
338 para_gui: $(gui_objs)
339 @[ -z "$(Q)" ] || echo 'LD $@'
340 $(Q) $(CC) -o $@ $(gui_objs) $(LDFLAGS)
342 para_audiod: $(audiod_objs)
343 @[ -z "$(Q)" ] || echo 'LD $@'
344 $(Q) $(CC) -o $@ $(audiod_objs) @audiod_ldflags@ $(LDFLAGS)
346 para_audioc: $(audioc_objs)
347 @[ -z "$(Q)" ] || echo 'LD $@'
348 $(Q) $(CC) -o $@ $(audioc_objs) @audioc_ldflags@ $(LDFLAGS)
350 para_fade: $(fade_objs)
351 @[ -z "$(Q)" ] || echo 'LD $@'
352 $(Q) $(CC) -o $@ $(fade_objs) @fade_ldflags@ $(LDFLAGS)
354 para_server: $(server_objs)
355 @[ -z "$(Q)" ] || echo 'LD $@'
356 $(Q) $(CC) -o $@ $(server_objs) @server_ldflags@ $(LDFLAGS)
358 para_write: $(write_objs)
359 @[ -z "$(Q)" ] || echo 'LD $@'
360 $(Q) $(CC) -o $@ $(write_objs) @write_ldflags@ $(LDFLAGS)
362 para_afh: $(afh_objs)
363 @[ -z "$(Q)" ] || echo 'LD $@'
364 $(Q) $(CC) -o $@ $(afh_objs) @afh_ldflags@ $(LDFLAGS)
366 para_play: $(play_objs)
367 @[ -z "$(Q)" ] || echo 'LD $@'
368 $(Q) $(CC) -o $@ $(play_objs) @play_ldflags@ $(LDFLAGS)
371 @[ -z "$(Q)" ] || echo 'CLEAN'
372 $(Q) rm -f $(executables)
373 $(Q) rm -rf $(object_dir)
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
385 maintainer-clean: distclean
386 rm -f *.tar.bz2 config.h configure config.h.in
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
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