]> git.cameronkatri.com Git - mandoc.git/blob - Makefile
Install the manuals of the web interface below the same directory
[mandoc.git] / Makefile
1 # $Id: Makefile,v 1.424 2014/07/13 09:39:32 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 # To build man.cgi, copy cgi.h.example to cgi.h, edit it, and
70 # either enable the following line or run "make man.cgi" by hand.
71 #DBBIN += man.cgi
72
73 # OpenBSD has the ohash functions in libutil.
74 # Comment the following line if your system doesn't.
75 DBLIB += -lutil
76
77 # === END OF USER SETTINGS =============================================
78
79 ALLBIN = mandoc preconv demandoc $(DBBIN)
80
81 all: $(ALLBIN)
82
83 TESTSRCS = test-fgetln.c \
84 test-getsubopt.c \
85 test-mmap.c \
86 test-ohash.c \
87 test-reallocarray.c \
88 test-strlcat.c \
89 test-strlcpy.c \
90 test-strnlen.c \
91 test-strptime.c
92
93 SRCS = LICENSE \
94 Makefile \
95 NEWS \
96 TODO \
97 apropos.1 \
98 apropos.c \
99 arch.c \
100 arch.in \
101 att.c \
102 att.in \
103 cgi.c \
104 chars.c \
105 chars.in \
106 compat_fgetln.c \
107 compat_getsubopt.c \
108 compat_ohash.c \
109 compat_ohash.h \
110 compat_reallocarray.c \
111 compat_strcasestr.c \
112 compat_strlcat.c \
113 compat_strlcpy.c \
114 compat_strnlen.c \
115 compat_strsep.c \
116 config.h.post \
117 config.h.pre \
118 configure \
119 demandoc.1 \
120 demandoc.c \
121 eqn.7 \
122 eqn.c \
123 eqn_html.c \
124 eqn_term.c \
125 example.style.css \
126 gmdiff \
127 html.c \
128 html.h \
129 lib.c \
130 lib.in \
131 libman.h \
132 libmandoc.h \
133 libmdoc.h \
134 libroff.h \
135 main.c \
136 main.h \
137 makewhatis.8 \
138 man.7 \
139 man.c \
140 man.cgi.8 \
141 man-cgi.css \
142 man.h \
143 man_hash.c \
144 man_html.c \
145 man_macro.c \
146 man_term.c \
147 man_validate.c \
148 mandoc.1 \
149 mandoc.3 \
150 mandoc.c \
151 mandoc.db.5 \
152 mandoc.h \
153 mandoc_aux.c \
154 mandoc_aux.h \
155 mandoc_char.7 \
156 mandocdb.c \
157 manpage.c \
158 manpath.c \
159 manpath.h \
160 mansearch.3 \
161 mansearch.c \
162 mansearch.h \
163 mansearch_const.c \
164 mdoc.7 \
165 mdoc.c \
166 mdoc.h \
167 mdoc_argv.c \
168 mdoc_hash.c \
169 mdoc_html.c \
170 mdoc_macro.c \
171 mdoc_man.c \
172 mdoc_term.c \
173 mdoc_validate.c \
174 msec.c \
175 msec.in \
176 out.c \
177 out.h \
178 preconv.1 \
179 preconv.c \
180 predefs.in \
181 read.c \
182 roff.7 \
183 roff.c \
184 st.c \
185 st.in \
186 style.css \
187 tbl.3 \
188 tbl.7 \
189 tbl.c \
190 tbl_data.c \
191 tbl_html.c \
192 tbl_layout.c \
193 tbl_opts.c \
194 tbl_term.c \
195 term.c \
196 term.h \
197 term_ascii.c \
198 term_ps.c \
199 tree.c \
200 vol.c \
201 vol.in \
202 $(TESTSRCS)
203
204 LIBMAN_OBJS = man.o \
205 man_hash.o \
206 man_macro.o \
207 man_validate.o
208
209 LIBMDOC_OBJS = arch.o \
210 att.o \
211 lib.o \
212 mdoc.o \
213 mdoc_argv.o \
214 mdoc_hash.o \
215 mdoc_macro.o \
216 mdoc_validate.o \
217 st.o \
218 vol.o
219
220 LIBROFF_OBJS = eqn.o \
221 roff.o \
222 tbl.o \
223 tbl_data.o \
224 tbl_layout.o \
225 tbl_opts.o
226
227 LIBMANDOC_OBJS = $(LIBMAN_OBJS) \
228 $(LIBMDOC_OBJS) \
229 $(LIBROFF_OBJS) \
230 chars.o \
231 mandoc.o \
232 mandoc_aux.o \
233 msec.o \
234 read.o
235
236 COMPAT_OBJS = compat_fgetln.o \
237 compat_getsubopt.o \
238 compat_ohash.o \
239 compat_reallocarray.o \
240 compat_strcasestr.o \
241 compat_strlcat.o \
242 compat_strlcpy.o \
243 compat_strnlen.o \
244 compat_strsep.o
245
246 # === DEPENDENCY HANDLING ==============================================
247
248 arch.o: arch.in
249 att.o: att.in
250 chars.o: chars.in
251 lib.o: lib.in
252 msec.o: msec.in
253 roff.o: predefs.in
254 st.o: st.in
255 vol.o: vol.in
256 cgi.o: cgi.h
257
258 $(LIBMAN_OBJS): libman.h
259 $(LIBMDOC_OBJS): libmdoc.h
260 $(LIBROFF_OBJS): libroff.h
261 $(LIBMANDOC_OBJS): mandoc.h mandoc_aux.h mdoc.h man.h libmandoc.h config.h
262 $(COMPAT_OBJS): config.h compat_ohash.h
263
264 MANDOC_HTML_OBJS = eqn_html.o \
265 html.o \
266 man_html.o \
267 mdoc_html.o \
268 tbl_html.o
269 $(MANDOC_HTML_OBJS): html.h
270
271 MANDOC_MAN_OBJS = mdoc_man.o
272
273 MANDOC_TERM_OBJS = eqn_term.o \
274 man_term.o \
275 mdoc_term.o \
276 term.o \
277 term_ascii.o \
278 term_ps.o \
279 tbl_term.o
280 $(MANDOC_TERM_OBJS): term.h
281
282 MANDOC_OBJS = $(MANDOC_HTML_OBJS) \
283 $(MANDOC_MAN_OBJS) \
284 $(MANDOC_TERM_OBJS) \
285 main.o \
286 out.o \
287 tree.o
288 $(MANDOC_OBJS): main.h mandoc.h mandoc_aux.h mdoc.h man.h config.h out.h
289
290 MAKEWHATIS_OBJS = mandocdb.o mansearch_const.o manpath.o
291 $(MAKEWHATIS_OBJS): mansearch.h mandoc.h mandoc_aux.h \
292 mdoc.h man.h config.h manpath.h
293
294 PRECONV_OBJS = preconv.o
295 $(PRECONV_OBJS): config.h
296
297 APROPOS_OBJS = apropos.o mansearch.o mansearch_const.o manpath.o
298 $(APROPOS_OBJS): config.h mandoc.h mandoc_aux.h manpath.h mansearch.h
299
300 CGI_OBJS = $(MANDOC_HTML_OBJS) \
301 cgi.o \
302 mansearch.o \
303 mansearch_const.o \
304 out.o
305 $(CGI_OBJS): main.h out.h config.h mandoc.h mandoc_aux.h \
306 manpath.h mansearch.h
307
308 MANPAGE_OBJS = manpage.o mansearch.o mansearch_const.o manpath.o
309 $(MANPAGE_OBJS): config.h mandoc.h mandoc_aux.h manpath.h mansearch.h
310
311 DEMANDOC_OBJS = demandoc.o
312 $(DEMANDOC_OBJS): config.h mandoc.h man.h mdoc.h
313
314 WWW_MANS = apropos.1.html \
315 demandoc.1.html \
316 mandoc.1.html \
317 preconv.1.html \
318 mandoc.3.html \
319 mansearch.3.html \
320 tbl.3.html \
321 mandoc.db.5.html \
322 eqn.7.html \
323 man.7.html \
324 mandoc_char.7.html \
325 mdoc.7.html \
326 roff.7.html \
327 tbl.7.html \
328 makewhatis.8.html \
329 man.cgi.8.html \
330 man.h.html \
331 mandoc.h.html \
332 mandoc_aux.h.html \
333 manpath.h.html \
334 mansearch.h.html \
335 mdoc.h.html
336
337 WWW_OBJS = mdocml.tar.gz \
338 mdocml.sha256
339
340 www: $(WWW_OBJS) $(WWW_MANS)
341
342 # === TARGETS CONTAINING SHELL COMMANDS ================================
343
344 clean:
345 rm -f libmandoc.a $(LIBMANDOC_OBJS)
346 rm -f apropos $(APROPOS_OBJS)
347 rm -f makewhatis $(MAKEWHATIS_OBJS)
348 rm -f preconv $(PRECONV_OBJS)
349 rm -f man.cgi $(CGI_OBJS)
350 rm -f manpage $(MANPAGE_OBJS)
351 rm -f demandoc $(DEMANDOC_OBJS)
352 rm -f mandoc $(MANDOC_OBJS)
353 rm -f config.h config.log $(COMPAT_OBJS)
354 rm -f $(WWW_MANS) $(WWW_OBJS)
355 rm -rf *.dSYM
356
357 install: all
358 mkdir -p $(DESTDIR)$(BINDIR)
359 mkdir -p $(DESTDIR)$(EXAMPLEDIR)
360 mkdir -p $(DESTDIR)$(LIBDIR)
361 mkdir -p $(DESTDIR)$(INCLUDEDIR)
362 mkdir -p $(DESTDIR)$(MANDIR)/man1
363 mkdir -p $(DESTDIR)$(MANDIR)/man3
364 mkdir -p $(DESTDIR)$(MANDIR)/man5
365 mkdir -p $(DESTDIR)$(MANDIR)/man7
366 $(INSTALL_PROGRAM) $(ALLBIN) $(DESTDIR)$(BINDIR)
367 $(INSTALL_LIB) libmandoc.a $(DESTDIR)$(LIBDIR)
368 $(INSTALL_LIB) man.h mdoc.h mandoc.h $(DESTDIR)$(INCLUDEDIR)
369 $(INSTALL_MAN) mandoc.1 preconv.1 demandoc.1 $(DESTDIR)$(MANDIR)/man1
370 $(INSTALL_MAN) mandoc.3 mansearch.3 tbl.3 $(DESTDIR)$(MANDIR)/man3
371 $(INSTALL_MAN) mandoc.db.5 $(DESTDIR)$(MANDIR)/man5
372 $(INSTALL_MAN) man.7 mdoc.7 roff.7 eqn.7 tbl.7 mandoc_char.7 \
373 $(DESTDIR)$(MANDIR)/man7
374 $(INSTALL_DATA) example.style.css $(DESTDIR)$(EXAMPLEDIR)
375
376 installcgi: all
377 mkdir -p $(DESTDIR)$(CGIBINDIR)
378 mkdir -p $(DESTDIR)$(HTDOCDIR)
379 mkdir -p $(DESTDIR)$(WWWPREFIX)/man/mandoc/man1
380 mkdir -p $(DESTDIR)$(WWWPREFIX)/man/mandoc/man8
381 $(INSTALL_PROGRAM) man.cgi $(DESTDIR)$(CGIBINDIR)
382 $(INSTALL_DATA) example.style.css $(DESTDIR)$(HTDOCDIR)/man.css
383 $(INSTALL_DATA) man-cgi.css $(DESTDIR)$(HTDOCDIR)
384 $(INSTALL_MAN) apropos.1 $(DESTDIR)$(WWWPREFIX)/man/mandoc/man1/
385 $(INSTALL_MAN) man.cgi.8 $(DESTDIR)$(WWWPREFIX)/man/mandoc/man8/
386
387 installwww: www
388 mkdir -p $(DESTDIR)$(HTDOCDIR)/snapshots
389 $(INSTALL_DATA) $(WWW_MANS) style.css $(DESTDIR)$(HTDOCDIR)
390 $(INSTALL_DATA) $(WWW_OBJS) $(DESTDIR)$(HTDOCDIR)/snapshots
391 $(INSTALL_DATA) mdocml.tar.gz \
392 $(DESTDIR)$(HTDOCDIR)/snapshots/mdocml-$(VERSION).tar.gz
393 $(INSTALL_DATA) mdocml.sha256 \
394 $(DESTDIR)$(HTDOCDIR)/snapshots/mdocml-$(VERSION).sha256
395
396 libmandoc.a: $(COMPAT_OBJS) $(LIBMANDOC_OBJS)
397 $(AR) rs $@ $(COMPAT_OBJS) $(LIBMANDOC_OBJS)
398
399 mandoc: $(MANDOC_OBJS) libmandoc.a
400 $(CC) $(LDFLAGS) -o $@ $(MANDOC_OBJS) libmandoc.a
401
402 makewhatis: $(MAKEWHATIS_OBJS) libmandoc.a
403 $(CC) $(LDFLAGS) -o $@ $(MAKEWHATIS_OBJS) libmandoc.a $(DBLIB)
404
405 preconv: $(PRECONV_OBJS)
406 $(CC) $(LDFLAGS) -o $@ $(PRECONV_OBJS)
407
408 manpage: $(MANPAGE_OBJS) libmandoc.a
409 $(CC) $(LDFLAGS) -o $@ $(MANPAGE_OBJS) libmandoc.a $(DBLIB)
410
411 apropos: $(APROPOS_OBJS) libmandoc.a
412 $(CC) $(LDFLAGS) -o $@ $(APROPOS_OBJS) libmandoc.a $(DBLIB)
413
414 man.cgi: $(CGI_OBJS) libmandoc.a
415 $(CC) $(LDFLAGS) $(STATIC) -o $@ $(CGI_OBJS) libmandoc.a $(DBLIB)
416
417 demandoc: $(DEMANDOC_OBJS) libmandoc.a
418 $(CC) $(LDFLAGS) -o $@ $(DEMANDOC_OBJS) libmandoc.a
419
420 mdocml.sha256: mdocml.tar.gz
421 sha256 mdocml.tar.gz > $@
422
423 mdocml.tar.gz: $(SRCS)
424 mkdir -p .dist/mdocml-$(VERSION)/
425 $(INSTALL_SOURCE) $(SRCS) .dist/mdocml-$(VERSION)
426 chmod 755 .dist/mdocml-$(VERSION)/configure
427 ( cd .dist/ && tar zcf ../$@ mdocml-$(VERSION) )
428 rm -rf .dist/
429
430 config.h: configure config.h.pre config.h.post $(TESTSRCS)
431 rm -f config.log
432 CC="$(CC)" CFLAGS="$(CFLAGS)" VERSION="$(VERSION)" ./configure
433
434 .PHONY: clean install installcgi installwww
435 .SUFFIXES: .1 .3 .5 .7 .8 .h
436 .SUFFIXES: .1.html .3.html .5.html .7.html .8.html .h.html
437
438 .h.h.html:
439 highlight -I $< > $@
440
441 .1.1.html .3.3.html .5.5.html .7.7.html .8.8.html: mandoc
442 ./mandoc -Thtml -Wall,stop \
443 -Ostyle=style.css,man=%N.%S.html,includes=%I.html $< > $@