]> git.cameronkatri.com Git - mandoc.git/blob - Makefile
Implement the obsolete macros .En .Es .Fr .Ot for backward compatibility,
[mandoc.git] / Makefile
1 # $Id: Makefile,v 1.420 2014/06/20 02:55:49 schwarze Exp $
2 #
3 # Copyright (c) 2010, 2011, 2012 Kristaps Dzonsons <kristaps@bsd.lv>
4 # Copyright (c) 2011, 2013, 2014 Ingo Schwarze <schwarze@openbsd.org>
5 #
6 # Permission to use, copy, modify, and distribute this software for any
7 # purpose with or without fee is hereby granted, provided that the above
8 # copyright notice and this permission notice appear in all copies.
9 #
10 # THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11 # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12 # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13 # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14 # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15 # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16 # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17
18 VERSION = 1.13.0
19
20 # === USER SETTINGS ====================================================
21
22 # Specify this if you want to hard-code the operating system to appear
23 # in the lower-left hand corner of -mdoc manuals.
24 #
25 # CFLAGS += -DOSNAME="\"OpenBSD 5.5\""
26
27 # IFF your system supports multi-byte functions (setlocale(), wcwidth(),
28 # putwchar()) AND has __STDC_ISO_10646__ (that is, wchar_t is simply a
29 # UCS-4 value) should you define USE_WCHAR. If you define it and your
30 # system DOESN'T support this, -Tlocale will produce garbage.
31 # If you don't define it, -Tlocale is a synonym for -Tacsii.
32 #
33 CFLAGS += -DUSE_WCHAR
34
35 # If your system has manpath(1), uncomment this. This is most any
36 # system that's not OpenBSD or NetBSD. If uncommented, manpage(1) and
37 # makewhatis(8) will use manpath(1) to get the MANPATH variable.
38 #CFLAGS += -DUSE_MANPATH
39
40 # If your system does not support static binaries, comment this,
41 # for example on Mac OS X.
42 STATIC = -static
43 # Linux requires -pthread to statically link with libdb.
44 #STATIC += -pthread
45
46 CFLAGS += -I/usr/local/include -g -DHAVE_CONFIG_H
47 CFLAGS += -W -Wall -Wstrict-prototypes -Wno-unused-parameter -Wwrite-strings
48 PREFIX = /usr/local
49 WWWPREFIX = /var/www
50 HTDOCDIR = $(WWWPREFIX)/htdocs
51 CGIBINDIR = $(WWWPREFIX)/cgi-bin
52 BINDIR = $(PREFIX)/bin
53 INCLUDEDIR = $(PREFIX)/include/mandoc
54 LIBDIR = $(PREFIX)/lib/mandoc
55 MANDIR = $(PREFIX)/man
56 EXAMPLEDIR = $(PREFIX)/share/examples/mandoc
57 INSTALL = install
58 INSTALL_PROGRAM = $(INSTALL) -m 0755
59 INSTALL_DATA = $(INSTALL) -m 0444
60 INSTALL_LIB = $(INSTALL) -m 0644
61 INSTALL_SOURCE = $(INSTALL) -m 0644
62 INSTALL_MAN = $(INSTALL_DATA)
63
64 # If you want to build without database support, for example to avoid
65 # the dependency on SQLite3, comment the following two lines.
66 DBLIB = -L/usr/local/lib -lsqlite3
67 DBBIN = makewhatis manpage apropos
68
69 # OpenBSD has the ohash functions in libutil.
70 # Comment the following line if your system doesn't.
71 DBLIB += -lutil
72
73 # === END OF USER SETTINGS =============================================
74
75 ALLBIN = mandoc preconv demandoc $(DBBIN)
76
77 all: $(ALLBIN)
78
79 TESTSRCS = test-fgetln.c \
80 test-getsubopt.c \
81 test-mmap.c \
82 test-ohash.c \
83 test-reallocarray.c \
84 test-strlcat.c \
85 test-strlcpy.c \
86 test-strnlen.c \
87 test-strptime.c
88
89 SRCS = LICENSE \
90 Makefile \
91 NEWS \
92 TODO \
93 apropos.1 \
94 apropos.c \
95 arch.c \
96 arch.in \
97 att.c \
98 att.in \
99 cgi.c \
100 chars.c \
101 chars.in \
102 compat_fgetln.c \
103 compat_getsubopt.c \
104 compat_ohash.c \
105 compat_ohash.h \
106 compat_reallocarray.c \
107 compat_strcasestr.c \
108 compat_strlcat.c \
109 compat_strlcpy.c \
110 compat_strnlen.c \
111 compat_strsep.c \
112 config.h.post \
113 config.h.pre \
114 configure \
115 demandoc.1 \
116 demandoc.c \
117 eqn.7 \
118 eqn.c \
119 eqn_html.c \
120 eqn_term.c \
121 example.style.css \
122 gmdiff \
123 html.c \
124 html.h \
125 lib.c \
126 lib.in \
127 libman.h \
128 libmandoc.h \
129 libmdoc.h \
130 libroff.h \
131 main.c \
132 main.h \
133 makewhatis.8 \
134 man.7 \
135 man.c \
136 man-cgi.css \
137 man.h \
138 man_hash.c \
139 man_html.c \
140 man_macro.c \
141 man_term.c \
142 man_validate.c \
143 mandoc.1 \
144 mandoc.3 \
145 mandoc.c \
146 mandoc.db.5 \
147 mandoc.h \
148 mandoc_aux.c \
149 mandoc_aux.h \
150 mandoc_char.7 \
151 mandocdb.c \
152 manpage.c \
153 manpath.c \
154 manpath.h \
155 mansearch.3 \
156 mansearch.c \
157 mansearch.h \
158 mansearch_const.c \
159 mdoc.7 \
160 mdoc.c \
161 mdoc.h \
162 mdoc_argv.c \
163 mdoc_hash.c \
164 mdoc_html.c \
165 mdoc_macro.c \
166 mdoc_man.c \
167 mdoc_term.c \
168 mdoc_validate.c \
169 msec.c \
170 msec.in \
171 out.c \
172 out.h \
173 preconv.1 \
174 preconv.c \
175 predefs.in \
176 read.c \
177 roff.7 \
178 roff.c \
179 st.c \
180 st.in \
181 style.css \
182 tbl.3 \
183 tbl.7 \
184 tbl.c \
185 tbl_data.c \
186 tbl_html.c \
187 tbl_layout.c \
188 tbl_opts.c \
189 tbl_term.c \
190 term.c \
191 term.h \
192 term_ascii.c \
193 term_ps.c \
194 tree.c \
195 vol.c \
196 vol.in \
197 $(TESTSRCS)
198
199 LIBMAN_OBJS = man.o \
200 man_hash.o \
201 man_macro.o \
202 man_validate.o
203
204 LIBMDOC_OBJS = arch.o \
205 att.o \
206 lib.o \
207 mdoc.o \
208 mdoc_argv.o \
209 mdoc_hash.o \
210 mdoc_macro.o \
211 mdoc_validate.o \
212 st.o \
213 vol.o
214
215 LIBROFF_OBJS = eqn.o \
216 roff.o \
217 tbl.o \
218 tbl_data.o \
219 tbl_layout.o \
220 tbl_opts.o
221
222 LIBMANDOC_OBJS = $(LIBMAN_OBJS) \
223 $(LIBMDOC_OBJS) \
224 $(LIBROFF_OBJS) \
225 chars.o \
226 mandoc.o \
227 mandoc_aux.o \
228 msec.o \
229 read.o
230
231 COMPAT_OBJS = compat_fgetln.o \
232 compat_getsubopt.o \
233 compat_ohash.o \
234 compat_reallocarray.o \
235 compat_strcasestr.o \
236 compat_strlcat.o \
237 compat_strlcpy.o \
238 compat_strnlen.o \
239 compat_strsep.o
240
241 # === DEPENDENCY HANDLING ==============================================
242
243 arch.o: arch.in
244 att.o: att.in
245 chars.o: chars.in
246 lib.o: lib.in
247 msec.o: msec.in
248 roff.o: predefs.in
249 st.o: st.in
250 vol.o: vol.in
251
252 $(LIBMAN_OBJS): libman.h
253 $(LIBMDOC_OBJS): libmdoc.h
254 $(LIBROFF_OBJS): libroff.h
255 $(LIBMANDOC_OBJS): mandoc.h mandoc_aux.h mdoc.h man.h libmandoc.h config.h
256 $(COMPAT_OBJS): config.h compat_ohash.h
257
258 MANDOC_HTML_OBJS = eqn_html.o \
259 html.o \
260 man_html.o \
261 mdoc_html.o \
262 tbl_html.o
263 $(MANDOC_HTML_OBJS): html.h
264
265 MANDOC_MAN_OBJS = mdoc_man.o
266
267 MANDOC_TERM_OBJS = eqn_term.o \
268 man_term.o \
269 mdoc_term.o \
270 term.o \
271 term_ascii.o \
272 term_ps.o \
273 tbl_term.o
274 $(MANDOC_TERM_OBJS): term.h
275
276 MANDOC_OBJS = $(MANDOC_HTML_OBJS) \
277 $(MANDOC_MAN_OBJS) \
278 $(MANDOC_TERM_OBJS) \
279 main.o \
280 out.o \
281 tree.o
282 $(MANDOC_OBJS): main.h mandoc.h mandoc_aux.h mdoc.h man.h config.h out.h
283
284 MAKEWHATIS_OBJS = mandocdb.o mansearch_const.o manpath.o
285 $(MAKEWHATIS_OBJS): mansearch.h mandoc.h mandoc_aux.h \
286 mdoc.h man.h config.h manpath.h
287
288 PRECONV_OBJS = preconv.o
289 $(PRECONV_OBJS): config.h
290
291 APROPOS_OBJS = apropos.o mansearch.o mansearch_const.o manpath.o
292 $(APROPOS_OBJS): config.h mandoc.h mandoc_aux.h manpath.h mansearch.h
293
294 MANPAGE_OBJS = manpage.o mansearch.o mansearch_const.o manpath.o
295 $(MANPAGE_OBJS): config.h mandoc.h mandoc_aux.h manpath.h mansearch.h
296
297 DEMANDOC_OBJS = demandoc.o
298 $(DEMANDOC_OBJS): config.h mandoc.h man.h mdoc.h
299
300 WWW_MANS = apropos.1.html \
301 demandoc.1.html \
302 mandoc.1.html \
303 preconv.1.html \
304 mandoc.3.html \
305 mansearch.3.html \
306 tbl.3.html \
307 mandoc.db.5.html \
308 eqn.7.html \
309 man.7.html \
310 mandoc_char.7.html \
311 mdoc.7.html \
312 roff.7.html \
313 tbl.7.html \
314 makewhatis.8.html \
315 man.h.html \
316 mandoc.h.html \
317 mandoc_aux.h.html \
318 manpath.h.html \
319 mansearch.h.html \
320 mdoc.h.html
321
322 WWW_OBJS = mdocml.tar.gz \
323 mdocml.sha256
324
325 www: $(WWW_OBJS) $(WWW_MANS)
326
327 # === TARGETS CONTAINING SHELL COMMANDS ================================
328
329 clean:
330 rm -f libmandoc.a $(LIBMANDOC_OBJS)
331 rm -f apropos $(APROPOS_OBJS)
332 rm -f makewhatis $(MAKEWHATIS_OBJS)
333 rm -f preconv $(PRECONV_OBJS)
334 rm -f manpage $(MANPAGE_OBJS)
335 rm -f demandoc $(DEMANDOC_OBJS)
336 rm -f mandoc $(MANDOC_OBJS)
337 rm -f config.h config.log $(COMPAT_OBJS)
338 rm -f $(WWW_MANS) $(WWW_OBJS)
339 rm -rf *.dSYM
340
341 install: all
342 mkdir -p $(DESTDIR)$(BINDIR)
343 mkdir -p $(DESTDIR)$(EXAMPLEDIR)
344 mkdir -p $(DESTDIR)$(LIBDIR)
345 mkdir -p $(DESTDIR)$(INCLUDEDIR)
346 mkdir -p $(DESTDIR)$(MANDIR)/man1
347 mkdir -p $(DESTDIR)$(MANDIR)/man3
348 mkdir -p $(DESTDIR)$(MANDIR)/man5
349 mkdir -p $(DESTDIR)$(MANDIR)/man7
350 $(INSTALL_PROGRAM) $(ALLBIN) $(DESTDIR)$(BINDIR)
351 $(INSTALL_LIB) libmandoc.a $(DESTDIR)$(LIBDIR)
352 $(INSTALL_LIB) man.h mdoc.h mandoc.h $(DESTDIR)$(INCLUDEDIR)
353 $(INSTALL_MAN) mandoc.1 preconv.1 demandoc.1 $(DESTDIR)$(MANDIR)/man1
354 $(INSTALL_MAN) mandoc.3 mansearch.3 tbl.3 $(DESTDIR)$(MANDIR)/man3
355 $(INSTALL_MAN) mandoc.db.5 $(DESTDIR)$(MANDIR)/man5
356 $(INSTALL_MAN) man.7 mdoc.7 roff.7 eqn.7 tbl.7 mandoc_char.7 \
357 $(DESTDIR)$(MANDIR)/man7
358 $(INSTALL_DATA) example.style.css $(DESTDIR)$(EXAMPLEDIR)
359
360 installcgi: all
361 mkdir -p $(DESTDIR)$(CGIBINDIR)
362 mkdir -p $(DESTDIR)$(HTDOCDIR)
363 #$(INSTALL_PROGRAM) man.cgi $(DESTDIR)$(CGIBINDIR)
364 $(INSTALL_DATA) example.style.css $(DESTDIR)$(HTDOCDIR)/man.css
365 $(INSTALL_DATA) man-cgi.css $(DESTDIR)$(HTDOCDIR)
366
367 installwww: www
368 mkdir -p $(DESTDIR)$(HTDOCDIR)/snapshots
369 $(INSTALL_DATA) $(WWW_MANS) style.css $(DESTDIR)$(HTDOCDIR)
370 $(INSTALL_DATA) $(WWW_OBJS) $(DESTDIR)$(HTDOCDIR)/snapshots
371 $(INSTALL_DATA) mdocml.tar.gz \
372 $(DESTDIR)$(HTDOCDIR)/snapshots/mdocml-$(VERSION).tar.gz
373 $(INSTALL_DATA) mdocml.sha256 \
374 $(DESTDIR)$(HTDOCDIR)/snapshots/mdocml-$(VERSION).sha256
375
376 libmandoc.a: $(COMPAT_OBJS) $(LIBMANDOC_OBJS)
377 $(AR) rs $@ $(COMPAT_OBJS) $(LIBMANDOC_OBJS)
378
379 mandoc: $(MANDOC_OBJS) libmandoc.a
380 $(CC) $(LDFLAGS) -o $@ $(MANDOC_OBJS) libmandoc.a
381
382 makewhatis: $(MAKEWHATIS_OBJS) libmandoc.a
383 $(CC) $(LDFLAGS) -o $@ $(MAKEWHATIS_OBJS) libmandoc.a $(DBLIB)
384
385 preconv: $(PRECONV_OBJS)
386 $(CC) $(LDFLAGS) -o $@ $(PRECONV_OBJS)
387
388 manpage: $(MANPAGE_OBJS) libmandoc.a
389 $(CC) $(LDFLAGS) -o $@ $(MANPAGE_OBJS) libmandoc.a $(DBLIB)
390
391 apropos: $(APROPOS_OBJS) libmandoc.a
392 $(CC) $(LDFLAGS) -o $@ $(APROPOS_OBJS) libmandoc.a $(DBLIB)
393
394 demandoc: $(DEMANDOC_OBJS) libmandoc.a
395 $(CC) $(LDFLAGS) -o $@ $(DEMANDOC_OBJS) libmandoc.a
396
397 mdocml.sha256: mdocml.tar.gz
398 sha256 mdocml.tar.gz > $@
399
400 mdocml.tar.gz: $(SRCS)
401 mkdir -p .dist/mdocml-$(VERSION)/
402 $(INSTALL_SOURCE) $(SRCS) .dist/mdocml-$(VERSION)
403 chmod 755 .dist/mdocml-$(VERSION)/configure
404 ( cd .dist/ && tar zcf ../$@ mdocml-$(VERSION) )
405 rm -rf .dist/
406
407 config.h: configure config.h.pre config.h.post $(TESTSRCS)
408 rm -f config.log
409 CC="$(CC)" CFLAGS="$(CFLAGS)" VERSION="$(VERSION)" ./configure
410
411 .PHONY: clean install installcgi installwww
412 .SUFFIXES: .1 .3 .5 .7 .8 .h
413 .SUFFIXES: .1.html .3.html .5.html .7.html .8.html .h.html
414
415 .h.h.html:
416 highlight -I $< > $@
417
418 .1.1.html .3.3.html .5.5.html .7.7.html .8.8.html: mandoc
419 ./mandoc -Thtml -Wall,stop \
420 -Ostyle=style.css,man=%N.%S.html,includes=%I.html $< > $@