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