]> git.cameronkatri.com Git - mandoc.git/blob - Makefile
15940d138fec70332bbec32e6247ed55b7f65c8c
[mandoc.git] / Makefile
1 # $Id: Makefile,v 1.479 2015/11/07 21:38:28 schwarze Exp $
2 #
3 # Copyright (c) 2010, 2011, 2012 Kristaps Dzonsons <kristaps@bsd.lv>
4 # Copyright (c) 2011, 2013, 2014, 2015 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.3
19
20 # === LIST OF FILES ====================================================
21
22 TESTSRCS = test-dirent-namlen.c \
23 test-err.c \
24 test-fts.c \
25 test-getline.c \
26 test-getsubopt.c \
27 test-isblank.c \
28 test-mkdtemp.c \
29 test-mmap.c \
30 test-ohash.c \
31 test-pledge.c \
32 test-progname.c \
33 test-reallocarray.c \
34 test-sqlite3.c \
35 test-sqlite3_errstr.c \
36 test-strcasestr.c \
37 test-stringlist.c \
38 test-strlcat.c \
39 test-strlcpy.c \
40 test-strptime.c \
41 test-strsep.c \
42 test-strtonum.c \
43 test-vasprintf.c \
44 test-wchar.c
45
46 SRCS = att.c \
47 cgi.c \
48 chars.c \
49 compat_err.c \
50 compat_fts.c \
51 compat_getline.c \
52 compat_getsubopt.c \
53 compat_isblank.c \
54 compat_mkdtemp.c \
55 compat_ohash.c \
56 compat_progname.c \
57 compat_reallocarray.c \
58 compat_sqlite3_errstr.c \
59 compat_strcasestr.c \
60 compat_stringlist.c \
61 compat_strlcat.c \
62 compat_strlcpy.c \
63 compat_strsep.c \
64 compat_strtonum.c \
65 compat_vasprintf.c \
66 demandoc.c \
67 eqn.c \
68 eqn_html.c \
69 eqn_term.c \
70 html.c \
71 lib.c \
72 main.c \
73 man.c \
74 man_hash.c \
75 man_html.c \
76 man_macro.c \
77 man_term.c \
78 man_validate.c \
79 mandoc.c \
80 mandoc_aux.c \
81 mandoc_ohash.c \
82 mandocdb.c \
83 manpage.c \
84 manpath.c \
85 mansearch.c \
86 mansearch_const.c \
87 mdoc.c \
88 mdoc_argv.c \
89 mdoc_hash.c \
90 mdoc_html.c \
91 mdoc_macro.c \
92 mdoc_man.c \
93 mdoc_state.c \
94 mdoc_term.c \
95 mdoc_validate.c \
96 msec.c \
97 out.c \
98 preconv.c \
99 read.c \
100 roff.c \
101 soelim.c \
102 st.c \
103 tag.c \
104 tbl.c \
105 tbl_data.c \
106 tbl_html.c \
107 tbl_layout.c \
108 tbl_opts.c \
109 tbl_term.c \
110 term.c \
111 term_ascii.c \
112 term_ps.c \
113 tree.c
114
115 DISTFILES = INSTALL \
116 LICENSE \
117 Makefile \
118 Makefile.depend \
119 NEWS \
120 TODO \
121 apropos.1 \
122 cgi.h.example \
123 compat_fts.h \
124 compat_ohash.h \
125 compat_stringlist.h \
126 configure \
127 configure.local.example \
128 demandoc.1 \
129 eqn.7 \
130 gmdiff \
131 html.h \
132 lib.in \
133 libman.h \
134 libmandoc.h \
135 libmdoc.h \
136 libroff.h \
137 main.h \
138 makewhatis.8 \
139 man.1 \
140 man.7 \
141 man.cgi.8 \
142 man.conf.5 \
143 man.h \
144 manconf.h \
145 mandoc.1 \
146 mandoc.3 \
147 mandoc.css \
148 mandoc.db.5 \
149 mandoc.h \
150 mandoc_aux.h \
151 mandoc_char.7 \
152 mandoc_escape.3 \
153 mandoc_headers.3 \
154 mandoc_html.3 \
155 mandoc_malloc.3 \
156 mandoc_ohash.h \
157 mansearch.3 \
158 mansearch.h \
159 mchars_alloc.3 \
160 mdoc.7 \
161 mdoc.h \
162 msec.in \
163 out.h \
164 predefs.in \
165 roff.7 \
166 roff.h \
167 soelim.1 \
168 st.in \
169 tag.h \
170 tbl.3 \
171 tbl.7 \
172 term.h \
173 $(SRCS) \
174 $(TESTSRCS)
175
176 LIBMAN_OBJS = man.o \
177 man_hash.o \
178 man_macro.o \
179 man_validate.o
180
181 LIBMDOC_OBJS = att.o \
182 lib.o \
183 mdoc.o \
184 mdoc_argv.o \
185 mdoc_hash.o \
186 mdoc_macro.o \
187 mdoc_state.o \
188 mdoc_validate.o \
189 st.o
190
191 LIBROFF_OBJS = eqn.o \
192 roff.o \
193 tbl.o \
194 tbl_data.o \
195 tbl_layout.o \
196 tbl_opts.o
197
198 LIBMANDOC_OBJS = $(LIBMAN_OBJS) \
199 $(LIBMDOC_OBJS) \
200 $(LIBROFF_OBJS) \
201 chars.o \
202 mandoc.o \
203 mandoc_aux.o \
204 mandoc_ohash.o \
205 msec.o \
206 preconv.o \
207 read.o
208
209 COMPAT_OBJS = compat_err.o \
210 compat_fts.o \
211 compat_getline.o \
212 compat_getsubopt.o \
213 compat_isblank.o \
214 compat_mkdtemp.o \
215 compat_ohash.o \
216 compat_progname.o \
217 compat_reallocarray.o \
218 compat_sqlite3_errstr.o \
219 compat_strcasestr.o \
220 compat_strlcat.o \
221 compat_strlcpy.o \
222 compat_strsep.o \
223 compat_strtonum.o \
224 compat_vasprintf.o
225
226 MANDOC_HTML_OBJS = eqn_html.o \
227 html.o \
228 man_html.o \
229 mdoc_html.o \
230 tbl_html.o
231
232 MANDOC_MAN_OBJS = mdoc_man.o
233
234 MANDOC_TERM_OBJS = eqn_term.o \
235 man_term.o \
236 mdoc_term.o \
237 term.o \
238 term_ascii.o \
239 term_ps.o \
240 tbl_term.o
241
242 BASE_OBJS = $(MANDOC_HTML_OBJS) \
243 $(MANDOC_MAN_OBJS) \
244 $(MANDOC_TERM_OBJS) \
245 main.o \
246 manpath.o \
247 out.o \
248 tag.o \
249 tree.o
250
251 MAIN_OBJS = $(BASE_OBJS)
252
253 DB_OBJS = mandocdb.o \
254 mansearch.o \
255 mansearch_const.o
256
257 CGI_OBJS = $(MANDOC_HTML_OBJS) \
258 cgi.o \
259 mansearch.o \
260 mansearch_const.o \
261 out.o
262
263 MANPAGE_OBJS = manpage.o mansearch.o mansearch_const.o manpath.o
264
265 DEMANDOC_OBJS = demandoc.o
266
267 SOELIM_OBJS = soelim.o \
268 compat_err.o \
269 compat_getline.o \
270 compat_progname.o \
271 compat_stringlist.o
272
273 WWW_MANS = apropos.1.html \
274 demandoc.1.html \
275 man.1.html \
276 mandoc.1.html \
277 soelim.1.html \
278 mandoc.3.html \
279 mandoc_escape.3.html \
280 mandoc_headers.3.html \
281 mandoc_html.3.html \
282 mandoc_malloc.3.html \
283 mansearch.3.html \
284 mchars_alloc.3.html \
285 tbl.3.html \
286 man.conf.5.html \
287 mandoc.db.5.html \
288 eqn.7.html \
289 man.7.html \
290 mandoc_char.7.html \
291 mdoc.7.html \
292 roff.7.html \
293 tbl.7.html \
294 makewhatis.8.html \
295 man.cgi.8.html \
296 man.h.html \
297 manconf.h.html \
298 mandoc.h.html \
299 mandoc_aux.h.html \
300 mansearch.h.html \
301 mdoc.h.html \
302 roff.h.html
303
304 WWW_OBJS = mdocml.tar.gz \
305 mdocml.sha256
306
307 # === USER CONFIGURATION ===============================================
308
309 include Makefile.local
310
311 # === DEPENDENCY HANDLING ==============================================
312
313 all: base-build $(BUILD_TARGETS) Makefile.local
314
315 base-build: mandoc demandoc soelim
316
317 cgi-build: man.cgi
318
319 install: base-install $(INSTALL_TARGETS)
320
321 www: $(WWW_OBJS) $(WWW_MANS)
322
323 $(WWW_MANS): mandoc
324
325 .PHONY: base-install cgi-install db-install install www-install
326 .PHONY: clean distclean depend
327
328 include Makefile.depend
329
330 # === TARGETS CONTAINING SHELL COMMANDS ================================
331
332 distclean: clean
333 rm -f Makefile.local config.h config.h.old config.log config.log.old
334
335 clean:
336 rm -f libmandoc.a $(LIBMANDOC_OBJS) $(COMPAT_OBJS)
337 rm -f mandoc $(BASE_OBJS) $(DB_OBJS)
338 rm -f man.cgi $(CGI_OBJS)
339 rm -f manpage $(MANPAGE_OBJS)
340 rm -f demandoc $(DEMANDOC_OBJS)
341 rm -f soelim $(SOELIM_OBJS)
342 rm -f $(WWW_MANS) $(WWW_OBJS)
343 rm -rf *.dSYM
344
345 base-install: base-build
346 mkdir -p $(DESTDIR)$(BINDIR)
347 mkdir -p $(DESTDIR)$(LIBDIR)
348 mkdir -p $(DESTDIR)$(INCLUDEDIR)
349 mkdir -p $(DESTDIR)$(MANDIR)/man1
350 mkdir -p $(DESTDIR)$(MANDIR)/man3
351 mkdir -p $(DESTDIR)$(MANDIR)/man5
352 mkdir -p $(DESTDIR)$(MANDIR)/man7
353 $(INSTALL_PROGRAM) mandoc demandoc $(DESTDIR)$(BINDIR)
354 $(INSTALL_PROGRAM) soelim $(DESTDIR)$(BINDIR)/$(BINM_SOELIM)
355 ln -f $(DESTDIR)$(BINDIR)/mandoc $(DESTDIR)$(BINDIR)/$(BINM_MAN)
356 $(INSTALL_LIB) libmandoc.a $(DESTDIR)$(LIBDIR)
357 $(INSTALL_LIB) man.h mandoc.h mandoc_aux.h mdoc.h roff.h \
358 $(DESTDIR)$(INCLUDEDIR)
359 $(INSTALL_MAN) mandoc.1 demandoc.1 $(DESTDIR)$(MANDIR)/man1
360 $(INSTALL_MAN) soelim.1 $(DESTDIR)$(MANDIR)/man1/$(BINM_SOELIM).1
361 $(INSTALL_MAN) man.1 $(DESTDIR)$(MANDIR)/man1/$(BINM_MAN).1
362 $(INSTALL_MAN) mandoc.3 mandoc_escape.3 mandoc_malloc.3 \
363 mchars_alloc.3 tbl.3 $(DESTDIR)$(MANDIR)/man3
364 $(INSTALL_MAN) man.conf.5 $(DESTDIR)$(MANDIR)/man5/${MANM_MANCONF}.5
365 $(INSTALL_MAN) man.7 $(DESTDIR)$(MANDIR)/man7/${MANM_MAN}.7
366 $(INSTALL_MAN) mdoc.7 $(DESTDIR)$(MANDIR)/man7/${MANM_MDOC}.7
367 $(INSTALL_MAN) roff.7 $(DESTDIR)$(MANDIR)/man7/${MANM_ROFF}.7
368 $(INSTALL_MAN) eqn.7 $(DESTDIR)$(MANDIR)/man7/${MANM_EQN}.7
369 $(INSTALL_MAN) tbl.7 $(DESTDIR)$(MANDIR)/man7/${MANM_TBL}.7
370 $(INSTALL_MAN) mandoc_char.7 $(DESTDIR)$(MANDIR)/man7
371
372 db-install: base-build
373 mkdir -p $(DESTDIR)$(BINDIR)
374 mkdir -p $(DESTDIR)$(SBINDIR)
375 mkdir -p $(DESTDIR)$(MANDIR)/man1
376 mkdir -p $(DESTDIR)$(MANDIR)/man3
377 mkdir -p $(DESTDIR)$(MANDIR)/man5
378 mkdir -p $(DESTDIR)$(MANDIR)/man8
379 ln -f $(DESTDIR)$(BINDIR)/mandoc $(DESTDIR)$(BINDIR)/$(BINM_APROPOS)
380 ln -f $(DESTDIR)$(BINDIR)/mandoc $(DESTDIR)$(BINDIR)/$(BINM_WHATIS)
381 ln -f $(DESTDIR)$(BINDIR)/mandoc \
382 $(DESTDIR)$(SBINDIR)/$(BINM_MAKEWHATIS)
383 $(INSTALL_MAN) apropos.1 $(DESTDIR)$(MANDIR)/man1/$(BINM_APROPOS).1
384 ln -f $(DESTDIR)$(MANDIR)/man1/$(BINM_APROPOS).1 \
385 $(DESTDIR)$(MANDIR)/man1/$(BINM_WHATIS).1
386 $(INSTALL_MAN) mansearch.3 $(DESTDIR)$(MANDIR)/man3
387 $(INSTALL_MAN) mandoc.db.5 $(DESTDIR)$(MANDIR)/man5
388 $(INSTALL_MAN) makewhatis.8 \
389 $(DESTDIR)$(MANDIR)/man8/$(BINM_MAKEWHATIS).8
390
391 cgi-install: cgi-build
392 mkdir -p $(DESTDIR)$(CGIBINDIR)
393 mkdir -p $(DESTDIR)$(HTDOCDIR)
394 mkdir -p $(DESTDIR)$(WWWPREFIX)/man/mandoc/man1
395 mkdir -p $(DESTDIR)$(WWWPREFIX)/man/mandoc/man8
396 $(INSTALL_PROGRAM) man.cgi $(DESTDIR)$(CGIBINDIR)
397 $(INSTALL_DATA) mandoc.css $(DESTDIR)$(HTDOCDIR)
398 $(INSTALL_MAN) apropos.1 $(DESTDIR)$(WWWPREFIX)/man/mandoc/man1/
399 $(INSTALL_MAN) man.cgi.8 $(DESTDIR)$(WWWPREFIX)/man/mandoc/man8/
400
401 Makefile.local config.h: configure ${TESTSRCS}
402 @echo "$@ is out of date; please run ./configure"
403 @exit 1
404
405 libmandoc.a: $(COMPAT_OBJS) $(LIBMANDOC_OBJS)
406 $(AR) rs $@ $(COMPAT_OBJS) $(LIBMANDOC_OBJS)
407
408 mandoc: $(MAIN_OBJS) libmandoc.a
409 $(CC) $(LDFLAGS) -o $@ $(MAIN_OBJS) libmandoc.a $(DBLIB)
410
411 manpage: $(MANPAGE_OBJS) libmandoc.a
412 $(CC) $(LDFLAGS) -o $@ $(MANPAGE_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 $(DBLIB)
419
420 soelim: $(SOELIM_OBJS) compat_reallocarray.o
421 $(CC) $(LDFLAGS) -o $@ $(SOELIM_OBJS) compat_reallocarray.o
422
423 # --- maintainer targets ---
424
425 www-install: www
426 mkdir -p $(HTDOCDIR)/snapshots
427 $(INSTALL_DATA) $(WWW_MANS) mandoc.css $(HTDOCDIR)
428 $(INSTALL_DATA) $(WWW_OBJS) $(HTDOCDIR)/snapshots
429 $(INSTALL_DATA) mdocml.tar.gz \
430 $(HTDOCDIR)/snapshots/mdocml-$(VERSION).tar.gz
431 $(INSTALL_DATA) mdocml.sha256 \
432 $(HTDOCDIR)/snapshots/mdocml-$(VERSION).sha256
433
434 depend: config.h
435 mkdep -f Makefile.depend $(CFLAGS) $(SRCS)
436 perl -e 'undef $$/; $$_ = <>; s|/usr/include/\S+||g; \
437 s|\\\n||g; s| +| |g; s| $$||mg; print;' \
438 Makefile.depend > Makefile.tmp
439 mv Makefile.tmp Makefile.depend
440
441 mdocml.sha256: mdocml.tar.gz
442 sha256 mdocml.tar.gz > $@
443
444 mdocml.tar.gz: $(DISTFILES)
445 mkdir -p .dist/mdocml-$(VERSION)/
446 $(INSTALL) -m 0644 $(DISTFILES) .dist/mdocml-$(VERSION)
447 chmod 755 .dist/mdocml-$(VERSION)/configure
448 ( cd .dist/ && tar zcf ../$@ mdocml-$(VERSION) )
449 rm -rf .dist/
450
451 # === SUFFIX RULES =====================================================
452
453 .SUFFIXES: .1 .3 .5 .7 .8 .h
454 .SUFFIXES: .1.html .3.html .5.html .7.html .8.html .h.html
455
456 .h.h.html:
457 highlight -I $< > $@
458
459 .1.1.html .3.3.html .5.5.html .7.7.html .8.8.html: mandoc
460 ./mandoc -Thtml -Wall,stop \
461 -Ostyle=mandoc.css,man=%N.%S.html,includes=%I.html $< > $@