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