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@
41 build_date := $(shell date)
42 uname_s := $(shell uname -s 2>/dev/null || echo "UNKNOWN_OS")
43 uname_rs := $(shell uname -rs)
44 cc_version := $(shell $(CC) --version | head -n 1)
46 GIT_VERSION := $(shell ./GIT-VERSION-GEN git-version.h)
48 m4_ggo_dir := m4/gengetopt
50 ifeq ("$(origin O)", "command line")
55 ggo_dir := $(build_dir)/ggo
56 object_dir := $(build_dir)/objects
57 dep_dir := $(build_dir)/deps
58 man_dir := $(build_dir)/man/man1
59 cmdline_dir := $(build_dir)/cmdline
60 m4depdir := $(build_dir)/m4deps
61 help2man_dir := $(build_dir)/help2man
62 hostbin_dir := $(build_dir)/host/bin
64 DEBUG_CPPFLAGS += -g -Wunused -Wundef -W
65 DEBUG_CPPFLAGS += -Wredundant-decls
66 DEBUG_CPPFLAGS += -Wall -Wno-sign-compare -Wno-unknown-pragmas
67 DEBUG_CPPFLAGS += -Wformat-security
68 DEBUG_CPPFLAGS += -Wmissing-format-attribute
70 ifeq ($(uname_s),Linux)
71 CPPFLAGS += -fdata-sections -ffunction-sections
72 LDFLAGS += -Wl,--gc-sections
73 CPPFLAGS += -Wstrict-prototypes
75 # causes warnings on *BSD for the feature test macros
76 CPPFLAGS += -Wunused-macros
79 CPPFLAGS += -Wuninitialized
80 CPPFLAGS += -Wchar-subscripts
81 CPPFLAGS += -DBINDIR='"$(BINDIR)"'
82 CPPFLAGS += -DBUILD_DATE='"$(build_date)"'
83 CPPFLAGS += -DUNAME_RS='"$(uname_rs)"'
84 CPPFLAGS += -DCC_VERSION='"$(cc_version)"'
85 CPPFLAGS += -Werror-implicit-function-declaration
86 CPPFLAGS += -Wmissing-noreturn
87 CPPFLAGS += -Wbad-function-cast
88 CPPFLAGS += -fno-strict-aliasing
89 CPPFLAGS += -DMAIN_INPUT_FILE_IS_$(*F)
90 CPPFLAGS += @arch_cppflags@
91 CPPFLAGS += -I/usr/local/include
92 CPPFLAGS += -I$(cmdline_dir)
93 CPPFLAGS += @osl_cppflags@
95 LDFLAGS += @clock_gettime_ldflags@
97 man_pages := $(patsubst %, $(man_dir)/%.1, $(executables))
99 autocrap := config.h.in configure
100 tarball_pfx := @PACKAGE_TARNAME@-$(PACKAGE_VERSION)
101 tarball_delete := $(addprefix $(tarball_pfx)/,\
102 web .changelog_before_cvs .changelog_cvs .gitignore)
103 tarball := @PACKAGE_TARNAME@-$(PACKAGE_VERSION).tar.bz2
105 # To put more focus on warnings, be less verbose as default
106 # Use 'make V=1' to see the full commands
107 ifeq ("$(origin V)", "command line")
113 .PHONY: dep all clean distclean maintainer-clean install man tarball
114 all: dep $(executables) $(man_pages)
119 $(object_dir) $(man_dir) $(ggo_dir) $(cmdline_dir) $(dep_dir) $(m4depdir) \
120 $(help2man_dir) $(hostbin_dir):
123 -include $(m4_ggo_dir)/makefile
125 # When in doubt, use brute force (Ken Thompson)
127 $(subst a,A,$(subst b,B,$(subst c,C,$(subst d,D,$(subst e,E,\
128 $(subst f,F,$(subst g,G,$(subst h,H,$(subst i,I,$(subst j,J,\
129 $(subst k,K,$(subst l,L,$(subst m,M,$(subst n,N,$(subst o,O,\
130 $(subst p,P,$(subst q,Q,$(subst r,R,$(subst s,S,$(subst t,T,\
131 $(subst u,U,$(subst v,V,$(subst w,W,$(subst x,X,$(subst y,Y,\
132 $(subst z,Z,$1))))))))))))))))))))))))))
134 %_command_list.h: %.cmd %.c
135 @[ -z "$(Q)" ] || echo 'GEN $@'
136 $(Q) ./command_util.sh h < $< >$@
137 %_command_list.man: %.cmd %.c
138 @[ -z "$(Q)" ] || echo 'GEN $@'
139 $(Q) ./command_util.sh man < $< > $@
140 %_completion.h: %.cmd %.c
141 @[ -z "$(Q)" ] || echo 'GEN $@'
142 $(Q) ./command_util.sh compl $(strip $(call TOUPPER,$(*F)))_COMPLETERS \
143 $(strip $(call TOUPPER,$(*F)))_COMMANDS < $< > $@
145 server_command_list.h server_command_list.man server_completion.h: command.c
146 afs_command_list.h afs_command_list.man afs_completion.h: afs.c aft.c attribute.c
147 audiod_command_list.h audiod_command_list.man audiod_completion.h: audiod_command.c
149 server_command_lists_man = server_command_list.man afs_command_list.man
150 $(man_dir)/para_server.1: $(help2man_dir)/para_server $(server_command_lists_man) | $(man_dir)
151 @[ -z "$(Q)" ] || echo 'MAN $<'
152 $(Q) opts="`for i in $(server_command_lists_man); do printf "%s\n" "-i $$i"; done`"; \
153 $(HELP2MAN) $$opts ./$< > $@
155 $(man_dir)/para_audiod.1: $(help2man_dir)/para_audiod audiod_command_list.man | $(man_dir)
156 @[ -z "$(Q)" ] || echo 'MAN $<'
157 $(Q) $(HELP2MAN) -N -i audiod_command_list.man ./$< > $@
159 $(man_dir)/para_play.1: $(help2man_dir)/para_play play_command_list.man | $(man_dir)
160 @[ -z "$(Q)" ] || echo 'MAN $<'
161 $(Q) $(HELP2MAN) -N -i play_command_list.man ./$< > $@
163 $(man_dir)/%.1: $(help2man_dir)/% | $(man_dir)
164 @[ -z "$(Q)" ] || echo 'MAN $<'
165 $(Q) $(HELP2MAN) -N ./$< > $@
167 $(hostbin_dir)/error2: error2.c | $(hostbin_dir)
168 @[ -z "$(Q)" ] || echo 'HCC $<'
169 $(Q) $(HOSTCC) -o $@ $<
170 error2.h: $(hostbin_dir)/error2
171 @[ -z "$(Q)" ] || echo 'ER2 $<'
172 @echo "$(object_executable_matrix)" | $< > $@
173 $(object_dir)/crypt.o: crypt.c | $(object_dir)
174 @[ -z "$(Q)" ] || echo 'CC $<'
175 $(Q) $(CC) -c -o $@ $(CPPFLAGS) $(DEBUG_CPPFLAGS) @openssl_cppflags@ $<
176 $(object_dir)/spx_common.o: spx_common.c | $(object_dir)
177 @[ -z "$(Q)" ] || echo 'CC $<'
178 $(Q) $(CC) -c -o $@ $(CPPFLAGS) $(DEBUG_CPPFLAGS) $(speex_cppflags) @ogg_cppflags@ $<
180 $(object_dir)/spxdec_filter.o: spxdec_filter.c | $(object_dir)
181 @[ -z "$(Q)" ] || echo 'CC $<'
182 $(Q) $(CC) -c -o $@ $(CPPFLAGS) $(DEBUG_CPPFLAGS) $(speex_cppflags) @ogg_cppflags@ $<
184 $(object_dir)/spx_afh.o: spx_afh.c | $(object_dir)
185 @[ -z "$(Q)" ] || echo 'CC $<'
186 $(Q) $(CC) -c -o $@ $(CPPFLAGS) $(DEBUG_CPPFLAGS) $(speex_cppflags) @ogg_cppflags@ $<
188 $(object_dir)/oggdec_filter.o: oggdec_filter.c | $(object_dir)
189 @[ -z "$(Q)" ] || echo 'CC $<'
190 $(Q) $(CC) -c -o $@ $(CPPFLAGS) $(DEBUG_CPPFLAGS) @ogg_cppflags@ $<
192 $(object_dir)/ogg_afh.o: ogg_afh.c | $(object_dir)
193 @[ -z "$(Q)" ] || echo 'CC $<'
194 $(Q) $(CC) -c -o $@ $(CPPFLAGS) $(DEBUG_CPPFLAGS) @ogg_cppflags@ $<
196 $(object_dir)/ogg_afh_common.o: ogg_afh_common.c | $(object_dir)
197 @[ -z "$(Q)" ] || echo 'CC $<'
198 $(Q) $(CC) -c -o $@ $(CPPFLAGS) $(DEBUG_CPPFLAGS) @ogg_cppflags@ $<
200 $(object_dir)/mp3dec_filter.o: mp3dec_filter.c | $(object_dir)
201 @[ -z "$(Q)" ] || echo 'CC $<'
202 $(Q) $(CC) -c -o $@ $(CPPFLAGS) $(DEBUG_CPPFLAGS) @mad_cppflags@ $<
204 $(object_dir)/compress_filter.o: compress_filter.c | $(object_dir)
205 @[ -z "$(Q)" ] || echo 'CC $<'
206 $(Q) $(CC) -c -o $@ $(CPPFLAGS) $(DEBUG_CPPFLAGS) -O3 $<
208 $(object_dir)/aacdec_filter.o: aacdec_filter.c | $(object_dir)
209 @[ -z "$(Q)" ] || echo 'CC $<'
210 $(Q) $(CC) -c -o $@ $(CPPFLAGS) $(DEBUG_CPPFLAGS) @faad_cppflags@ $<
212 $(object_dir)/aac_common.o: aac_common.c | $(object_dir)
213 @[ -z "$(Q)" ] || echo 'CC $<'
214 $(Q) $(CC) -c -o $@ $(CPPFLAGS) $(DEBUG_CPPFLAGS) @faad_cppflags@ $<
216 $(object_dir)/aac_afh.o: aac_afh.c | $(object_dir)
217 @[ -z "$(Q)" ] || echo 'CC $<'
218 $(Q) $(CC) -c -o $@ $(CPPFLAGS) $(DEBUG_CPPFLAGS) @faad_cppflags@ $<
220 $(object_dir)/opus%.o: CPPFLAGS += $(opus_cppflags)
221 $(object_dir)/mp3_afh.o: CPPFLAGS += @id3tag_cppflags@
222 $(object_dir)/mp3_afh.o: mp3_afh.c | $(object_dir)
224 $(object_dir)/gui%.o: gui%.c | $(object_dir)
225 @[ -z "$(Q)" ] || echo 'CC $<'
226 $(Q) $(CC) -c -o $@ $(CPPFLAGS) $(DEBUG_CPPFLAGS) @curses_cppflags@ $<
227 $(object_dir)/ao_write.o: ao_write.c | $(object_dir)
228 @[ -z "$(Q)" ] || echo 'CC $<'
229 $(Q) $(CC) -c -o $@ $(CPPFLAGS) $(DEBUG_CPPFLAGS) @ao_cppflags@ $<
231 $(object_dir)/%.cmdline.o: $(cmdline_dir)/%.cmdline.c $(cmdline_dir)/%.cmdline.h | $(object_dir)
232 @[ -z "$(Q)" ] || echo 'CC $<'
233 $(Q) $(CC) -c $(CPPFLAGS) -Wno-unused-function -o $@ $<
235 $(object_dir)/%.o: %.c | $(object_dir)
236 @[ -z "$(Q)" ] || echo 'CC $<'
237 $(Q) $(CC) -c -o $@ $(CPPFLAGS) $(DEBUG_CPPFLAGS) $<
239 $(dep_dir)/%.cmdline.d: $(cmdline_dir)/%.cmdline.c | $(dep_dir)
240 @[ -z "$(Q)" ] || echo 'DEP $<'
241 $(Q) ./depend.sh $(dep_dir) $(object_dir) $(cmdline_dir) \
244 $(dep_dir)/%.d: %.c | $(dep_dir)
245 @[ -z "$(Q)" ] || echo 'DEP $<'
246 $(Q) ./depend.sh $(dep_dir) $(object_dir) $(cmdline_dir) \
249 # sort removes duplicate words, which is all we need here
250 all_objs := $(sort @recv_objs@ @filter_objs@ @client_objs@ @gui_objs@ \
251 @audiod_objs@ @audioc_objs@ @fade_objs@ @server_objs@ \
252 @write_objs@ @afh_objs@ @play_objs@)
253 deps := $(addprefix $(dep_dir)/, $(all_objs:.o=.d))
254 m4_deps := $(addprefix $(m4depdir)/, $(addsuffix .m4d, @executables@))
256 recv_objs := $(addprefix $(object_dir)/, @recv_objs@)
257 filter_objs := $(addprefix $(object_dir)/, @filter_objs@)
258 client_objs := $(addprefix $(object_dir)/, @client_objs@)
259 gui_objs := $(addprefix $(object_dir)/, @gui_objs@)
260 audiod_objs := $(addprefix $(object_dir)/, @audiod_objs@)
261 audioc_objs := $(addprefix $(object_dir)/, @audioc_objs@)
262 fade_objs := $(addprefix $(object_dir)/, @fade_objs@)
263 server_objs := $(addprefix $(object_dir)/, @server_objs@)
264 write_objs := $(addprefix $(object_dir)/, @write_objs@)
265 afh_objs := $(addprefix $(object_dir)/, @afh_objs@)
266 play_objs := $(addprefix $(object_dir)/, @play_objs@)
268 ifeq ($(findstring clean, $(MAKECMDGOALS)),)
273 para_recv para_afh para_play para_server: LDFLAGS += $(id3tag_ldflags)
274 para_write para_play para_audiod: LDFLAGS += $(ao_ldflags)
275 para_client para_audioc para_play : LDFLAGS += $(readline_ldflags)
276 para_server: LDFLAGS += $(osl_ldflags)
277 para_server para_client para_audiod: LDFLAGS += $(openssl_ldflags)
284 $(samplerate_ldflags)
308 para_recv: $(recv_objs)
309 @[ -z "$(Q)" ] || echo 'LD $@'
310 $(Q) $(CC) $(recv_objs) -o $@ @recv_ldflags@ $(LDFLAGS)
312 para_filter: $(filter_objs)
313 @[ -z "$(Q)" ] || echo 'LD $@'
314 $(Q) $(CC) $(filter_objs) -o $@ @filter_ldflags@ $(LDFLAGS)
316 para_client: $(client_objs)
317 @[ -z "$(Q)" ] || echo 'LD $@'
318 $(Q) $(CC) -o $@ $(client_objs) @client_ldflags@ $(LDFLAGS)
320 para_gui: $(gui_objs)
321 @[ -z "$(Q)" ] || echo 'LD $@'
322 $(Q) $(CC) -o $@ $(gui_objs) @curses_ldflags@ $(LDFLAGS)
324 para_audiod: $(audiod_objs)
325 @[ -z "$(Q)" ] || echo 'LD $@'
326 $(Q) $(CC) -o $@ $(audiod_objs) @audiod_ldflags@ $(LDFLAGS)
328 para_audioc: $(audioc_objs)
329 @[ -z "$(Q)" ] || echo 'LD $@'
330 $(Q) $(CC) -o $@ $(audioc_objs) @audioc_ldflags@ $(LDFLAGS)
332 para_fade: $(fade_objs)
333 @[ -z "$(Q)" ] || echo 'LD $@'
334 $(Q) $(CC) -o $@ $(fade_objs) @fade_ldflags@ $(LDFLAGS)
336 para_server: $(server_objs)
337 @[ -z "$(Q)" ] || echo 'LD $@'
338 $(Q) $(CC) -o $@ $(server_objs) @server_ldflags@ $(LDFLAGS)
340 para_write: $(write_objs)
341 @[ -z "$(Q)" ] || echo 'LD $@'
342 $(Q) $(CC) -o $@ $(write_objs) @write_ldflags@ $(LDFLAGS)
344 para_afh: $(afh_objs)
345 @[ -z "$(Q)" ] || echo 'LD $@'
346 $(Q) $(CC) -o $@ $(afh_objs) @afh_ldflags@ $(LDFLAGS)
348 para_play: $(play_objs)
349 @[ -z "$(Q)" ] || echo 'LD $@'
350 $(Q) $(CC) -o $@ $(play_objs) @play_ldflags@ $(LDFLAGS)
353 @[ -z "$(Q)" ] || echo 'CLEAN'
354 $(Q) rm -f $(executables)
355 $(Q) rm -rf $(object_dir)
358 @[ -z "$(Q)" ] || echo 'CLEAN2'
359 $(Q) rm -f *_command_list.* *_completion.h
360 $(Q) rm -rf $(build_dir)
361 distclean: clean2 test-clean
362 @[ -z "$(Q)" ] || echo 'DISTCLEAN'
363 $(Q) rm -f Makefile autoscan.log config.status config.log
364 $(Q) rm -rf autom4te.cache
365 $(Q) rm -f GPATH GRTAGS GSYMS GTAGS
367 maintainer-clean: distclean
368 rm -f *.tar.bz2 config.h configure config.h.in
372 $(MKDIR_P) $(BINDIR) $(MANDIR)
373 $(INSTALL) -s --strip-program $(STRIP) -m 755 $(executables) $(BINDIR)
374 $(INSTALL) -m 644 $(man_pages) $(MANDIR)
375 $(MKDIR_P) $(VARDIR) >/dev/null 2>&1 || true # not fatal, so don't complain
378 rm -rf $(tarball_pfx).tar.bz2 $(tarball_pfx)
379 git archive --format=tar --prefix=$(tarball_pfx)/ HEAD \
380 | tar --delete $(tarball_delete) > $(tarball_pfx).tar
381 $(MKDIR_P) $(tarball_pfx)
382 ./GIT-VERSION-GEN > $(tarball_pfx)/VERSION
383 cp -r $(autocrap) $(tarball_pfx)
384 tar rf $(tarball_pfx).tar $(tarball_pfx)/*
385 bzip2 -9 $(tarball_pfx).tar
386 ls -l $(tarball_pfx).tar.bz2
387 rm -rf $(tarball_pfx)
388 include $(test_dir)/makefile.test