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