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