1 VARDIR := /var/paraslash
2 MANDIR := $(datarootdir)/man/man1
3 STRIP := $(CROSS_COMPILE)strip
6 prefixed_executables := $(addprefix para_, $(executables))
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)
14 ifeq ("$(origin O)", "command line")
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 cmdlist_dir := $(build_dir)/cmdlist
25 m4depdir := $(build_dir)/m4deps
26 help2man_dir := $(build_dir)/help2man
27 hostbin_dir := $(build_dir)/host/bin
28 m4_ggo_dir := m4/gengetopt
31 # sort removes duplicate words, which is all we need here
32 all_objs := $(sort $(recv_objs) $(filter_objs) $(client_objs) $(gui_objs) \
33 $(audiod_objs) $(audioc_objs) $(fade_objs) $(server_objs) \
34 $(write_objs) $(afh_objs) $(play_objs))
35 deps := $(addprefix $(dep_dir)/, $(filter-out %.cmdline.d, $(all_objs:.o=.d)))
36 m4_deps := $(addprefix $(m4depdir)/, $(addsuffix .m4d, $(executables)))
38 # now prefix all objects with object dir
39 recv_objs := $(addprefix $(object_dir)/, $(recv_objs))
40 filter_objs := $(addprefix $(object_dir)/, $(filter_objs))
41 client_objs := $(addprefix $(object_dir)/, $(client_objs))
42 gui_objs := $(addprefix $(object_dir)/, $(gui_objs))
43 audiod_objs := $(addprefix $(object_dir)/, $(audiod_objs))
44 audioc_objs := $(addprefix $(object_dir)/, $(audioc_objs))
45 fade_objs := $(addprefix $(object_dir)/, $(fade_objs))
46 server_objs := $(addprefix $(object_dir)/, $(server_objs))
47 write_objs := $(addprefix $(object_dir)/, $(write_objs))
48 afh_objs := $(addprefix $(object_dir)/, $(afh_objs))
49 play_objs := $(addprefix $(object_dir)/, $(play_objs))
51 man_pages := $(patsubst %, $(man_dir)/%.1, $(prefixed_executables))
53 autocrap := config.h.in configure
54 tarball_pfx := $(PACKAGE_TARNAME)-$(GIT_VERSION)
55 tarball_delete := $(addprefix $(tarball_pfx)/, web .gitignore)
56 tarball := $(tarball_pfx).tar.bz2
58 .PHONY: dep all clean clean2 distclean maintainer-clean install man tarball
59 all: dep $(prefixed_executables) $(man_pages)
64 include $(m4_ggo_dir)/makefile
65 include $(test_dir)/makefile.test
66 ifeq ($(findstring clean, $(MAKECMDGOALS)),)
71 $(object_dir) $(man_dir) $(ggo_dir) $(cmdline_dir) $(dep_dir) $(m4depdir) \
72 $(help2man_dir) $(hostbin_dir) $(cmdlist_dir):
75 # When in doubt, use brute force (Ken Thompson)
77 $(subst a,A,$(subst b,B,$(subst c,C,$(subst d,D,$(subst e,E,\
78 $(subst f,F,$(subst g,G,$(subst h,H,$(subst i,I,$(subst j,J,\
79 $(subst k,K,$(subst l,L,$(subst m,M,$(subst n,N,$(subst o,O,\
80 $(subst p,P,$(subst q,Q,$(subst r,R,$(subst s,S,$(subst t,T,\
81 $(subst u,U,$(subst v,V,$(subst w,W,$(subst x,X,$(subst y,Y,\
82 $(subst z,Z,$1))))))))))))))))))))))))))
84 CPPFLAGS += -DBINDIR='"$(BINDIR)"'
85 CPPFLAGS += -DBUILD_DATE='"$(build_date)"'
86 CPPFLAGS += -DUNAME_RS='"$(uname_rs)"'
87 CPPFLAGS += -DCC_VERSION='"$(cc_version)"'
88 CPPFLAGS += -DMAIN_INPUT_FILE_IS_$(*F)
89 CPPFLAGS += $(arch_cppflags)
90 CPPFLAGS += -I/usr/local/include
91 CPPFLAGS += -I$(cmdline_dir)
92 CPPFLAGS += -I$(cmdlist_dir)
95 CFLAGS += -Wuninitialized
96 CFLAGS += -Wchar-subscripts
97 CFLAGS += -Werror-implicit-function-declaration
98 CFLAGS += -Wmissing-noreturn
99 CFLAGS += -Wbad-function-cast
100 CFLAGS += -fno-strict-aliasing
102 STRICT_CFLAGS = $(CFLAGS)
103 STRICT_CFLAGS += -g -Wundef -W
104 STRICT_CFLAGS += -Wredundant-decls
105 STRICT_CFLAGS += -Wno-sign-compare -Wno-unknown-pragmas
106 STRICT_CFLAGS += -Wformat -Wformat-security
107 STRICT_CFLAGS += -Wmissing-format-attribute
109 LDFLAGS += $(clock_gettime_ldflags)
111 ifeq ($(uname_s),Linux)
112 # these cause warnings on *BSD
113 STRICT_CFLAGS += -fdata-sections -ffunction-sections
114 STRICT_CFLAGS += -Wstrict-prototypes
115 STRICT_CFLAGS += -Wshadow
116 STRICT_CFLAGS += -Wunused -Wall
117 LDFLAGS += -Wl,--gc-sections
120 # To put more focus on warnings, be less verbose as default
121 # Use 'make V=1' to see the full commands
122 ifeq ("$(origin V)", "command line")
128 $(cmdlist_dir)/%.command_list.h: %.cmd %.c | $(cmdlist_dir)
129 @[ -z "$(Q)" ] || echo 'GEN $@'
130 $(Q) ./command_util.bash h < $< >$@
131 $(cmdlist_dir)/%.command_list.man: %.cmd %.c | $(cmdlist_dir)
132 @[ -z "$(Q)" ] || echo 'GEN $@'
133 $(Q) ./command_util.bash man < $< > $@
134 $(cmdlist_dir)/%.completion.h: %.cmd %.c | $(cmdlist_dir)
135 @[ -z "$(Q)" ] || echo 'GEN $@'
136 $(Q) ./command_util.bash compl $(strip $(call TOUPPER,$(*F)))_COMPLETERS \
137 $(strip $(call TOUPPER,$(*F)))_COMMANDS < $< > $@
139 $(cmdlist_dir)/server.command_list.h \
140 $(cmdlist_dir)/server.command_list.man \
141 $(cmdlist_dir)/server.completion.h \
144 $(cmdlist_dir)/afs.command_list.h \
145 $(cmdlist_dir)/afs.command_list.man \
146 $(cmdlist_dir)/afs.completion.h \
147 : afs.c aft.c attribute.c
149 $(cmdlist_dir)/audiod,command_list.h \
150 $(cmdlist_dir)/audiod,command_list.man \
151 $(cmdlist_dir)/audiod,completion.h \
154 server_command_lists := $(cmdlist_dir)/server.command_list.man \
155 $(cmdlist_dir)/afs.command_list.man
156 audiod_command_lists := $(cmdlist_dir)/audiod.command_list.man
157 play_command_lists := $(cmdlist_dir)/play.command_list.man
159 $(man_dir)/para_server.1: $(server_command_lists)
160 $(man_dir)/para_audiod.1: $(audiod_command_lists)
161 $(man_dir)/para_play.1: $(play_command_lists)
163 $(man_dir)/para_server.1: man_util_command_lists := $(server_command_lists)
164 $(man_dir)/para_audiod.1: man_util_command_lists := $(audiod_command_lists)
165 $(man_dir)/para_play.1: man_util_command_lists := $(play_command_lists)
167 $(man_dir)/para_%.1: $(ggo_dir)/%.ggo man_util.bash | $(man_dir) $(help2man_dir)
168 @[ -z "$(Q)" ] || echo 'MAN $<'
170 COMMAND_LISTS="$(man_util_command_lists)" \
171 FILTERS="$(filters)" \
172 GENGETOPT=$(GENGETOPT) \
174 HELP2MAN=$(HELP2MAN) \
175 HELP2MAN_DIR=$(help2man_dir) \
176 RECEIVERS="$(receivers)" \
177 VERSION="$(GIT_VERSION)" \
178 WRITERS="$(writers)" \
181 $(hostbin_dir)/error2: error2.c | $(hostbin_dir)
182 @[ -z "$(Q)" ] || echo 'HCC $<'
183 $(Q) $(HOSTCC) -o $@ $<
184 error2.h: $(hostbin_dir)/error2 config.h
185 @[ -z "$(Q)" ] || echo 'ER2 $<'
186 @echo "$(object_executable_matrix)" | $< > $@
188 $(object_dir)/%.o: %.c | $(object_dir)
190 $(object_dir)/opus%.o $(dep_dir)/opus%.d: CPPFLAGS += $(opus_cppflags)
191 $(object_dir)/gui.o $(object_dir)/gui%.o $(dep_dir)/gui%.d \
192 : CPPFLAGS += $(curses_cppflags)
193 $(object_dir)/spx%.o $(dep_dir)/spx%.d: CPPFLAGS += $(speex_cppflags)
194 $(object_dir)/flac%.o $(dep_dir)/flac%.d: CPPFLAGS += $(flac_cppflags)
196 $(object_dir)/mp3_afh.o $(dep_dir)/mp3_afh.d: CPPFLAGS += $(id3tag_cppflags)
197 $(object_dir)/crypt.o $(dep_dir)/crypt.d: CPPFLAGS += $(openssl_cppflags)
198 $(object_dir)/gcrypt.o $(dep_dir)/gcrypt.d: CPPFLAGS += $(gcrypt_cppflags)
199 $(object_dir)/ao_write.o $(dep_dir)/ao_write.d: CPPFLAGS += $(ao_cppflags)
201 $(object_dir)/interactive.o $(dep_dir)/interactive.d \
202 : CPPFLAGS += $(readline_cppflags)
204 $(object_dir)/resample_filter.o $(dep_dir)/resample_filter.d \
205 : CPPFLAGS += $(samplerate_cppflags)
207 $(object_dir)/mp3dec_filter.o $(dep_dir)/mp3dec_filter.d \
208 : CPPFLAGS += $(mad_cppflags)
210 $(object_dir)/aacdec_filter.o $(dep_dir)/aacdec_filter.d \
211 $(object_dir)/aac_common.o $(dep_dir)/aac_common.d \
212 $(object_dir)/aac_afh.o $(dep_dir)/aac_afh.d \
213 : CPPFLAGS += $(faad_cppflags)
215 $(object_dir)/ogg_afh.o $(dep_dir)/ogg_afh.d \
216 $(object_dir)/oggdec_filter.o $(dep_dir)/oggdec_filter.d \
217 : CPPFLAGS += $(vorbis_cppflags)
219 $(object_dir)/spx_common.o $(dep_dir)/spx_common.d \
220 $(object_dir)/spxdec_filter.o $(dep_dir)/spxdec_filter.d \
221 $(object_dir)/spx_afh.o $(dep_dir)/spx_afh.d \
222 $(object_dir)/oggdec_filter.o $(dep_dir)/oggdec_filter.d \
223 $(object_dir)/ogg_afh.o $(dep_dir)/ogg_afh.d \
224 $(object_dir)/ogg_afh_common.o $(dep_dir)/ogg_afh_common.d \
225 $(object_dir)/opus%.o $(dep_dir)/opus%.d \
226 : CPPFLAGS += $(ogg_cppflags)
228 $(object_dir)/afs.o $(dep_dir)/afs.d \
229 $(object_dir)/aft.o $(dep_dir)/aft.d \
230 $(object_dir)/attribute.o $(dep_dir)/attribute.d \
231 $(object_dir)/blob.o $(dep_dir)/blob.d \
232 $(object_dir)/mood.o $(dep_dir)/mood.d \
233 $(object_dir)/playlist.o $(dep_dir)/playlist.d \
234 $(object_dir)/score.o $(dep_dir)/score.d \
235 $(object_dir)/server.o $(dep_dir)/server.d \
236 $(object_dir)/vss.o $(dep_dir)/vss.d \
237 $(object_dir)/command.o $(dep_dir)/command.d \
238 $(object_dir)/http_send.o $(dep_dir)/http_send.d \
239 $(object_dir)/dccp_send.o $(dep_dir)/dccp_send.d \
240 $(object_dir)/udp_send.o $(dep_dir)/udp_send.d \
241 $(object_dir)/send_common.o $(dep_dir)/send_common.d \
242 $(object_dir)/mm.o $(dep_dir)/mm.d \
243 : CPPFLAGS += $(osl_cppflags)
245 $(object_dir)/%.cmdline.o: CFLAGS += -Wno-unused-function
246 $(object_dir)/compress_filter.o: CFLAGS += -O3
248 $(object_dir)/%.o: %.c | $(object_dir)
249 @[ -z "$(Q)" ] || echo 'CC $<'
250 $(Q) $(CC) -c -o $@ $(CPPFLAGS) $(STRICT_CFLAGS) $<
252 $(object_dir)/%.cmdline.o: $(cmdline_dir)/%.cmdline.c $(cmdline_dir)/%.cmdline.h | $(object_dir)
253 @[ -z "$(Q)" ] || echo 'CC $<'
254 $(Q) $(CC) -c -o $@ $(CPPFLAGS) $(CFLAGS) $<
256 # The compiler outputs dependencies either as foo.h or as some_directory/foo.h,
257 # depending on whether the latter file exists. Since make needs the directory
258 # part we prefix the dependency as appropriate.
259 $(dep_dir)/%.d: %.c error2.h | $(dep_dir)
260 @[ -z "$(Q)" ] || echo 'DEP $<'
261 $(Q) $(CC) $(CPPFLAGS) -MM -MG -MP -MT $@ -MT $(object_dir)/$(*F).o $< \
262 | sed -e "s@ \([a-zA-Z0-9_]\{1,\}\.cmdline.h\)@ $(cmdline_dir)/\1@g" \
263 -e "s@ \([a-zA-Z0-9_]\{1,\}\.command_list.h\)@ $(cmdlist_dir)/\1@g" \
264 -e "s@ \([a-zA-Z0-9_]\{1,\}\.completion.h\)@ $(cmdlist_dir)/\1@g" > $@
266 para_recv para_afh para_play para_server: LDFLAGS += $(id3tag_ldflags)
267 para_write para_play para_audiod: LDFLAGS += $(ao_ldflags) $(core_audio_ldflags)
268 para_client para_audioc para_play : LDFLAGS += $(readline_ldflags)
269 para_server: LDFLAGS += $(osl_ldflags)
270 para_gui: LDFLAGS += $(curses_ldflags)
282 $(samplerate_ldflags) \
313 $(socket_ldflags) $(nsl_ldflags)
315 $(foreach exe,$(executables),$(eval para_$(exe): $$($(exe)_objs)))
316 $(prefixed_executables):
317 @[ -z "$(Q)" ] || echo 'LD $@'
318 $(Q) $(CC) $^ -o $@ $(LDFLAGS)
321 @[ -z "$(Q)" ] || echo 'CLEAN'
323 $(Q) rm -rf $(object_dir)
326 @[ -z "$(Q)" ] || echo 'CLEAN2'
327 $(Q) rm -rf $(build_dir)
328 distclean: clean2 test-clean
329 @[ -z "$(Q)" ] || echo 'DISTCLEAN'
330 $(Q) rm -f Makefile autoscan.log config.status config.log error2.h
331 $(Q) rm -f GPATH GRTAGS GSYMS GTAGS
333 maintainer-clean: distclean
334 @[ -z "$(Q)" ] || echo 'MAINTAINER-CLEAN'
335 $(Q) rm -f *.tar.bz2 config.h configure config.h.in
339 $(MKDIR_P) $(BINDIR) $(MANDIR)
340 $(INSTALL) -s --strip-program $(STRIP) -m 755 \
341 $(prefixed_executables) $(BINDIR)
342 $(INSTALL) -m 644 $(man_pages) $(MANDIR)
343 $(MKDIR_P) $(VARDIR) >/dev/null 2>&1 || true # not fatal, so don't complain
346 $(Q) rm -rf $(tarball) $(tarball_pfx)
347 $(Q) git archive --format=tar --prefix=$(tarball_pfx)/ HEAD \
348 | tar --delete $(tarball_delete) > $(tarball_pfx).tar
349 $(Q) $(MKDIR_P) $(tarball_pfx)
350 $(Q) ./GIT-VERSION-GEN > $(tarball_pfx)/VERSION
351 $(Q) cp $(autocrap) $(tarball_pfx)
352 $(Q) tar rf $(tarball_pfx).tar $(tarball_pfx)/*
353 $(Q) bzip2 -9 $(tarball_pfx).tar
354 $(Q) ls -l $(tarball)
355 $(Q) ln -sf $(tarball) paraslash-git.tar.bz2
356 $(Q) rm -rf $(tarball_pfx)