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