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