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