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