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 yy_build_dir = $(build_dir)/yy
38 # sort removes duplicate words, which is all we need here
39 all_objs := $(sort $(recv_objs) $(filter_objs) $(client_objs) $(gui_objs) \
40 $(audiod_objs) $(audioc_objs) $(mixer_objs) $(server_objs) \
41 $(write_objs) $(afh_objs) $(play_objs))
42 deps := $(addprefix $(dep_dir)/, $(all_objs:.o=.d))
43 deps += $(addprefix $(dep_dir)/, mp.bison.d mp.flex.d)
46 audioc_objs += audioc.lsg.o
47 audiod_objs += $(addsuffix _cmd.lsg.o, recv filter audiod write) \
48 client.lsg.o audiod.lsg.o
49 client_objs += client.lsg.o
50 mixer_objs += mixer.lsg.o
51 filter_objs += filter_cmd.lsg.o filter.lsg.o
53 play_objs += $(addsuffix _cmd.lsg.o, recv filter play write) play.lsg.o
54 recv_objs += recv_cmd.lsg.o recv.lsg.o
55 server_objs += server_cmd.lsg.o server.lsg.o
56 write_objs += write_cmd.lsg.o write.lsg.o
58 cmd_suites := $(addsuffix _cmd, audiod server play recv filter write)
59 suites := $(addprefix $(lls_suite_dir)/, $(cmd_suites) $(executables))
60 m4_lls_deps := $(addsuffix .m4d, $(suites))
61 lsg_h := $(addsuffix .lsg.h, $(suites))
63 # flex/bison objects and headers are only needed if para_server is built
64 ifeq ("$(findstring server, $(executables))", "server")
65 server_objs += mp.flex.o mp.bison.o
66 yy_h := $(yy_build_dir)/mp.bison.h
69 # now prefix all objects with object dir
70 recv_objs := $(addprefix $(object_dir)/, $(recv_objs))
71 filter_objs := $(addprefix $(object_dir)/, $(filter_objs))
72 client_objs := $(addprefix $(object_dir)/, $(client_objs))
73 gui_objs := $(addprefix $(object_dir)/, $(gui_objs))
74 audiod_objs := $(addprefix $(object_dir)/, $(audiod_objs))
75 audioc_objs := $(addprefix $(object_dir)/, $(audioc_objs))
76 mixer_objs := $(addprefix $(object_dir)/, $(mixer_objs))
77 server_objs := $(addprefix $(object_dir)/, $(server_objs))
78 write_objs := $(addprefix $(object_dir)/, $(write_objs))
79 afh_objs := $(addprefix $(object_dir)/, $(afh_objs))
80 play_objs := $(addprefix $(object_dir)/, $(play_objs))
82 man_pages := $(patsubst %, $(man_dir)/%.1, $(prefixed_executables))
84 autocrap := config.h.in configure
85 tarball_pfx := $(PACKAGE_TARNAME)-$(GIT_VERSION)
86 tarball_delete := $(addprefix $(tarball_pfx)/, web .gitignore)
87 tarball := $(tarball_pfx).tar.xz
89 all: $(prefixed_executables) $(man_pages)
90 .PHONY: all mostlyclean clean distclean maintainer-clean install \
91 install-strip man dist tarball
95 include $(lls_m4_dir)/makefile
96 include $(test_dir)/makefile.test
97 include $(yy_src_dir)/makefile
98 ifeq ($(findstring clean, $(MAKECMDGOALS)),)
100 -include $(m4_lls_deps)
103 $(object_dir) $(man_dir) $(dep_dir) $(m4depdir) $(lls_suite_dir) \
107 CPPFLAGS += -DBINDIR='"$(bindir)"'
108 CPPFLAGS += -DCOPYRIGHT_YEAR='"$(COPYRIGHT_YEAR)"'
109 CPPFLAGS += -DBUILD_DATE='"$(build_date)"'
110 CPPFLAGS += -DLOGLEVELS='$(LOGLEVELS)'
111 CPPFLAGS += -DUNAME_RS='"$(uname_rs)"'
112 CPPFLAGS += -DCC_VERSION='"$(cc_version)"'
113 CPPFLAGS += -I/usr/local/include
114 CPPFLAGS += -I$(lls_suite_dir)
115 CPPFLAGS += -I$(yy_build_dir)
116 CPPFLAGS += $(lopsub_cppflags)
118 STRICT_CFLAGS += -fno-strict-aliasing
121 STRICT_CFLAGS += -Wundef -W -Wuninitialized
122 STRICT_CFLAGS += -Wchar-subscripts
123 STRICT_CFLAGS += -Werror-implicit-function-declaration
124 STRICT_CFLAGS += -Wmissing-noreturn
125 STRICT_CFLAGS += -Wbad-function-cast
126 STRICT_CFLAGS += -Wredundant-decls
127 STRICT_CFLAGS += -Wno-sign-compare -Wno-unknown-pragmas
128 STRICT_CFLAGS += -Wdeclaration-after-statement
129 STRICT_CFLAGS += -Wformat -Wformat-security -Wmissing-format-attribute
131 ifeq ($(uname_s),Linux)
132 # these cause warnings on *BSD
133 CPPFLAGS += -Wunused-macros
134 STRICT_CFLAGS += -fdata-sections -ffunction-sections
135 STRICT_CFLAGS += -Wstrict-prototypes
136 STRICT_CFLAGS += -Wshadow
137 STRICT_CFLAGS += -Wunused -Wall
138 LDFLAGS += -Wl,--gc-sections
141 cc-option = $(shell \
142 $(CC) $(1) -Werror -c -x c /dev/null -o /dev/null > /dev/null 2>&1 \
146 STRICT_CFLAGS += $(call cc-option, -Wformat-signedness)
148 # To put more focus on warnings, be less verbose as default
149 # Use 'make V=1' to see the full commands
150 ifeq ("$(origin V)", "command line")
156 audiod_commands := $(addprefix $(lls_suite_dir)/, \
157 $(addsuffix _cmd.lsg.man, audiod recv filter write))
158 filter_commands := $(lls_suite_dir)/filter_cmd.lsg.man
159 play_commands := $(lls_suite_dir)/play_cmd.lsg.man
160 recv_commands := $(lls_suite_dir)/recv_cmd.lsg.man
161 server_commands := $(lls_suite_dir)/server_cmd.lsg.man
162 write_commands := $(lls_suite_dir)/write_cmd.lsg.man
164 $(man_dir)/para_audiod.1: $(audiod_commands)
165 $(man_dir)/para_filter.1: $(filter_commands)
166 $(man_dir)/para_play.1: $(play_commands)
167 $(man_dir)/para_recv.1: $(recv_commands)
168 $(man_dir)/para_server.1: $(server_commands)
169 $(man_dir)/para_write.1: $(write_commands)
171 $(man_dir)/para_audiod.1: all_commands := $(audiod_commands)
172 $(man_dir)/para_filter.1: all_commands := $(filter_commands)
173 $(man_dir)/para_play.1: all_commands := $(play_commands)
174 $(man_dir)/para_recv.1: all_commands := $(recv_commands)
175 $(man_dir)/para_server.1: all_commands := $(server_commands)
176 $(man_dir)/para_write.1: all_commands := $(write_commands)
178 $(man_dir)/para_%.1: $(lls_suite_dir)/%.lsg.man \
179 $(lls_m4_dir)/copyright.m4 | $(man_dir)
180 @[ -z "$(Q)" ] || echo 'LLSMAN $<'
181 $(Q) cat $< $(all_commands) > $@
182 $(Q) $(M4) -D COPYRIGHT_YEAR=$(COPYRIGHT_YEAR) $(lls_m4_dir)/copyright.m4 >> $@
184 $(object_dir)/%.o: %.c | $(object_dir)
186 $(object_dir)/opus%.o: CPPFLAGS += $(opus_cppflags)
187 $(object_dir)/gui.o $(object_dir)/gui%.o \
188 : CPPFLAGS += $(curses_cppflags)
189 $(object_dir)/spx%.o: CPPFLAGS += $(speex_cppflags)
190 $(object_dir)/flac%.o: CPPFLAGS += $(flac_cppflags)
192 $(object_dir)/mp3_afh.o: CPPFLAGS += $(id3tag_cppflags)
193 $(object_dir)/crypt.o: CPPFLAGS += $(openssl_cppflags)
194 $(object_dir)/gcrypt.o: CPPFLAGS += $(gcrypt_cppflags)
195 $(object_dir)/ao_write.o: CPPFLAGS += $(ao_cppflags)
196 $(object_dir)/alsa%.o: CPPFLAGS += $(alsa_cppflags)
198 $(object_dir)/interactive.o \
199 : CPPFLAGS += $(readline_cppflags)
201 $(object_dir)/resample_filter.o \
202 : CPPFLAGS += $(samplerate_cppflags)
204 $(object_dir)/oss_write.o \
205 : CPPFLAGS += $(oss_cppflags)
207 $(object_dir)/ao_write.o \
208 : CPPFLAGS += $(ao_cppflags) $(pthread_cppflags)
210 $(object_dir)/mp3dec_filter.o \
211 : CPPFLAGS += $(mad_cppflags)
213 $(object_dir)/aacdec_filter.o \
214 $(object_dir)/aac_afh.o \
215 : CPPFLAGS += $(faad_cppflags)
217 $(object_dir)/ogg_afh.o \
218 $(object_dir)/oggdec_filter.o \
219 : CPPFLAGS += $(vorbis_cppflags)
221 $(object_dir)/spx_common.o \
222 $(object_dir)/spxdec_filter.o \
223 $(object_dir)/spx_afh.o \
224 $(object_dir)/oggdec_filter.o \
225 $(object_dir)/ogg_afh.o \
226 $(object_dir)/ogg_afh_common.o \
227 $(object_dir)/opus%.o \
228 : CPPFLAGS += $(ogg_cppflags)
230 $(object_dir)/afs.o \
231 $(object_dir)/aft.o \
232 $(object_dir)/attribute.o \
233 $(object_dir)/blob.o \
234 $(object_dir)/mood.o \
235 $(object_dir)/playlist.o \
236 $(object_dir)/score.o \
237 $(object_dir)/server.o \
238 $(object_dir)/vss.o \
239 $(object_dir)/command.o \
240 $(object_dir)/http_send.o \
241 $(object_dir)/dccp_send.o \
242 $(object_dir)/udp_send.o \
243 $(object_dir)/send_common.o \
245 : CPPFLAGS += $(osl_cppflags)
247 $(object_dir)/compress_filter.o: CFLAGS += -O3
249 $(object_dir)/%.o: %.c | $(object_dir) $(dep_dir) $(lsg_h) $(yy_h)
250 @[ -z "$(Q)" ] || echo 'CC $<'
251 $(Q) $(CC) -c -o $@ -MMD -MF $(dep_dir)/$(*F).d -MT $@ $(CPPFLAGS) \
252 $(STRICT_CFLAGS) $(CFLAGS) $<
254 para_recv para_afh para_play para_server: LDFLAGS += $(id3tag_ldflags)
255 para_write para_play para_audiod \
256 : LDFLAGS += $(ao_ldflags) $(pthread_ldflags)
257 para_client para_audioc para_play : LDFLAGS += $(readline_ldflags)
258 para_server: LDFLAGS += $(osl_ldflags)
259 para_gui: LDFLAGS += $(curses_ldflags)
272 $(samplerate_ldflags) \
275 para_mixer: LDFLAGS += -lm
296 : LDFLAGS += $(lopsub_ldflags)
312 para_afh para_recv para_server para_play: LDFLAGS += $(iconv_ldflags)
314 $(foreach exe,$(executables),$(eval para_$(exe): $$($(exe)_objs)))
315 $(prefixed_executables):
316 @[ -z "$(Q)" ] || echo 'LD $@'
317 $(Q) $(CC) $^ -o $@ $(LDFLAGS)
320 @[ -z "$(Q)" ] || echo 'MOSTLYCLEAN'
322 $(Q) rm -rf $(object_dir)
324 @[ -z "$(Q)" ] || echo 'CLEAN'
325 $(Q) rm -rf $(build_dir)
327 @[ -z "$(Q)" ] || echo 'DISTCLEAN'
328 $(Q) rm -f Makefile autoscan.log config.status config.log
329 $(Q) rm -f config.h configure config.h.in
330 maintainer-clean: distclean
331 @[ -z "$(Q)" ] || echo 'MAINTAINER-CLEAN'
332 $(Q) rm -f *.tar.bz2 *.tar.xz
333 $(Q) rm -f GPATH GRTAGS GSYMS GTAGS
336 INSTALL_PROGRAM ?= $(INSTALL)
337 INSTALL_DATA ?= $(INSTALL) -m 644
338 ifneq ($(findstring strip, $(MAKECMDGOALS)),)
342 install install-strip: all man
343 $(MKDIR_P) $(DESTDIR)$(bindir) $(DESTDIR)$(mandir)
344 $(INSTALL) $(strip_option) $(prefixed_executables) $(DESTDIR)$(bindir)
345 $(INSTALL_DATA) $(man_pages) $(DESTDIR)$(mandir)
346 $(MKDIR_P) $(DESTDIR)$(vardir) >/dev/null 2>&1 || true # not fatal, so don't complain
348 $(tarball) dist tarball:
349 $(Q) rm -rf $(tarball) $(tarball_pfx)
350 $(Q) git archive --format=tar --prefix=$(tarball_pfx)/ HEAD \
351 | tar --delete $(tarball_delete) > $(tarball_pfx).tar
352 $(Q) $(MKDIR_P) $(tarball_pfx)
353 $(Q) ./GIT-VERSION-GEN > $(tarball_pfx)/VERSION
354 $(Q) cp $(autocrap) $(tarball_pfx)
355 $(Q) tar rf $(tarball_pfx).tar $(tarball_pfx)/*
356 $(Q) xz -9 $(tarball_pfx).tar
357 $(Q) ls -l $(tarball)
358 $(Q) ln -sf $(tarball) paraslash-git.tar.xz
359 $(Q) rm -rf $(tarball_pfx)