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