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