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