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
14 prefixed_executables := $(addprefix para_, $(executables))
16 build_date := $(shell date)
17 uname_s := $(shell uname -s 2>/dev/null || echo "UNKNOWN_OS")
18 uname_rs := $(shell uname -rs)
19 cc_version := $(shell $(CC) --version | head -n 1)
20 GIT_VERSION := $(shell ./GIT-VERSION-GEN git-version.h)
21 COPYRIGHT_YEAR := 2017
23 ifeq ("$(origin O)", "command line")
28 object_dir := $(build_dir)/objects
29 dep_dir := $(build_dir)/deps
30 man_dir := $(build_dir)/man/man1
31 m4depdir := $(build_dir)/m4deps
32 lls_suite_dir := $(build_dir)/lls
36 # sort removes duplicate words, which is all we need here
37 all_objs := $(sort $(recv_objs) $(filter_objs) $(client_objs) $(gui_objs) \
38 $(audiod_objs) $(audioc_objs) $(mixer_objs) $(server_objs) \
39 $(write_objs) $(afh_objs) $(play_objs))
40 deps := $(addprefix $(dep_dir)/, $(all_objs:.o=.d))
43 audioc_objs += audioc.lsg.o
44 audiod_objs += $(addsuffix _cmd.lsg.o, recv filter audiod write) \
45 client.lsg.o audiod.lsg.o
46 client_objs += client.lsg.o
47 mixer_objs += mixer.lsg.o
48 filter_objs += filter_cmd.lsg.o filter.lsg.o
50 play_objs += $(addsuffix _cmd.lsg.o, recv filter play write) play.lsg.o
51 recv_objs += recv_cmd.lsg.o recv.lsg.o
52 server_objs += server_cmd.lsg.o server.lsg.o
53 write_objs += write_cmd.lsg.o write.lsg.o
55 cmd_suites := $(addsuffix _cmd, audiod server play recv filter write)
56 suites := $(addprefix $(lls_suite_dir)/, $(cmd_suites) $(executables))
57 m4_lls_deps := $(addsuffix .m4d, $(suites))
58 lsg_h := $(addsuffix .lsg.h, $(suites))
60 # now prefix all objects with object dir
61 recv_objs := $(addprefix $(object_dir)/, $(recv_objs))
62 filter_objs := $(addprefix $(object_dir)/, $(filter_objs))
63 client_objs := $(addprefix $(object_dir)/, $(client_objs))
64 gui_objs := $(addprefix $(object_dir)/, $(gui_objs))
65 audiod_objs := $(addprefix $(object_dir)/, $(audiod_objs))
66 audioc_objs := $(addprefix $(object_dir)/, $(audioc_objs))
67 mixer_objs := $(addprefix $(object_dir)/, $(mixer_objs))
68 server_objs := $(addprefix $(object_dir)/, $(server_objs))
69 write_objs := $(addprefix $(object_dir)/, $(write_objs))
70 afh_objs := $(addprefix $(object_dir)/, $(afh_objs))
71 play_objs := $(addprefix $(object_dir)/, $(play_objs))
73 man_pages := $(patsubst %, $(man_dir)/%.1, $(prefixed_executables))
75 autocrap := config.h.in configure
76 tarball_pfx := $(PACKAGE_TARNAME)-$(GIT_VERSION)
77 tarball_delete := $(addprefix $(tarball_pfx)/, web .gitignore)
78 tarball := $(tarball_pfx).tar.xz
80 all: $(prefixed_executables) $(man_pages)
81 .PHONY: all mostlyclean clean distclean maintainer-clean install \
82 install-strip man dist tarball
86 include $(lls_m4_dir)/makefile
87 include $(test_dir)/makefile.test
88 ifeq ($(findstring clean, $(MAKECMDGOALS)),)
90 -include $(m4_lls_deps)
93 $(object_dir) $(man_dir) $(dep_dir) $(m4depdir) $(lls_suite_dir):
96 CPPFLAGS += -DBINDIR='"$(bindir)"'
97 CPPFLAGS += -DCOPYRIGHT_YEAR='"$(COPYRIGHT_YEAR)"'
98 CPPFLAGS += -DBUILD_DATE='"$(build_date)"'
99 CPPFLAGS += -DLOGLEVELS='$(LOGLEVELS)'
100 CPPFLAGS += -DUNAME_RS='"$(uname_rs)"'
101 CPPFLAGS += -DCC_VERSION='"$(cc_version)"'
102 CPPFLAGS += -I/usr/local/include
103 CPPFLAGS += -I$(lls_suite_dir)
104 CPPFLAGS += $(lopsub_cppflags)
106 STRICT_CFLAGS += -fno-strict-aliasing
109 STRICT_CFLAGS += -Wundef -W -Wuninitialized
110 STRICT_CFLAGS += -Wchar-subscripts
111 STRICT_CFLAGS += -Werror-implicit-function-declaration
112 STRICT_CFLAGS += -Wmissing-noreturn
113 STRICT_CFLAGS += -Wbad-function-cast
114 STRICT_CFLAGS += -Wredundant-decls
115 STRICT_CFLAGS += -Wno-sign-compare -Wno-unknown-pragmas
116 STRICT_CFLAGS += -Wdeclaration-after-statement
117 STRICT_CFLAGS += -Wformat -Wformat-security -Wmissing-format-attribute
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 cc-option = $(shell \
130 $(CC) $(1) -Werror -c -x c /dev/null -o /dev/null > /dev/null 2>&1 \
134 STRICT_CFLAGS += $(call cc-option, -Wformat-signedness)
136 # To put more focus on warnings, be less verbose as default
137 # Use 'make V=1' to see the full commands
138 ifeq ("$(origin V)", "command line")
144 audiod_commands := $(addprefix $(lls_suite_dir)/, \
145 $(addsuffix _cmd.lsg.man, audiod recv filter write))
146 filter_commands := $(lls_suite_dir)/filter_cmd.lsg.man
147 play_commands := $(lls_suite_dir)/play_cmd.lsg.man
148 recv_commands := $(lls_suite_dir)/recv_cmd.lsg.man
149 server_commands := $(lls_suite_dir)/server_cmd.lsg.man
150 write_commands := $(lls_suite_dir)/write_cmd.lsg.man
152 $(man_dir)/para_audiod.1: $(audiod_commands)
153 $(man_dir)/para_filter.1: $(filter_commands)
154 $(man_dir)/para_play.1: $(play_commands)
155 $(man_dir)/para_recv.1: $(recv_commands)
156 $(man_dir)/para_server.1: $(server_commands)
157 $(man_dir)/para_write.1: $(write_commands)
159 $(man_dir)/para_audiod.1: all_commands := $(audiod_commands)
160 $(man_dir)/para_filter.1: all_commands := $(filter_commands)
161 $(man_dir)/para_play.1: all_commands := $(play_commands)
162 $(man_dir)/para_recv.1: all_commands := $(recv_commands)
163 $(man_dir)/para_server.1: all_commands := $(server_commands)
164 $(man_dir)/para_write.1: all_commands := $(write_commands)
166 $(man_dir)/para_%.1: $(lls_suite_dir)/%.lsg.man \
167 $(lls_m4_dir)/copyright.m4 | $(man_dir)
168 @[ -z "$(Q)" ] || echo 'LLSMAN $<'
169 $(Q) cat $< $(all_commands) > $@
170 $(Q) $(M4) -D COPYRIGHT_YEAR=$(COPYRIGHT_YEAR) $(lls_m4_dir)/copyright.m4 >> $@
172 $(object_dir)/%.o: %.c | $(object_dir)
174 $(object_dir)/opus%.o: CPPFLAGS += $(opus_cppflags)
175 $(object_dir)/gui.o $(object_dir)/gui%.o \
176 : CPPFLAGS += $(curses_cppflags)
177 $(object_dir)/spx%.o: CPPFLAGS += $(speex_cppflags)
178 $(object_dir)/flac%.o: CPPFLAGS += $(flac_cppflags)
180 $(object_dir)/mp3_afh.o: CPPFLAGS += $(id3tag_cppflags)
181 $(object_dir)/crypt.o: CPPFLAGS += $(openssl_cppflags)
182 $(object_dir)/gcrypt.o: CPPFLAGS += $(gcrypt_cppflags)
183 $(object_dir)/ao_write.o: CPPFLAGS += $(ao_cppflags)
184 $(object_dir)/alsa%.o: CPPFLAGS += $(alsa_cppflags)
186 $(object_dir)/interactive.o \
187 : CPPFLAGS += $(readline_cppflags)
189 $(object_dir)/resample_filter.o \
190 : CPPFLAGS += $(samplerate_cppflags)
192 $(object_dir)/oss_write.o \
193 : CPPFLAGS += $(oss_cppflags)
195 $(object_dir)/ao_write.o \
196 : CPPFLAGS += $(ao_cppflags) $(pthread_cppflags)
198 $(object_dir)/mp3dec_filter.o \
199 : CPPFLAGS += $(mad_cppflags)
201 $(object_dir)/aacdec_filter.o \
202 $(object_dir)/aac_afh.o \
203 : CPPFLAGS += $(faad_cppflags)
205 $(object_dir)/ogg_afh.o \
206 $(object_dir)/oggdec_filter.o \
207 : CPPFLAGS += $(vorbis_cppflags)
209 $(object_dir)/spx_common.o \
210 $(object_dir)/spxdec_filter.o \
211 $(object_dir)/spx_afh.o \
212 $(object_dir)/oggdec_filter.o \
213 $(object_dir)/ogg_afh.o \
214 $(object_dir)/ogg_afh_common.o \
215 $(object_dir)/opus%.o \
216 : CPPFLAGS += $(ogg_cppflags)
218 $(object_dir)/afs.o \
219 $(object_dir)/aft.o \
220 $(object_dir)/attribute.o \
221 $(object_dir)/blob.o \
222 $(object_dir)/mood.o \
223 $(object_dir)/playlist.o \
224 $(object_dir)/score.o \
225 $(object_dir)/server.o \
226 $(object_dir)/vss.o \
227 $(object_dir)/command.o \
228 $(object_dir)/http_send.o \
229 $(object_dir)/dccp_send.o \
230 $(object_dir)/udp_send.o \
231 $(object_dir)/send_common.o \
233 : CPPFLAGS += $(osl_cppflags)
235 $(object_dir)/compress_filter.o: CFLAGS += -O3
237 $(object_dir)/%.o: %.c | $(object_dir) $(dep_dir) $(lsg_h)
238 @[ -z "$(Q)" ] || echo 'CC $<'
239 $(Q) $(CC) -c -o $@ -MMD -MF $(dep_dir)/$(*F).d -MT $@ $(CPPFLAGS) \
240 $(STRICT_CFLAGS) $(CFLAGS) $<
242 para_recv para_afh para_play para_server: LDFLAGS += $(id3tag_ldflags)
243 para_write para_play para_audiod \
244 : LDFLAGS += $(ao_ldflags) $(pthread_ldflags)
245 para_client para_audioc para_play : LDFLAGS += $(readline_ldflags)
246 para_server: LDFLAGS += $(osl_ldflags)
247 para_gui: LDFLAGS += $(curses_ldflags)
260 $(samplerate_ldflags) \
263 para_mixer: LDFLAGS += -lm
284 : LDFLAGS += $(lopsub_ldflags)
300 para_afh para_recv para_server para_play: LDFLAGS += $(iconv_ldflags)
302 $(foreach exe,$(executables),$(eval para_$(exe): $$($(exe)_objs)))
303 $(prefixed_executables):
304 @[ -z "$(Q)" ] || echo 'LD $@'
305 $(Q) $(CC) $^ -o $@ $(LDFLAGS)
308 @[ -z "$(Q)" ] || echo 'MOSTLYCLEAN'
310 $(Q) rm -rf $(object_dir)
312 @[ -z "$(Q)" ] || echo 'CLEAN'
313 $(Q) rm -rf $(build_dir)
315 @[ -z "$(Q)" ] || echo 'DISTCLEAN'
316 $(Q) rm -f Makefile autoscan.log config.status config.log
317 $(Q) rm -f config.h configure config.h.in
318 maintainer-clean: distclean
319 @[ -z "$(Q)" ] || echo 'MAINTAINER-CLEAN'
320 $(Q) rm -f *.tar.bz2 *.tar.xz
321 $(Q) rm -f GPATH GRTAGS GSYMS GTAGS
324 INSTALL_PROGRAM ?= $(INSTALL)
325 INSTALL_DATA ?= $(INSTALL) -m 644
326 ifneq ($(findstring strip, $(MAKECMDGOALS)),)
330 install install-strip: all man
331 $(MKDIR_P) $(DESTDIR)$(bindir) $(DESTDIR)$(mandir)
332 $(INSTALL) $(strip_option) $(prefixed_executables) $(DESTDIR)$(bindir)
333 $(INSTALL_DATA) $(man_pages) $(DESTDIR)$(mandir)
334 $(MKDIR_P) $(DESTDIR)$(vardir) >/dev/null 2>&1 || true # not fatal, so don't complain
336 $(tarball) dist tarball:
337 $(Q) rm -rf $(tarball) $(tarball_pfx)
338 $(Q) git archive --format=tar --prefix=$(tarball_pfx)/ HEAD \
339 | tar --delete $(tarball_delete) > $(tarball_pfx).tar
340 $(Q) $(MKDIR_P) $(tarball_pfx)
341 $(Q) ./GIT-VERSION-GEN > $(tarball_pfx)/VERSION
342 $(Q) cp $(autocrap) $(tarball_pfx)
343 $(Q) tar rf $(tarball_pfx).tar $(tarball_pfx)/*
344 $(Q) xz -9 $(tarball_pfx).tar
345 $(Q) ls -l $(tarball)
346 $(Q) ln -sf $(tarball) paraslash-git.tar.xz
347 $(Q) rm -rf $(tarball_pfx)