2 exec_prefix := @exec_prefix@
5 VARDIR := /var/paraslash
6 MANDIR := @datarootdir@/man/man1
7 PACKAGE_VERSION := @PACKAGE_VERSION@
9 STRIP := $(CROSS_COMPILE)strip
11 executables := $(addprefix para_, @executables@)
12 ggo_descriptions_declared := @ggo_descriptions_declared@
13 object_executable_matrix := @object_executable_matrix@
16 GENGETOPT := @gengetopt@
17 HELP2MAN := @help2man@
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@
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@
53 build_date := $(shell date)
54 uname_s := $(shell uname -s 2>/dev/null || echo "UNKNOWN_OS")
55 uname_rs := $(shell uname -rs)
56 cc_version := $(shell $(CC) --version | head -n 1)
58 GIT_VERSION := $(shell ./GIT-VERSION-GEN git-version.h)
60 m4_ggo_dir := m4/gengetopt
62 ifeq ("$(origin O)", "command line")
67 ggo_dir := $(build_dir)/ggo
68 object_dir := $(build_dir)/objects
69 dep_dir := $(build_dir)/deps
70 man_dir := $(build_dir)/man/man1
71 cmdline_dir := $(build_dir)/cmdline
72 m4depdir := $(build_dir)/m4deps
73 help2man_dir := $(build_dir)/help2man
74 hostbin_dir := $(build_dir)/host/bin
76 DEBUG_CPPFLAGS += -g -Wunused -Wundef -W
77 DEBUG_CPPFLAGS += -Wredundant-decls
78 DEBUG_CPPFLAGS += -Wall -Wno-sign-compare -Wno-unknown-pragmas
79 DEBUG_CPPFLAGS += -Wformat-security
80 DEBUG_CPPFLAGS += -Wmissing-format-attribute
82 ifeq ($(uname_s),Linux)
83 CPPFLAGS += -fdata-sections -ffunction-sections
84 LDFLAGS += -Wl,--gc-sections
85 CPPFLAGS += -Wstrict-prototypes
87 # causes warnings on *BSD for the feature test macros
88 CPPFLAGS += -Wunused-macros
91 CPPFLAGS += -Wuninitialized
92 CPPFLAGS += -Wchar-subscripts
93 CPPFLAGS += -DBINDIR='"$(BINDIR)"'
94 CPPFLAGS += -DBUILD_DATE='"$(build_date)"'
95 CPPFLAGS += -DUNAME_RS='"$(uname_rs)"'
96 CPPFLAGS += -DCC_VERSION='"$(cc_version)"'
97 CPPFLAGS += -Werror-implicit-function-declaration
98 CPPFLAGS += -Wmissing-noreturn
99 CPPFLAGS += -Wbad-function-cast
100 CPPFLAGS += -fno-strict-aliasing
101 CPPFLAGS += -DMAIN_INPUT_FILE_IS_$(*F)
102 CPPFLAGS += $(arch_cppflags)
103 CPPFLAGS += -I/usr/local/include
104 CPPFLAGS += -I$(cmdline_dir)
105 CPPFLAGS += $(osl_cppflags)
107 LDFLAGS += @clock_gettime_ldflags@
109 man_pages := $(patsubst %, $(man_dir)/%.1, $(executables))
111 autocrap := config.h.in configure
112 tarball_pfx := @PACKAGE_TARNAME@-$(PACKAGE_VERSION)
113 tarball_delete := $(addprefix $(tarball_pfx)/,\
114 web .changelog_before_cvs .changelog_cvs .gitignore)
115 tarball := @PACKAGE_TARNAME@-$(PACKAGE_VERSION).tar.bz2
117 # To put more focus on warnings, be less verbose as default
118 # Use 'make V=1' to see the full commands
119 ifeq ("$(origin V)", "command line")
125 .PHONY: dep all clean distclean maintainer-clean install man tarball
126 all: dep $(executables) $(man_pages)
131 $(object_dir) $(man_dir) $(ggo_dir) $(cmdline_dir) $(dep_dir) $(m4depdir) \
132 $(help2man_dir) $(hostbin_dir):
135 -include $(m4_ggo_dir)/makefile
137 # When in doubt, use brute force (Ken Thompson)
139 $(subst a,A,$(subst b,B,$(subst c,C,$(subst d,D,$(subst e,E,\
140 $(subst f,F,$(subst g,G,$(subst h,H,$(subst i,I,$(subst j,J,\
141 $(subst k,K,$(subst l,L,$(subst m,M,$(subst n,N,$(subst o,O,\
142 $(subst p,P,$(subst q,Q,$(subst r,R,$(subst s,S,$(subst t,T,\
143 $(subst u,U,$(subst v,V,$(subst w,W,$(subst x,X,$(subst y,Y,\
144 $(subst z,Z,$1))))))))))))))))))))))))))
146 %_command_list.h: %.cmd %.c
147 @[ -z "$(Q)" ] || echo 'GEN $@'
148 $(Q) ./command_util.sh h < $< >$@
149 %_command_list.man: %.cmd %.c
150 @[ -z "$(Q)" ] || echo 'GEN $@'
151 $(Q) ./command_util.sh man < $< > $@
152 %_completion.h: %.cmd %.c
153 @[ -z "$(Q)" ] || echo 'GEN $@'
154 $(Q) ./command_util.sh compl $(strip $(call TOUPPER,$(*F)))_COMPLETERS \
155 $(strip $(call TOUPPER,$(*F)))_COMMANDS < $< > $@
157 server_command_list.h server_command_list.man server_completion.h: command.c
158 afs_command_list.h afs_command_list.man afs_completion.h: afs.c aft.c attribute.c
159 audiod_command_list.h audiod_command_list.man audiod_completion.h: audiod_command.c
161 server_command_lists_man = server_command_list.man afs_command_list.man
162 $(man_dir)/para_server.1: $(help2man_dir)/para_server $(server_command_lists_man) | $(man_dir)
163 @[ -z "$(Q)" ] || echo 'MAN $<'
164 $(Q) opts="`for i in $(server_command_lists_man); do printf "%s\n" "-i $$i"; done`"; \
165 $(HELP2MAN) $$opts ./$< > $@
167 $(man_dir)/para_audiod.1: $(help2man_dir)/para_audiod audiod_command_list.man | $(man_dir)
168 @[ -z "$(Q)" ] || echo 'MAN $<'
169 $(Q) $(HELP2MAN) -N -i audiod_command_list.man ./$< > $@
171 $(man_dir)/para_play.1: $(help2man_dir)/para_play play_command_list.man | $(man_dir)
172 @[ -z "$(Q)" ] || echo 'MAN $<'
173 $(Q) $(HELP2MAN) -N -i play_command_list.man ./$< > $@
175 $(man_dir)/%.1: $(help2man_dir)/% | $(man_dir)
176 @[ -z "$(Q)" ] || echo 'MAN $<'
177 $(Q) $(HELP2MAN) -N ./$< > $@
179 $(hostbin_dir)/error2: error2.c | $(hostbin_dir)
180 @[ -z "$(Q)" ] || echo 'HCC $<'
181 $(Q) $(HOSTCC) -o $@ $<
182 error2.h: $(hostbin_dir)/error2
183 @[ -z "$(Q)" ] || echo 'ER2 $<'
184 @echo "$(object_executable_matrix)" | $< > $@
185 $(object_dir)/crypt.o: crypt.c | $(object_dir)
186 @[ -z "$(Q)" ] || echo 'CC $<'
187 $(Q) $(CC) -c -o $@ $(CPPFLAGS) $(DEBUG_CPPFLAGS) $(openssl_cppflags) $<
188 $(object_dir)/spx_common.o: spx_common.c | $(object_dir)
189 @[ -z "$(Q)" ] || echo 'CC $<'
190 $(Q) $(CC) -c -o $@ $(CPPFLAGS) $(DEBUG_CPPFLAGS) $(speex_cppflags) $(ogg_cppflags) $<
192 $(object_dir)/spxdec_filter.o: spxdec_filter.c | $(object_dir)
193 @[ -z "$(Q)" ] || echo 'CC $<'
194 $(Q) $(CC) -c -o $@ $(CPPFLAGS) $(DEBUG_CPPFLAGS) $(speex_cppflags) $(ogg_cppflags) $<
196 $(object_dir)/spx_afh.o: spx_afh.c | $(object_dir)
197 @[ -z "$(Q)" ] || echo 'CC $<'
198 $(Q) $(CC) -c -o $@ $(CPPFLAGS) $(DEBUG_CPPFLAGS) $(speex_cppflags) $(ogg_cppflags) $<
200 $(object_dir)/oggdec_filter.o: oggdec_filter.c | $(object_dir)
201 @[ -z "$(Q)" ] || echo 'CC $<'
202 $(Q) $(CC) -c -o $@ $(CPPFLAGS) $(DEBUG_CPPFLAGS) $(ogg_cppflags) $<
204 $(object_dir)/ogg_afh.o: ogg_afh.c | $(object_dir)
205 @[ -z "$(Q)" ] || echo 'CC $<'
206 $(Q) $(CC) -c -o $@ $(CPPFLAGS) $(DEBUG_CPPFLAGS) $(ogg_cppflags) $<
208 $(object_dir)/ogg_afh_common.o: ogg_afh_common.c | $(object_dir)
209 @[ -z "$(Q)" ] || echo 'CC $<'
210 $(Q) $(CC) -c -o $@ $(CPPFLAGS) $(DEBUG_CPPFLAGS) $(ogg_cppflags) $<
212 $(object_dir)/mp3dec_filter.o: mp3dec_filter.c | $(object_dir)
213 @[ -z "$(Q)" ] || echo 'CC $<'
214 $(Q) $(CC) -c -o $@ $(CPPFLAGS) $(DEBUG_CPPFLAGS) $(mad_cppflags) $<
216 $(object_dir)/compress_filter.o: compress_filter.c | $(object_dir)
217 @[ -z "$(Q)" ] || echo 'CC $<'
218 $(Q) $(CC) -c -o $@ $(CPPFLAGS) $(DEBUG_CPPFLAGS) -O3 $<
220 $(object_dir)/aacdec_filter.o: aacdec_filter.c | $(object_dir)
221 @[ -z "$(Q)" ] || echo 'CC $<'
222 $(Q) $(CC) -c -o $@ $(CPPFLAGS) $(DEBUG_CPPFLAGS) $(faad_cppflags) $<
224 $(object_dir)/aac_common.o: aac_common.c | $(object_dir)
225 @[ -z "$(Q)" ] || echo 'CC $<'
226 $(Q) $(CC) -c -o $@ $(CPPFLAGS) $(DEBUG_CPPFLAGS) $(faad_cppflags) $<
228 $(object_dir)/aac_afh.o: aac_afh.c | $(object_dir)
229 @[ -z "$(Q)" ] || echo 'CC $<'
230 $(Q) $(CC) -c -o $@ $(CPPFLAGS) $(DEBUG_CPPFLAGS) $(faad_cppflags) $<
232 $(object_dir)/opus%.o: CPPFLAGS += $(opus_cppflags)
233 $(object_dir)/mp3_afh.o: CPPFLAGS += $(id3tag_cppflags)
235 $(object_dir)/mp3_afh.o: mp3_afh.c | $(object_dir)
237 $(object_dir)/gui%.o: gui%.c | $(object_dir)
238 @[ -z "$(Q)" ] || echo 'CC $<'
239 $(Q) $(CC) -c -o $@ $(CPPFLAGS) $(DEBUG_CPPFLAGS) $(curses_cppflags) $<
240 $(object_dir)/ao_write.o: ao_write.c | $(object_dir)
241 @[ -z "$(Q)" ] || echo 'CC $<'
242 $(Q) $(CC) -c -o $@ $(CPPFLAGS) $(DEBUG_CPPFLAGS) $(ao_cppflags) $<
244 $(object_dir)/%.cmdline.o: $(cmdline_dir)/%.cmdline.c $(cmdline_dir)/%.cmdline.h | $(object_dir)
245 @[ -z "$(Q)" ] || echo 'CC $<'
246 $(Q) $(CC) -c $(CPPFLAGS) -Wno-unused-function -o $@ $<
248 $(object_dir)/%.o: %.c | $(object_dir)
249 @[ -z "$(Q)" ] || echo 'CC $<'
250 $(Q) $(CC) -c -o $@ $(CPPFLAGS) $(DEBUG_CPPFLAGS) $<
252 $(dep_dir)/%.cmdline.d: $(cmdline_dir)/%.cmdline.c | $(dep_dir)
253 @[ -z "$(Q)" ] || echo 'DEP $<'
254 $(Q) ./depend.sh $(dep_dir) $(object_dir) $(cmdline_dir) \
257 $(dep_dir)/%.d: %.c | $(dep_dir)
258 @[ -z "$(Q)" ] || echo 'DEP $<'
259 $(Q) ./depend.sh $(dep_dir) $(object_dir) $(cmdline_dir) \
262 # sort removes duplicate words, which is all we need here
263 all_objs := $(sort @recv_objs@ @filter_objs@ @client_objs@ @gui_objs@ \
264 @audiod_objs@ @audioc_objs@ @fade_objs@ @server_objs@ \
265 @write_objs@ @afh_objs@ @play_objs@)
266 deps := $(addprefix $(dep_dir)/, $(all_objs:.o=.d))
267 m4_deps := $(addprefix $(m4depdir)/, $(addsuffix .m4d, @executables@))
269 recv_objs := $(addprefix $(object_dir)/, @recv_objs@)
270 filter_objs := $(addprefix $(object_dir)/, @filter_objs@)
271 client_objs := $(addprefix $(object_dir)/, @client_objs@)
272 gui_objs := $(addprefix $(object_dir)/, @gui_objs@)
273 audiod_objs := $(addprefix $(object_dir)/, @audiod_objs@)
274 audioc_objs := $(addprefix $(object_dir)/, @audioc_objs@)
275 fade_objs := $(addprefix $(object_dir)/, @fade_objs@)
276 server_objs := $(addprefix $(object_dir)/, @server_objs@)
277 write_objs := $(addprefix $(object_dir)/, @write_objs@)
278 afh_objs := $(addprefix $(object_dir)/, @afh_objs@)
279 play_objs := $(addprefix $(object_dir)/, @play_objs@)
281 ifeq ($(findstring clean, $(MAKECMDGOALS)),)
286 para_recv para_afh para_play para_server: LDFLAGS += $(id3tag_ldflags)
287 para_write para_play para_audiod: LDFLAGS += $(ao_ldflags) $(core_audio_ldflags)
288 para_client para_audioc para_play : LDFLAGS += $(readline_ldflags)
289 para_server: LDFLAGS += $(osl_ldflags)
290 para_gui: LDFLAGS += $(curses_ldflags)
303 $(samplerate_ldflags) \
334 $(socket_ldflags) $(nsl_ldflags)
336 para_recv: $(recv_objs)
337 @[ -z "$(Q)" ] || echo 'LD $@'
338 $(Q) $(CC) $(recv_objs) -o $@ $(LDFLAGS)
340 para_filter: $(filter_objs)
341 @[ -z "$(Q)" ] || echo 'LD $@'
342 $(Q) $(CC) $(filter_objs) -o $@ $(LDFLAGS)
344 para_client: $(client_objs)
345 @[ -z "$(Q)" ] || echo 'LD $@'
346 $(Q) $(CC) -o $@ $(client_objs) $(LDFLAGS)
348 para_gui: $(gui_objs)
349 @[ -z "$(Q)" ] || echo 'LD $@'
350 $(Q) $(CC) -o $@ $(gui_objs) $(LDFLAGS)
352 para_audiod: $(audiod_objs)
353 @[ -z "$(Q)" ] || echo 'LD $@'
354 $(Q) $(CC) -o $@ $(audiod_objs) $(LDFLAGS)
356 para_audioc: $(audioc_objs)
357 @[ -z "$(Q)" ] || echo 'LD $@'
358 $(Q) $(CC) -o $@ $(audioc_objs) $(LDFLAGS)
360 para_fade: $(fade_objs)
361 @[ -z "$(Q)" ] || echo 'LD $@'
362 $(Q) $(CC) -o $@ $(fade_objs) $(LDFLAGS)
364 para_server: $(server_objs)
365 @[ -z "$(Q)" ] || echo 'LD $@'
366 $(Q) $(CC) -o $@ $(server_objs) $(LDFLAGS)
368 para_write: $(write_objs)
369 @[ -z "$(Q)" ] || echo 'LD $@'
370 $(Q) $(CC) -o $@ $(write_objs) $(LDFLAGS)
372 para_afh: $(afh_objs)
373 @[ -z "$(Q)" ] || echo 'LD $@'
374 $(Q) $(CC) -o $@ $(afh_objs) $(LDFLAGS)
376 para_play: $(play_objs)
377 @[ -z "$(Q)" ] || echo 'LD $@'
378 $(Q) $(CC) -o $@ $(play_objs) $(LDFLAGS)
381 @[ -z "$(Q)" ] || echo 'CLEAN'
382 $(Q) rm -f $(executables)
383 $(Q) rm -rf $(object_dir)
386 @[ -z "$(Q)" ] || echo 'CLEAN2'
387 $(Q) rm -f *_command_list.* *_completion.h
388 $(Q) rm -rf $(build_dir)
389 distclean: clean2 test-clean
390 @[ -z "$(Q)" ] || echo 'DISTCLEAN'
391 $(Q) rm -f Makefile autoscan.log config.status config.log
392 $(Q) rm -rf autom4te.cache
393 $(Q) rm -f GPATH GRTAGS GSYMS GTAGS
395 maintainer-clean: distclean
396 rm -f *.tar.bz2 config.h configure config.h.in
400 $(MKDIR_P) $(BINDIR) $(MANDIR)
401 $(INSTALL) -s --strip-program $(STRIP) -m 755 $(executables) $(BINDIR)
402 $(INSTALL) -m 644 $(man_pages) $(MANDIR)
403 $(MKDIR_P) $(VARDIR) >/dev/null 2>&1 || true # not fatal, so don't complain
406 rm -rf $(tarball_pfx).tar.bz2 $(tarball_pfx)
407 git archive --format=tar --prefix=$(tarball_pfx)/ HEAD \
408 | tar --delete $(tarball_delete) > $(tarball_pfx).tar
409 $(MKDIR_P) $(tarball_pfx)
410 ./GIT-VERSION-GEN > $(tarball_pfx)/VERSION
411 cp -r $(autocrap) $(tarball_pfx)
412 tar rf $(tarball_pfx).tar $(tarball_pfx)/*
413 bzip2 -9 $(tarball_pfx).tar
414 ls -l $(tarball_pfx).tar.bz2
415 rm -rf $(tarball_pfx)
416 include $(test_dir)/makefile.test