]> git.cameronkatri.com Git - mandoc.git/blob - Makefile
Rename makewhatis [back] into mandocdb. This is to maintain consistency
[mandoc.git] / Makefile
1 .PHONY: clean install installwww
2 .SUFFIXES: .sgml .html .md5 .h .h.html
3 .SUFFIXES: .1 .3 .7
4 .SUFFIXES: .1.txt .3.txt .7.txt
5 .SUFFIXES: .1.pdf .3.pdf .7.pdf
6 .SUFFIXES: .1.ps .3.ps .7.ps
7 .SUFFIXES: .1.html .3.html .7.html
8 .SUFFIXES: .1.xhtml .3.xhtml .7.xhtml
9
10 # Specify this if you want to hard-code the operating system to appear
11 # in the lower-left hand corner of -mdoc manuals.
12 # CFLAGS += -DOSNAME="\"OpenBSD 4.5\""
13
14 VERSION = 1.11.4
15 VDATE = 12 July 2011
16 # IFF your system supports multi-byte functions (setlocale(), wcwidth(),
17 # putwchar()) AND has __STDC_ISO_10646__ (that is, wchar_t is simply a
18 # UCS-4 value) should you define USE_WCHAR. If you define it and your
19 # system DOESN'T support this, -Tlocale will produce garbage.
20 # If you don't define it, -Tlocale is a synonym for -Tacsii.
21 CFLAGS += -g -DUSE_WCHAR -DHAVE_CONFIG_H -DVERSION="\"$(VERSION)\""
22 CFLAGS += -W -Wall -Wstrict-prototypes -Wno-unused-parameter -Wwrite-strings
23 PREFIX = /usr/local
24 BINDIR = $(PREFIX)/bin
25 INCLUDEDIR = $(PREFIX)/include/mandoc
26 LIBDIR = $(PREFIX)/lib/mandoc
27 MANDIR = $(PREFIX)/man
28 EXAMPLEDIR = $(PREFIX)/share/examples/mandoc
29 INSTALL = install
30 INSTALL_PROGRAM = $(INSTALL) -m 0755
31 INSTALL_DATA = $(INSTALL) -m 0444
32 INSTALL_LIB = $(INSTALL) -m 0644
33 INSTALL_SOURCE = $(INSTALL) -m 0644
34 INSTALL_MAN = $(INSTALL_DATA)
35
36 all: mandoc preconv
37
38 SRCS = Makefile \
39 arch.c \
40 arch.in \
41 att.c \
42 att.in \
43 chars.c \
44 chars.in \
45 compat.c \
46 config.h.post \
47 config.h.pre \
48 eqn.7 \
49 eqn.c \
50 example.style.css \
51 external.png \
52 html.c \
53 html.h \
54 index.css \
55 index.sgml \
56 lib.c \
57 lib.in \
58 libman.h \
59 libmandoc.h \
60 libmdoc.h \
61 libroff.h \
62 main.c \
63 main.h \
64 man.h \
65 man.7 \
66 man.c \
67 man_hash.c \
68 man_html.c \
69 man_macro.c \
70 man_term.c \
71 man_validate.c \
72 mandoc.1 \
73 mandoc.3 \
74 mandoc.c \
75 mandoc.h \
76 mandocdb.1 \
77 mandocdb.c \
78 mandoc_char.7 \
79 mdoc.h \
80 mdoc.7 \
81 mdoc.c \
82 mdoc_argv.c \
83 mdoc_hash.c \
84 mdoc_html.c \
85 mdoc_macro.c \
86 mdoc_term.c \
87 mdoc_validate.c \
88 msec.c \
89 msec.in \
90 out.c \
91 out.h \
92 preconv.1 \
93 preconv.c \
94 predefs.in \
95 read.c \
96 roff.7 \
97 roff.c \
98 st.c \
99 st.in \
100 style.css \
101 tbl.7 \
102 tbl.c \
103 tbl_data.c \
104 tbl_html.c \
105 tbl_layout.c \
106 tbl_opts.c \
107 tbl_term.c \
108 term.c \
109 term.h \
110 term_ascii.c \
111 term_ps.c \
112 test-mmap.c \
113 test-strlcat.c \
114 test-strlcpy.c \
115 tree.c \
116 vol.c \
117 vol.in
118
119 LIBMAN_OBJS = man.o \
120 man_hash.o \
121 man_macro.o \
122 man_validate.o
123 LIBMAN_LNS = man.ln \
124 man_hash.ln \
125 man_macro.ln \
126 man_validate.ln
127
128 LIBMDOC_OBJS = arch.o \
129 att.o \
130 lib.o \
131 mdoc.o \
132 mdoc_argv.o \
133 mdoc_hash.o \
134 mdoc_macro.o \
135 mdoc_validate.o \
136 msec.o \
137 st.o \
138 vol.o
139 LIBMDOC_LNS = arch.ln \
140 att.ln \
141 lib.ln \
142 mdoc.ln \
143 mdoc_argv.ln \
144 mdoc_hash.ln \
145 mdoc_macro.ln \
146 mdoc_validate.ln \
147 msec.ln \
148 st.ln \
149 vol.ln
150
151 LIBROFF_OBJS = eqn.o \
152 roff.o \
153 tbl.o \
154 tbl_data.o \
155 tbl_layout.o \
156 tbl_opts.o
157 LIBROFF_LNS = eqn.ln \
158 roff.ln \
159 tbl.ln \
160 tbl_data.ln \
161 tbl_layout.ln \
162 tbl_opts.ln
163
164 LIBMANDOC_OBJS = $(LIBMAN_OBJS) \
165 $(LIBMDOC_OBJS) \
166 $(LIBROFF_OBJS) \
167 chars.o \
168 mandoc.o \
169 read.o
170 LIBMANDOC_LNS = $(LIBMAN_LNS) \
171 $(LIBMDOC_LNS) \
172 $(LIBROFF_LNS) \
173 chars.ln \
174 mandoc.ln \
175 read.ln
176
177 arch.o arch.ln: arch.in
178 att.o att.ln: att.in
179 chars.o chars.ln: chars.in
180 lib.o lib.ln: lib.in
181 msec.o msec.ln: msec.in
182 roff.o roff.ln: predefs.in
183 st.o st.ln: st.in
184 vol.o vol.ln: vol.in
185
186 $(LIBMAN_OBJS) $(LIBMAN_LNS): libman.h
187 $(LIBMDOC_OBJS) $(LIBMDOC_LNS): libmdoc.h
188 $(LIBROFF_OBJS) $(LIBROFF_LNS): libroff.h
189 $(LIBMANDOC_OBJS) $(LIBMANDOC_LNS): mandoc.h mdoc.h man.h libmandoc.h config.h
190
191 MANDOC_HTML_OBJS = html.o \
192 man_html.o \
193 mdoc_html.o \
194 tbl_html.o
195 MANDOC_HTML_LNS = html.ln \
196 man_html.ln \
197 mdoc_html.ln \
198 tbl_html.ln
199
200 MANDOC_TERM_OBJS = man_term.o \
201 mdoc_term.o \
202 term.o \
203 term_ascii.o \
204 term_ps.o \
205 tbl_term.o
206 MANDOC_TERM_LNS = man_term.ln \
207 mdoc_term.ln \
208 term.ln \
209 term_ascii.ln \
210 term_ps.ln \
211 tbl_term.ln
212
213 MANDOC_OBJS = $(MANDOC_HTML_OBJS) \
214 $(MANDOC_TERM_OBJS) \
215 main.o \
216 out.o \
217 tree.o
218 MANDOC_LNS = $(MANDOC_HTML_LNS) \
219 $(MANDOC_TERM_LNS) \
220 main.ln \
221 out.ln \
222 tree.ln
223
224 $(MANDOC_HTML_OBJS) $(MANDOC_HTML_LNS): html.h
225 $(MANDOC_TERM_OBJS) $(MANDOC_TERM_LNS): term.h
226 $(MANDOC_OBJS) $(MANDOC_LNS): main.h mandoc.h mdoc.h man.h config.h out.h
227
228 compat.o compat.ln: config.h
229
230 MANDOCDB_OBJS = mandocdb.o
231 MANDOCDB_LNS = mandocdb.ln
232
233 $(MANDOCDB_OBJS) $(MANDOCDB_LNS): mandoc.h mdoc.h man.h config.h
234
235 PRECONV_OBJS = preconv.o
236 PRECONV_LNS = preconv.ln
237
238 $(PRECONV_OBJS) $(PRECONV_LNS): config.h
239
240 INDEX_MANS = mandocdb.1.html \
241 mandocdb.1.xhtml \
242 mandocdb.1.ps \
243 mandocdb.1.pdf \
244 mandocdb.1.txt \
245 mandoc.1.html \
246 mandoc.1.xhtml \
247 mandoc.1.ps \
248 mandoc.1.pdf \
249 mandoc.1.txt \
250 mandoc.3.html \
251 mandoc.3.xhtml \
252 mandoc.3.ps \
253 mandoc.3.pdf \
254 mandoc.3.txt \
255 eqn.7.html \
256 eqn.7.xhtml \
257 eqn.7.ps \
258 eqn.7.pdf \
259 eqn.7.txt \
260 man.7.html \
261 man.7.xhtml \
262 man.7.ps \
263 man.7.pdf \
264 man.7.txt \
265 mandoc_char.7.html \
266 mandoc_char.7.xhtml \
267 mandoc_char.7.ps \
268 mandoc_char.7.pdf \
269 mandoc_char.7.txt \
270 mdoc.7.html \
271 mdoc.7.xhtml \
272 mdoc.7.ps \
273 mdoc.7.pdf \
274 mdoc.7.txt \
275 preconv.1.html \
276 preconv.1.xhtml \
277 preconv.1.ps \
278 preconv.1.pdf \
279 preconv.1.txt \
280 roff.7.html \
281 roff.7.xhtml \
282 roff.7.ps \
283 roff.7.pdf \
284 roff.7.txt \
285 tbl.7.html \
286 tbl.7.xhtml \
287 tbl.7.ps \
288 tbl.7.pdf \
289 tbl.7.txt
290
291 $(INDEX_MANS): mandoc
292
293 INDEX_OBJS = $(INDEX_MANS) \
294 man.h.html \
295 mandoc.h.html \
296 mdoc.h.html \
297 mdocml.tar.gz \
298 mdocml.md5
299
300 www: index.html
301
302 lint: llib-llibmandoc.ln llib-lmandoc.ln llib-lpreconv.ln
303
304 clean:
305 rm -f libmandoc.a $(LIBMANDOC_OBJS)
306 rm -f llib-llibmandoc.ln $(LIBMANDOC_LNS)
307 rm -f mandocdb $(MANDOCDB_OBJS)
308 rm -f llib-lmandocdb.ln $(MANDOCDB_LNS)
309 rm -f preconv $(PRECONV_OBJS)
310 rm -f llib-lpreconv.ln $(PRECONV_LNS)
311 rm -f mandoc $(MANDOC_OBJS)
312 rm -f llib-lmandoc.ln $(MANDOC_LNS)
313 rm -f config.h config.log compat.o compat.ln
314 rm -f mdocml.tar.gz
315 rm -f index.html $(INDEX_OBJS)
316
317 install: all
318 mkdir -p $(DESTDIR)$(BINDIR)
319 mkdir -p $(DESTDIR)$(EXAMPLEDIR)
320 mkdir -p $(DESTDIR)$(LIBDIR)
321 mkdir -p $(DESTDIR)$(INCLUDEDIR)
322 mkdir -p $(DESTDIR)$(MANDIR)/man1
323 mkdir -p $(DESTDIR)$(MANDIR)/man3
324 mkdir -p $(DESTDIR)$(MANDIR)/man7
325 $(INSTALL_PROGRAM) mandoc preconv $(DESTDIR)$(BINDIR)
326 $(INSTALL_LIB) libmandoc.a $(DESTDIR)$(LIBDIR)
327 $(INSTALL_LIB) man.h mdoc.h mandoc.h $(DESTDIR)$(INCLUDEDIR)
328 $(INSTALL_MAN) mandoc.1 preconv.1 $(DESTDIR)$(MANDIR)/man1
329 $(INSTALL_MAN) mandoc.3 $(DESTDIR)$(MANDIR)/man3
330 $(INSTALL_MAN) man.7 mdoc.7 roff.7 eqn.7 tbl.7 mandoc_char.7 $(DESTDIR)$(MANDIR)/man7
331 $(INSTALL_DATA) example.style.css $(DESTDIR)$(EXAMPLEDIR)
332
333 installwww: www
334 mkdir -p $(PREFIX)/snapshots
335 $(INSTALL_DATA) index.html external.png index.css $(PREFIX)
336 $(INSTALL_DATA) $(INDEX_MANS) style.css $(PREFIX)
337 $(INSTALL_DATA) mandoc.h.html man.h.html mdoc.h.html $(PREFIX)
338 $(INSTALL_DATA) mdocml.tar.gz $(PREFIX)/snapshots
339 $(INSTALL_DATA) mdocml.md5 $(PREFIX)/snapshots
340 $(INSTALL_DATA) mdocml.tar.gz $(PREFIX)/snapshots/mdocml-$(VERSION).tar.gz
341 $(INSTALL_DATA) mdocml.md5 $(PREFIX)/snapshots/mdocml-$(VERSION).md5
342
343 libmandoc.a: compat.o $(LIBMANDOC_OBJS)
344 $(AR) rs $@ compat.o $(LIBMANDOC_OBJS)
345
346 llib-llibmandoc.ln: compat.ln $(LIBMANDOC_LNS)
347 $(LINT) $(LINTFLAGS) -Clibmandoc compat.ln $(LIBMANDOC_LNS)
348
349 mandoc: $(MANDOC_OBJS) libmandoc.a
350 $(CC) -o $@ $(MANDOC_OBJS) libmandoc.a
351
352 llib-lmandoc.ln: $(MANDOC_LNS)
353 $(LINT) $(LINTFLAGS) -Cmandoc $(MANDOC_LNS)
354
355 # You'll need -ldb for Linux.
356 mandocdb: $(MANDOCDB_OBJS) libmandoc.a
357 $(CC) -o $@ $(MANDOCDB_OBJS) libmandoc.a
358
359 llib-lmandocdb.ln: $(MANDOCDB_LNS)
360 $(LINT) $(LINTFLAGS) -Cmandocdb $(MANDOCDB_LNS)
361
362 preconv: $(PRECONV_OBJS)
363 $(CC) -o $@ $(PRECONV_OBJS)
364
365 llib-lpreconv.ln: $(PRECONV_LNS)
366 $(LINT) $(LINTFLAGS) -Cpreconv $(PRECONV_LNS)
367
368 mdocml.md5: mdocml.tar.gz
369 md5 mdocml.tar.gz >$@
370
371 mdocml.tar.gz: $(SRCS)
372 mkdir -p .dist/mdocml-$(VERSION)/
373 $(INSTALL_SOURCE) $(SRCS) .dist/mdocml-$(VERSION)
374 ( cd .dist/ && tar zcf ../$@ ./ )
375 rm -rf .dist/
376
377 index.html: $(INDEX_OBJS)
378
379 config.h: config.h.pre config.h.post
380 rm -f config.log
381 ( cat config.h.pre; \
382 echo; \
383 if $(CC) $(CFLAGS) -Werror -o test-strlcat test-strlcat.c >> config.log 2>&1; then \
384 echo '#define HAVE_STRLCAT'; \
385 rm test-strlcat; \
386 fi; \
387 if $(CC) $(CFLAGS) -Werror -o test-mmap test-mmap.c >> config.log 2>&1; then \
388 echo '#define HAVE_MMAP'; \
389 rm test-mmap; \
390 fi; \
391 if $(CC) $(CFLAGS) -Werror -o test-strlcpy test-strlcpy.c >> config.log 2>&1; then \
392 echo '#define HAVE_STRLCPY'; \
393 rm test-strlcpy; \
394 fi; \
395 echo; \
396 cat config.h.post \
397 ) > $@
398
399 .h.h.html:
400 highlight -I $< >$@
401
402 .1.1.txt .3.3.txt .7.7.txt:
403 ./mandoc -Tascii -Wall,stop $< | col -b >$@
404
405 .1.1.html .3.3.html .7.7.html:
406 ./mandoc -Thtml -Wall,stop -Ostyle=style.css,man=%N.%S.html,includes=%I.html $< >$@
407
408 .1.1.ps .3.3.ps .7.7.ps:
409 ./mandoc -Tps -Wall,stop $< >$@
410
411 .1.1.xhtml .3.3.xhtml .7.7.xhtml:
412 ./mandoc -Txhtml -Wall,stop -Ostyle=style.css,man=%N.%S.xhtml,includes=%I.html $< >$@
413
414 .1.1.pdf .3.3.pdf .7.7.pdf:
415 ./mandoc -Tpdf -Wall,stop $< >$@
416
417 .sgml.html:
418 validate --warn $<
419 sed -e "s!@VERSION@!$(VERSION)!" -e "s!@VDATE@!$(VDATE)!" $< >$@