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 m4_ggo_dir := m4/gengetopt
16 ifeq ("$(origin O)", "command line")
21 ggo_dir := $(build_dir)/ggo
22 object_dir := $(build_dir)/objects
23 dep_dir := $(build_dir)/deps
24 man_dir := $(build_dir)/man/man1
25 cmdline_dir := $(build_dir)/cmdline
26 m4depdir := $(build_dir)/m4deps
27 help2man_dir := $(build_dir)/help2man
28 hostbin_dir := $(build_dir)/host/bin
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)))
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))
51 DEBUG_CPPFLAGS += -g -Wunused -Wundef -W
52 DEBUG_CPPFLAGS += -Wredundant-decls
53 DEBUG_CPPFLAGS += -Wall -Wno-sign-compare -Wno-unknown-pragmas
54 DEBUG_CPPFLAGS += -Wformat-security
55 DEBUG_CPPFLAGS += -Wmissing-format-attribute
57 ifeq ($(uname_s),Linux)
58 CPPFLAGS += -fdata-sections -ffunction-sections
59 LDFLAGS += -Wl,--gc-sections
60 CPPFLAGS += -Wstrict-prototypes
62 # causes warnings on *BSD for the feature test macros
63 CPPFLAGS += -Wunused-macros
66 CPPFLAGS += -Wuninitialized
67 CPPFLAGS += -Wchar-subscripts
68 CPPFLAGS += -DBINDIR='"$(BINDIR)"'
69 CPPFLAGS += -DBUILD_DATE='"$(build_date)"'
70 CPPFLAGS += -DUNAME_RS='"$(uname_rs)"'
71 CPPFLAGS += -DCC_VERSION='"$(cc_version)"'
72 CPPFLAGS += -Werror-implicit-function-declaration
73 CPPFLAGS += -Wmissing-noreturn
74 CPPFLAGS += -Wbad-function-cast
75 CPPFLAGS += -fno-strict-aliasing
76 CPPFLAGS += -DMAIN_INPUT_FILE_IS_$(*F)
77 CPPFLAGS += $(arch_cppflags)
78 CPPFLAGS += -I/usr/local/include
79 CPPFLAGS += -I$(cmdline_dir)
80 CPPFLAGS += $(osl_cppflags)
82 LDFLAGS += $(clock_gettime_ldflags)
84 man_pages := $(patsubst %, $(man_dir)/%.1, $(prefixed_executables))
86 autocrap := config.h.in configure
87 tarball_pfx := $(PACKAGE_TARNAME)-$(PACKAGE_VERSION)
88 tarball_delete := $(addprefix $(tarball_pfx)/,\
89 web .changelog_before_cvs .changelog_cvs .gitignore)
90 tarball := $(tarball_pfx).tar.bz2
92 # To put more focus on warnings, be less verbose as default
93 # Use 'make V=1' to see the full commands
94 ifeq ("$(origin V)", "command line")
100 .PHONY: dep all clean distclean maintainer-clean install man tarball
101 all: dep $(prefixed_executables) $(man_pages)
106 $(object_dir) $(man_dir) $(ggo_dir) $(cmdline_dir) $(dep_dir) $(m4depdir) \
107 $(help2man_dir) $(hostbin_dir):
110 -include $(m4_ggo_dir)/makefile
112 # When in doubt, use brute force (Ken Thompson)
114 $(subst a,A,$(subst b,B,$(subst c,C,$(subst d,D,$(subst e,E,\
115 $(subst f,F,$(subst g,G,$(subst h,H,$(subst i,I,$(subst j,J,\
116 $(subst k,K,$(subst l,L,$(subst m,M,$(subst n,N,$(subst o,O,\
117 $(subst p,P,$(subst q,Q,$(subst r,R,$(subst s,S,$(subst t,T,\
118 $(subst u,U,$(subst v,V,$(subst w,W,$(subst x,X,$(subst y,Y,\
119 $(subst z,Z,$1))))))))))))))))))))))))))
121 %_command_list.h: %.cmd %.c
122 @[ -z "$(Q)" ] || echo 'GEN $@'
123 $(Q) ./command_util.sh h < $< >$@
124 %_command_list.man: %.cmd %.c
125 @[ -z "$(Q)" ] || echo 'GEN $@'
126 $(Q) ./command_util.sh man < $< > $@
127 %_completion.h: %.cmd %.c
128 @[ -z "$(Q)" ] || echo 'GEN $@'
129 $(Q) ./command_util.sh compl $(strip $(call TOUPPER,$(*F)))_COMPLETERS \
130 $(strip $(call TOUPPER,$(*F)))_COMMANDS < $< > $@
132 server_command_list.h server_command_list.man server_completion.h: command.c
133 afs_command_list.h afs_command_list.man afs_completion.h: afs.c aft.c attribute.c
134 audiod_command_list.h audiod_command_list.man audiod_completion.h: audiod_command.c
136 server_command_lists_man = server_command_list.man afs_command_list.man
137 $(man_dir)/para_server.1: $(help2man_dir)/para_server $(server_command_lists_man) | $(man_dir)
138 @[ -z "$(Q)" ] || echo 'MAN $<'
139 $(Q) opts="`for i in $(server_command_lists_man); do printf "%s\n" "-i $$i"; done`"; \
140 $(HELP2MAN) $$opts ./$< > $@
142 $(man_dir)/para_audiod.1: $(help2man_dir)/para_audiod audiod_command_list.man | $(man_dir)
143 @[ -z "$(Q)" ] || echo 'MAN $<'
144 $(Q) $(HELP2MAN) -N -i audiod_command_list.man ./$< > $@
146 $(man_dir)/para_play.1: $(help2man_dir)/para_play play_command_list.man | $(man_dir)
147 @[ -z "$(Q)" ] || echo 'MAN $<'
148 $(Q) $(HELP2MAN) -N -i play_command_list.man ./$< > $@
150 $(man_dir)/%.1: $(help2man_dir)/% | $(man_dir)
151 @[ -z "$(Q)" ] || echo 'MAN $<'
152 $(Q) $(HELP2MAN) -N ./$< > $@
154 $(hostbin_dir)/error2: error2.c | $(hostbin_dir)
155 @[ -z "$(Q)" ] || echo 'HCC $<'
156 $(Q) $(HOSTCC) -o $@ $<
157 error2.h: $(hostbin_dir)/error2
158 @[ -z "$(Q)" ] || echo 'ER2 $<'
159 @echo "$(object_executable_matrix)" | $< > $@
161 $(object_dir)/%.o: %.c | $(object_dir)
162 $(object_dir)/opus%.o: CPPFLAGS += $(opus_cppflags)
163 $(object_dir)/gui%.o: CPPFLAGS += $(curses_cppflags)
164 $(object_dir)/spx%.o: CPPFLAGS += $(speex_cppflags)
165 $(object_dir)/%.cmdline.o: CPPFLAGS += -Wno-unused-function
167 $(object_dir)/mp3_afh.o: CPPFLAGS += $(id3tag_cppflags)
168 $(object_dir)/crypt.o: CPPFLAGS += $(openssl_cppflags)
169 $(object_dir)/mp3dec_filter.o: CPPFLAGS += $(mad_cppflags)
170 $(object_dir)/compress_filter.o: CPPFLAGS += -O3
171 $(object_dir)/ao_write.o: CPPFLAGS += $(ao_cppflags)
173 $(object_dir)/aacdec_filter.o \
174 $(object_dir)/aac_common.o \
175 $(object_dir)/aac_afh.o \
176 : CPPFLAGS += $(faad_cppflags)
178 $(object_dir)/spx_common.o \
179 $(object_dir)/spxdec_filter.o \
180 $(object_dir)/spx_afh.o \
181 $(object_dir)/oggdec_filter.o \
182 $(object_dir)/ogg_afh.o \
183 $(object_dir)/ogg_afh_common.o \
184 : CPPFLAGS += $(ogg_cppflags)
186 $(object_dir)/%.o: %.c | $(object_dir)
187 @[ -z "$(Q)" ] || echo 'CC $<'
188 $(Q) $(CC) -c -o $@ $(CPPFLAGS) $(DEBUG_CPPFLAGS) $<
190 $(object_dir)/%.cmdline.o: $(cmdline_dir)/%.cmdline.c $(cmdline_dir)/%.cmdline.h | $(object_dir)
191 @[ -z "$(Q)" ] || echo 'CC $<'
192 $(Q) $(CC) -c $(CPPFLAGS) -Wno-unused-function -o $@ $<
194 $(dep_dir)/%.cmdline.d: $(cmdline_dir)/%.cmdline.c error2.h | $(dep_dir)
195 @[ -z "$(Q)" ] || echo 'DEP $<'
196 $(Q) ./depend.sh $(dep_dir) $(object_dir) $(cmdline_dir) \
199 $(dep_dir)/%.d: %.c error2.h | $(dep_dir)
200 @[ -z "$(Q)" ] || echo 'DEP $<'
201 $(Q) ./depend.sh $(dep_dir) $(object_dir) $(cmdline_dir) \
204 ifeq ($(findstring clean, $(MAKECMDGOALS)),)
209 para_recv para_afh para_play para_server: LDFLAGS += $(id3tag_ldflags)
210 para_write para_play para_audiod: LDFLAGS += $(ao_ldflags) $(core_audio_ldflags)
211 para_client para_audioc para_play : LDFLAGS += $(readline_ldflags)
212 para_server: LDFLAGS += $(osl_ldflags)
213 para_gui: LDFLAGS += $(curses_ldflags)
226 $(samplerate_ldflags) \
257 $(socket_ldflags) $(nsl_ldflags)
259 $(foreach exe,$(executables),$(eval para_$(exe): $$($(exe)_objs)))
260 $(prefixed_executables):
261 @[ -z "$(Q)" ] || echo 'LD $@'
262 $(Q) $(CC) $^ -o $@ $(LDFLAGS)
265 @[ -z "$(Q)" ] || echo 'CLEAN'
266 $(Q) rm -f $(prefixed_executables)
267 $(Q) rm -rf $(object_dir)
270 @[ -z "$(Q)" ] || echo 'CLEAN2'
271 $(Q) rm -f *_command_list.* *_completion.h
272 $(Q) rm -rf $(build_dir)
273 distclean: clean2 test-clean
274 @[ -z "$(Q)" ] || echo 'DISTCLEAN'
275 $(Q) rm -f Makefile autoscan.log config.status config.log error2.h
276 $(Q) rm -rf autom4te.cache
277 $(Q) rm -f GPATH GRTAGS GSYMS GTAGS
279 maintainer-clean: distclean
280 rm -f *.tar.bz2 config.h configure config.h.in
284 $(MKDIR_P) $(BINDIR) $(MANDIR)
285 $(INSTALL) -s --strip-program $(STRIP) -m 755 \
286 $(prefixed_executables) $(BINDIR)
287 $(INSTALL) -m 644 $(man_pages) $(MANDIR)
288 $(MKDIR_P) $(VARDIR) >/dev/null 2>&1 || true # not fatal, so don't complain
291 rm -rf $(tarball_pfx).tar.bz2 $(tarball_pfx)
292 git archive --format=tar --prefix=$(tarball_pfx)/ HEAD \
293 | tar --delete $(tarball_delete) > $(tarball_pfx).tar
294 $(MKDIR_P) $(tarball_pfx)
295 ./GIT-VERSION-GEN > $(tarball_pfx)/VERSION
296 cp -r $(autocrap) $(tarball_pfx)
297 tar rf $(tarball_pfx).tar $(tarball_pfx)/*
298 bzip2 -9 $(tarball_pfx).tar
299 ls -l $(tarball_pfx).tar.bz2
300 rm -rf $(tarball_pfx)
301 include $(test_dir)/makefile.test