]> git.cameronkatri.com Git - mandoc.git/blob - Makefile
Added generation of Universal binary. Fixed up index.sgml to be shorter
[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.6
15 VDATE = 16 August 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-getsubopt.c \
121 test-mmap.c \
122 test-strlcat.c \
123 test-strlcpy.c \
124 test-strptime.c \
125 tree.c \
126 vol.c \
127 vol.in
128
129 LIBMAN_OBJS = man.o \
130 man_hash.o \
131 man_macro.o \
132 man_validate.o
133 LIBMAN_LNS = man.ln \
134 man_hash.ln \
135 man_macro.ln \
136 man_validate.ln
137
138 LIBMDOC_OBJS = arch.o \
139 att.o \
140 lib.o \
141 mdoc.o \
142 mdoc_argv.o \
143 mdoc_hash.o \
144 mdoc_macro.o \
145 mdoc_validate.o \
146 msec.o \
147 st.o \
148 vol.o
149 LIBMDOC_LNS = arch.ln \
150 att.ln \
151 lib.ln \
152 mdoc.ln \
153 mdoc_argv.ln \
154 mdoc_hash.ln \
155 mdoc_macro.ln \
156 mdoc_validate.ln \
157 msec.ln \
158 st.ln \
159 vol.ln
160
161 LIBROFF_OBJS = eqn.o \
162 roff.o \
163 tbl.o \
164 tbl_data.o \
165 tbl_layout.o \
166 tbl_opts.o
167 LIBROFF_LNS = eqn.ln \
168 roff.ln \
169 tbl.ln \
170 tbl_data.ln \
171 tbl_layout.ln \
172 tbl_opts.ln
173
174 LIBMANDOC_OBJS = $(LIBMAN_OBJS) \
175 $(LIBMDOC_OBJS) \
176 $(LIBROFF_OBJS) \
177 chars.o \
178 mandoc.o \
179 read.o
180 LIBMANDOC_LNS = $(LIBMAN_LNS) \
181 $(LIBMDOC_LNS) \
182 $(LIBROFF_LNS) \
183 chars.ln \
184 mandoc.ln \
185 read.ln
186
187 COMPAT_OBJS = compat_getsubopt.o \
188 compat_strlcat.o \
189 compat_strlcpy.o
190 COMPAT_LNS = compat_getsubopt.ln \
191 compat_strlcat.ln \
192 compat_strlcpy.ln
193
194 arch.o arch.ln: arch.in
195 att.o att.ln: att.in
196 chars.o chars.ln: chars.in
197 lib.o lib.ln: lib.in
198 msec.o msec.ln: msec.in
199 roff.o roff.ln: predefs.in
200 st.o st.ln: st.in
201 vol.o vol.ln: vol.in
202
203 $(LIBMAN_OBJS) $(LIBMAN_LNS): libman.h
204 $(LIBMDOC_OBJS) $(LIBMDOC_LNS): libmdoc.h
205 $(LIBROFF_OBJS) $(LIBROFF_LNS): libroff.h
206 $(LIBMANDOC_OBJS) $(LIBMANDOC_LNS): mandoc.h mdoc.h man.h libmandoc.h config.h
207
208 $(COMPAT_OBJS) $(COMPAT_LNS): config.h
209
210 MANDOC_HTML_OBJS = eqn_html.o \
211 html.o \
212 man_html.o \
213 mdoc_html.o \
214 tbl_html.o
215 MANDOC_HTML_LNS = eqn_html.ln \
216 html.ln \
217 man_html.ln \
218 mdoc_html.ln \
219 tbl_html.ln
220
221 MANDOC_TERM_OBJS = eqn_term.o \
222 man_term.o \
223 mdoc_term.o \
224 term.o \
225 term_ascii.o \
226 term_ps.o \
227 tbl_term.o
228 MANDOC_TERM_LNS = eqn_term.ln \
229 man_term.ln \
230 mdoc_term.ln \
231 term.ln \
232 term_ascii.ln \
233 term_ps.ln \
234 tbl_term.ln
235
236 MANDOC_OBJS = $(MANDOC_HTML_OBJS) \
237 $(MANDOC_TERM_OBJS) \
238 main.o \
239 out.o \
240 tree.o
241 MANDOC_LNS = $(MANDOC_HTML_LNS) \
242 $(MANDOC_TERM_LNS) \
243 main.ln \
244 out.ln \
245 tree.ln
246
247 $(MANDOC_HTML_OBJS) $(MANDOC_HTML_LNS): html.h
248 $(MANDOC_TERM_OBJS) $(MANDOC_TERM_LNS): term.h
249 $(MANDOC_OBJS) $(MANDOC_LNS): main.h mandoc.h mdoc.h man.h config.h out.h
250
251 MANDOCDB_OBJS = mandocdb.o
252 MANDOCDB_LNS = mandocdb.ln
253
254 $(MANDOCDB_OBJS) $(MANDOCDB_LNS): mandoc.h mdoc.h man.h config.h
255
256 PRECONV_OBJS = preconv.o
257 PRECONV_LNS = preconv.ln
258
259 $(PRECONV_OBJS) $(PRECONV_LNS): config.h
260
261 INDEX_MANS = mandoc.1.html \
262 mandoc.1.xhtml \
263 mandoc.1.ps \
264 mandoc.1.pdf \
265 mandoc.1.txt \
266 mandoc.3.html \
267 mandoc.3.xhtml \
268 mandoc.3.ps \
269 mandoc.3.pdf \
270 mandoc.3.txt \
271 eqn.7.html \
272 eqn.7.xhtml \
273 eqn.7.ps \
274 eqn.7.pdf \
275 eqn.7.txt \
276 man.7.html \
277 man.7.xhtml \
278 man.7.ps \
279 man.7.pdf \
280 man.7.txt \
281 mandoc_char.7.html \
282 mandoc_char.7.xhtml \
283 mandoc_char.7.ps \
284 mandoc_char.7.pdf \
285 mandoc_char.7.txt \
286 mdoc.7.html \
287 mdoc.7.xhtml \
288 mdoc.7.ps \
289 mdoc.7.pdf \
290 mdoc.7.txt \
291 preconv.1.html \
292 preconv.1.xhtml \
293 preconv.1.ps \
294 preconv.1.pdf \
295 preconv.1.txt \
296 roff.7.html \
297 roff.7.xhtml \
298 roff.7.ps \
299 roff.7.pdf \
300 roff.7.txt \
301 tbl.7.html \
302 tbl.7.xhtml \
303 tbl.7.ps \
304 tbl.7.pdf \
305 tbl.7.txt \
306 mandocdb.8.html \
307 mandocdb.8.xhtml \
308 mandocdb.8.ps \
309 mandocdb.8.pdf \
310 mandocdb.8.txt
311
312 $(INDEX_MANS): mandoc
313
314 INDEX_OBJS = $(INDEX_MANS) \
315 man.h.html \
316 mandoc.h.html \
317 mdoc.h.html \
318 mdocml.tar.gz \
319 mdocml.md5
320
321 www: index.html
322
323 lint: llib-llibmandoc.ln llib-lmandoc.ln llib-lpreconv.ln
324
325 clean:
326 rm -f libmandoc.a $(LIBMANDOC_OBJS)
327 rm -f llib-llibmandoc.ln $(LIBMANDOC_LNS)
328 rm -f mandocdb $(MANDOCDB_OBJS)
329 rm -f llib-lmandocdb.ln $(MANDOCDB_LNS)
330 rm -f preconv $(PRECONV_OBJS)
331 rm -f llib-lpreconv.ln $(PRECONV_LNS)
332 rm -f mandoc $(MANDOC_OBJS)
333 rm -f llib-lmandoc.ln $(MANDOC_LNS)
334 rm -f config.h config.log $(COMPAT_OBJS) $(COMPAT_LNS)
335 rm -f mdocml.tar.gz mdocml-win32.zip mdocml-win64.zip mdocml-macosx.zip
336 rm -f index.html $(INDEX_OBJS)
337 rm -rf test-strlcpy.DSYM
338 rm -rf test-strlcat.DSYM
339 rm -rf test-strptime.DSYM
340 rm -rf test-mmap.DSYM
341 rm -rf test-getsubopt.DSYM
342
343 install: all
344 mkdir -p $(DESTDIR)$(BINDIR)
345 mkdir -p $(DESTDIR)$(EXAMPLEDIR)
346 mkdir -p $(DESTDIR)$(LIBDIR)
347 mkdir -p $(DESTDIR)$(INCLUDEDIR)
348 mkdir -p $(DESTDIR)$(MANDIR)/man1
349 mkdir -p $(DESTDIR)$(MANDIR)/man3
350 mkdir -p $(DESTDIR)$(MANDIR)/man7
351 mkdir -p $(DESTDIR)$(MANDIR)/man8
352 $(INSTALL_PROGRAM) mandoc preconv $(DESTDIR)$(BINDIR)
353 $(INSTALL_LIB) libmandoc.a $(DESTDIR)$(LIBDIR)
354 $(INSTALL_LIB) man.h mdoc.h mandoc.h $(DESTDIR)$(INCLUDEDIR)
355 $(INSTALL_MAN) mandoc.1 preconv.1 $(DESTDIR)$(MANDIR)/man1
356 $(INSTALL_MAN) mandoc.3 $(DESTDIR)$(MANDIR)/man3
357 $(INSTALL_MAN) man.7 mdoc.7 roff.7 eqn.7 tbl.7 mandoc_char.7 $(DESTDIR)$(MANDIR)/man7
358 $(INSTALL_DATA) example.style.css $(DESTDIR)$(EXAMPLEDIR)
359
360 installwww: www
361 mkdir -p $(PREFIX)/snapshots
362 mkdir -p $(PREFIX)/binaries
363 $(INSTALL_DATA) index.html external.png index.css $(PREFIX)
364 $(INSTALL_DATA) $(INDEX_MANS) style.css $(PREFIX)
365 $(INSTALL_DATA) mandoc.h.html man.h.html mdoc.h.html $(PREFIX)
366 $(INSTALL_DATA) mdocml.tar.gz $(PREFIX)/snapshots
367 $(INSTALL_DATA) mdocml.md5 $(PREFIX)/snapshots
368 $(INSTALL_DATA) mdocml.tar.gz $(PREFIX)/snapshots/mdocml-$(VERSION).tar.gz
369 $(INSTALL_DATA) mdocml.md5 $(PREFIX)/snapshots/mdocml-$(VERSION).md5
370
371 libmandoc.a: $(COMPAT_OBJS) $(LIBMANDOC_OBJS)
372 $(AR) rs $@ $(COMPAT_OBJS) $(LIBMANDOC_OBJS)
373
374 llib-llibmandoc.ln: $(COMPAT_LNS) $(LIBMANDOC_LNS)
375 $(LINT) $(LINTFLAGS) -Clibmandoc $(COMPAT_LNS) $(LIBMANDOC_LNS)
376
377 mandoc: $(MANDOC_OBJS) libmandoc.a
378 $(CC) $(LDFLAGS) -o $@ $(MANDOC_OBJS) libmandoc.a
379
380 llib-lmandoc.ln: $(MANDOC_LNS)
381 $(LINT) $(LINTFLAGS) -Cmandoc $(MANDOC_LNS)
382
383 mandocdb: $(MANDOCDB_OBJS) libmandoc.a
384 $(CC) $(LDFLAGS) -o $@ $(MANDOCDB_OBJS) libmandoc.a $(DBLIB)
385
386 llib-lmandocdb.ln: $(MANDOCDB_LNS)
387 $(LINT) $(LINTFLAGS) -Cmandocdb $(MANDOCDB_LNS)
388
389 preconv: $(PRECONV_OBJS)
390 $(CC) $(LDFLAGS) -o $@ $(PRECONV_OBJS)
391
392 llib-lpreconv.ln: $(PRECONV_LNS)
393 $(LINT) $(LINTFLAGS) -Cpreconv $(PRECONV_LNS)
394
395 mdocml.md5: mdocml.tar.gz
396 md5 mdocml.tar.gz >$@
397
398 mdocml.tar.gz: $(SRCS)
399 mkdir -p .dist/mdocml-$(VERSION)/
400 $(INSTALL_SOURCE) $(SRCS) .dist/mdocml-$(VERSION)
401 ( cd .dist/ && tar zcf ../$@ ./ )
402 rm -rf .dist/
403
404 mdocml-win32.zip: $(SRCS)
405 mkdir -p .win32/mdocml-$(VERSION)/
406 $(INSTALL_SOURCE) $(SRCS) .win32
407 cp .win32/Makefile .win32/Makefile.old
408 grep -v DUSE_WCHAR .win32/Makefile.old >.win32/Makefile
409 ( cd .win32; \
410 CC=i686-w64-mingw32-gcc AR=i686-w64-mingw32-ar CFLAGS='-DOSNAME=\"Windows\"' make; \
411 make install PREFIX=mdocml-$(VERSION) ; \
412 zip -r ../$@ mdocml-$(VERSION) )
413 rm -rf .win32
414
415 mdocml-win64.zip: $(SRCS)
416 mkdir -p .win64/mdocml-$(VERSION)/
417 $(INSTALL_SOURCE) $(SRCS) .win64
418 cp .win64/Makefile .win64/Makefile.old
419 grep -v DUSE_WCHAR .win64/Makefile.old >.win64/Makefile
420 ( cd .win64; \
421 CC=x86_64-w64-mingw32-gcc AR=x86_64-w64-mingw32-ar CFLAGS='-DOSNAME=\"Windows\"' make; \
422 make install PREFIX=mdocml-$(VERSION) ; \
423 zip -r ../$@ mdocml-$(VERSION) )
424 rm -rf .win64
425
426 mdocml-macosx.zip: $(SRCS)
427 mkdir -p .macosx/mdocml-$(VERSION)/
428 $(INSTALL_SOURCE) $(SRCS) .macosx
429 ( cd .macosx; \
430 CFLAGS="-arch i386 -arch x86_64 -arch ppc" LDFLAGS="-arch i386 -arch x86_64 -arch ppc" make; \
431 make install PREFIX=mdocml-$(VERSION) ; \
432 zip -r ../$@ mdocml-$(VERSION) )
433 rm -rf .macosx
434
435 index.html: $(INDEX_OBJS)
436
437 config.h: config.h.pre config.h.post
438 rm -f config.log
439 ( cat config.h.pre; \
440 echo; \
441 if $(CC) $(CFLAGS) -Werror -o test-strptime test-strptime.c >> config.log 2>&1; then \
442 echo '#define HAVE_STRPTIME'; \
443 rm test-strptime; \
444 fi; \
445 if $(CC) $(CFLAGS) -Werror -o test-getsubopt test-getsubopt.c >> config.log 2>&1; then \
446 echo '#define HAVE_GETSUBOPT'; \
447 rm test-getsubopt; \
448 fi; \
449 if $(CC) $(CFLAGS) -Werror -o test-strlcat test-strlcat.c >> config.log 2>&1; then \
450 echo '#define HAVE_STRLCAT'; \
451 rm test-strlcat; \
452 fi; \
453 if $(CC) $(CFLAGS) -Werror -o test-mmap test-mmap.c >> config.log 2>&1; then \
454 echo '#define HAVE_MMAP'; \
455 rm test-mmap; \
456 fi; \
457 if $(CC) $(CFLAGS) -Werror -o test-strlcpy test-strlcpy.c >> config.log 2>&1; then \
458 echo '#define HAVE_STRLCPY'; \
459 rm test-strlcpy; \
460 fi; \
461 echo; \
462 cat config.h.post \
463 ) > $@
464
465 .h.h.html:
466 highlight -I $< >$@
467
468 .1.1.txt .3.3.txt .7.7.txt .8.8.txt:
469 ./mandoc -Tascii -Wall,stop $< | col -b >$@
470
471 .1.1.html .3.3.html .7.7.html .8.8.html:
472 ./mandoc -Thtml -Wall,stop -Ostyle=style.css,man=%N.%S.html,includes=%I.html $< >$@
473
474 .1.1.ps .3.3.ps .7.7.ps .8.8.ps:
475 ./mandoc -Tps -Wall,stop $< >$@
476
477 .1.1.xhtml .3.3.xhtml .7.7.xhtml .8.8.xhtml:
478 ./mandoc -Txhtml -Wall,stop -Ostyle=style.css,man=%N.%S.xhtml,includes=%I.html $< >$@
479
480 .1.1.pdf .3.3.pdf .7.7.pdf .8.8.pdf:
481 ./mandoc -Tpdf -Wall,stop $< >$@
482
483 .sgml.html:
484 validate --warn $<
485 sed -e "s!@VERSION@!$(VERSION)!" -e "s!@VDATE@!$(VDATE)!" $< >$@