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