]> git.cameronkatri.com Git - mandoc.git/blob - Makefile
57f3ce7f635ee36597d842e80965ffa4e060916c
[mandoc.git] / Makefile
1 .PHONY: clean install installcgi installwww
2 .SUFFIXES: .md5 .h .h.html
3 .SUFFIXES: .1 .3 .5 .7 .8
4 .SUFFIXES: .1.html .3.html .5.html .7.html .8.html
5
6 VERSION = 1.13.0
7
8 # === USER SETTINGS ====================================================
9
10 # Specify this if you want to hard-code the operating system to appear
11 # in the lower-left hand corner of -mdoc manuals.
12 #
13 # CFLAGS += -DOSNAME="\"OpenBSD 5.4\""
14
15 # IFF your system supports multi-byte functions (setlocale(), wcwidth(),
16 # putwchar()) AND has __STDC_ISO_10646__ (that is, wchar_t is simply a
17 # UCS-4 value) should you define USE_WCHAR. If you define it and your
18 # system DOESN'T support this, -Tlocale will produce garbage.
19 # If you don't define it, -Tlocale is a synonym for -Tacsii.
20 #
21 CFLAGS += -DUSE_WCHAR
22
23 # If your system has manpath(1), uncomment this. This is most any
24 # system that's not OpenBSD or NetBSD. If uncommented, manpage(1) and
25 # makewhatis(8) will use manpath(1) to get the MANPATH variable.
26 #CFLAGS += -DUSE_MANPATH
27
28 # If your system does not support static binaries, comment this,
29 # for example on Mac OS X.
30 STATIC = -static
31 # Linux requires -pthread to statically link with libdb.
32 #STATIC += -pthread
33
34 CFLAGS += -I/usr/local/include -g -DHAVE_CONFIG_H
35 CFLAGS += -W -Wall -Wstrict-prototypes -Wno-unused-parameter -Wwrite-strings
36 PREFIX = /usr/local
37 WWWPREFIX = /var/www
38 HTDOCDIR = $(WWWPREFIX)/htdocs
39 CGIBINDIR = $(WWWPREFIX)/cgi-bin
40 BINDIR = $(PREFIX)/bin
41 INCLUDEDIR = $(PREFIX)/include/mandoc
42 LIBDIR = $(PREFIX)/lib/mandoc
43 MANDIR = $(PREFIX)/man
44 EXAMPLEDIR = $(PREFIX)/share/examples/mandoc
45 INSTALL = install
46 INSTALL_PROGRAM = $(INSTALL) -m 0755
47 INSTALL_DATA = $(INSTALL) -m 0444
48 INSTALL_LIB = $(INSTALL) -m 0644
49 INSTALL_SOURCE = $(INSTALL) -m 0644
50 INSTALL_MAN = $(INSTALL_DATA)
51
52 # If you want to build without database support, for example to avoid
53 # the dependency on SQLite3, comment the following two lines.
54 DBLIB = -L/usr/local/lib -lsqlite3
55 DBBIN = makewhatis manpage apropos
56
57 # === END OF USER SETTINGS =============================================
58
59 ALLBIN = mandoc preconv demandoc $(DBBIN)
60
61 all: $(ALLBIN)
62
63 TESTSRCS = test-fgetln.c \
64 test-getsubopt.c \
65 test-mmap.c \
66 test-ohash.c \
67 test-reallocarray.c \
68 test-strlcat.c \
69 test-strlcpy.c \
70 test-strnlen.c \
71 test-strptime.c
72
73 SRCS = LICENSE \
74 Makefile \
75 NEWS \
76 TODO \
77 apropos.1 \
78 apropos.c \
79 arch.c \
80 arch.in \
81 att.c \
82 att.in \
83 cgi.c \
84 chars.c \
85 chars.in \
86 compat_fgetln.c \
87 compat_getsubopt.c \
88 compat_ohash.c \
89 compat_ohash.h \
90 compat_reallocarray.c \
91 compat_strcasestr.c \
92 compat_strlcat.c \
93 compat_strlcpy.c \
94 compat_strnlen.c \
95 compat_strsep.c \
96 config.h.post \
97 config.h.pre \
98 configure \
99 demandoc.1 \
100 demandoc.c \
101 eqn.7 \
102 eqn.c \
103 eqn_html.c \
104 eqn_term.c \
105 example.style.css \
106 gmdiff \
107 html.c \
108 html.h \
109 lib.c \
110 lib.in \
111 libman.h \
112 libmandoc.h \
113 libmdoc.h \
114 libroff.h \
115 main.c \
116 main.h \
117 makewhatis.8 \
118 man.7 \
119 man.c \
120 man-cgi.css \
121 man.h \
122 man_hash.c \
123 man_html.c \
124 man_macro.c \
125 man_term.c \
126 man_validate.c \
127 mandoc.1 \
128 mandoc.3 \
129 mandoc.c \
130 mandoc.db.5 \
131 mandoc.h \
132 mandoc_aux.c \
133 mandoc_aux.h \
134 mandoc_char.7 \
135 mandocdb.c \
136 manpage.c \
137 manpath.c \
138 manpath.h \
139 mansearch.3 \
140 mansearch.c \
141 mansearch.h \
142 mansearch_const.c \
143 mdoc.7 \
144 mdoc.c \
145 mdoc.h \
146 mdoc_argv.c \
147 mdoc_hash.c \
148 mdoc_html.c \
149 mdoc_macro.c \
150 mdoc_man.c \
151 mdoc_term.c \
152 mdoc_validate.c \
153 msec.c \
154 msec.in \
155 out.c \
156 out.h \
157 preconv.1 \
158 preconv.c \
159 predefs.in \
160 read.c \
161 roff.7 \
162 roff.c \
163 st.c \
164 st.in \
165 style.css \
166 tbl.3 \
167 tbl.7 \
168 tbl.c \
169 tbl_data.c \
170 tbl_html.c \
171 tbl_layout.c \
172 tbl_opts.c \
173 tbl_term.c \
174 term.c \
175 term.h \
176 term_ascii.c \
177 term_ps.c \
178 tree.c \
179 vol.c \
180 vol.in \
181 $(TESTSRCS)
182
183 LIBMAN_OBJS = man.o \
184 man_hash.o \
185 man_macro.o \
186 man_validate.o
187
188 LIBMDOC_OBJS = arch.o \
189 att.o \
190 lib.o \
191 mdoc.o \
192 mdoc_argv.o \
193 mdoc_hash.o \
194 mdoc_macro.o \
195 mdoc_validate.o \
196 st.o \
197 vol.o
198
199 LIBROFF_OBJS = eqn.o \
200 roff.o \
201 tbl.o \
202 tbl_data.o \
203 tbl_layout.o \
204 tbl_opts.o
205
206 LIBMANDOC_OBJS = $(LIBMAN_OBJS) \
207 $(LIBMDOC_OBJS) \
208 $(LIBROFF_OBJS) \
209 chars.o \
210 mandoc.o \
211 mandoc_aux.o \
212 msec.o \
213 read.o
214
215 COMPAT_OBJS = compat_fgetln.o \
216 compat_getsubopt.o \
217 compat_ohash.o \
218 compat_reallocarray.o \
219 compat_strcasestr.o \
220 compat_strlcat.o \
221 compat_strlcpy.o \
222 compat_strnlen.o \
223 compat_strsep.o
224
225 arch.o: arch.in
226 att.o: att.in
227 chars.o: chars.in
228 lib.o: lib.in
229 msec.o: msec.in
230 roff.o: predefs.in
231 st.o: st.in
232 vol.o: vol.in
233
234 $(LIBMAN_OBJS): libman.h
235 $(LIBMDOC_OBJS): libmdoc.h
236 $(LIBROFF_OBJS): libroff.h
237 $(LIBMANDOC_OBJS): mandoc.h mandoc_aux.h mdoc.h man.h libmandoc.h config.h
238 $(COMPAT_OBJS): config.h compat_ohash.h
239
240 MANDOC_HTML_OBJS = eqn_html.o \
241 html.o \
242 man_html.o \
243 mdoc_html.o \
244 tbl_html.o
245 $(MANDOC_HTML_OBJS): html.h
246
247 MANDOC_MAN_OBJS = mdoc_man.o
248
249 MANDOC_TERM_OBJS = eqn_term.o \
250 man_term.o \
251 mdoc_term.o \
252 term.o \
253 term_ascii.o \
254 term_ps.o \
255 tbl_term.o
256 $(MANDOC_TERM_OBJS): term.h
257
258 MANDOC_OBJS = $(MANDOC_HTML_OBJS) \
259 $(MANDOC_MAN_OBJS) \
260 $(MANDOC_TERM_OBJS) \
261 main.o \
262 out.o \
263 tree.o
264 $(MANDOC_OBJS): main.h mandoc.h mandoc_aux.h mdoc.h man.h config.h out.h
265
266 MAKEWHATIS_OBJS = mandocdb.o mansearch_const.o manpath.o
267 $(MAKEWHATIS_OBJS): mansearch.h mandoc.h mandoc_aux.h \
268 mdoc.h man.h config.h manpath.h
269
270 PRECONV_OBJS = preconv.o
271 $(PRECONV_OBJS): config.h
272
273 APROPOS_OBJS = apropos.o mansearch.o mansearch_const.o manpath.o
274 $(APROPOS_OBJS): config.h manpath.h mansearch.h
275
276 MANPAGE_OBJS = manpage.o mansearch.o mansearch_const.o manpath.o
277 $(MANPAGE_OBJS): config.h manpath.h mansearch.h
278
279 DEMANDOC_OBJS = demandoc.o
280 $(DEMANDOC_OBJS): config.h
281
282 WWW_MANS = apropos.1.html \
283 demandoc.1.html \
284 mandoc.1.html \
285 preconv.1.html \
286 mandoc.3.html \
287 mansearch.3.html \
288 tbl.3.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.h.html \
298 mandoc.h.html \
299 manpath.h.html \
300 mansearch.h.html \
301 mdoc.h.html
302
303 $(WWW_MANS): mandoc
304
305 WWW_OBJS = mdocml.tar.gz \
306 mdocml.md5
307
308 clean:
309 rm -f libmandoc.a $(LIBMANDOC_OBJS)
310 rm -f apropos $(APROPOS_OBJS)
311 rm -f makewhatis $(MAKEWHATIS_OBJS)
312 rm -f preconv $(PRECONV_OBJS)
313 rm -f manpage $(MANPAGE_OBJS)
314 rm -f demandoc $(DEMANDOC_OBJS)
315 rm -f mandoc $(MANDOC_OBJS)
316 rm -f config.h config.log $(COMPAT_OBJS)
317 rm -f $(WWW_MANS) $(WWW_OBJS)
318 rm -rf *.dSYM
319
320 install: all
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) $(ALLBIN) $(DESTDIR)$(BINDIR)
330 $(INSTALL_LIB) libmandoc.a $(DESTDIR)$(LIBDIR)
331 $(INSTALL_LIB) man.h mdoc.h mandoc.h $(DESTDIR)$(INCLUDEDIR)
332 $(INSTALL_MAN) mandoc.1 preconv.1 demandoc.1 $(DESTDIR)$(MANDIR)/man1
333 $(INSTALL_MAN) mandoc.3 mansearch.3 tbl.3 $(DESTDIR)$(MANDIR)/man3
334 $(INSTALL_MAN) mandoc.db.5 $(DESTDIR)$(MANDIR)/man5
335 $(INSTALL_MAN) man.7 mdoc.7 roff.7 eqn.7 tbl.7 mandoc_char.7 $(DESTDIR)$(MANDIR)/man7
336 $(INSTALL_DATA) example.style.css $(DESTDIR)$(EXAMPLEDIR)
337
338 installcgi: all
339 mkdir -p $(DESTDIR)$(CGIBINDIR)
340 mkdir -p $(DESTDIR)$(HTDOCDIR)
341 #$(INSTALL_PROGRAM) man.cgi $(DESTDIR)$(CGIBINDIR)
342 $(INSTALL_DATA) example.style.css $(DESTDIR)$(HTDOCDIR)/man.css
343 $(INSTALL_DATA) man-cgi.css $(DESTDIR)$(HTDOCDIR)
344
345 installwww: $(WWW_MANS) $(WWW_OBJS)
346 mkdir -p $(DESTDIR)$(HTDOCDIR)/snapshots
347 $(INSTALL_DATA) $(WWW_MANS) style.css $(DESTDIR)$(HTDOCDIR)
348 $(INSTALL_DATA) $(WWW_OBJS) $(DESTDIR)$(HTDOCDIR)/snapshots
349 $(INSTALL_DATA) mdocml.tar.gz \
350 $(DESTDIR)$(HTDOCDIR)/snapshots/mdocml-$(VERSION).tar.gz
351 $(INSTALL_DATA) mdocml.md5 \
352 $(DESTDIR)$(HTDOCDIR)/snapshots/mdocml-$(VERSION).md5
353
354 libmandoc.a: $(COMPAT_OBJS) $(LIBMANDOC_OBJS)
355 $(AR) rs $@ $(COMPAT_OBJS) $(LIBMANDOC_OBJS)
356
357 mandoc: $(MANDOC_OBJS) libmandoc.a
358 $(CC) $(LDFLAGS) -o $@ $(MANDOC_OBJS) libmandoc.a
359
360 makewhatis: $(MAKEWHATIS_OBJS) libmandoc.a
361 $(CC) $(LDFLAGS) -o $@ $(MAKEWHATIS_OBJS) libmandoc.a $(DBLIB)
362
363 preconv: $(PRECONV_OBJS)
364 $(CC) $(LDFLAGS) -o $@ $(PRECONV_OBJS)
365
366 manpage: $(MANPAGE_OBJS) libmandoc.a
367 $(CC) $(LDFLAGS) -o $@ $(MANPAGE_OBJS) libmandoc.a $(DBLIB)
368
369 apropos: $(APROPOS_OBJS) libmandoc.a
370 $(CC) $(LDFLAGS) -o $@ $(APROPOS_OBJS) libmandoc.a $(DBLIB)
371
372 demandoc: $(DEMANDOC_OBJS) libmandoc.a
373 $(CC) $(LDFLAGS) -o $@ $(DEMANDOC_OBJS) libmandoc.a
374
375 mdocml.md5: mdocml.tar.gz
376 md5 mdocml.tar.gz >$@
377
378 mdocml.tar.gz: $(SRCS)
379 mkdir -p .dist/mdocml-$(VERSION)/
380 $(INSTALL_SOURCE) $(SRCS) .dist/mdocml-$(VERSION)
381 chmod 755 .dist/mdocml-$(VERSION)/configure
382 ( cd .dist/ && tar zcf ../$@ mdocml-$(VERSION) )
383 rm -rf .dist/
384
385 config.h: configure config.h.pre config.h.post $(TESTSRCS)
386 rm -f config.log
387 CC="$(CC)" CFLAGS="$(CFLAGS)" VERSION="$(VERSION)" ./configure
388
389 .h.h.html:
390 highlight -I $< >$@
391
392 .1.1.html .3.3.html .5.5.html .7.7.html .8.8.html:
393 ./mandoc -Thtml -Wall,stop -Ostyle=style.css,man=%N.%S.html,includes=%I.html $< >$@