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