]> git.tuebingen.mpg.de Git - paraslash.git/blob - Makefile.real
15abf14fcc7c43e4bf3eaa6d0f39cdc494acaa31
[paraslash.git] / Makefile.real
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.
4 .SUFFIXES:
5 MAKEFLAGS += -Rr
6 ifeq ("$(origin CC)", "default")
7         CC := cc
8 endif
9
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
14 MKDIR_P := mkdir -p
15 prefixed_executables := $(addprefix para_, $(executables))
16
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
23
24 ifeq ("$(origin O)", "command line")
25         build_dir := $(O)
26 else
27         build_dir := build
28 endif
29 object_dir := $(build_dir)/objects
30 dep_dir := $(build_dir)/deps
31 man_dir := $(build_dir)/man/man1
32 m4depdir := $(build_dir)/m4deps
33 lls_suite_dir := $(build_dir)/lls
34 lls_m4_dir := m4/lls
35 test_dir := t
36
37 # sort removes duplicate words, which is all we need here
38 all_objs := $(sort $(recv_objs) $(filter_objs) $(client_objs) $(gui_objs) \
39         $(audiod_objs) $(audioc_objs) $(fade_objs) $(server_objs) \
40         $(write_objs) $(afh_objs) $(play_objs))
41 deps := $(addprefix $(dep_dir)/, $(all_objs:.o=.d))
42
43 afh_objs += afh.lsg.o
44 audioc_objs += audioc.lsg.o
45 audiod_objs += $(addsuffix _cmd.lsg.o, recv filter audiod write) \
46         client.lsg.o audiod.lsg.o
47 client_objs += client.lsg.o
48 fade_objs += fade.lsg.o
49 filter_objs += filter_cmd.lsg.o filter.lsg.o
50 gui_objs += gui.lsg.o
51 play_objs += $(addsuffix _cmd.lsg.o, recv filter play write) play.lsg.o
52 recv_objs += recv_cmd.lsg.o recv.lsg.o
53 server_objs += server_cmd.lsg.o server.lsg.o
54 write_objs += write_cmd.lsg.o write.lsg.o
55
56 cmd_suites := $(addsuffix _cmd, audiod server play recv filter write)
57 suites := $(addprefix $(lls_suite_dir)/, $(cmd_suites) $(executables))
58 m4_lls_deps := $(addsuffix .m4d, $(suites))
59
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 fade_objs := $(addprefix $(object_dir)/, $(fade_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))
72
73 man_pages := $(patsubst %, $(man_dir)/%.1, $(prefixed_executables))
74
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.bz2
79
80 .PHONY: all clean clean2 distclean maintainer-clean install man tarball
81 all: $(prefixed_executables) $(man_pages)
82 man: $(man_pages)
83 tarball: $(tarball)
84
85 include $(lls_m4_dir)/makefile
86 include $(test_dir)/makefile.test
87 ifeq ($(findstring clean, $(MAKECMDGOALS)),)
88 -include $(deps)
89 -include $(m4_lls_deps)
90 endif
91
92 $(object_dir) $(man_dir) $(dep_dir) $(m4depdir) $(lls_suite_dir):
93         $(Q) $(MKDIR_P) $@
94
95 CPPFLAGS += -DBINDIR='"$(bindir)"'
96 CPPFLAGS += -DCOPYRIGHT_YEAR='"$(COPYRIGHT_YEAR)"'
97 CPPFLAGS += -DBUILD_DATE='"$(build_date)"'
98 CPPFLAGS += -DLOGLEVELS='$(LOGLEVELS)'
99 CPPFLAGS += -DUNAME_RS='"$(uname_rs)"'
100 CPPFLAGS += -DCC_VERSION='"$(cc_version)"'
101 CPPFLAGS += -I/usr/local/include
102 CPPFLAGS += -I$(lls_suite_dir)
103 CPPFLAGS += $(lopsub_cppflags)
104
105 STRICT_CFLAGS += -fno-strict-aliasing
106 STRICT_CFLAGS += -g
107 STRICT_CFLAGS += -Os
108 STRICT_CFLAGS += -Wundef -W -Wuninitialized
109 STRICT_CFLAGS += -Wchar-subscripts
110 STRICT_CFLAGS += -Werror-implicit-function-declaration
111 STRICT_CFLAGS += -Wmissing-noreturn
112 STRICT_CFLAGS += -Wbad-function-cast
113 STRICT_CFLAGS += -Wredundant-decls
114 STRICT_CFLAGS += -Wno-sign-compare -Wno-unknown-pragmas
115 STRICT_CFLAGS += -Wdeclaration-after-statement
116 STRICT_CFLAGS += -Wformat -Wformat-security -Wmissing-format-attribute
117
118 LDFLAGS += $(clock_gettime_ldflags)
119
120 ifeq ($(uname_s),Linux)
121         # these cause warnings on *BSD
122         CPPFLAGS += -Wunused-macros
123         STRICT_CFLAGS += -fdata-sections -ffunction-sections
124         STRICT_CFLAGS += -Wstrict-prototypes
125         STRICT_CFLAGS += -Wshadow
126         STRICT_CFLAGS += -Wunused -Wall
127         LDFLAGS += -Wl,--gc-sections
128 endif
129
130 cc-option = $(shell \
131         $(CC) $(1) -Werror -c -x c /dev/null -o /dev/null > /dev/null 2>&1 \
132         && echo "$(1)" \
133 )
134
135 STRICT_CFLAGS += $(call cc-option, -Wformat-signedness)
136
137 # To put more focus on warnings, be less verbose as default
138 # Use 'make V=1' to see the full commands
139 ifeq ("$(origin V)", "command line")
140         Q :=
141 else
142         Q := @
143 endif
144
145 audiod_commands := $(addprefix $(lls_suite_dir)/, \
146         $(addsuffix _cmd.lsg.man, audiod recv filter write))
147 filter_commands := $(lls_suite_dir)/filter_cmd.lsg.man
148 play_commands := $(lls_suite_dir)/play_cmd.lsg.man
149 recv_commands := $(lls_suite_dir)/recv_cmd.lsg.man
150 server_commands := $(lls_suite_dir)/server_cmd.lsg.man
151 write_commands := $(lls_suite_dir)/write_cmd.lsg.man
152
153 $(man_dir)/para_audiod.1: $(audiod_commands)
154 $(man_dir)/para_filter.1: $(filter_commands)
155 $(man_dir)/para_play.1: $(play_commands)
156 $(man_dir)/para_recv.1: $(recv_commands)
157 $(man_dir)/para_server.1: $(server_commands)
158 $(man_dir)/para_write.1: $(write_commands)
159
160 $(man_dir)/para_audiod.1: all_commands := $(audiod_commands)
161 $(man_dir)/para_filter.1: all_commands := $(filter_commands)
162 $(man_dir)/para_play.1: all_commands := $(play_commands)
163 $(man_dir)/para_recv.1: all_commands := $(recv_commands)
164 $(man_dir)/para_server.1: all_commands := $(server_commands)
165 $(man_dir)/para_write.1: all_commands := $(write_commands)
166
167 $(man_dir)/para_%.1: $(lls_suite_dir)/%.lsg.man \
168                 $(lls_m4_dir)/copyright.m4 | $(man_dir)
169         @[ -z "$(Q)" ] || echo 'LLSMAN $<'
170         $(Q) cat $< $(all_commands) > $@
171         $(Q) $(M4) -D COPYRIGHT_YEAR=$(COPYRIGHT_YEAR) $(lls_m4_dir)/copyright.m4 >> $@
172
173 $(object_dir)/%.o: %.c | $(object_dir)
174
175 $(object_dir)/opus%.o $(dep_dir)/opus%.d: CPPFLAGS += $(opus_cppflags)
176 $(object_dir)/gui.o $(object_dir)/gui%.o $(dep_dir)/gui%.d \
177 : CPPFLAGS += $(curses_cppflags)
178 $(object_dir)/spx%.o $(dep_dir)/spx%.d: CPPFLAGS += $(speex_cppflags)
179 $(object_dir)/flac%.o $(dep_dir)/flac%.d: CPPFLAGS += $(flac_cppflags)
180
181 $(object_dir)/mp3_afh.o $(dep_dir)/mp3_afh.d: CPPFLAGS += $(id3tag_cppflags)
182 $(object_dir)/crypt.o $(dep_dir)/crypt.d: CPPFLAGS += $(openssl_cppflags)
183 $(object_dir)/gcrypt.o $(dep_dir)/gcrypt.d: CPPFLAGS += $(gcrypt_cppflags)
184 $(object_dir)/ao_write.o $(dep_dir)/ao_write.d: CPPFLAGS += $(ao_cppflags)
185 $(object_dir)/aac_afh.o $(dep_dir)/aac_afh.d: CPPFLAGS += $(mp4v2_cppflags)
186 $(object_dir)/alsa%.o $(dep_dir)/alsa%.d: CPPFLAGS += $(alsa_cppflags)
187
188 $(object_dir)/interactive.o $(dep_dir)/interactive.d \
189 : CPPFLAGS += $(readline_cppflags)
190
191 $(object_dir)/resample_filter.o $(dep_dir)/resample_filter.d \
192 : CPPFLAGS += $(samplerate_cppflags)
193
194 $(object_dir)/oss_write.o $(dep_dir)/oss_write.d \
195 : CPPFLAGS += $(oss_cppflags)
196
197 $(object_dir)/ao_write.o $(dep_dir)/ao_write.d \
198 : CPPFLAGS += $(ao_cppflags) $(pthread_cppflags)
199
200 $(object_dir)/mp3dec_filter.o $(dep_dir)/mp3dec_filter.d \
201 : CPPFLAGS += $(mad_cppflags)
202
203 $(object_dir)/aacdec_filter.o $(dep_dir)/aacdec_filter.d \
204 $(object_dir)/aac_common.o $(dep_dir)/aac_common.d \
205 $(object_dir)/aac_afh.o $(dep_dir)/aac_afh.d \
206 : CPPFLAGS += $(faad_cppflags)
207
208 $(object_dir)/ogg_afh.o $(dep_dir)/ogg_afh.d \
209 $(object_dir)/oggdec_filter.o $(dep_dir)/oggdec_filter.d \
210 : CPPFLAGS += $(vorbis_cppflags)
211
212 $(object_dir)/spx_common.o $(dep_dir)/spx_common.d \
213 $(object_dir)/spxdec_filter.o $(dep_dir)/spxdec_filter.d \
214 $(object_dir)/spx_afh.o $(dep_dir)/spx_afh.d \
215 $(object_dir)/oggdec_filter.o $(dep_dir)/oggdec_filter.d \
216 $(object_dir)/ogg_afh.o $(dep_dir)/ogg_afh.d \
217 $(object_dir)/ogg_afh_common.o $(dep_dir)/ogg_afh_common.d \
218 $(object_dir)/opus%.o $(dep_dir)/opus%.d \
219 : CPPFLAGS += $(ogg_cppflags)
220
221 $(object_dir)/afs.o $(dep_dir)/afs.d \
222 $(object_dir)/aft.o $(dep_dir)/aft.d \
223 $(object_dir)/attribute.o $(dep_dir)/attribute.d \
224 $(object_dir)/blob.o $(dep_dir)/blob.d  \
225 $(object_dir)/mood.o $(dep_dir)/mood.d \
226 $(object_dir)/playlist.o $(dep_dir)/playlist.d \
227 $(object_dir)/score.o $(dep_dir)/score.d \
228 $(object_dir)/server.o $(dep_dir)/server.d \
229 $(object_dir)/vss.o $(dep_dir)/vss.d \
230 $(object_dir)/command.o $(dep_dir)/command.d \
231 $(object_dir)/http_send.o $(dep_dir)/http_send.d \
232 $(object_dir)/dccp_send.o $(dep_dir)/dccp_send.d \
233 $(object_dir)/udp_send.o $(dep_dir)/udp_send.d \
234 $(object_dir)/send_common.o $(dep_dir)/send_common.d \
235 $(object_dir)/mm.o $(dep_dir)/mm.d \
236 : CPPFLAGS += $(osl_cppflags)
237
238 $(object_dir)/compress_filter.o: CFLAGS += -O3
239
240 $(object_dir)/%.o: %.c | $(object_dir)
241         @[ -z "$(Q)" ] || echo 'CC $<'
242         $(Q) $(CC) -c -o $@ -MMD -MF $(dep_dir)/$(*F).d -MT $@ $(CPPFLAGS) \
243                 $(STRICT_CFLAGS) $(CFLAGS) $<
244
245 # The compiler outputs dependencies either as foo.h or as some_directory/foo.h,
246 # depending on whether the latter file exists. Since make needs the directory
247 # part we prefix the dependency as appropriate.
248 $(dep_dir)/%.d: %.c | $(dep_dir)
249         @[ -z "$(Q)" ] || echo 'DEP $<'
250         $(Q) $(CC) $(CPPFLAGS) -MM -MG -MT $(object_dir)/$(*F).o $< \
251                 | sed -e "s@ \([a-zA-Z0-9_]\{1,\}.lsg.h\)@ $(lls_suite_dir)/\1@g" > $@
252
253 para_recv para_afh para_play para_server: LDFLAGS += $(id3tag_ldflags)
254 para_write para_play para_audiod \
255 : LDFLAGS += $(ao_ldflags) $(pthread_ldflags) $(core_audio_ldflags)
256 para_client para_audioc para_play : LDFLAGS += $(readline_ldflags)
257 para_server: LDFLAGS += $(osl_ldflags)
258 para_gui: LDFLAGS += $(curses_ldflags)
259 para_server \
260 para_client \
261 para_audiod \
262 :LDFLAGS += \
263         $(crypto_ldflags)
264
265 para_audiod \
266 para_filter \
267 para_play \
268 : LDFLAGS += \
269         $(mad_ldflags) \
270         $(faad_ldflags) \
271         $(samplerate_ldflags) \
272         -lm
273
274 para_write \
275 para_play \
276 para_audiod \
277 para_fade \
278 : LDFLAGS += \
279         $(oss_ldflags) \
280         $(alsa_ldflags)
281
282 para_afh \
283 para_audioc \
284 para_audiod \
285 para_client \
286 para_fade \
287 para_filter \
288 para_gui \
289 para_play \
290 para_recv \
291 para_server \
292 para_write \
293 : LDFLAGS += $(lopsub_ldflags)
294
295 para_server \
296 para_filter \
297 para_audiod \
298 para_play \
299 para_afh \
300 para_recv \
301 : LDFLAGS += \
302         $(ogg_ldflags) \
303         $(vorbis_ldflags) \
304         $(speex_ldflags) \
305         $(opus_ldflags) \
306         $(faad_ldflags) \
307         $(flac_ldflags)
308
309 para_server \
310 para_play \
311 para_afh \
312 para_recv \
313 : LDFLAGS += \
314         $(mp4v2_ldflags)
315
316 para_afh para_recv para_server para_play: LDFLAGS += $(iconv_ldflags)
317
318 $(foreach exe,$(executables),$(eval para_$(exe): $$($(exe)_objs)))
319 $(prefixed_executables):
320         @[ -z "$(Q)" ] || echo 'LD $@'
321         $(Q) $(CC) $^ -o $@ $(LDFLAGS)
322
323 clean:
324         @[ -z "$(Q)" ] || echo 'CLEAN'
325         $(Q) rm -f para_*
326         $(Q) rm -rf $(object_dir)
327
328 clean2: clean
329         @[ -z "$(Q)" ] || echo 'CLEAN2'
330         $(Q) rm -rf $(build_dir)
331 distclean: clean2 test-clean
332         @[ -z "$(Q)" ] || echo 'DISTCLEAN'
333         $(Q) rm -f Makefile autoscan.log config.status config.log
334         $(Q) rm -f GPATH GRTAGS GSYMS GTAGS
335
336 maintainer-clean: distclean
337         @[ -z "$(Q)" ] || echo 'MAINTAINER-CLEAN'
338         $(Q) rm -f *.tar.bz2 config.h configure config.h.in
339
340 install: all man
341         $(MKDIR_P) $(bindir) $(mandir)
342         $(INSTALL) -s --strip-program $(STRIP) -m 755 \
343                 $(prefixed_executables) $(bindir)
344         $(INSTALL) -m 644 $(man_pages) $(mandir)
345         $(MKDIR_P) $(vardir) >/dev/null 2>&1 || true # not fatal, so don't complain
346
347 $(tarball):
348         $(Q) rm -rf $(tarball) $(tarball_pfx)
349         $(Q) git archive --format=tar --prefix=$(tarball_pfx)/ HEAD \
350                 | tar --delete $(tarball_delete) > $(tarball_pfx).tar
351         $(Q) $(MKDIR_P) $(tarball_pfx)
352         $(Q) ./GIT-VERSION-GEN > $(tarball_pfx)/VERSION
353         $(Q) cp $(autocrap) $(tarball_pfx)
354         $(Q) tar rf $(tarball_pfx).tar $(tarball_pfx)/*
355         $(Q) bzip2 -9 $(tarball_pfx).tar
356         $(Q) ls -l $(tarball)
357         $(Q) ln -sf $(tarball) paraslash-git.tar.bz2
358         $(Q) rm -rf $(tarball_pfx)