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