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