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