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