build: Generate man pages directly from ggo 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 := $(addprefix para_, @executables@)
12 ggo_descriptions_declared := @ggo_descriptions_declared@
13
14 GENGETOPT := @gengetopt@
15 HELP2MAN := @help2man@
16 MKDIR_P := mkdir -p
17
18 build_date := $(shell date)
19 uname_s := $(shell uname -s 2>/dev/null || echo "UNKNOWN_OS")
20 uname_rs := $(shell uname -rs)
21 cc_version := $(shell $(CC) --version | head -n 1)
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 m4depdir := $(build_dir)/m4deps
38 help2man_dir := $(build_dir)/help2man
39
40 DEBUG_CPPFLAGS += -g -Wunused -Wundef -W
41 DEBUG_CPPFLAGS += -Wredundant-decls
42 DEBUG_CPPFLAGS += -Wall -Wno-sign-compare -Wno-unknown-pragmas
43 DEBUG_CPPFLAGS += -Wformat-security
44 DEBUG_CPPFLAGS += -Wmissing-format-attribute
45 # produces false positives
46 # DEBUG_CPPFLAGS += -Wunreachable-code
47 # DEBUG_CPPFLAGS += -Wwrite-strings
48
49 # invalid option for gcc-3.3.3
50 # DEBUG_CPPFLAGS += -Wextra
51 # DEBUG_CPPFLAGS += -Wold-style-definition
52 # DEBUG_CPPFLAGS += -Wdeclaration-after-statement
53 # DEBUG_CPPFLAGS += -Wsuggest-attribute=const
54
55 # many warnings about trivial stuff
56 # CPPFLAGS += -Wconversion
57
58 ifeq ($(uname_s),Linux)
59 CPPFLAGS += -fdata-sections -ffunction-sections
60 LDFLAGS += -Wl,--gc-sections
61 CPPFLAGS += -Wstrict-prototypes
62 CPPFLAGS += -Wshadow
63 # causes warnings on *BSD for the feature test macros
64 CPPFLAGS += -Wunused-macros
65 endif
66 CPPFLAGS += -Os
67 CPPFLAGS += -Wuninitialized
68 CPPFLAGS += -Wchar-subscripts
69 CPPFLAGS += -DBINDIR='"$(BINDIR)"'
70 CPPFLAGS += -DBUILD_DATE='"$(build_date)"'
71 CPPFLAGS += -DUNAME_RS='"$(uname_rs)"'
72 CPPFLAGS += -DCC_VERSION='"$(cc_version)"'
73 CPPFLAGS += -Werror-implicit-function-declaration
74 CPPFLAGS += -Wmissing-noreturn
75 CPPFLAGS += -Wbad-function-cast
76 CPPFLAGS += -fno-strict-aliasing
77 CPPFLAGS += -DMAIN_INPUT_FILE_IS_$(*F)
78 CPPFLAGS += @arch_cppflags@
79 CPPFLAGS += -I/usr/local/include
80 CPPFLAGS += -I$(cmdline_dir)
81 CPPFLAGS += @osl_cppflags@
82
83 LDFLAGS += @clock_gettime_ldflags@
84
85 man_pages := $(patsubst %, $(man_dir)/%.1, $(executables))
86
87 autocrap := config.h.in configure
88 tarball_pfx := @PACKAGE_TARNAME@-$(PACKAGE_VERSION)
89 tarball_delete := $(addprefix $(tarball_pfx)/,\
90 web .changelog_before_cvs .changelog_cvs .gitignore)
91 tarball := @PACKAGE_TARNAME@-$(PACKAGE_VERSION).tar.bz2
92
93 # To put more focus on warnings, be less verbose as default
94 # Use 'make V=1' to see the full commands
95 ifeq ("$(origin V)", "command line")
96 Q :=
97 else
98 Q := @
99 endif
100
101 .PHONY: dep all clean distclean maintainer-clean install man tarball
102 all: dep $(executables) $(man_pages)
103 dep: $(deps)
104 man: $(man_pages)
105 tarball: $(tarball)
106
107 $(object_dir) $(man_dir) $(ggo_dir) $(cmdline_dir) $(dep_dir) $(m4depdir) \
108 $(help2man_dir):
109 $(Q) $(MKDIR_P) $@
110
111 -include $(m4_ggo_dir)/makefile
112
113 # When in doubt, use brute force (Ken Thompson)
114 TOUPPER = \
115 $(subst a,A,$(subst b,B,$(subst c,C,$(subst d,D,$(subst e,E,\
116 $(subst f,F,$(subst g,G,$(subst h,H,$(subst i,I,$(subst j,J,\
117 $(subst k,K,$(subst l,L,$(subst m,M,$(subst n,N,$(subst o,O,\
118 $(subst p,P,$(subst q,Q,$(subst r,R,$(subst s,S,$(subst t,T,\
119 $(subst u,U,$(subst v,V,$(subst w,W,$(subst x,X,$(subst y,Y,\
120 $(subst z,Z,$1))))))))))))))))))))))))))
121
122 %_command_list.h: %.cmd %.c
123 @[ -z "$(Q)" ] || echo 'GEN $@'
124 $(Q) ./command_util.sh h < $< >$@
125 %_command_list.man: %.cmd %.c
126 @[ -z "$(Q)" ] || echo 'GEN $@'
127 $(Q) ./command_util.sh man < $< > $@
128 %_completion.h: %.cmd %.c
129 @[ -z "$(Q)" ] || echo 'GEN $@'
130 $(Q) ./command_util.sh compl $(strip $(call TOUPPER,$(*F)))_COMPLETERS \
131 $(strip $(call TOUPPER,$(*F)))_COMMANDS < $< > $@
132
133 server_command_list.h server_command_list.man server_completion.h: command.c
134 afs_command_list.h afs_command_list.man afs_completion.h: afs.c aft.c attribute.c
135 audiod_command_list.h audiod_command_list.man audiod_completion.h: audiod_command.c
136
137 server_command_lists_man = server_command_list.man afs_command_list.man
138 $(man_dir)/para_server.1: $(help2man_dir)/para_server $(server_command_lists_man) | $(man_dir)
139 @[ -z "$(Q)" ] || echo 'MAN $<'
140 $(Q) opts="`for i in $(server_command_lists_man); do printf "%s\n" "-i $$i"; done`"; \
141 $(HELP2MAN) $$opts ./$< > $@
142
143 $(man_dir)/para_audiod.1: $(help2man_dir)/para_audiod audiod_command_list.man | $(man_dir)
144 @[ -z "$(Q)" ] || echo 'MAN $<'
145 $(Q) $(HELP2MAN) -N -i audiod_command_list.man ./$< > $@
146
147 $(man_dir)/para_play.1: $(help2man_dir)/para_play play_command_list.man | $(man_dir)
148 @[ -z "$(Q)" ] || echo 'MAN $<'
149 $(Q) $(HELP2MAN) -N -i play_command_list.man ./$< > $@
150
151 $(man_dir)/%.1: $(help2man_dir)/% | $(man_dir)
152 @[ -z "$(Q)" ] || echo 'MAN $<'
153 $(Q) $(HELP2MAN) -N ./$< > $@
154
155 $(object_dir)/crypt.o: crypt.c | $(object_dir)
156 @[ -z "$(Q)" ] || echo 'CC $<'
157 $(Q) $(CC) -c -o $@ $(CPPFLAGS) $(DEBUG_CPPFLAGS) @openssl_cppflags@ $<
158 $(object_dir)/spx_common.o: spx_common.c | $(object_dir)
159 @[ -z "$(Q)" ] || echo 'CC $<'
160 $(Q) $(CC) -c -o $@ $(CPPFLAGS) $(DEBUG_CPPFLAGS) @ogg_cppflags@ $<
161
162 $(object_dir)/spxdec_filter.o: spxdec_filter.c | $(object_dir)
163 @[ -z "$(Q)" ] || echo 'CC $<'
164 $(Q) $(CC) -c -o $@ $(CPPFLAGS) $(DEBUG_CPPFLAGS) @ogg_cppflags@ $<
165
166 $(object_dir)/spx_afh.o: spx_afh.c | $(object_dir)
167 @[ -z "$(Q)" ] || echo 'CC $<'
168 $(Q) $(CC) -c -o $@ $(CPPFLAGS) $(DEBUG_CPPFLAGS) @ogg_cppflags@ $<
169
170 $(object_dir)/oggdec_filter.o: oggdec_filter.c | $(object_dir)
171 @[ -z "$(Q)" ] || echo 'CC $<'
172 $(Q) $(CC) -c -o $@ $(CPPFLAGS) $(DEBUG_CPPFLAGS) @ogg_cppflags@ $<
173
174 $(object_dir)/ogg_afh.o: ogg_afh.c | $(object_dir)
175 @[ -z "$(Q)" ] || echo 'CC $<'
176 $(Q) $(CC) -c -o $@ $(CPPFLAGS) $(DEBUG_CPPFLAGS) @ogg_cppflags@ $<
177
178 $(object_dir)/ogg_afh_common.o: ogg_afh_common.c | $(object_dir)
179 @[ -z "$(Q)" ] || echo 'CC $<'
180 $(Q) $(CC) -c -o $@ $(CPPFLAGS) $(DEBUG_CPPFLAGS) @ogg_cppflags@ $<
181
182 $(object_dir)/mp3dec_filter.o: mp3dec_filter.c | $(object_dir)
183 @[ -z "$(Q)" ] || echo 'CC $<'
184 $(Q) $(CC) -c -o $@ $(CPPFLAGS) $(DEBUG_CPPFLAGS) @mad_cppflags@ $<
185
186 $(object_dir)/compress_filter.o: compress_filter.c | $(object_dir)
187 @[ -z "$(Q)" ] || echo 'CC $<'
188 $(Q) $(CC) -c -o $@ $(CPPFLAGS) $(DEBUG_CPPFLAGS) -O3 $<
189
190 $(object_dir)/aacdec_filter.o: aacdec_filter.c | $(object_dir)
191 @[ -z "$(Q)" ] || echo 'CC $<'
192 $(Q) $(CC) -c -o $@ $(CPPFLAGS) $(DEBUG_CPPFLAGS) @faad_cppflags@ $<
193
194 $(object_dir)/aac_common.o: aac_common.c | $(object_dir)
195 @[ -z "$(Q)" ] || echo 'CC $<'
196 $(Q) $(CC) -c -o $@ $(CPPFLAGS) $(DEBUG_CPPFLAGS) @faad_cppflags@ $<
197
198 $(object_dir)/aac_afh.o: aac_afh.c | $(object_dir)
199 @[ -z "$(Q)" ] || echo 'CC $<'
200 $(Q) $(CC) -c -o $@ $(CPPFLAGS) $(DEBUG_CPPFLAGS) @faad_cppflags@ $<
201
202 $(object_dir)/mp3_afh.o: mp3_afh.c | $(object_dir)
203 @[ -z "$(Q)" ] || echo 'CC $<'
204 $(Q) $(CC) -c -o $@ $(CPPFLAGS) $(DEBUG_CPPFLAGS) @id3tag_cppflags@ $<
205
206 $(object_dir)/gui%.o: gui%.c | $(object_dir)
207 @[ -z "$(Q)" ] || echo 'CC $<'
208 $(Q) $(CC) -c -o $@ $(CPPFLAGS) $(DEBUG_CPPFLAGS) @curses_cppflags@ $<
209 $(object_dir)/ao_write.o: ao_write.c | $(object_dir)
210 @[ -z "$(Q)" ] || echo 'CC $<'
211 $(Q) $(CC) -c -o $@ $(CPPFLAGS) $(DEBUG_CPPFLAGS) @ao_cppflags@ $<
212
213 $(object_dir)/%.cmdline.o: $(cmdline_dir)/%.cmdline.c $(cmdline_dir)/%.cmdline.h | $(object_dir)
214 @[ -z "$(Q)" ] || echo 'CC $<'
215 $(Q) $(CC) -c $(CPPFLAGS) -Wno-unused-function -o $@ $<
216
217 $(object_dir)/%.o: %.c | $(object_dir)
218 @[ -z "$(Q)" ] || echo 'CC $<'
219 $(Q) $(CC) -c -o $@ $(CPPFLAGS) $(DEBUG_CPPFLAGS) $<
220
221 $(dep_dir)/%.cmdline.d: $(cmdline_dir)/%.cmdline.c | $(dep_dir)
222 @[ -z "$(Q)" ] || echo 'DEP $<'
223 $(Q) ./depend.sh $(dep_dir) $(object_dir) $(cmdline_dir) \
224 $(CPPFLAGS) $< > $@
225
226 $(dep_dir)/%.d: %.c | $(dep_dir)
227 @[ -z "$(Q)" ] || echo 'DEP $<'
228 $(Q) ./depend.sh $(dep_dir) $(object_dir) $(cmdline_dir) \
229 $(CPPFLAGS) $< > $@
230
231 all_objs := @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) @gui_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_sh) -s -m 755 $(executables) $(BINDIR)
320 $(install_sh) -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