]> git.tuebingen.mpg.de Git - paraslash.git/blob - Makefile.real
udp_send.c: Remove pointless function.
[paraslash.git] / Makefile.real
1 vardir := /var/paraslash
2 mandir := $(datarootdir)/man/man1
3 STRIP := $(CROSS_COMPILE)strip
4 HOSTCC ?= cc
5 MKDIR_P := mkdir -p
6 prefixed_executables := $(addprefix para_, $(executables))
7
8 build_date := $(shell date)
9 uname_s := $(shell uname -s 2>/dev/null || echo "UNKNOWN_OS")
10 uname_rs := $(shell uname -rs)
11 cc_version := $(shell $(CC) --version | head -n 1)
12 GIT_VERSION := $(shell ./GIT-VERSION-GEN git-version.h)
13 build_date := $(shell date)
14
15 ifeq ("$(origin O)", "command line")
16         build_dir := $(O)
17 else
18         build_dir := build
19 endif
20 ggo_dir := $(build_dir)/ggo
21 object_dir := $(build_dir)/objects
22 dep_dir := $(build_dir)/deps
23 man_dir := $(build_dir)/man/man1
24 cmdline_dir := $(build_dir)/cmdline
25 cmdlist_dir := $(build_dir)/cmdlist
26 m4depdir := $(build_dir)/m4deps
27 help2man_dir := $(build_dir)/help2man
28 hostbin_dir := $(build_dir)/host/bin
29 m4_ggo_dir := m4/gengetopt
30 test_dir := t
31
32 # sort removes duplicate words, which is all we need here
33 all_objs := $(sort $(recv_objs) $(filter_objs) $(client_objs) $(gui_objs) \
34         $(audiod_objs) $(audioc_objs) $(fade_objs) $(server_objs) \
35         $(write_objs) $(afh_objs) $(play_objs))
36 deps := $(addprefix $(dep_dir)/, $(filter-out %.cmdline.d, $(all_objs:.o=.d)))
37 m4_deps := $(addprefix $(m4depdir)/, $(addsuffix .m4d, $(executables)))
38
39 # now prefix all objects with object dir
40 recv_objs := $(addprefix $(object_dir)/, $(recv_objs))
41 filter_objs := $(addprefix $(object_dir)/, $(filter_objs))
42 client_objs := $(addprefix $(object_dir)/, $(client_objs))
43 gui_objs := $(addprefix $(object_dir)/, $(gui_objs))
44 audiod_objs := $(addprefix $(object_dir)/, $(audiod_objs))
45 audioc_objs := $(addprefix $(object_dir)/, $(audioc_objs))
46 fade_objs := $(addprefix $(object_dir)/, $(fade_objs))
47 server_objs := $(addprefix $(object_dir)/, $(server_objs))
48 write_objs := $(addprefix $(object_dir)/, $(write_objs))
49 afh_objs := $(addprefix $(object_dir)/, $(afh_objs))
50 play_objs := $(addprefix $(object_dir)/, $(play_objs))
51
52 man_pages := $(patsubst %, $(man_dir)/%.1, $(prefixed_executables))
53
54 autocrap := config.h.in configure
55 tarball_pfx := $(PACKAGE_TARNAME)-$(GIT_VERSION)
56 tarball_delete := $(addprefix $(tarball_pfx)/, web .gitignore)
57 tarball := $(tarball_pfx).tar.bz2
58
59 .PHONY: dep all clean clean2 distclean maintainer-clean install man tarball
60 all: dep $(prefixed_executables) $(man_pages)
61 dep: $(deps)
62 man: $(man_pages)
63 tarball: $(tarball)
64
65 include $(m4_ggo_dir)/makefile
66 include $(test_dir)/makefile.test
67 ifeq ($(findstring clean, $(MAKECMDGOALS)),)
68 -include $(deps)
69 -include $(m4_deps)
70 endif
71
72 $(object_dir) $(man_dir) $(ggo_dir) $(cmdline_dir) $(dep_dir) $(m4depdir) \
73                 $(help2man_dir) $(hostbin_dir) $(cmdlist_dir):
74         $(Q) $(MKDIR_P) $@
75
76 # When in doubt, use brute force (Ken Thompson)
77 TOUPPER = \
78 $(subst a,A,$(subst b,B,$(subst c,C,$(subst d,D,$(subst e,E,\
79 $(subst f,F,$(subst g,G,$(subst h,H,$(subst i,I,$(subst j,J,\
80 $(subst k,K,$(subst l,L,$(subst m,M,$(subst n,N,$(subst o,O,\
81 $(subst p,P,$(subst q,Q,$(subst r,R,$(subst s,S,$(subst t,T,\
82 $(subst u,U,$(subst v,V,$(subst w,W,$(subst x,X,$(subst y,Y,\
83 $(subst z,Z,$1))))))))))))))))))))))))))
84
85 CPPFLAGS += -DBINDIR='"$(bindir)"'
86 CPPFLAGS += -DBUILD_DATE='"$(build_date)"'
87 CPPFLAGS += -DUNAME_RS='"$(uname_rs)"'
88 CPPFLAGS += -DCC_VERSION='"$(cc_version)"'
89 CPPFLAGS += -DMAIN_INPUT_FILE_IS_$(*F)
90 CPPFLAGS += $(arch_cppflags)
91 CPPFLAGS += -I/usr/local/include
92 CPPFLAGS += -I$(cmdline_dir)
93 CPPFLAGS += -I$(cmdlist_dir)
94
95 CFLAGS += -Os
96 CFLAGS += -Wuninitialized
97 CFLAGS += -Wchar-subscripts
98 CFLAGS += -Werror-implicit-function-declaration
99 CFLAGS += -Wmissing-noreturn
100 CFLAGS += -Wbad-function-cast
101 CFLAGS += -fno-strict-aliasing
102
103 STRICT_CFLAGS = $(CFLAGS)
104 STRICT_CFLAGS += -g -Wundef -W
105 STRICT_CFLAGS += -Wredundant-decls
106 STRICT_CFLAGS += -Wno-sign-compare -Wno-unknown-pragmas
107 STRICT_CFLAGS += -Wformat -Wformat-security
108 STRICT_CFLAGS += -Wmissing-format-attribute
109
110 LDFLAGS += $(clock_gettime_ldflags)
111
112 ifeq ($(uname_s),Linux)
113         # these cause warnings on *BSD
114         CPPFLAGS += -Wunused-macros
115         STRICT_CFLAGS += -fdata-sections -ffunction-sections
116         STRICT_CFLAGS += -Wstrict-prototypes
117         STRICT_CFLAGS += -Wshadow
118         STRICT_CFLAGS += -Wunused -Wall
119         LDFLAGS += -Wl,--gc-sections
120 endif
121
122 # To put more focus on warnings, be less verbose as default
123 # Use 'make V=1' to see the full commands
124 ifeq ("$(origin V)", "command line")
125         Q :=
126 else
127         Q := @
128 endif
129
130 $(cmdlist_dir)/%.command_list.h: %.cmd %.c | $(cmdlist_dir)
131         @[ -z "$(Q)" ] || echo 'GEN $@'
132         $(Q) ./command_util.bash h < $< >$@
133 $(cmdlist_dir)/%.command_list.man: %.cmd %.c | $(cmdlist_dir)
134         @[ -z "$(Q)" ] || echo 'GEN $@'
135         $(Q) ./command_util.bash man < $< > $@
136 $(cmdlist_dir)/%.completion.h: %.cmd | $(cmdlist_dir)
137         @[ -z "$(Q)" ] || echo 'GEN $@'
138         $(Q) ./command_util.bash compl $(strip $(call TOUPPER,$(*F)))_COMPLETERS \
139                 $(strip $(call TOUPPER,$(*F)))_COMMANDS < $< > $@
140
141 $(cmdlist_dir)/server.command_list.h \
142 $(cmdlist_dir)/server.command_list.man \
143 $(cmdlist_dir)/server.completion.h \
144 : command.c
145
146 $(cmdlist_dir)/afs.command_list.h \
147 $(cmdlist_dir)/afs.command_list.man \
148 $(cmdlist_dir)/afs.completion.h \
149 : afs.c aft.c attribute.c
150
151 $(cmdlist_dir)/audiod.command_list.h \
152 $(cmdlist_dir)/audiod.command_list.man \
153 $(cmdlist_dir)/audiod.completion.h \
154 : audiod_command.c
155
156 server_command_lists := $(cmdlist_dir)/server.command_list.man \
157         $(cmdlist_dir)/afs.command_list.man
158 audiod_command_lists := $(cmdlist_dir)/audiod.command_list.man
159 play_command_lists := $(cmdlist_dir)/play.command_list.man
160
161 $(man_dir)/para_server.1: $(server_command_lists)
162 $(man_dir)/para_audiod.1: $(audiod_command_lists)
163 $(man_dir)/para_play.1: $(play_command_lists)
164
165 $(man_dir)/para_server.1: man_util_command_lists := $(server_command_lists)
166 $(man_dir)/para_audiod.1: man_util_command_lists := $(audiod_command_lists)
167 $(man_dir)/para_play.1: man_util_command_lists := $(play_command_lists)
168
169 $(man_dir)/para_%.1: $(ggo_dir)/%.ggo man_util.bash | $(man_dir) $(help2man_dir)
170         @[ -z "$(Q)" ] || echo 'MAN $<'
171         $(Q) \
172                 COMMAND_LISTS="$(man_util_command_lists)" \
173                 FILTERS="$(filters)" \
174                 GENGETOPT=$(GENGETOPT) \
175                 GGO_DIR=$(ggo_dir) \
176                 HELP2MAN=$(HELP2MAN) \
177                 HELP2MAN_DIR=$(help2man_dir) \
178                 RECEIVERS="$(receivers)" \
179                 VERSION="$(GIT_VERSION)" \
180                 WRITERS="$(writers)" \
181                 ./man_util.bash $@
182
183 $(hostbin_dir)/error2: error2.c | $(hostbin_dir)
184         @[ -z "$(Q)" ] || echo 'HCC $<'
185         $(Q) $(HOSTCC) -o $@ $<
186 error2.h: $(hostbin_dir)/error2 config.h
187         @[ -z "$(Q)" ] || echo 'ER2 $<'
188         @echo "$(object_executable_matrix)" | $< > $@
189
190 $(object_dir)/%.o: %.c | $(object_dir)
191
192 $(object_dir)/opus%.o $(dep_dir)/opus%.d: CPPFLAGS += $(opus_cppflags)
193 $(object_dir)/gui.o $(object_dir)/gui%.o $(dep_dir)/gui%.d \
194 : CPPFLAGS += $(curses_cppflags)
195 $(object_dir)/spx%.o $(dep_dir)/spx%.d: CPPFLAGS += $(speex_cppflags)
196 $(object_dir)/flac%.o $(dep_dir)/flac%.d: CPPFLAGS += $(flac_cppflags)
197
198 $(object_dir)/mp3_afh.o $(dep_dir)/mp3_afh.d: CPPFLAGS += $(id3tag_cppflags)
199 $(object_dir)/crypt.o $(dep_dir)/crypt.d: CPPFLAGS += $(openssl_cppflags)
200 $(object_dir)/gcrypt.o $(dep_dir)/gcrypt.d: CPPFLAGS += $(gcrypt_cppflags)
201 $(object_dir)/ao_write.o $(dep_dir)/ao_write.d: CPPFLAGS += $(ao_cppflags)
202 $(object_dir)/aac_afh.o $(dep_dir)/aac_afh.d: CPPFLAGS += $(mp4v2_cppflags)
203 $(object_dir)/alsa%.o $(dep_dir)/alsa%.d: CPPFLAGS += $(alsa_cppflags)
204
205 $(object_dir)/interactive.o $(dep_dir)/interactive.d \
206 : CPPFLAGS += $(readline_cppflags)
207
208 $(object_dir)/resample_filter.o $(dep_dir)/resample_filter.d \
209 : CPPFLAGS += $(samplerate_cppflags)
210
211 $(object_dir)/oss_write.o $(dep_dir)/oss_write.d \
212 : CPPFLAGS += $(oss_cppflags)
213
214 $(object_dir)/ao_write.o $(dep_dir)/ao_write.d \
215 : CPPFLAGS += $(ao_cppflags) $(pthread_cppflags)
216
217 $(object_dir)/mp3dec_filter.o $(dep_dir)/mp3dec_filter.d \
218 : CPPFLAGS += $(mad_cppflags)
219
220 $(object_dir)/aacdec_filter.o $(dep_dir)/aacdec_filter.d \
221 $(object_dir)/aac_common.o $(dep_dir)/aac_common.d \
222 $(object_dir)/aac_afh.o $(dep_dir)/aac_afh.d \
223 : CPPFLAGS += $(faad_cppflags)
224
225 $(object_dir)/ogg_afh.o $(dep_dir)/ogg_afh.d \
226 $(object_dir)/oggdec_filter.o $(dep_dir)/oggdec_filter.d \
227 : CPPFLAGS += $(vorbis_cppflags)
228
229 $(object_dir)/spx_common.o $(dep_dir)/spx_common.d \
230 $(object_dir)/spxdec_filter.o $(dep_dir)/spxdec_filter.d \
231 $(object_dir)/spx_afh.o $(dep_dir)/spx_afh.d \
232 $(object_dir)/oggdec_filter.o $(dep_dir)/oggdec_filter.d \
233 $(object_dir)/ogg_afh.o $(dep_dir)/ogg_afh.d \
234 $(object_dir)/ogg_afh_common.o $(dep_dir)/ogg_afh_common.d \
235 $(object_dir)/opus%.o $(dep_dir)/opus%.d \
236 : CPPFLAGS += $(ogg_cppflags)
237
238 $(object_dir)/afs.o $(dep_dir)/afs.d \
239 $(object_dir)/aft.o $(dep_dir)/aft.d \
240 $(object_dir)/attribute.o $(dep_dir)/attribute.d \
241 $(object_dir)/blob.o $(dep_dir)/blob.d  \
242 $(object_dir)/mood.o $(dep_dir)/mood.d \
243 $(object_dir)/playlist.o $(dep_dir)/playlist.d \
244 $(object_dir)/score.o $(dep_dir)/score.d \
245 $(object_dir)/server.o $(dep_dir)/server.d \
246 $(object_dir)/vss.o $(dep_dir)/vss.d \
247 $(object_dir)/command.o $(dep_dir)/command.d \
248 $(object_dir)/http_send.o $(dep_dir)/http_send.d \
249 $(object_dir)/dccp_send.o $(dep_dir)/dccp_send.d \
250 $(object_dir)/udp_send.o $(dep_dir)/udp_send.d \
251 $(object_dir)/send_common.o $(dep_dir)/send_common.d \
252 $(object_dir)/mm.o $(dep_dir)/mm.d \
253 : CPPFLAGS += $(osl_cppflags)
254
255 $(object_dir)/%.cmdline.o: CFLAGS += -Wno-unused-function
256 $(object_dir)/compress_filter.o: CFLAGS += -O3
257
258 $(object_dir)/%.o: %.c | $(object_dir)
259         @[ -z "$(Q)" ] || echo 'CC $<'
260         $(Q) $(CC) -c -o $@ $(CPPFLAGS) $(STRICT_CFLAGS) $<
261
262 $(object_dir)/%.cmdline.o: $(cmdline_dir)/%.cmdline.c $(cmdline_dir)/%.cmdline.h | $(object_dir)
263         @[ -z "$(Q)" ] || echo 'CC $<'
264         $(Q) $(CC) -c -o $@ $(CPPFLAGS) $(CFLAGS) $<
265
266 # The compiler outputs dependencies either as foo.h or as some_directory/foo.h,
267 # depending on whether the latter file exists. Since make needs the directory
268 # part we prefix the dependency as appropriate.
269 $(dep_dir)/%.d: %.c error2.h | $(dep_dir)
270         @[ -z "$(Q)" ] || echo 'DEP $<'
271         $(Q) $(CC) $(CPPFLAGS) -MM -MG -MP -MT $@ -MT $(object_dir)/$(*F).o $< \
272                 | sed -e "s@ \([a-zA-Z0-9_]\{1,\}\.cmdline.h\)@ $(cmdline_dir)/\1@g" \
273                 -e "s@ \([a-zA-Z0-9_]\{1,\}\.command_list.h\)@ $(cmdlist_dir)/\1@g" \
274                 -e "s@ \([a-zA-Z0-9_]\{1,\}\.completion.h\)@ $(cmdlist_dir)/\1@g" > $@
275
276 para_recv para_afh para_play para_server: LDFLAGS += $(id3tag_ldflags)
277 para_write para_play para_audiod \
278 : LDFLAGS += $(ao_ldflags) $(pthread_ldflags) $(core_audio_ldflags)
279 para_client para_audioc para_play : LDFLAGS += $(readline_ldflags)
280 para_server: LDFLAGS += $(osl_ldflags)
281 para_gui: LDFLAGS += $(curses_ldflags)
282 para_server \
283 para_client \
284 para_audiod \
285 :LDFLAGS += \
286         $(crypto_ldflags)
287
288 para_audiod \
289 para_filter \
290 para_play \
291 : LDFLAGS += \
292         $(mad_ldflags) \
293         $(faad_ldflags) \
294         $(samplerate_ldflags) \
295         -lm
296
297 para_write \
298 para_play \
299 para_audiod \
300 para_fade \
301 : LDFLAGS += \
302         $(oss_ldflags) \
303         $(alsa_ldflags)
304
305 para_server \
306 para_filter \
307 para_audiod \
308 para_play \
309 para_afh \
310 para_recv \
311 : LDFLAGS += \
312         $(ogg_ldflags) \
313         $(vorbis_ldflags) \
314         $(speex_ldflags) \
315         $(opus_ldflags) \
316         $(faad_ldflags) \
317         $(flac_ldflags)
318
319 para_server \
320 para_play \
321 para_afh \
322 para_recv \
323 : LDFLAGS += \
324         $(mp4v2_ldflags)
325
326 para_server \
327 para_client \
328 para_audioc \
329 para_audiod \
330 para_recv \
331 : LDFLAGS += \
332         $(socket_ldflags) $(nsl_ldflags)
333
334 para_afh para_recv para_server para_play: LDFLAGS += $(iconv_ldflags)
335
336 $(foreach exe,$(executables),$(eval para_$(exe): $$($(exe)_objs)))
337 $(prefixed_executables):
338         @[ -z "$(Q)" ] || echo 'LD $@'
339         $(Q) $(CC) $^ -o $@ $(LDFLAGS)
340
341 clean:
342         @[ -z "$(Q)" ] || echo 'CLEAN'
343         $(Q) rm -f para_*
344         $(Q) rm -rf $(object_dir)
345
346 clean2: clean
347         @[ -z "$(Q)" ] || echo 'CLEAN2'
348         $(Q) rm -rf $(build_dir)
349 distclean: clean2 test-clean
350         @[ -z "$(Q)" ] || echo 'DISTCLEAN'
351         $(Q) rm -f Makefile autoscan.log config.status config.log error2.h
352         $(Q) rm -f GPATH GRTAGS GSYMS GTAGS
353
354 maintainer-clean: distclean
355         @[ -z "$(Q)" ] || echo 'MAINTAINER-CLEAN'
356         $(Q) rm -f *.tar.bz2 config.h configure config.h.in
357
358 install: all man
359         $(MKDIR_P) $(bindir) $(mandir)
360         $(INSTALL) -s --strip-program $(STRIP) -m 755 \
361                 $(prefixed_executables) $(bindir)
362         $(INSTALL) -m 644 $(man_pages) $(mandir)
363         $(MKDIR_P) $(vardir) >/dev/null 2>&1 || true # not fatal, so don't complain
364
365 $(tarball):
366         $(Q) rm -rf $(tarball) $(tarball_pfx)
367         $(Q) git archive --format=tar --prefix=$(tarball_pfx)/ HEAD \
368                 | tar --delete $(tarball_delete) > $(tarball_pfx).tar
369         $(Q) $(MKDIR_P) $(tarball_pfx)
370         $(Q) ./GIT-VERSION-GEN > $(tarball_pfx)/VERSION
371         $(Q) cp $(autocrap) $(tarball_pfx)
372         $(Q) tar rf $(tarball_pfx).tar $(tarball_pfx)/*
373         $(Q) bzip2 -9 $(tarball_pfx).tar
374         $(Q) ls -l $(tarball)
375         $(Q) ln -sf $(tarball) paraslash-git.tar.bz2
376         $(Q) rm -rf $(tarball_pfx)