Import mdocml-1.11.1
[dragonfly.git] / contrib / mdocml / Makefile
CommitLineData
60e1e752
SW
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
80387638
SW
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.
60e1e752
SW
12# CFLAGS += -DOSNAME="\"OpenBSD 4.5\""
13
14VERSION = 1.11.1
15VDATE = 04 April 2011
16CFLAGS += -g -DHAVE_CONFIG_H -DVERSION="\"$(VERSION)\""
17CFLAGS += -W -Wall -Wstrict-prototypes -Wno-unused-parameter -Wwrite-strings
18PREFIX = /usr/local
19BINDIR = $(PREFIX)/bin
20INCLUDEDIR = $(PREFIX)/include/mandoc
21LIBDIR = $(PREFIX)/lib/mandoc
22MANDIR = $(PREFIX)/man
23EXAMPLEDIR = $(PREFIX)/share/examples/mandoc
24INSTALL = install
25INSTALL_PROGRAM = $(INSTALL) -m 0755
26INSTALL_DATA = $(INSTALL) -m 0444
27INSTALL_LIB = $(INSTALL) -m 0644
28INSTALL_MAN = $(INSTALL_DATA)
29
30all: mandoc
31
32SRCS = Makefile \
33 arch.c \
34 arch.in \
35 att.c \
36 att.in \
37 chars.c \
38 chars.in \
39 compat.c \
40 config.h.post \
41 config.h.pre \
42 eqn.7 \
43 eqn.c \
44 example.style.css \
45 external.png \
46 html.c \
47 html.h \
48 index.css \
49 index.sgml \
50 lib.c \
51 lib.in \
52 libman.h \
53 libmandoc.h \
54 libmdoc.h \
55 libroff.h \
56 main.c \
57 main.h \
58 man.h \
59 man.7 \
60 man.c \
61 man_hash.c \
62 man_html.c \
63 man_macro.c \
64 man_term.c \
65 man_validate.c \
66 mandoc.1 \
67 mandoc.3 \
68 mandoc.c \
69 mandoc.h \
70 mandoc-db.1 \
71 mandoc-db.c \
72 mandoc_char.7 \
73 mdoc.h \
74 mdoc.7 \
75 mdoc.c \
76 mdoc_argv.c \
77 mdoc_hash.c \
78 mdoc_html.c \
79 mdoc_macro.c \
80 mdoc_term.c \
81 mdoc_validate.c \
82 msec.c \
83 msec.in \
84 out.c \
85 out.h \
86 read.c \
87 roff.7 \
88 roff.c \
89 st.c \
90 st.in \
91 style.css \
92 tbl.7 \
93 tbl.c \
94 tbl_data.c \
95 tbl_html.c \
96 tbl_layout.c \
97 tbl_opts.c \
98 tbl_term.c \
99 term.c \
100 term.h \
101 term_ascii.c \
102 term_ps.c \
103 test-strlcat.c \
104 test-strlcpy.c \
105 tree.c \
106 vol.c \
107 vol.in
108
109LIBMAN_OBJS = man.o \
110 man_hash.o \
111 man_macro.o \
112 man_validate.o
113LIBMAN_LNS = man.ln \
114 man_hash.ln \
115 man_macro.ln \
116 man_validate.ln
117
118LIBMDOC_OBJS = arch.o \
119 att.o \
120 lib.o \
121 mdoc.o \
122 mdoc_argv.o \
123 mdoc_hash.o \
124 mdoc_macro.o \
125 mdoc_validate.o \
126 msec.o \
127 st.o \
128 vol.o
129LIBMDOC_LNS = arch.ln \
130 att.ln \
131 lib.ln \
132 mdoc.ln \
133 mdoc_argv.ln \
134 mdoc_hash.ln \
135 mdoc_macro.ln \
136 mdoc_validate.ln \
137 msec.ln \
138 st.ln \
139 vol.ln
140
141LIBROFF_OBJS = eqn.o \
142 roff.o \
143 tbl.o \
144 tbl_data.o \
145 tbl_layout.o \
146 tbl_opts.o
147LIBROFF_LNS = eqn.ln \
148 roff.ln \
149 tbl.ln \
150 tbl_data.ln \
151 tbl_layout.ln \
152 tbl_opts.ln
153
154LIBMANDOC_OBJS = $(LIBMAN_OBJS) \
155 $(LIBMDOC_OBJS) \
156 $(LIBROFF_OBJS) \
157 mandoc.o \
158 read.o
159LIBMANDOC_LNS = $(LIBMAN_LNS) \
160 $(LIBMDOC_LNS) \
161 $(LIBROFF_LNS) \
162 mandoc.ln \
163 read.ln
164
165arch.o arch.ln: arch.in
166att.o att.ln: att.in
167lib.o lib.ln: lib.in
168msec.o msec.ln: msec.in
169st.o st.ln: st.in
170vol.o vol.ln: vol.in
171
172$(LIBMAN_OBJS) $(LIBMAN_LNS): libman.h
173$(LIBMDOC_OBJS) $(LIBMDOC_LNS): libmdoc.h
174$(LIBROFF_OBJS) $(LIBROFF_LNS): libroff.h
175$(LIBMANDOC_OBJS) $(LIBMANDOC_LNS): mandoc.h mdoc.h man.h libmandoc.h config.h
176
177MANDOC_HTML_OBJS = html.o \
178 man_html.o \
179 mdoc_html.o \
180 tbl_html.o
181MANDOC_HTML_LNS = html.ln \
182 man_html.ln \
183 mdoc_html.ln \
184 tbl_html.ln
185
186MANDOC_TERM_OBJS = man_term.o \
187 mdoc_term.o \
188 term.o \
189 term_ascii.o \
190 term_ps.o \
191 tbl_term.o
192MANDOC_TERM_LNS = man_term.ln \
193 mdoc_term.ln \
194 term.ln \
195 term_ascii.ln \
196 term_ps.ln \
197 tbl_term.ln
198
199MANDOC_OBJS = $(MANDOC_HTML_OBJS) \
200 $(MANDOC_TERM_OBJS) \
201 chars.o \
202 main.o \
203 out.o \
204 tree.o
205MANDOC_LNS = $(MANDOC_HTML_LNS) \
206 $(MANDOC_TERM_LNS) \
207 chars.ln \
208 main.ln \
209 out.ln \
210 tree.ln
211
212chars.o chars.ln: chars.in
213
214$(MANDOC_HTML_OBJS) $(MANDOC_HTML_LNS): html.h
215$(MANDOC_TERM_OBJS) $(MANDOC_TERM_LNS): term.h
216$(MANDOC_OBJS) $(MANDOC_LNS): main.h mandoc.h mdoc.h man.h config.h out.h
217
218compat.o compat.ln: config.h
219
220MANDOCDB_OBJS = mandoc-db.o
221MANDOCDB_LNS = mandoc-db.ln
222
223$(MANDOCDB_OBJS) $(MANDOCDB_LNS): mandoc.h mdoc.h man.h config.h
224
225INDEX_MANS = mandoc.1.html \
226 mandoc.1.xhtml \
227 mandoc.1.ps \
228 mandoc.1.pdf \
229 mandoc.1.txt \
230 mandoc.3.html \
231 mandoc.3.xhtml \
232 mandoc.3.ps \
233 mandoc.3.pdf \
234 mandoc.3.txt \
235 eqn.7.html \
236 eqn.7.xhtml \
237 eqn.7.ps \
238 eqn.7.pdf \
239 eqn.7.txt \
240 man.7.html \
241 man.7.xhtml \
242 man.7.ps \
243 man.7.pdf \
244 man.7.txt \
245 mandoc_char.7.html \
246 mandoc_char.7.xhtml \
247 mandoc_char.7.ps \
248 mandoc_char.7.pdf \
249 mandoc_char.7.txt \
250 mdoc.7.html \
251 mdoc.7.xhtml \
252 mdoc.7.ps \
253 mdoc.7.pdf \
254 mdoc.7.txt \
255 roff.7.html \
256 roff.7.xhtml \
257 roff.7.ps \
258 roff.7.pdf \
259 roff.7.txt \
260 tbl.7.html \
261 tbl.7.xhtml \
262 tbl.7.ps \
263 tbl.7.pdf \
264 tbl.7.txt
265
266$(INDEX_MANS): mandoc
267
268INDEX_OBJS = $(INDEX_MANS) \
269 man.h.html \
270 mandoc.h.html \
271 mdoc.h.html \
272 mdocml.tar.gz \
273 mdocml.md5
274
275www: index.html
276
277lint: llib-llibmandoc.ln llib-lmandoc.ln
80387638
SW
278
279clean:
60e1e752
SW
280 rm -f libmandoc.a $(LIBMANDOC_OBJS)
281 rm -f llib-llibmandoc.ln $(LIBMANDOC_LNS)
282 rm -f mandoc-db $(MANDOCDB_OBJS)
283 rm -f llib-lmandoc-db.ln $(MANDOCDB_LNS)
284 rm -f mandoc $(MANDOC_OBJS)
285 rm -f llib-lmandoc.ln $(MANDOC_LNS)
286 rm -f config.h config.log compat.o compat.ln
287 rm -f mdocml.tar.gz
288 rm -f index.html $(INDEX_OBJS)
289
290install: all
80387638
SW
291 mkdir -p $(DESTDIR)$(BINDIR)
292 mkdir -p $(DESTDIR)$(EXAMPLEDIR)
293 mkdir -p $(DESTDIR)$(MANDIR)/man1
60e1e752 294 mkdir -p $(DESTDIR)$(MANDIR)/man3
80387638
SW
295 mkdir -p $(DESTDIR)$(MANDIR)/man7
296 $(INSTALL_PROGRAM) mandoc $(DESTDIR)$(BINDIR)
60e1e752 297 $(INSTALL_LIB) libmandoc.a $(DESTDIR)$(LIBDIR)
80387638 298 $(INSTALL_MAN) mandoc.1 $(DESTDIR)$(MANDIR)/man1
60e1e752
SW
299 $(INSTALL_MAN) mandoc.3 $(DESTDIR)$(MANDIR)/man3
300 $(INSTALL_MAN) man.7 mdoc.7 roff.7 eqn.7 tbl.7 mandoc_char.7 $(DESTDIR)$(MANDIR)/man7
80387638
SW
301 $(INSTALL_DATA) example.style.css $(DESTDIR)$(EXAMPLEDIR)
302
60e1e752
SW
303installwww: www
304 mkdir -p $(PREFIX)/snapshots
305 $(INSTALL_DATA) index.html external.png index.css $(PREFIX)
306 $(INSTALL_DATA) $(INDEX_MANS) style.css $(PREFIX)
307 $(INSTALL_DATA) mandoc.h.html man.h.html mdoc.h.html $(PREFIX)
308 $(INSTALL_DATA) mdocml.tar.gz $(PREFIX)/snapshots
309 $(INSTALL_DATA) mdocml.md5 $(PREFIX)/snapshots
310 $(INSTALL_DATA) mdocml.tar.gz $(PREFIX)/snapshots/mdocml-$(VERSION).tar.gz
311 $(INSTALL_DATA) mdocml.md5 $(PREFIX)/snapshots/mdocml-$(VERSION).md5
80387638 312
60e1e752
SW
313libmandoc.a: compat.o $(LIBMANDOC_OBJS)
314 $(AR) rs $@ compat.o $(LIBMANDOC_OBJS)
80387638 315
60e1e752
SW
316llib-llibmandoc.ln: compat.ln $(LIBMANDOC_LNS)
317 $(LINT) $(LINTFLAGS) -Clibmandoc compat.ln $(LIBMANDOC_LNS)
80387638 318
60e1e752
SW
319mandoc: $(MANDOC_OBJS) libmandoc.a
320 $(CC) -o $@ $(MANDOC_OBJS) libmandoc.a
80387638 321
60e1e752
SW
322# You'll need -ldb for Linux.
323mandoc-db: $(MANDOCDB_OBJS) libmandoc.a
324 $(CC) -o $@ $(MANDOCDB_OBJS) libmandoc.a
80387638 325
60e1e752
SW
326llib-lmandoc.ln: $(MANDOC_LNS)
327 $(LINT) $(LINTFLAGS) -Cmandoc $(MANDOC_LNS)
80387638 328
60e1e752
SW
329llib-lmandoc-db.ln: $(MANDOCDB_LNS)
330 $(LINT) $(LINTFLAGS) -Cmandoc-db $(MANDOCDB_LNS)
80387638 331
60e1e752
SW
332mdocml.md5: mdocml.tar.gz
333 md5 mdocml.tar.gz >$@
80387638 334
60e1e752
SW
335mdocml.tar.gz: $(SRCS)
336 mkdir -p .dist/mdocml-$(VERSION)/
337 $(INSTALL) -m 0444 $(SRCS) .dist/mdocml-$(VERSION)
338 ( cd .dist/ && tar zcf ../$@ ./ )
80387638
SW
339 rm -rf .dist/
340
60e1e752 341index.html: $(INDEX_OBJS)
80387638 342
60e1e752
SW
343config.h: config.h.pre config.h.post
344 rm -f config.log
345 ( cat config.h.pre; \
346 echo; \
347 if $(CC) $(CFLAGS) -Werror -o test-strlcat test-strlcat.c >> config.log 2>&1; then \
348 echo '#define HAVE_STRLCAT'; \
349 rm test-strlcat; \
350 fi; \
351 if $(CC) $(CFLAGS) -Werror -o test-strlcpy test-strlcpy.c >> config.log 2>&1; then \
352 echo '#define HAVE_STRLCPY'; \
353 rm test-strlcpy; \
354 fi; \
355 echo; \
356 cat config.h.post \
357 ) > $@
80387638 358
60e1e752
SW
359.h.h.html:
360 highlight -I $< >$@
80387638
SW
361
362.1.1.txt .3.3.txt .7.7.txt:
60e1e752 363 ./mandoc -Tascii -Wall,stop $< | col -b >$@
80387638 364
60e1e752
SW
365.1.1.html .3.3.html .7.7.html:
366 ./mandoc -Thtml -Wall,stop -Ostyle=style.css,man=%N.%S.html,includes=%I.html $< >$@
80387638
SW
367
368.1.1.ps .3.3.ps .7.7.ps:
60e1e752 369 ./mandoc -Tps -Wall,stop $< >$@
80387638
SW
370
371.1.1.xhtml .3.3.xhtml .7.7.xhtml:
60e1e752 372 ./mandoc -Txhtml -Wall,stop -Ostyle=style.css,man=%N.%S.xhtml,includes=%I.html $< >$@
80387638
SW
373
374.1.1.pdf .3.3.pdf .7.7.pdf:
60e1e752 375 ./mandoc -Tpdf -Wall,stop $< >$@
80387638 376
60e1e752
SW
377.sgml.html:
378 validate --warn $<
379 sed -e "s!@VERSION@!$(VERSION)!" -e "s!@VDATE@!$(VDATE)!" $< >$@