]> git.cameronkatri.com Git - mandoc.git/blob - Makefile
a8523931de868e7016bdb0097029b8181a1a7701
[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-strlcat.c \
68 test-strlcpy.c \
69 test-strnlen.c \
70 test-strptime.c
71
72 SRCS = Makefile \
73 NEWS \
74 TODO \
75 apropos.1 \
76 apropos.c \
77 arch.c \
78 arch.in \
79 att.c \
80 att.in \
81 cgi.c \
82 chars.c \
83 chars.in \
84 compat_fgetln.c \
85 compat_getsubopt.c \
86 compat_ohash.c \
87 compat_ohash.h \
88 compat_strcasestr.c \
89 compat_strlcat.c \
90 compat_strlcpy.c \
91 compat_strnlen.c \
92 compat_strsep.c \
93 config.h.post \
94 config.h.pre \
95 configure \
96 demandoc.1 \
97 demandoc.c \
98 eqn.7 \
99 eqn.c \
100 eqn_html.c \
101 eqn_term.c \
102 example.style.css \
103 gmdiff \
104 html.c \
105 html.h \
106 lib.c \
107 lib.in \
108 libman.h \
109 libmandoc.h \
110 libmdoc.h \
111 libroff.h \
112 main.c \
113 main.h \
114 makewhatis.8 \
115 man.7 \
116 man.c \
117 man-cgi.css \
118 man.h \
119 man_hash.c \
120 man_html.c \
121 man_macro.c \
122 man_term.c \
123 man_validate.c \
124 mandoc.1 \
125 mandoc.3 \
126 mandoc.c \
127 mandoc.db.5 \
128 mandoc.h \
129 mandoc_aux.c \
130 mandoc_aux.h \
131 mandoc_char.7 \
132 mandocdb.c \
133 manpage.c \
134 manpath.c \
135 manpath.h \
136 mansearch.3 \
137 mansearch.c \
138 mansearch.h \
139 mansearch_const.c \
140 mdoc.7 \
141 mdoc.c \
142 mdoc.h \
143 mdoc_argv.c \
144 mdoc_hash.c \
145 mdoc_html.c \
146 mdoc_macro.c \
147 mdoc_man.c \
148 mdoc_term.c \
149 mdoc_validate.c \
150 msec.c \
151 msec.in \
152 out.c \
153 out.h \
154 preconv.1 \
155 preconv.c \
156 predefs.in \
157 read.c \
158 roff.7 \
159 roff.c \
160 st.c \
161 st.in \
162 style.css \
163 tbl.3 \
164 tbl.7 \
165 tbl.c \
166 tbl_data.c \
167 tbl_html.c \
168 tbl_layout.c \
169 tbl_opts.c \
170 tbl_term.c \
171 term.c \
172 term.h \
173 term_ascii.c \
174 term_ps.c \
175 tree.c \
176 vol.c \
177 vol.in \
178 $(TESTSRCS)
179
180 LIBMAN_OBJS = man.o \
181 man_hash.o \
182 man_macro.o \
183 man_validate.o
184
185 LIBMDOC_OBJS = arch.o \
186 att.o \
187 lib.o \
188 mdoc.o \
189 mdoc_argv.o \
190 mdoc_hash.o \
191 mdoc_macro.o \
192 mdoc_validate.o \
193 st.o \
194 vol.o
195
196 LIBROFF_OBJS = eqn.o \
197 roff.o \
198 tbl.o \
199 tbl_data.o \
200 tbl_layout.o \
201 tbl_opts.o
202
203 LIBMANDOC_OBJS = $(LIBMAN_OBJS) \
204 $(LIBMDOC_OBJS) \
205 $(LIBROFF_OBJS) \
206 chars.o \
207 mandoc.o \
208 mandoc_aux.o \
209 msec.o \
210 read.o
211
212 COMPAT_OBJS = compat_fgetln.o \
213 compat_getsubopt.o \
214 compat_ohash.o \
215 compat_strcasestr.o \
216 compat_strlcat.o \
217 compat_strlcpy.o \
218 compat_strnlen.o \
219 compat_strsep.o
220
221 arch.o: arch.in
222 att.o: att.in
223 chars.o: chars.in
224 lib.o: lib.in
225 msec.o: msec.in
226 roff.o: predefs.in
227 st.o: st.in
228 vol.o: vol.in
229
230 $(LIBMAN_OBJS): libman.h
231 $(LIBMDOC_OBJS): libmdoc.h
232 $(LIBROFF_OBJS): libroff.h
233 $(LIBMANDOC_OBJS): mandoc.h mandoc_aux.h mdoc.h man.h libmandoc.h config.h
234 $(COMPAT_OBJS): config.h compat_ohash.h
235
236 MANDOC_HTML_OBJS = eqn_html.o \
237 html.o \
238 man_html.o \
239 mdoc_html.o \
240 tbl_html.o
241 $(MANDOC_HTML_OBJS): html.h
242
243 MANDOC_MAN_OBJS = mdoc_man.o
244
245 MANDOC_TERM_OBJS = eqn_term.o \
246 man_term.o \
247 mdoc_term.o \
248 term.o \
249 term_ascii.o \
250 term_ps.o \
251 tbl_term.o
252 $(MANDOC_TERM_OBJS): term.h
253
254 MANDOC_OBJS = $(MANDOC_HTML_OBJS) \
255 $(MANDOC_MAN_OBJS) \
256 $(MANDOC_TERM_OBJS) \
257 main.o \
258 out.o \
259 tree.o
260 $(MANDOC_OBJS): main.h mandoc.h mandoc_aux.h mdoc.h man.h config.h out.h
261
262 MAKEWHATIS_OBJS = mandocdb.o mansearch_const.o manpath.o
263 $(MAKEWHATIS_OBJS): mansearch.h mandoc.h mandoc_aux.h \
264 mdoc.h man.h config.h manpath.h
265
266 PRECONV_OBJS = preconv.o
267 $(PRECONV_OBJS): config.h
268
269 APROPOS_OBJS = apropos.o mansearch.o mansearch_const.o manpath.o
270 $(APROPOS_OBJS): config.h manpath.h mansearch.h
271
272 MANPAGE_OBJS = manpage.o mansearch.o mansearch_const.o manpath.o
273 $(MANPAGE_OBJS): config.h manpath.h mansearch.h
274
275 DEMANDOC_OBJS = demandoc.o
276 $(DEMANDOC_OBJS): config.h
277
278 WWW_MANS = apropos.1.html \
279 demandoc.1.html \
280 mandoc.1.html \
281 preconv.1.html \
282 mandoc.3.html \
283 mansearch.3.html \
284 tbl.3.html \
285 mandoc.db.5.html \
286 eqn.7.html \
287 man.7.html \
288 mandoc_char.7.html \
289 mdoc.7.html \
290 roff.7.html \
291 tbl.7.html \
292 makewhatis.8.html \
293 man.h.html \
294 mandoc.h.html \
295 manpath.h.html \
296 mansearch.h.html \
297 mdoc.h.html
298
299 $(WWW_MANS): mandoc
300
301 WWW_OBJS = mdocml.tar.gz \
302 mdocml.md5
303
304 clean:
305 rm -f libmandoc.a $(LIBMANDOC_OBJS)
306 rm -f apropos $(APROPOS_OBJS)
307 rm -f makewhatis $(MAKEWHATIS_OBJS)
308 rm -f preconv $(PRECONV_OBJS)
309 rm -f manpage $(MANPAGE_OBJS)
310 rm -f demandoc $(DEMANDOC_OBJS)
311 rm -f mandoc $(MANDOC_OBJS)
312 rm -f config.h config.log $(COMPAT_OBJS)
313 rm -f $(WWW_MANS) $(WWW_OBJS)
314 rm -rf *.dSYM
315
316 install: all
317 mkdir -p $(DESTDIR)$(BINDIR)
318 mkdir -p $(DESTDIR)$(EXAMPLEDIR)
319 mkdir -p $(DESTDIR)$(LIBDIR)
320 mkdir -p $(DESTDIR)$(INCLUDEDIR)
321 mkdir -p $(DESTDIR)$(MANDIR)/man1
322 mkdir -p $(DESTDIR)$(MANDIR)/man3
323 mkdir -p $(DESTDIR)$(MANDIR)/man5
324 mkdir -p $(DESTDIR)$(MANDIR)/man7
325 $(INSTALL_PROGRAM) $(ALLBIN) $(DESTDIR)$(BINDIR)
326 $(INSTALL_LIB) libmandoc.a $(DESTDIR)$(LIBDIR)
327 $(INSTALL_LIB) man.h mdoc.h mandoc.h $(DESTDIR)$(INCLUDEDIR)
328 $(INSTALL_MAN) mandoc.1 preconv.1 demandoc.1 $(DESTDIR)$(MANDIR)/man1
329 $(INSTALL_MAN) mandoc.3 mansearch.3 tbl.3 $(DESTDIR)$(MANDIR)/man3
330 $(INSTALL_MAN) mandoc.db.5 $(DESTDIR)$(MANDIR)/man5
331 $(INSTALL_MAN) man.7 mdoc.7 roff.7 eqn.7 tbl.7 mandoc_char.7 $(DESTDIR)$(MANDIR)/man7
332 $(INSTALL_DATA) example.style.css $(DESTDIR)$(EXAMPLEDIR)
333
334 installcgi: all
335 mkdir -p $(DESTDIR)$(CGIBINDIR)
336 mkdir -p $(DESTDIR)$(HTDOCDIR)
337 #$(INSTALL_PROGRAM) man.cgi $(DESTDIR)$(CGIBINDIR)
338 $(INSTALL_DATA) example.style.css $(DESTDIR)$(HTDOCDIR)/man.css
339 $(INSTALL_DATA) man-cgi.css $(DESTDIR)$(HTDOCDIR)
340
341 installwww: $(WWW_MANS) $(WWW_OBJS)
342 mkdir -p $(DESTDIR)$(HTDOCDIR)/snapshots
343 $(INSTALL_DATA) $(WWW_MANS) style.css $(DESTDIR)$(HTDOCDIR)
344 $(INSTALL_DATA) $(WWW_OBJS) $(DESTDIR)$(HTDOCDIR)/snapshots
345 $(INSTALL_DATA) mdocml.tar.gz \
346 $(DESTDIR)$(HTDOCDIR)/snapshots/mdocml-$(VERSION).tar.gz
347 $(INSTALL_DATA) mdocml.md5 \
348 $(DESTDIR)$(HTDOCDIR)/snapshots/mdocml-$(VERSION).md5
349
350 libmandoc.a: $(COMPAT_OBJS) $(LIBMANDOC_OBJS)
351 $(AR) rs $@ $(COMPAT_OBJS) $(LIBMANDOC_OBJS)
352
353 mandoc: $(MANDOC_OBJS) libmandoc.a
354 $(CC) $(LDFLAGS) -o $@ $(MANDOC_OBJS) libmandoc.a
355
356 makewhatis: $(MAKEWHATIS_OBJS) libmandoc.a
357 $(CC) $(LDFLAGS) -o $@ $(MAKEWHATIS_OBJS) libmandoc.a $(DBLIB)
358
359 preconv: $(PRECONV_OBJS)
360 $(CC) $(LDFLAGS) -o $@ $(PRECONV_OBJS)
361
362 manpage: $(MANPAGE_OBJS) libmandoc.a
363 $(CC) $(LDFLAGS) -o $@ $(MANPAGE_OBJS) libmandoc.a $(DBLIB)
364
365 apropos: $(APROPOS_OBJS) libmandoc.a
366 $(CC) $(LDFLAGS) -o $@ $(APROPOS_OBJS) libmandoc.a $(DBLIB)
367
368 demandoc: $(DEMANDOC_OBJS) libmandoc.a
369 $(CC) $(LDFLAGS) -o $@ $(DEMANDOC_OBJS) libmandoc.a
370
371 mdocml.md5: mdocml.tar.gz
372 md5 mdocml.tar.gz >$@
373
374 mdocml.tar.gz: $(SRCS)
375 mkdir -p .dist/mdocml-$(VERSION)/
376 $(INSTALL_SOURCE) $(SRCS) .dist/mdocml-$(VERSION)
377 chmod 755 .dist/mdocml-$(VERSION)/configure
378 ( cd .dist/ && tar zcf ../$@ mdocml-$(VERSION) )
379 rm -rf .dist/
380
381 config.h: configure config.h.pre config.h.post $(TESTSRCS)
382 rm -f config.log
383 CC="$(CC)" CFLAGS="$(CFLAGS)" VERSION="$(VERSION)" ./configure
384
385 .h.h.html:
386 highlight -I $< >$@
387
388 .1.1.html .3.3.html .5.5.html .7.7.html .8.8.html:
389 ./mandoc -Thtml -Wall,stop -Ostyle=style.css,man=%N.%S.html,includes=%I.html $< >$@