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