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 LOGLEVELS := LL_DEBUG,LL_INFO,LL_NOTICE,LL_WARNING,LL_ERROR,LL_CRIT,LL_EMERG
11 vardir := /var/paraslash
12 mandir := $(datarootdir)/man/man1
13 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)
22 COPYRIGHT_YEAR := 2017
24 ifeq ("$(origin O)", "command line")
29 ggo_dir := $(build_dir)/ggo
30 object_dir := $(build_dir)/objects
31 dep_dir := $(build_dir)/deps
32 man_dir := $(build_dir)/man/man1
33 cmdline_dir := $(build_dir)/cmdline
34 m4depdir := $(build_dir)/m4deps
35 help2man_dir := $(build_dir)/help2man
36 lls_suite_dir := $(build_dir)/lls
38 m4_ggo_dir := m4/gengetopt
41 # sort removes duplicate words, which is all we need here
42 all_objs := $(sort $(recv_objs) $(filter_objs) $(client_objs) $(gui_objs) \
43 $(audiod_objs) $(audioc_objs) $(fade_objs) $(server_objs) \
44 $(write_objs) $(afh_objs) $(play_objs))
45 deps := $(addprefix $(dep_dir)/, $(filter-out %.cmdline.d, $(all_objs:.o=.d)))
46 converted_executables := audioc client fade play recv
47 unconverted_executables := $(filter-out $(converted_executables), $(executables))
49 audioc_objs += audioc.lsg.o
50 audiod_objs += $(addsuffix _cmd.lsg.o, recv filter audiod write) client.lsg.o
51 client_objs += client.lsg.o
52 fade_objs += fade.lsg.o
53 filter_objs += filter_cmd.lsg.o
54 play_objs += $(addsuffix _cmd.lsg.o, recv filter play write) play.lsg.o
55 recv_objs += recv_cmd.lsg.o recv.lsg.o
56 server_objs += server_cmd.lsg.o
57 write_objs += write_cmd.lsg.o
59 m4_deps := $(addprefix $(m4depdir)/, $(addsuffix .m4d, $(unconverted_executables)))
67 $(converted_executables)
68 m4_lls_deps := $(addprefix $(lls_suite_dir)/, $(addsuffix .m4d, $(m4_lls_deps)))
70 # now prefix all objects with object dir
71 recv_objs := $(addprefix $(object_dir)/, $(recv_objs))
72 filter_objs := $(addprefix $(object_dir)/, $(filter_objs))
73 client_objs := $(addprefix $(object_dir)/, $(client_objs))
74 gui_objs := $(addprefix $(object_dir)/, $(gui_objs))
75 audiod_objs := $(addprefix $(object_dir)/, $(audiod_objs))
76 audioc_objs := $(addprefix $(object_dir)/, $(audioc_objs))
77 fade_objs := $(addprefix $(object_dir)/, $(fade_objs))
78 server_objs := $(addprefix $(object_dir)/, $(server_objs))
79 write_objs := $(addprefix $(object_dir)/, $(write_objs))
80 afh_objs := $(addprefix $(object_dir)/, $(afh_objs))
81 play_objs := $(addprefix $(object_dir)/, $(play_objs))
83 man_pages := $(patsubst %, $(man_dir)/%.1, $(prefixed_executables))
85 autocrap := config.h.in configure
86 tarball_pfx := $(PACKAGE_TARNAME)-$(GIT_VERSION)
87 tarball_delete := $(addprefix $(tarball_pfx)/, web .gitignore)
88 tarball := $(tarball_pfx).tar.bz2
90 .PHONY: all clean clean2 distclean maintainer-clean install man tarball
91 all: $(prefixed_executables) $(man_pages)
95 include $(lls_m4_dir)/makefile
96 include $(m4_ggo_dir)/makefile
97 include $(test_dir)/makefile.test
98 ifeq ($(findstring clean, $(MAKECMDGOALS)),)
101 -include $(m4_lls_deps)
104 $(object_dir) $(man_dir) $(ggo_dir) $(cmdline_dir) $(dep_dir) $(m4depdir) \
105 $(help2man_dir) $(lls_suite_dir):
108 CPPFLAGS += -DBINDIR='"$(bindir)"'
109 CPPFLAGS += -DCOPYRIGHT_YEAR='"$(COPYRIGHT_YEAR)"'
110 CPPFLAGS += -DBUILD_DATE='"$(build_date)"'
111 CPPFLAGS += -DLOGLEVELS='$(LOGLEVELS)'
112 CPPFLAGS += -DUNAME_RS='"$(uname_rs)"'
113 CPPFLAGS += -DCC_VERSION='"$(cc_version)"'
114 CPPFLAGS += -I/usr/local/include
115 CPPFLAGS += -I$(cmdline_dir)
116 CPPFLAGS += -I$(lls_suite_dir)
117 CPPFLAGS += $(lopsub_cppflags)
120 CFLAGS += -Wuninitialized
121 CFLAGS += -Wchar-subscripts
122 CFLAGS += -Werror-implicit-function-declaration
123 CFLAGS += -Wmissing-noreturn
124 CFLAGS += -Wbad-function-cast
125 CFLAGS += -fno-strict-aliasing
127 STRICT_CFLAGS = $(CFLAGS)
128 STRICT_CFLAGS += -g -Wundef -W
129 STRICT_CFLAGS += -Wredundant-decls
130 STRICT_CFLAGS += -Wno-sign-compare -Wno-unknown-pragmas
131 STRICT_CFLAGS += -Wformat -Wformat-security
132 STRICT_CFLAGS += -Wmissing-format-attribute
133 STRICT_CFLAGS += -Wdeclaration-after-statement
135 LDFLAGS += $(clock_gettime_ldflags)
137 ifeq ($(uname_s),Linux)
138 # these cause warnings on *BSD
139 CPPFLAGS += -Wunused-macros
140 STRICT_CFLAGS += -fdata-sections -ffunction-sections
141 STRICT_CFLAGS += -Wstrict-prototypes
142 STRICT_CFLAGS += -Wshadow
143 STRICT_CFLAGS += -Wunused -Wall
144 LDFLAGS += -Wl,--gc-sections
147 cc-option = $(shell \
148 $(CC) $(1) -Werror -c -x c /dev/null -o /dev/null > /dev/null 2>&1 \
152 STRICT_CFLAGS += $(call cc-option, -Wformat-signedness)
154 # To put more focus on warnings, be less verbose as default
155 # Use 'make V=1' to see the full commands
156 ifeq ("$(origin V)", "command line")
162 audiod_command_lists := $(addprefix $(lls_suite_dir)/, \
163 $(addsuffix _cmd.lsg.man, audiod recv filter write))
164 filter_command_lists := $(lls_suite_dir)/filter_cmd.lsg.man
165 play_command_lists := $(lls_suite_dir)/play_cmd.lsg.man
166 recv_command_lists := $(lls_suite_dir)/recv_cmd.lsg.man
167 server_command_lists := $(lls_suite_dir)/server_cmd.lsg.man
168 write_command_lists := $(lls_suite_dir)/write_cmd.lsg.man
170 $(man_dir)/para_server.1: $(server_command_lists)
171 $(man_dir)/para_filter.1: $(filter_command_lists)
172 $(man_dir)/para_write.1: $(write_command_lists)
173 $(man_dir)/para_audiod.1: $(audiod_command_lists)
174 $(man_dir)/para_play.1: $(play_command_lists)
175 $(man_dir)/para_recv.1: $(recv_command_lists)
177 $(man_dir)/para_server.1: man_util_command_lists := $(server_command_lists)
178 $(man_dir)/para_filter.1: man_util_command_lists := $(filter_command_lists)
179 $(man_dir)/para_write.1: man_util_command_lists := $(write_command_lists)
180 $(man_dir)/para_audiod.1: man_util_command_lists := $(audiod_command_lists)
181 $(man_dir)/para_play.1: man_util_command_lists := $(play_command_lists)
182 $(man_dir)/para_recv.1: man_util_command_lists := $(recv_command_lists)
184 $(man_dir)/para_%.1: $(lls_suite_dir)/%.lsg.man $(man_util_command_lists) \
185 $(lls_m4_dir)/copyright.m4 | $(man_dir)
186 @[ -z "$(Q)" ] || echo 'LLSMAN $<'
187 $(Q) cat $< $(man_util_command_lists) > $@
188 $(Q) $(M4) -D COPYRIGHT_YEAR=$(COPYRIGHT_YEAR) $(lls_m4_dir)/copyright.m4 >> $@
190 $(man_dir)/para_%.1: $(man_util_command_lists) \
191 $(ggo_dir)/%.ggo man_util.bash \
192 | $(man_dir) $(help2man_dir)
193 @[ -z "$(Q)" ] || echo 'MAN $<'
195 COMMAND_LISTS="$(man_util_command_lists)" \
196 FILTERS="$(filters)" \
197 GENGETOPT=$(GENGETOPT) \
199 HELP2MAN=$(HELP2MAN) \
200 HELP2MAN_DIR=$(help2man_dir) \
201 RECEIVERS="$(receivers)" \
202 VERSION="$(GIT_VERSION)" \
203 WRITERS="$(writers)" \
206 $(object_dir)/%.o: %.c | $(object_dir)
208 $(object_dir)/opus%.o $(dep_dir)/opus%.d: CPPFLAGS += $(opus_cppflags)
209 $(object_dir)/gui.o $(object_dir)/gui%.o $(dep_dir)/gui%.d \
210 : CPPFLAGS += $(curses_cppflags)
211 $(object_dir)/spx%.o $(dep_dir)/spx%.d: CPPFLAGS += $(speex_cppflags)
212 $(object_dir)/flac%.o $(dep_dir)/flac%.d: CPPFLAGS += $(flac_cppflags)
214 $(object_dir)/mp3_afh.o $(dep_dir)/mp3_afh.d: CPPFLAGS += $(id3tag_cppflags)
215 $(object_dir)/crypt.o $(dep_dir)/crypt.d: CPPFLAGS += $(openssl_cppflags)
216 $(object_dir)/gcrypt.o $(dep_dir)/gcrypt.d: CPPFLAGS += $(gcrypt_cppflags)
217 $(object_dir)/ao_write.o $(dep_dir)/ao_write.d: CPPFLAGS += $(ao_cppflags)
218 $(object_dir)/aac_afh.o $(dep_dir)/aac_afh.d: CPPFLAGS += $(mp4v2_cppflags)
219 $(object_dir)/alsa%.o $(dep_dir)/alsa%.d: CPPFLAGS += $(alsa_cppflags)
221 $(object_dir)/interactive.o $(dep_dir)/interactive.d \
222 : CPPFLAGS += $(readline_cppflags)
224 $(object_dir)/resample_filter.o $(dep_dir)/resample_filter.d \
225 : CPPFLAGS += $(samplerate_cppflags)
227 $(object_dir)/oss_write.o $(dep_dir)/oss_write.d \
228 : CPPFLAGS += $(oss_cppflags)
230 $(object_dir)/ao_write.o $(dep_dir)/ao_write.d \
231 : CPPFLAGS += $(ao_cppflags) $(pthread_cppflags)
233 $(object_dir)/mp3dec_filter.o $(dep_dir)/mp3dec_filter.d \
234 : CPPFLAGS += $(mad_cppflags)
236 $(object_dir)/aacdec_filter.o $(dep_dir)/aacdec_filter.d \
237 $(object_dir)/aac_common.o $(dep_dir)/aac_common.d \
238 $(object_dir)/aac_afh.o $(dep_dir)/aac_afh.d \
239 : CPPFLAGS += $(faad_cppflags)
241 $(object_dir)/ogg_afh.o $(dep_dir)/ogg_afh.d \
242 $(object_dir)/oggdec_filter.o $(dep_dir)/oggdec_filter.d \
243 : CPPFLAGS += $(vorbis_cppflags)
245 $(object_dir)/spx_common.o $(dep_dir)/spx_common.d \
246 $(object_dir)/spxdec_filter.o $(dep_dir)/spxdec_filter.d \
247 $(object_dir)/spx_afh.o $(dep_dir)/spx_afh.d \
248 $(object_dir)/oggdec_filter.o $(dep_dir)/oggdec_filter.d \
249 $(object_dir)/ogg_afh.o $(dep_dir)/ogg_afh.d \
250 $(object_dir)/ogg_afh_common.o $(dep_dir)/ogg_afh_common.d \
251 $(object_dir)/opus%.o $(dep_dir)/opus%.d \
252 : CPPFLAGS += $(ogg_cppflags)
254 $(object_dir)/afs.o $(dep_dir)/afs.d \
255 $(object_dir)/aft.o $(dep_dir)/aft.d \
256 $(object_dir)/attribute.o $(dep_dir)/attribute.d \
257 $(object_dir)/blob.o $(dep_dir)/blob.d \
258 $(object_dir)/mood.o $(dep_dir)/mood.d \
259 $(object_dir)/playlist.o $(dep_dir)/playlist.d \
260 $(object_dir)/score.o $(dep_dir)/score.d \
261 $(object_dir)/server.o $(dep_dir)/server.d \
262 $(object_dir)/vss.o $(dep_dir)/vss.d \
263 $(object_dir)/command.o $(dep_dir)/command.d \
264 $(object_dir)/http_send.o $(dep_dir)/http_send.d \
265 $(object_dir)/dccp_send.o $(dep_dir)/dccp_send.d \
266 $(object_dir)/udp_send.o $(dep_dir)/udp_send.d \
267 $(object_dir)/send_common.o $(dep_dir)/send_common.d \
268 $(object_dir)/mm.o $(dep_dir)/mm.d \
269 : CPPFLAGS += $(osl_cppflags)
271 $(object_dir)/%.cmdline.o: CFLAGS += -Wno-unused-function
272 $(object_dir)/compress_filter.o: CFLAGS += -O3
274 $(object_dir)/%.o: %.c | $(object_dir)
275 @[ -z "$(Q)" ] || echo 'CC $<'
276 $(Q) $(CC) -c -o $@ $(CPPFLAGS) $(STRICT_CFLAGS) $<
278 $(object_dir)/%.cmdline.o: $(cmdline_dir)/%.cmdline.c $(cmdline_dir)/%.cmdline.h | $(object_dir)
279 @[ -z "$(Q)" ] || echo 'CC $<'
280 $(Q) $(CC) -c -o $@ $(CPPFLAGS) $(CFLAGS) $<
282 # The compiler outputs dependencies either as foo.h or as some_directory/foo.h,
283 # depending on whether the latter file exists. Since make needs the directory
284 # part we prefix the dependency as appropriate.
285 $(dep_dir)/%.d: %.c | $(dep_dir)
286 @[ -z "$(Q)" ] || echo 'DEP $<'
287 $(Q) $(CC) $(CPPFLAGS) -MM -MG -MP -MT $@ -MT $(object_dir)/$(*F).o $< \
288 | sed -e "s@ \([a-zA-Z0-9_]\{1,\}\.cmdline.h\)@ $(cmdline_dir)/\1@g" \
289 -e "s@ \([a-zA-Z0-9_]\{1,\}.lsg.h\)@ $(lls_suite_dir)/\1@g" > $@
291 para_recv para_afh para_play para_server: LDFLAGS += $(id3tag_ldflags)
292 para_write para_play para_audiod \
293 : LDFLAGS += $(ao_ldflags) $(pthread_ldflags) $(core_audio_ldflags)
294 para_client para_audioc para_play : LDFLAGS += $(readline_ldflags)
295 para_server: LDFLAGS += $(osl_ldflags)
296 para_gui: LDFLAGS += $(curses_ldflags)
309 $(samplerate_ldflags) \
329 : LDFLAGS += $(lopsub_ldflags)
352 para_afh para_recv para_server para_play: LDFLAGS += $(iconv_ldflags)
354 $(foreach exe,$(executables),$(eval para_$(exe): $$($(exe)_objs)))
355 $(prefixed_executables):
356 @[ -z "$(Q)" ] || echo 'LD $@'
357 $(Q) $(CC) $^ -o $@ $(LDFLAGS)
360 @[ -z "$(Q)" ] || echo 'CLEAN'
362 $(Q) rm -rf $(object_dir)
365 @[ -z "$(Q)" ] || echo 'CLEAN2'
366 $(Q) rm -rf $(build_dir)
367 distclean: clean2 test-clean
368 @[ -z "$(Q)" ] || echo 'DISTCLEAN'
369 $(Q) rm -f Makefile autoscan.log config.status config.log
370 $(Q) rm -f GPATH GRTAGS GSYMS GTAGS
372 maintainer-clean: distclean
373 @[ -z "$(Q)" ] || echo 'MAINTAINER-CLEAN'
374 $(Q) rm -f *.tar.bz2 config.h configure config.h.in
377 $(MKDIR_P) $(bindir) $(mandir)
378 $(INSTALL) -s --strip-program $(STRIP) -m 755 \
379 $(prefixed_executables) $(bindir)
380 $(INSTALL) -m 644 $(man_pages) $(mandir)
381 $(MKDIR_P) $(vardir) >/dev/null 2>&1 || true # not fatal, so don't complain
384 $(Q) rm -rf $(tarball) $(tarball_pfx)
385 $(Q) git archive --format=tar --prefix=$(tarball_pfx)/ HEAD \
386 | tar --delete $(tarball_delete) > $(tarball_pfx).tar
387 $(Q) $(MKDIR_P) $(tarball_pfx)
388 $(Q) ./GIT-VERSION-GEN > $(tarball_pfx)/VERSION
389 $(Q) cp $(autocrap) $(tarball_pfx)
390 $(Q) tar rf $(tarball_pfx).tar $(tarball_pfx)/*
391 $(Q) bzip2 -9 $(tarball_pfx).tar
392 $(Q) ls -l $(tarball)
393 $(Q) ln -sf $(tarball) paraslash-git.tar.bz2
394 $(Q) rm -rf $(tarball_pfx)