]> git.cameronkatri.com Git - mandoc.git/blob - Makefile
Delete useless variables that could sneak into the Makefile
[mandoc.git] / Makefile
1 # $Id: Makefile,v 1.483 2016/05/18 23:51:16 schwarze Exp $
2 #
3 # Copyright (c) 2010, 2011, 2012 Kristaps Dzonsons <kristaps@bsd.lv>
4 # Copyright (c) 2011, 2013-2016 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.3 \
142 man.cgi.8 \
143 man.conf.5 \
144 man.h \
145 manconf.h \
146 mandoc.1 \
147 mandoc.3 \
148 mandoc.css \
149 mandoc.db.5 \
150 mandoc.h \
151 mandoc_aux.h \
152 mandoc_char.7 \
153 mandoc_escape.3 \
154 mandoc_headers.3 \
155 mandoc_html.3 \
156 mandoc_malloc.3 \
157 mandoc_ohash.h \
158 mansearch.3 \
159 mansearch.h \
160 mchars_alloc.3 \
161 mdoc.7 \
162 mdoc.h \
163 msec.in \
164 out.h \
165 predefs.in \
166 roff.7 \
167 roff.h \
168 soelim.1 \
169 st.in \
170 tag.h \
171 tbl.3 \
172 tbl.7 \
173 term.h \
174 $(SRCS) \
175 $(TESTSRCS)
176
177 LIBMAN_OBJS = man.o \
178 man_hash.o \
179 man_macro.o \
180 man_validate.o
181
182 LIBMDOC_OBJS = att.o \
183 lib.o \
184 mdoc.o \
185 mdoc_argv.o \
186 mdoc_hash.o \
187 mdoc_macro.o \
188 mdoc_state.o \
189 mdoc_validate.o \
190 st.o
191
192 LIBROFF_OBJS = eqn.o \
193 roff.o \
194 tbl.o \
195 tbl_data.o \
196 tbl_layout.o \
197 tbl_opts.o
198
199 LIBMANDOC_OBJS = $(LIBMAN_OBJS) \
200 $(LIBMDOC_OBJS) \
201 $(LIBROFF_OBJS) \
202 chars.o \
203 mandoc.o \
204 mandoc_aux.o \
205 mandoc_ohash.o \
206 msec.o \
207 preconv.o \
208 read.o
209
210 COMPAT_OBJS = compat_err.o \
211 compat_fts.o \
212 compat_getline.o \
213 compat_getsubopt.o \
214 compat_isblank.o \
215 compat_mkdtemp.o \
216 compat_ohash.o \
217 compat_progname.o \
218 compat_reallocarray.o \
219 compat_sqlite3_errstr.o \
220 compat_strcasestr.o \
221 compat_strlcat.o \
222 compat_strlcpy.o \
223 compat_strsep.o \
224 compat_strtonum.o \
225 compat_vasprintf.o
226
227 MANDOC_HTML_OBJS = eqn_html.o \
228 html.o \
229 man_html.o \
230 mdoc_html.o \
231 tbl_html.o
232
233 MANDOC_MAN_OBJS = mdoc_man.o
234
235 MANDOC_TERM_OBJS = eqn_term.o \
236 man_term.o \
237 mdoc_term.o \
238 term.o \
239 term_ascii.o \
240 term_ps.o \
241 tbl_term.o
242
243 BASE_OBJS = $(MANDOC_HTML_OBJS) \
244 $(MANDOC_MAN_OBJS) \
245 $(MANDOC_TERM_OBJS) \
246 main.o \
247 manpath.o \
248 out.o \
249 tag.o \
250 tree.o
251
252 MAIN_OBJS = $(BASE_OBJS)
253
254 DB_OBJS = mandocdb.o \
255 mansearch.o \
256 mansearch_const.o
257
258 CGI_OBJS = $(MANDOC_HTML_OBJS) \
259 cgi.o \
260 mansearch.o \
261 mansearch_const.o \
262 out.o
263
264 MANPAGE_OBJS = manpage.o mansearch.o mansearch_const.o manpath.o
265
266 DEMANDOC_OBJS = demandoc.o
267
268 SOELIM_OBJS = soelim.o \
269 compat_err.o \
270 compat_getline.o \
271 compat_progname.o \
272 compat_reallocarray.o \
273 compat_stringlist.o
274
275 WWW_MANS = apropos.1.html \
276 demandoc.1.html \
277 man.1.html \
278 mandoc.1.html \
279 soelim.1.html \
280 mandoc.3.html \
281 mandoc_escape.3.html \
282 mandoc_headers.3.html \
283 mandoc_html.3.html \
284 mandoc_malloc.3.html \
285 mansearch.3.html \
286 mchars_alloc.3.html \
287 tbl.3.html \
288 man.conf.5.html \
289 mandoc.db.5.html \
290 eqn.7.html \
291 man.7.html \
292 mandoc_char.7.html \
293 mdoc.7.html \
294 roff.7.html \
295 tbl.7.html \
296 makewhatis.8.html \
297 man.cgi.3.html \
298 man.cgi.8.html \
299 man.h.html \
300 manconf.h.html \
301 mandoc.h.html \
302 mandoc_aux.h.html \
303 mansearch.h.html \
304 mdoc.h.html \
305 roff.h.html
306
307 WWW_OBJS = mdocml.tar.gz \
308 mdocml.sha256
309
310 # === USER CONFIGURATION ===============================================
311
312 include Makefile.local
313
314 # === DEPENDENCY HANDLING ==============================================
315
316 all: base-build $(BUILD_TARGETS) Makefile.local
317
318 base-build: mandoc demandoc soelim
319
320 cgi-build: man.cgi
321
322 install: base-install $(INSTALL_TARGETS)
323
324 www: $(WWW_OBJS) $(WWW_MANS)
325
326 $(WWW_MANS): mandoc
327
328 .PHONY: base-install cgi-install db-install install www-install
329 .PHONY: clean distclean depend
330
331 include Makefile.depend
332
333 # === TARGETS CONTAINING SHELL COMMANDS ================================
334
335 distclean: clean
336 rm -f Makefile.local config.h config.h.old config.log config.log.old
337
338 clean:
339 rm -f libmandoc.a $(LIBMANDOC_OBJS) $(COMPAT_OBJS)
340 rm -f mandoc $(BASE_OBJS) $(DB_OBJS)
341 rm -f man.cgi $(CGI_OBJS)
342 rm -f manpage $(MANPAGE_OBJS)
343 rm -f demandoc $(DEMANDOC_OBJS)
344 rm -f soelim $(SOELIM_OBJS)
345 rm -f $(WWW_MANS) $(WWW_OBJS)
346 rm -rf *.dSYM
347
348 base-install: base-build
349 mkdir -p $(DESTDIR)$(BINDIR)
350 mkdir -p $(DESTDIR)$(LIBDIR)
351 mkdir -p $(DESTDIR)$(INCLUDEDIR)
352 mkdir -p $(DESTDIR)$(MANDIR)/man1
353 mkdir -p $(DESTDIR)$(MANDIR)/man3
354 mkdir -p $(DESTDIR)$(MANDIR)/man5
355 mkdir -p $(DESTDIR)$(MANDIR)/man7
356 $(INSTALL_PROGRAM) mandoc demandoc $(DESTDIR)$(BINDIR)
357 $(INSTALL_PROGRAM) soelim $(DESTDIR)$(BINDIR)/$(BINM_SOELIM)
358 ln -f $(DESTDIR)$(BINDIR)/mandoc $(DESTDIR)$(BINDIR)/$(BINM_MAN)
359 $(INSTALL_LIB) libmandoc.a $(DESTDIR)$(LIBDIR)
360 $(INSTALL_LIB) man.h mandoc.h mandoc_aux.h mdoc.h roff.h \
361 $(DESTDIR)$(INCLUDEDIR)
362 $(INSTALL_MAN) mandoc.1 demandoc.1 $(DESTDIR)$(MANDIR)/man1
363 $(INSTALL_MAN) soelim.1 $(DESTDIR)$(MANDIR)/man1/$(BINM_SOELIM).1
364 $(INSTALL_MAN) man.1 $(DESTDIR)$(MANDIR)/man1/$(BINM_MAN).1
365 $(INSTALL_MAN) mandoc.3 mandoc_escape.3 mandoc_malloc.3 \
366 mchars_alloc.3 tbl.3 $(DESTDIR)$(MANDIR)/man3
367 $(INSTALL_MAN) man.conf.5 $(DESTDIR)$(MANDIR)/man5/${MANM_MANCONF}.5
368 $(INSTALL_MAN) man.7 $(DESTDIR)$(MANDIR)/man7/${MANM_MAN}.7
369 $(INSTALL_MAN) mdoc.7 $(DESTDIR)$(MANDIR)/man7/${MANM_MDOC}.7
370 $(INSTALL_MAN) roff.7 $(DESTDIR)$(MANDIR)/man7/${MANM_ROFF}.7
371 $(INSTALL_MAN) eqn.7 $(DESTDIR)$(MANDIR)/man7/${MANM_EQN}.7
372 $(INSTALL_MAN) tbl.7 $(DESTDIR)$(MANDIR)/man7/${MANM_TBL}.7
373 $(INSTALL_MAN) mandoc_char.7 $(DESTDIR)$(MANDIR)/man7
374
375 db-install: base-build
376 mkdir -p $(DESTDIR)$(BINDIR)
377 mkdir -p $(DESTDIR)$(SBINDIR)
378 mkdir -p $(DESTDIR)$(MANDIR)/man1
379 mkdir -p $(DESTDIR)$(MANDIR)/man3
380 mkdir -p $(DESTDIR)$(MANDIR)/man5
381 mkdir -p $(DESTDIR)$(MANDIR)/man8
382 ln -f $(DESTDIR)$(BINDIR)/mandoc $(DESTDIR)$(BINDIR)/$(BINM_APROPOS)
383 ln -f $(DESTDIR)$(BINDIR)/mandoc $(DESTDIR)$(BINDIR)/$(BINM_WHATIS)
384 ln -f $(DESTDIR)$(BINDIR)/mandoc \
385 $(DESTDIR)$(SBINDIR)/$(BINM_MAKEWHATIS)
386 $(INSTALL_MAN) apropos.1 $(DESTDIR)$(MANDIR)/man1/$(BINM_APROPOS).1
387 ln -f $(DESTDIR)$(MANDIR)/man1/$(BINM_APROPOS).1 \
388 $(DESTDIR)$(MANDIR)/man1/$(BINM_WHATIS).1
389 $(INSTALL_MAN) mansearch.3 $(DESTDIR)$(MANDIR)/man3
390 $(INSTALL_MAN) mandoc.db.5 $(DESTDIR)$(MANDIR)/man5
391 $(INSTALL_MAN) makewhatis.8 \
392 $(DESTDIR)$(MANDIR)/man8/$(BINM_MAKEWHATIS).8
393
394 cgi-install: cgi-build
395 mkdir -p $(DESTDIR)$(CGIBINDIR)
396 mkdir -p $(DESTDIR)$(HTDOCDIR)
397 mkdir -p $(DESTDIR)$(WWWPREFIX)/man/mandoc/man1
398 mkdir -p $(DESTDIR)$(WWWPREFIX)/man/mandoc/man8
399 $(INSTALL_PROGRAM) man.cgi $(DESTDIR)$(CGIBINDIR)
400 $(INSTALL_DATA) mandoc.css $(DESTDIR)$(HTDOCDIR)
401 $(INSTALL_MAN) apropos.1 $(DESTDIR)$(WWWPREFIX)/man/mandoc/man1/
402 $(INSTALL_MAN) man.cgi.8 $(DESTDIR)$(WWWPREFIX)/man/mandoc/man8/
403
404 Makefile.local config.h: configure ${TESTSRCS}
405 @echo "$@ is out of date; please run ./configure"
406 @exit 1
407
408 libmandoc.a: $(COMPAT_OBJS) $(LIBMANDOC_OBJS)
409 ar rs $@ $(COMPAT_OBJS) $(LIBMANDOC_OBJS)
410
411 mandoc: $(MAIN_OBJS) libmandoc.a
412 $(CC) -o $@ $(MAIN_OBJS) libmandoc.a $(LDADD)
413
414 manpage: $(MANPAGE_OBJS) libmandoc.a
415 $(CC) -o $@ $(MANPAGE_OBJS) libmandoc.a $(LDADD)
416
417 man.cgi: $(CGI_OBJS) libmandoc.a
418 $(CC) $(STATIC) -o $@ $(CGI_OBJS) libmandoc.a $(LDADD)
419
420 demandoc: $(DEMANDOC_OBJS) libmandoc.a
421 $(CC) -o $@ $(DEMANDOC_OBJS) libmandoc.a $(LDADD)
422
423 soelim: $(SOELIM_OBJS)
424 $(CC) -o $@ $(SOELIM_OBJS)
425
426 # --- maintainer targets ---
427
428 www-install: www
429 mkdir -p $(HTDOCDIR)/snapshots
430 $(INSTALL_DATA) $(WWW_MANS) mandoc.css $(HTDOCDIR)
431 $(INSTALL_DATA) $(WWW_OBJS) $(HTDOCDIR)/snapshots
432 $(INSTALL_DATA) mdocml.tar.gz \
433 $(HTDOCDIR)/snapshots/mdocml-$(VERSION).tar.gz
434 $(INSTALL_DATA) mdocml.sha256 \
435 $(HTDOCDIR)/snapshots/mdocml-$(VERSION).sha256
436
437 depend: config.h
438 mkdep -f Makefile.depend $(CFLAGS) $(SRCS)
439 perl -e 'undef $$/; $$_ = <>; s|/usr/include/\S+||g; \
440 s|\\\n||g; s| +| |g; s| $$||mg; print;' \
441 Makefile.depend > Makefile.tmp
442 mv Makefile.tmp Makefile.depend
443
444 mdocml.sha256: mdocml.tar.gz
445 sha256 mdocml.tar.gz > $@
446
447 mdocml.tar.gz: $(DISTFILES)
448 mkdir -p .dist/mdocml-$(VERSION)/
449 $(INSTALL) -m 0644 $(DISTFILES) .dist/mdocml-$(VERSION)
450 chmod 755 .dist/mdocml-$(VERSION)/configure
451 ( cd .dist/ && tar zcf ../$@ mdocml-$(VERSION) )
452 rm -rf .dist/
453
454 # === SUFFIX RULES =====================================================
455
456 .SUFFIXES: .1 .3 .5 .7 .8 .h
457 .SUFFIXES: .1.html .3.html .5.html .7.html .8.html .h.html
458
459 .h.h.html:
460 highlight -I $< > $@
461
462 .1.1.html .3.3.html .5.5.html .7.7.html .8.8.html: mandoc
463 ./mandoc -Thtml -Wall,stop \
464 -Ostyle=mandoc.css,man=%N.%S.html,includes=%I.html $< > $@