1 # Implicit rules are implemented in make as suffix rules. The following rule
2 # empties the suffix list to disable the predefined implicit rules. This
3 # increases performance and avoids hard-to-debug behaviour.
6 ifeq ("$(origin CC)", "default")
10 vardir := /var/paraslash
11 mandir := $(datarootdir)/man/man1
12 STRIP := $(CROSS_COMPILE)strip
15 prefixed_executables := $(addprefix para_, $(executables))
17 build_date := $(shell date)
18 uname_s := $(shell uname -s 2>/dev/null || echo "UNKNOWN_OS")
19 uname_rs := $(shell uname -rs)
20 cc_version := $(shell $(CC) --version | head -n 1)
21 GIT_VERSION := $(shell ./GIT-VERSION-GEN git-version.h)
23 ifeq ("$(origin O)", "command line")
28 ggo_dir := $(build_dir)/ggo
29 object_dir := $(build_dir)/objects
30 dep_dir := $(build_dir)/deps
31 man_dir := $(build_dir)/man/man1
32 cmdline_dir := $(build_dir)/cmdline
33 cmdlist_dir := $(build_dir)/cmdlist
34 m4depdir := $(build_dir)/m4deps
35 help2man_dir := $(build_dir)/help2man
36 hostbin_dir := $(build_dir)/host/bin
37 m4_ggo_dir := m4/gengetopt
40 # sort removes duplicate words, which is all we need here
41 all_objs := $(sort $(recv_objs) $(filter_objs) $(client_objs) $(gui_objs) \
42 $(audiod_objs) $(audioc_objs) $(fade_objs) $(server_objs) \
43 $(write_objs) $(afh_objs) $(play_objs))
44 deps := $(addprefix $(dep_dir)/, $(filter-out %.cmdline.d, $(all_objs:.o=.d)))
45 m4_deps := $(addprefix $(m4depdir)/, $(addsuffix .m4d, $(executables)))
47 # now prefix all objects with object dir
48 recv_objs := $(addprefix $(object_dir)/, $(recv_objs))
49 filter_objs := $(addprefix $(object_dir)/, $(filter_objs))
50 client_objs := $(addprefix $(object_dir)/, $(client_objs))
51 gui_objs := $(addprefix $(object_dir)/, $(gui_objs))
52 audiod_objs := $(addprefix $(object_dir)/, $(audiod_objs))
53 audioc_objs := $(addprefix $(object_dir)/, $(audioc_objs))
54 fade_objs := $(addprefix $(object_dir)/, $(fade_objs))
55 server_objs := $(addprefix $(object_dir)/, $(server_objs))
56 write_objs := $(addprefix $(object_dir)/, $(write_objs))
57 afh_objs := $(addprefix $(object_dir)/, $(afh_objs))
58 play_objs := $(addprefix $(object_dir)/, $(play_objs))
60 man_pages := $(patsubst %, $(man_dir)/%.1, $(prefixed_executables))
62 autocrap := config.h.in configure
63 tarball_pfx := $(PACKAGE_TARNAME)-$(GIT_VERSION)
64 tarball_delete := $(addprefix $(tarball_pfx)/, web .gitignore)
65 tarball := $(tarball_pfx).tar.bz2
67 .PHONY: dep all clean clean2 distclean maintainer-clean install man tarball
68 all: dep $(prefixed_executables) $(man_pages)
73 include $(m4_ggo_dir)/makefile
74 include $(test_dir)/makefile.test
75 ifeq ($(findstring clean, $(MAKECMDGOALS)),)
80 $(object_dir) $(man_dir) $(ggo_dir) $(cmdline_dir) $(dep_dir) $(m4depdir) \
81 $(help2man_dir) $(hostbin_dir) $(cmdlist_dir):
84 # When in doubt, use brute force (Ken Thompson)
86 $(subst a,A,$(subst b,B,$(subst c,C,$(subst d,D,$(subst e,E,\
87 $(subst f,F,$(subst g,G,$(subst h,H,$(subst i,I,$(subst j,J,\
88 $(subst k,K,$(subst l,L,$(subst m,M,$(subst n,N,$(subst o,O,\
89 $(subst p,P,$(subst q,Q,$(subst r,R,$(subst s,S,$(subst t,T,\
90 $(subst u,U,$(subst v,V,$(subst w,W,$(subst x,X,$(subst y,Y,\
91 $(subst z,Z,$1))))))))))))))))))))))))))
93 CPPFLAGS += -DBINDIR='"$(bindir)"'
94 CPPFLAGS += -DBUILD_DATE='"$(build_date)"'
95 CPPFLAGS += -DUNAME_RS='"$(uname_rs)"'
96 CPPFLAGS += -DCC_VERSION='"$(cc_version)"'
97 CPPFLAGS += -DMAIN_INPUT_FILE_IS_$(*F)
98 CPPFLAGS += -I/usr/local/include
99 CPPFLAGS += -I$(cmdline_dir)
100 CPPFLAGS += -I$(cmdlist_dir)
103 CFLAGS += -Wuninitialized
104 CFLAGS += -Wchar-subscripts
105 CFLAGS += -Werror-implicit-function-declaration
106 CFLAGS += -Wmissing-noreturn
107 CFLAGS += -Wbad-function-cast
108 CFLAGS += -fno-strict-aliasing
110 STRICT_CFLAGS = $(CFLAGS)
111 STRICT_CFLAGS += -g -Wundef -W
112 STRICT_CFLAGS += -Wredundant-decls
113 STRICT_CFLAGS += -Wno-sign-compare -Wno-unknown-pragmas
114 STRICT_CFLAGS += -Wformat -Wformat-security
115 STRICT_CFLAGS += -Wmissing-format-attribute
117 LDFLAGS += $(clock_gettime_ldflags)
119 ifeq ($(uname_s),Linux)
120 # these cause warnings on *BSD
121 CPPFLAGS += -Wunused-macros
122 STRICT_CFLAGS += -fdata-sections -ffunction-sections
123 STRICT_CFLAGS += -Wstrict-prototypes
124 STRICT_CFLAGS += -Wshadow
125 STRICT_CFLAGS += -Wunused -Wall
126 LDFLAGS += -Wl,--gc-sections
129 # To put more focus on warnings, be less verbose as default
130 # Use 'make V=1' to see the full commands
131 ifeq ("$(origin V)", "command line")
137 $(cmdlist_dir)/%.command_list.h: %.cmd %.c | $(cmdlist_dir)
138 @[ -z "$(Q)" ] || echo 'GEN $@'
139 $(Q) ./command_util.bash h < $< >$@
140 $(cmdlist_dir)/%.command_list.man: %.cmd %.c | $(cmdlist_dir)
141 @[ -z "$(Q)" ] || echo 'GEN $@'
142 $(Q) ./command_util.bash man < $< > $@
143 $(cmdlist_dir)/%.completion.h: %.cmd | $(cmdlist_dir)
144 @[ -z "$(Q)" ] || echo 'GEN $@'
145 $(Q) ./command_util.bash compl $(strip $(call TOUPPER,$(*F)))_COMPLETERS \
146 $(strip $(call TOUPPER,$(*F)))_COMMANDS < $< > $@
148 $(cmdlist_dir)/server.command_list.h \
149 $(cmdlist_dir)/server.command_list.man \
150 $(cmdlist_dir)/server.completion.h \
153 $(cmdlist_dir)/afs.command_list.h \
154 $(cmdlist_dir)/afs.command_list.man \
155 $(cmdlist_dir)/afs.completion.h \
156 : afs.c aft.c attribute.c
158 $(cmdlist_dir)/audiod.command_list.h \
159 $(cmdlist_dir)/audiod.command_list.man \
160 $(cmdlist_dir)/audiod.completion.h \
163 server_command_lists := $(cmdlist_dir)/server.command_list.man \
164 $(cmdlist_dir)/afs.command_list.man
165 audiod_command_lists := $(cmdlist_dir)/audiod.command_list.man
166 play_command_lists := $(cmdlist_dir)/play.command_list.man
168 $(man_dir)/para_server.1: $(server_command_lists)
169 $(man_dir)/para_audiod.1: $(audiod_command_lists)
170 $(man_dir)/para_play.1: $(play_command_lists)
172 $(man_dir)/para_server.1: man_util_command_lists := $(server_command_lists)
173 $(man_dir)/para_audiod.1: man_util_command_lists := $(audiod_command_lists)
174 $(man_dir)/para_play.1: man_util_command_lists := $(play_command_lists)
176 $(man_dir)/para_%.1: $(ggo_dir)/%.ggo man_util.bash \
177 git-version.h | $(man_dir) $(help2man_dir)
178 @[ -z "$(Q)" ] || echo 'MAN $<'
180 COMMAND_LISTS="$(man_util_command_lists)" \
181 FILTERS="$(filters)" \
182 GENGETOPT=$(GENGETOPT) \
184 HELP2MAN=$(HELP2MAN) \
185 HELP2MAN_DIR=$(help2man_dir) \
186 RECEIVERS="$(receivers)" \
187 VERSION="$(GIT_VERSION)" \
188 WRITERS="$(writers)" \
191 $(hostbin_dir)/error2: error2.c | $(hostbin_dir)
192 @[ -z "$(Q)" ] || echo 'HCC $<'
193 $(Q) $(HOSTCC) -o $@ $<
194 error2.h: $(hostbin_dir)/error2 config.h
195 @[ -z "$(Q)" ] || echo 'ER2 $<'
196 @echo "$(object_executable_matrix)" | $< > $@
198 $(object_dir)/%.o: %.c | $(object_dir)
200 $(object_dir)/opus%.o $(dep_dir)/opus%.d: CPPFLAGS += $(opus_cppflags)
201 $(object_dir)/gui.o $(object_dir)/gui%.o $(dep_dir)/gui%.d \
202 : CPPFLAGS += $(curses_cppflags)
203 $(object_dir)/spx%.o $(dep_dir)/spx%.d: CPPFLAGS += $(speex_cppflags)
204 $(object_dir)/flac%.o $(dep_dir)/flac%.d: CPPFLAGS += $(flac_cppflags)
206 $(object_dir)/mp3_afh.o $(dep_dir)/mp3_afh.d: CPPFLAGS += $(id3tag_cppflags)
207 $(object_dir)/crypt.o $(dep_dir)/crypt.d: CPPFLAGS += $(openssl_cppflags)
208 $(object_dir)/gcrypt.o $(dep_dir)/gcrypt.d: CPPFLAGS += $(gcrypt_cppflags)
209 $(object_dir)/ao_write.o $(dep_dir)/ao_write.d: CPPFLAGS += $(ao_cppflags)
210 $(object_dir)/aac_afh.o $(dep_dir)/aac_afh.d: CPPFLAGS += $(mp4v2_cppflags)
211 $(object_dir)/alsa%.o $(dep_dir)/alsa%.d: CPPFLAGS += $(alsa_cppflags)
213 $(object_dir)/interactive.o $(dep_dir)/interactive.d \
214 : CPPFLAGS += $(readline_cppflags)
216 $(object_dir)/resample_filter.o $(dep_dir)/resample_filter.d \
217 : CPPFLAGS += $(samplerate_cppflags)
219 $(object_dir)/oss_write.o $(dep_dir)/oss_write.d \
220 : CPPFLAGS += $(oss_cppflags)
222 $(object_dir)/ao_write.o $(dep_dir)/ao_write.d \
223 : CPPFLAGS += $(ao_cppflags) $(pthread_cppflags)
225 $(object_dir)/mp3dec_filter.o $(dep_dir)/mp3dec_filter.d \
226 : CPPFLAGS += $(mad_cppflags)
228 $(object_dir)/aacdec_filter.o $(dep_dir)/aacdec_filter.d \
229 $(object_dir)/aac_common.o $(dep_dir)/aac_common.d \
230 $(object_dir)/aac_afh.o $(dep_dir)/aac_afh.d \
231 : CPPFLAGS += $(faad_cppflags)
233 $(object_dir)/ogg_afh.o $(dep_dir)/ogg_afh.d \
234 $(object_dir)/oggdec_filter.o $(dep_dir)/oggdec_filter.d \
235 : CPPFLAGS += $(vorbis_cppflags)
237 $(object_dir)/spx_common.o $(dep_dir)/spx_common.d \
238 $(object_dir)/spxdec_filter.o $(dep_dir)/spxdec_filter.d \
239 $(object_dir)/spx_afh.o $(dep_dir)/spx_afh.d \
240 $(object_dir)/oggdec_filter.o $(dep_dir)/oggdec_filter.d \
241 $(object_dir)/ogg_afh.o $(dep_dir)/ogg_afh.d \
242 $(object_dir)/ogg_afh_common.o $(dep_dir)/ogg_afh_common.d \
243 $(object_dir)/opus%.o $(dep_dir)/opus%.d \
244 : CPPFLAGS += $(ogg_cppflags)
246 $(object_dir)/afs.o $(dep_dir)/afs.d \
247 $(object_dir)/aft.o $(dep_dir)/aft.d \
248 $(object_dir)/attribute.o $(dep_dir)/attribute.d \
249 $(object_dir)/blob.o $(dep_dir)/blob.d \
250 $(object_dir)/mood.o $(dep_dir)/mood.d \
251 $(object_dir)/playlist.o $(dep_dir)/playlist.d \
252 $(object_dir)/score.o $(dep_dir)/score.d \
253 $(object_dir)/server.o $(dep_dir)/server.d \
254 $(object_dir)/vss.o $(dep_dir)/vss.d \
255 $(object_dir)/command.o $(dep_dir)/command.d \
256 $(object_dir)/http_send.o $(dep_dir)/http_send.d \
257 $(object_dir)/dccp_send.o $(dep_dir)/dccp_send.d \
258 $(object_dir)/udp_send.o $(dep_dir)/udp_send.d \
259 $(object_dir)/send_common.o $(dep_dir)/send_common.d \
260 $(object_dir)/mm.o $(dep_dir)/mm.d \
261 : CPPFLAGS += $(osl_cppflags)
263 $(object_dir)/%.cmdline.o: CFLAGS += -Wno-unused-function
264 $(object_dir)/compress_filter.o: CFLAGS += -O3
266 $(object_dir)/%.o: %.c | $(object_dir)
267 @[ -z "$(Q)" ] || echo 'CC $<'
268 $(Q) $(CC) -c -o $@ $(CPPFLAGS) $(STRICT_CFLAGS) $<
270 $(object_dir)/%.cmdline.o: $(cmdline_dir)/%.cmdline.c $(cmdline_dir)/%.cmdline.h | $(object_dir)
271 @[ -z "$(Q)" ] || echo 'CC $<'
272 $(Q) $(CC) -c -o $@ $(CPPFLAGS) $(CFLAGS) $<
274 # The compiler outputs dependencies either as foo.h or as some_directory/foo.h,
275 # depending on whether the latter file exists. Since make needs the directory
276 # part we prefix the dependency as appropriate.
277 $(dep_dir)/%.d: %.c error2.h | $(dep_dir)
278 @[ -z "$(Q)" ] || echo 'DEP $<'
279 $(Q) $(CC) $(CPPFLAGS) -MM -MG -MP -MT $@ -MT $(object_dir)/$(*F).o $< \
280 | sed -e "s@ \([a-zA-Z0-9_]\{1,\}\.cmdline.h\)@ $(cmdline_dir)/\1@g" \
281 -e "s@ \([a-zA-Z0-9_]\{1,\}\.command_list.h\)@ $(cmdlist_dir)/\1@g" \
282 -e "s@ \([a-zA-Z0-9_]\{1,\}\.completion.h\)@ $(cmdlist_dir)/\1@g" > $@
284 para_recv para_afh para_play para_server: LDFLAGS += $(id3tag_ldflags)
285 para_write para_play para_audiod \
286 : LDFLAGS += $(ao_ldflags) $(pthread_ldflags) $(core_audio_ldflags)
287 para_client para_audioc para_play : LDFLAGS += $(readline_ldflags)
288 para_server: LDFLAGS += $(osl_ldflags)
289 para_gui: LDFLAGS += $(curses_ldflags)
302 $(samplerate_ldflags) \
340 $(socket_ldflags) $(nsl_ldflags)
342 para_afh para_recv para_server para_play: LDFLAGS += $(iconv_ldflags)
344 $(foreach exe,$(executables),$(eval para_$(exe): $$($(exe)_objs)))
345 $(prefixed_executables):
346 @[ -z "$(Q)" ] || echo 'LD $@'
347 $(Q) $(CC) $^ -o $@ $(LDFLAGS)
350 @[ -z "$(Q)" ] || echo 'CLEAN'
352 $(Q) rm -rf $(object_dir)
355 @[ -z "$(Q)" ] || echo 'CLEAN2'
356 $(Q) rm -rf $(build_dir)
357 distclean: clean2 test-clean
358 @[ -z "$(Q)" ] || echo 'DISTCLEAN'
359 $(Q) rm -f Makefile autoscan.log config.status config.log error2.h
360 $(Q) rm -f GPATH GRTAGS GSYMS GTAGS
362 maintainer-clean: distclean
363 @[ -z "$(Q)" ] || echo 'MAINTAINER-CLEAN'
364 $(Q) rm -f *.tar.bz2 config.h configure config.h.in
367 $(MKDIR_P) $(bindir) $(mandir)
368 $(INSTALL) -s --strip-program $(STRIP) -m 755 \
369 $(prefixed_executables) $(bindir)
370 $(INSTALL) -m 644 $(man_pages) $(mandir)
371 $(MKDIR_P) $(vardir) >/dev/null 2>&1 || true # not fatal, so don't complain
374 $(Q) rm -rf $(tarball) $(tarball_pfx)
375 $(Q) git archive --format=tar --prefix=$(tarball_pfx)/ HEAD \
376 | tar --delete $(tarball_delete) > $(tarball_pfx).tar
377 $(Q) $(MKDIR_P) $(tarball_pfx)
378 $(Q) ./GIT-VERSION-GEN > $(tarball_pfx)/VERSION
379 $(Q) cp $(autocrap) $(tarball_pfx)
380 $(Q) tar rf $(tarball_pfx).tar $(tarball_pfx)/*
381 $(Q) bzip2 -9 $(tarball_pfx).tar
382 $(Q) ls -l $(tarball)
383 $(Q) ln -sf $(tarball) paraslash-git.tar.bz2
384 $(Q) rm -rf $(tarball_pfx)