task_register() conversion: play task
[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
14 ifeq ("$(origin O)", "command line")
15 build_dir := $(O)
16 else
17 build_dir := build
18 endif
19 ggo_dir := $(build_dir)/ggo
20 object_dir := $(build_dir)/objects
21 dep_dir := $(build_dir)/deps
22 man_dir := $(build_dir)/man/man1
23 cmdline_dir := $(build_dir)/cmdline
24 m4depdir := $(build_dir)/m4deps
25 help2man_dir := $(build_dir)/help2man
26 hostbin_dir := $(build_dir)/host/bin
27 m4_ggo_dir := m4/gengetopt
28 test_dir := t
29
30 # sort removes duplicate words, which is all we need here
31 all_objs := $(sort $(recv_objs) $(filter_objs) $(client_objs) $(gui_objs) \
32 $(audiod_objs) $(audioc_objs) $(fade_objs) $(server_objs) \
33 $(write_objs) $(afh_objs) $(play_objs))
34 deps := $(addprefix $(dep_dir)/, $(all_objs:.o=.d))
35 m4_deps := $(addprefix $(m4depdir)/, $(addsuffix .m4d, $(executables)))
36
37 # now prefix all objects with object dir
38 recv_objs := $(addprefix $(object_dir)/, $(recv_objs))
39 filter_objs := $(addprefix $(object_dir)/, $(filter_objs))
40 client_objs := $(addprefix $(object_dir)/, $(client_objs))
41 gui_objs := $(addprefix $(object_dir)/, $(gui_objs))
42 audiod_objs := $(addprefix $(object_dir)/, $(audiod_objs))
43 audioc_objs := $(addprefix $(object_dir)/, $(audioc_objs))
44 fade_objs := $(addprefix $(object_dir)/, $(fade_objs))
45 server_objs := $(addprefix $(object_dir)/, $(server_objs))
46 write_objs := $(addprefix $(object_dir)/, $(write_objs))
47 afh_objs := $(addprefix $(object_dir)/, $(afh_objs))
48 play_objs := $(addprefix $(object_dir)/, $(play_objs))
49
50 man_pages := $(patsubst %, $(man_dir)/%.1, $(prefixed_executables))
51
52 autocrap := config.h.in configure
53 tarball_pfx := $(PACKAGE_TARNAME)-$(PACKAGE_VERSION)
54 tarball_delete := $(addprefix $(tarball_pfx)/, web .gitignore)
55 tarball := $(tarball_pfx).tar.bz2
56
57 .PHONY: dep all clean clean2 distclean maintainer-clean install man tarball
58 all: dep $(prefixed_executables) $(man_pages)
59 dep: $(deps)
60 man: $(man_pages)
61 tarball: $(tarball)
62
63 include $(m4_ggo_dir)/makefile
64 include $(test_dir)/makefile.test
65 ifeq ($(findstring clean, $(MAKECMDGOALS)),)
66 -include $(deps)
67 -include $(m4_deps)
68 endif
69
70 $(object_dir) $(man_dir) $(ggo_dir) $(cmdline_dir) $(dep_dir) $(m4depdir) \
71 $(help2man_dir) $(hostbin_dir):
72 $(Q) $(MKDIR_P) $@
73
74 # When in doubt, use brute force (Ken Thompson)
75 TOUPPER = \
76 $(subst a,A,$(subst b,B,$(subst c,C,$(subst d,D,$(subst e,E,\
77 $(subst f,F,$(subst g,G,$(subst h,H,$(subst i,I,$(subst j,J,\
78 $(subst k,K,$(subst l,L,$(subst m,M,$(subst n,N,$(subst o,O,\
79 $(subst p,P,$(subst q,Q,$(subst r,R,$(subst s,S,$(subst t,T,\
80 $(subst u,U,$(subst v,V,$(subst w,W,$(subst x,X,$(subst y,Y,\
81 $(subst z,Z,$1))))))))))))))))))))))))))
82
83
84 DEBUG_CPPFLAGS += -g -Wunused -Wundef -W
85 DEBUG_CPPFLAGS += -Wredundant-decls
86 DEBUG_CPPFLAGS += -Wall -Wno-sign-compare -Wno-unknown-pragmas
87 DEBUG_CPPFLAGS += -Wformat-security
88 DEBUG_CPPFLAGS += -Wmissing-format-attribute
89
90 ifeq ($(uname_s),Linux)
91 CPPFLAGS += -fdata-sections -ffunction-sections
92 LDFLAGS += -Wl,--gc-sections
93 CPPFLAGS += -Wstrict-prototypes
94 CPPFLAGS += -Wshadow
95 # causes warnings on *BSD for the feature test macros
96 CPPFLAGS += -Wunused-macros
97 endif
98 CPPFLAGS += -Os
99 CPPFLAGS += -Wuninitialized
100 CPPFLAGS += -Wchar-subscripts
101 CPPFLAGS += -DBINDIR='"$(BINDIR)"'
102 CPPFLAGS += -DBUILD_DATE='"$(build_date)"'
103 CPPFLAGS += -DUNAME_RS='"$(uname_rs)"'
104 CPPFLAGS += -DCC_VERSION='"$(cc_version)"'
105 CPPFLAGS += -Werror-implicit-function-declaration
106 CPPFLAGS += -Wmissing-noreturn
107 CPPFLAGS += -Wbad-function-cast
108 CPPFLAGS += -fno-strict-aliasing
109 CPPFLAGS += -DMAIN_INPUT_FILE_IS_$(*F)
110 CPPFLAGS += $(arch_cppflags)
111 CPPFLAGS += -I/usr/local/include
112 CPPFLAGS += -I$(cmdline_dir)
113 CPPFLAGS += $(osl_cppflags)
114
115 LDFLAGS += $(clock_gettime_ldflags)
116
117 # To put more focus on warnings, be less verbose as default
118 # Use 'make V=1' to see the full commands
119 ifeq ("$(origin V)", "command line")
120 Q :=
121 else
122 Q := @
123 endif
124
125 %_command_list.h: %.cmd %.c
126 @[ -z "$(Q)" ] || echo 'GEN $@'
127 $(Q) ./command_util.bash h < $< >$@
128 %_command_list.man: %.cmd %.c
129 @[ -z "$(Q)" ] || echo 'GEN $@'
130 $(Q) ./command_util.bash man < $< > $@
131 %_completion.h: %.cmd %.c
132 @[ -z "$(Q)" ] || echo 'GEN $@'
133 $(Q) ./command_util.bash compl $(strip $(call TOUPPER,$(*F)))_COMPLETERS \
134 $(strip $(call TOUPPER,$(*F)))_COMMANDS < $< > $@
135
136 server_command_list.h server_command_list.man server_completion.h: command.c
137 afs_command_list.h afs_command_list.man afs_completion.h: afs.c aft.c attribute.c
138 audiod_command_list.h audiod_command_list.man audiod_completion.h: audiod_command.c
139
140 server_command_lists := server_command_list.man afs_command_list.man
141 audiod_command_lists := audiod_command_list.man
142 play_command_lists := play_command_list.man
143
144 $(man_dir)/para_server.1: $(server_command_lists)
145 $(man_dir)/para_audiod.1: $(audiod_command_lists)
146 $(man_dir)/para_play.1: $(play_command_lists)
147
148 $(man_dir)/para_server.1: man_util_command_lists := $(server_command_lists)
149 $(man_dir)/para_audiod.1: man_util_command_lists := $(audiod_command_lists)
150 $(man_dir)/para_play.1: man_util_command_lists := $(play_command_lists)
151
152 $(man_dir)/para_%.1: $(ggo_dir)/%.ggo man_util.bash | $(man_dir) $(help2man_dir)
153 @[ -z "$(Q)" ] || echo 'MAN $<'
154 $(Q) \
155 COMMAND_LISTS="$(man_util_command_lists)" \
156 FILTERS="$(filters)" \
157 GENGETOPT=$(GENGETOPT) \
158 GGO_DIR=$(ggo_dir) \
159 HELP2MAN=$(HELP2MAN) \
160 HELP2MAN_DIR=$(help2man_dir) \
161 RECEIVERS="$(receivers)" \
162 VERSION="$(GIT_VERSION)" \
163 WRITERS="$(writers)" \
164 ./man_util.bash $@
165
166 $(hostbin_dir)/error2: error2.c | $(hostbin_dir)
167 @[ -z "$(Q)" ] || echo 'HCC $<'
168 $(Q) $(HOSTCC) -o $@ $<
169 error2.h: $(hostbin_dir)/error2 Makefile
170 @[ -z "$(Q)" ] || echo 'ER2 $<'
171 @echo "$(object_executable_matrix)" | $< > $@
172
173 $(object_dir)/%.o: %.c | $(object_dir)
174 $(object_dir)/opus%.o: CPPFLAGS += $(opus_cppflags)
175 $(object_dir)/gui%.o: CPPFLAGS += $(curses_cppflags)
176 $(object_dir)/spx%.o: CPPFLAGS += $(speex_cppflags)
177 $(object_dir)/%.cmdline.o: CPPFLAGS += -Wno-unused-function
178
179 $(object_dir)/mp3_afh.o: CPPFLAGS += $(id3tag_cppflags)
180 $(object_dir)/crypt.o: CPPFLAGS += $(openssl_cppflags)
181 $(object_dir)/mp3dec_filter.o: CPPFLAGS += $(mad_cppflags)
182 $(object_dir)/compress_filter.o: CPPFLAGS += -O3
183 $(object_dir)/ao_write.o: CPPFLAGS += $(ao_cppflags)
184
185 $(object_dir)/aacdec_filter.o \
186 $(object_dir)/aac_common.o \
187 $(object_dir)/aac_afh.o \
188 : CPPFLAGS += $(faad_cppflags)
189
190 $(object_dir)/spx_common.o \
191 $(object_dir)/spxdec_filter.o \
192 $(object_dir)/spx_afh.o \
193 $(object_dir)/oggdec_filter.o \
194 $(object_dir)/ogg_afh.o \
195 $(object_dir)/ogg_afh_common.o \
196 : CPPFLAGS += $(ogg_cppflags)
197
198 $(object_dir)/%.o: %.c | $(object_dir)
199 @[ -z "$(Q)" ] || echo 'CC $<'
200 $(Q) $(CC) -c -o $@ $(CPPFLAGS) $(DEBUG_CPPFLAGS) $<
201
202 $(object_dir)/%.cmdline.o: $(cmdline_dir)/%.cmdline.c $(cmdline_dir)/%.cmdline.h | $(object_dir)
203 @[ -z "$(Q)" ] || echo 'CC $<'
204 $(Q) $(CC) -c $(CPPFLAGS) -Wno-unused-function -o $@ $<
205
206 $(dep_dir)/%.cmdline.d: $(cmdline_dir)/%.cmdline.c error2.h | $(dep_dir)
207 @[ -z "$(Q)" ] || echo 'DEP $<'
208 $(Q) ./depend.sh $(dep_dir) $(object_dir) $(cmdline_dir) \
209 $(CPPFLAGS) $< > $@
210
211 $(dep_dir)/%.d: %.c error2.h | $(dep_dir)
212 @[ -z "$(Q)" ] || echo 'DEP $<'
213 $(Q) ./depend.sh $(dep_dir) $(object_dir) $(cmdline_dir) \
214 $(CPPFLAGS) $< > $@
215
216 para_recv para_afh para_play para_server: LDFLAGS += $(id3tag_ldflags)
217 para_write para_play para_audiod: LDFLAGS += $(ao_ldflags) $(core_audio_ldflags)
218 para_client para_audioc para_play : LDFLAGS += $(readline_ldflags)
219 para_server: LDFLAGS += $(osl_ldflags)
220 para_gui: LDFLAGS += $(curses_ldflags)
221 para_server \
222 para_client \
223 para_audiod \
224 :LDFLAGS += \
225 $(openssl_ldflags) \
226 $(gcrypt_ldflags)
227
228 para_audiod \
229 para_filter \
230 para_play \
231 : LDFLAGS += \
232 $(mad_ldflags) \
233 $(samplerate_ldflags) \
234 -lm
235
236 para_write \
237 para_play \
238 para_audiod \
239 para_fade \
240 : LDFLAGS += \
241 $(oss_ldflags) \
242 $(alsa_ldflags)
243
244 para_server \
245 para_filter \
246 para_audiod \
247 para_play \
248 para_afh \
249 para_recv \
250 : LDFLAGS += \
251 $(ogg_ldflags) \
252 $(vorbis_ldflags) \
253 $(speex_ldflags) \
254 $(opus_ldflags) \
255 $(faad_ldflags) \
256 $(flac_ldflags)
257
258 para_server \
259 para_client \
260 para_audioc \
261 para_audiod \
262 para_recv \
263 : LDFLAGS += \
264 $(socket_ldflags) $(nsl_ldflags)
265
266 $(foreach exe,$(executables),$(eval para_$(exe): $$($(exe)_objs)))
267 $(prefixed_executables):
268 @[ -z "$(Q)" ] || echo 'LD $@'
269 $(Q) $(CC) $^ -o $@ $(LDFLAGS)
270
271 clean:
272 @[ -z "$(Q)" ] || echo 'CLEAN'
273 $(Q) rm -f $(prefixed_executables)
274 $(Q) rm -rf $(object_dir)
275
276 clean2: clean
277 @[ -z "$(Q)" ] || echo 'CLEAN2'
278 $(Q) rm -f *_command_list.* *_completion.h
279 $(Q) rm -rf $(build_dir)
280 distclean: clean2 test-clean
281 @[ -z "$(Q)" ] || echo 'DISTCLEAN'
282 $(Q) rm -f Makefile autoscan.log config.status config.log error2.h
283 $(Q) rm -rf autom4te.cache
284 $(Q) rm -f GPATH GRTAGS GSYMS GTAGS
285
286 maintainer-clean: distclean
287 rm -f *.tar.bz2 config.h configure config.h.in
288 rm -rf web_sync
289
290 install: all man
291 $(MKDIR_P) $(BINDIR) $(MANDIR)
292 $(INSTALL) -s --strip-program $(STRIP) -m 755 \
293 $(prefixed_executables) $(BINDIR)
294 $(INSTALL) -m 644 $(man_pages) $(MANDIR)
295 $(MKDIR_P) $(VARDIR) >/dev/null 2>&1 || true # not fatal, so don't complain
296
297 $(tarball):
298 rm -rf $(tarball_pfx).tar.bz2 $(tarball_pfx)
299 git archive --format=tar --prefix=$(tarball_pfx)/ HEAD \
300 | tar --delete $(tarball_delete) > $(tarball_pfx).tar
301 $(MKDIR_P) $(tarball_pfx)
302 ./GIT-VERSION-GEN > $(tarball_pfx)/VERSION
303 cp -r $(autocrap) $(tarball_pfx)
304 tar rf $(tarball_pfx).tar $(tarball_pfx)/*
305 bzip2 -9 $(tarball_pfx).tar
306 ls -l $(tarball_pfx).tar.bz2
307 rm -rf $(tarball_pfx)