]> git.cameronkatri.com Git - mandoc.git/blob - Makefile
Use a default prefix of /usr/local. Honour DESTDIR for install targets.
[mandoc.git] / Makefile
1 .SUFFIXES: .html .xml .sgml .1 .3 .7 .md5 .tar.gz .1.txt .3.txt .7.txt .1.sgml .3.sgml .7.sgml .h .h.html
2
3 PREFIX = /usr/local
4 BINDIR = $(PREFIX)/bin
5 INCLUDEDIR = $(PREFIX)/include
6 LIBDIR = $(PREFIX)/lib
7 MANDIR = $(PREFIX)/man
8 EXAMPLEDIR = $(PREFIX)/share/examples/mandoc
9 INSTALL = install
10 INSTALL_PROGRAM = $(INSTALL) -m 0755
11 INSTALL_DATA = $(INSTALL) -m 0444
12 INSTALL_LIB = $(INSTALL) -m 0644
13 INSTALL_MAN = $(INSTALL_DATA)
14
15 VERSION = 1.9.25
16 VDATE = 13 May 2010
17
18 VFLAGS = -DVERSION="\"$(VERSION)\""
19 WFLAGS = -W -Wall -Wstrict-prototypes -Wno-unused-parameter -Wwrite-strings
20 CFLAGS += -g $(WFLAGS) $(VFLAGS) -DHAVE_CONFIG_H
21
22 # Specify this if you want to hard-code the operating system to appear
23 # in the lower-left hand corner of -mdoc manuals.
24 # CFLAGS += -DOSNAME="\"OpenBSD 4.5\""
25
26 # Unset this if you don't want Xo/Xc allowing split `It' lines, which
27 # breaks symmetry.
28 CFLAGS += -DUGLY
29
30 LINTFLAGS += $(VFLAGS)
31
32 MANDOCFLAGS = -Wall -fstrict
33
34 MANDOCHTML = -Thtml -Ostyle=style.css,man=%N.%S.html,includes=%I.html
35
36 ROFFLNS = roff.ln
37
38 ROFFSRCS = roff.c
39
40 ROFFOBJS = roff.o
41
42 MANDOCLNS = mandoc.ln
43
44 MANDOCSRCS = mandoc.c
45
46 MANDOCOBJS = mandoc.o
47
48 MDOCLNS = mdoc_macro.ln mdoc.ln mdoc_hash.ln mdoc_strings.ln \
49 mdoc_argv.ln mdoc_validate.ln mdoc_action.ln \
50 lib.ln att.ln arch.ln vol.ln msec.ln st.ln
51
52 MDOCOBJS = mdoc_macro.o mdoc.o mdoc_hash.o mdoc_strings.o \
53 mdoc_argv.o mdoc_validate.o mdoc_action.o lib.o att.o \
54 arch.o vol.o msec.o st.o
55
56 MDOCSRCS = mdoc_macro.c mdoc.c mdoc_hash.c mdoc_strings.c \
57 mdoc_argv.c mdoc_validate.c mdoc_action.c lib.c att.c \
58 arch.c vol.c msec.c st.c
59
60 MANLNS = man_macro.ln man.ln man_hash.ln man_validate.ln \
61 man_action.ln man_argv.ln
62
63 MANOBJS = man_macro.o man.o man_hash.o man_validate.o \
64 man_action.o man_argv.o
65 MANSRCS = man_macro.c man.c man_hash.c man_validate.c \
66 man_action.c mandoc.c man_argv.c
67
68 MAINLNS = main.ln mdoc_term.ln chars.ln term.ln tree.ln \
69 compat.ln man_term.ln html.ln mdoc_html.ln \
70 man_html.ln out.ln
71
72 MAINOBJS = main.o mdoc_term.o chars.o term.o tree.o compat.o \
73 man_term.o html.o mdoc_html.o man_html.o out.o
74
75 MAINSRCS = main.c mdoc_term.c chars.c term.c tree.c compat.c \
76 man_term.c html.c mdoc_html.c man_html.c out.c
77
78 LLNS = llib-llibmdoc.ln llib-llibman.ln llib-lmandoc.ln \
79 llib-llibmandoc.ln llib-llibroff.ln
80
81 LNS = $(MAINLNS) $(MDOCLNS) $(MANLNS) \
82 $(MANDOCLNS) $(ROFFLNS)
83
84 LIBS = libmdoc.a libman.a libmandoc.a libroff.a
85
86 OBJS = $(MDOCOBJS) $(MAINOBJS) $(MANOBJS) \
87 $(MANDOCOBJS) $(ROFFOBJS)
88
89 SRCS = $(MDOCSRCS) $(MAINSRCS) $(MANSRCS) \
90 $(MANDOCSRCS) $(ROFFSRCS)
91
92 DATAS = arch.in att.in lib.in msec.in st.in \
93 vol.in chars.in
94
95 HEADS = mdoc.h libmdoc.h man.h libman.h term.h \
96 libmandoc.h html.h chars.h out.h main.h roff.h
97
98 GSGMLS = mandoc.1.sgml mdoc.3.sgml mdoc.7.sgml manuals.7.sgml \
99 mandoc_char.7.sgml man.7.sgml man.3.sgml
100
101 SGMLS = index.sgml
102
103 HTMLS = ChangeLog.html index.html man.h.html mdoc.h.html
104
105 XSLS = ChangeLog.xsl
106
107 GHTMLS = mandoc.1.html mdoc.3.html man.3.html mdoc.7.html \
108 man.7.html mandoc_char.7.html manuals.7.html
109
110 TEXTS = mandoc.1.txt mdoc.3.txt man.3.txt mdoc.7.txt man.7.txt \
111 mandoc_char.7.txt manuals.7.txt ChangeLog.txt
112
113 EXAMPLES = example.style.css
114
115 XMLS = ChangeLog.xml
116
117 STATICS = index.css style.css external.png
118
119 MD5S = mdocml-$(VERSION).md5
120
121 TARGZS = mdocml-$(VERSION).tar.gz
122
123 MANS = mandoc.1 mdoc.3 mdoc.7 manuals.7 mandoc_char.7 \
124 man.7 man.3
125
126 BINS = mandoc
127
128 TESTS = test-strlcat.c test-strlcpy.c
129
130 CONFIGS = config.h.pre config.h.post
131
132 DOCLEAN = $(BINS) $(LNS) $(LLNS) $(LIBS) $(OBJS) $(HTMLS) \
133 $(TARGZS) tags $(MD5S) $(XMLS) $(TEXTS) $(GSGMLS) \
134 $(GHTMLS) config.h config.log
135
136 DOINSTALL = $(SRCS) $(HEADS) Makefile $(MANS) $(SGMLS) $(STATICS) \
137 $(DATAS) $(XSLS) $(EXAMPLES) $(TESTS) $(CONFIGS)
138
139 all: $(BINS)
140
141 lint: $(LLNS)
142
143 clean:
144 rm -f $(DOCLEAN)
145
146 cleanlint:
147 rm -f $(LNS) $(LLNS)
148
149 cleanhtml:
150 rm -f $(HTMLS) $(GSGMLS) $(GHTMLS)
151
152 dist: mdocml-$(VERSION).tar.gz
153
154 www: all $(GSGMLS) $(GHTMLS) $(HTMLS) $(TEXTS) $(MD5S) $(TARGZS)
155
156 htmls: all $(GSGMLS) $(GHTMLS)
157
158 installwww: www
159 $(INSTALL_DATA) $(GHTMLS) $(HTMLS) $(TEXTS) $(STATICS) $(DESTDIR)$(PREFIX)/
160 $(INSTALL_DATA) mdocml-$(VERSION).tar.gz $(DESTDIR)$(PREFIX)/snapshots/
161 $(INSTALL_DATA) mdocml-$(VERSION).md5 $(DESTDIR)$(PREFIX)/snapshots/
162 $(INSTALL_DATA) mdocml-$(VERSION).tar.gz $(DESTDIR)$(PREFIX)/snapshots/mdocml.tar.gz
163 $(INSTALL_DATA) mdocml-$(VERSION).md5 $(DESTDIR)$(PREFIX)/snapshots/mdocml.md5
164
165 install:
166 mkdir -p $(DESTDIR)$(BINDIR)
167 mkdir -p $(DESTDIR)$(EXAMPLEDIR)
168 mkdir -p $(DESTDIR)$(MANDIR)/man1
169 mkdir -p $(DESTDIR)$(MANDIR)/man7
170 $(INSTALL_PROGRAM) mandoc $(DESTDIR)$(BINDIR)
171 $(INSTALL_MAN) mandoc.1 $(DESTDIR)$(MANDIR)/man1
172 $(INSTALL_MAN) man.7 mdoc.7 mandoc_char.7 $(DESTDIR)$(MANDIR)/man7
173 $(INSTALL_DATA) example.style.css $(DESTDIR)$(EXAMPLEDIR)
174
175 uninstall:
176 rm -f $(DESTDIR)$(BINDIR)/mandoc
177 rm -f $(DESTDIR)$(MANDIR)/man1/mandoc.1
178 rm -f $(DESTDIR)$(MANDIR)/man7/mdoc.7
179 rm -f $(DESTDIR)$(MANDIR)/man7/man.7
180 rm -f $(DESTDIR)$(MANDIR)/man7/mandoc_char.7
181 rm -f $(DESTDIR)$(EXAMPLEDIR)/example.style.css
182
183 $(OBJS): config.h
184
185 $(LNS): config.h
186
187 man_macro.ln man_macro.o: man_macro.c libman.h
188
189 lib.ln lib.o: lib.c lib.in libmdoc.h
190
191 att.ln att.o: att.c att.in libmdoc.h
192
193 arch.ln arch.o: arch.c arch.in libmdoc.h
194
195 vol.ln vol.o: vol.c vol.in libmdoc.h
196
197 chars.ln chars.o: chars.c chars.in chars.h
198
199 msec.ln msec.o: msec.c msec.in libmdoc.h
200
201 st.ln st.o: st.c st.in libmdoc.h
202
203 mdoc_macro.ln mdoc_macro.o: mdoc_macro.c libmdoc.h
204
205 mdoc_term.ln mdoc_term.o: mdoc_term.c term.h mdoc.h
206
207 mdoc_strings.ln mdoc_strings.o: mdoc_strings.c libmdoc.h
208
209 man_hash.ln man_hash.o: man_hash.c libman.h
210
211 mdoc_hash.ln mdoc_hash.o: mdoc_hash.c libmdoc.h
212
213 mdoc.ln mdoc.o: mdoc.c libmdoc.h
214
215 man.ln man.o: man.c libman.h
216
217 main.ln main.o: main.c mdoc.h man.h roff.h
218
219 compat.ln compat.o: compat.c
220
221 term.ln term.o: term.c term.h man.h mdoc.h chars.h
222
223 html.ln html.o: html.c html.h chars.h
224
225 mdoc_html.ln mdoc_html.o: mdoc_html.c html.h mdoc.h
226
227 man_html.ln man_html.o: man_html.c html.h man.h out.h
228
229 out.ln out.o: out.c out.h
230
231 mandoc.ln mandoc.o: mandoc.c libmandoc.h
232
233 tree.ln tree.o: tree.c man.h mdoc.h
234
235 mdoc_argv.ln mdoc_argv.o: mdoc_argv.c libmdoc.h
236
237 man_argv.ln man_argv.o: man_argv.c libman.h
238
239 man_validate.ln man_validate.o: man_validate.c libman.h
240
241 mdoc_validate.ln mdoc_validate.o: mdoc_validate.c libmdoc.h
242
243 mdoc_action.ln mdoc_action.o: mdoc_action.c libmdoc.h
244
245 libmdoc.h: mdoc.h
246
247 ChangeLog.xml:
248 cvs2cl --xml --xml-encoding iso-8859-15 -t --noxmlns -f $@
249
250 ChangeLog.txt:
251 cvs2cl -t -f $@
252
253 ChangeLog.html: ChangeLog.xml ChangeLog.xsl
254 xsltproc -o $@ ChangeLog.xsl ChangeLog.xml
255
256 mdocml-$(VERSION).tar.gz: $(DOINSTALL)
257 mkdir -p .dist/mdocml/mdocml-$(VERSION)/
258 cp -f $(DOINSTALL) .dist/mdocml/mdocml-$(VERSION)/
259 ( cd .dist/mdocml/ && tar zcf ../../$@ mdocml-$(VERSION)/ )
260 rm -rf .dist/
261
262 llib-llibmdoc.ln: $(MDOCLNS)
263 $(LINT) -Clibmdoc $(MDOCLNS)
264
265 llib-llibman.ln: $(MANLNS)
266 $(LINT) -Clibman $(MANLNS)
267
268 llib-llibmandoc.ln: $(MANDOCLNS)
269 $(LINT) -Clibmandoc $(MANDOCLNS)
270
271 llib-llibroff.ln: $(ROFFLNS)
272 $(LINT) -Clibroff $(ROFFLNS)
273
274 llib-lmandoc.ln: $(MAINLNS) llib-llibmdoc.ln llib-llibman.ln llib-llibmandoc.ln llib-llibroff.ln
275 $(LINT) -Cmandoc $(MAINLNS) llib-llibmdoc.ln llib-llibman.ln llib-llibmandoc.ln llib-llibroff.ln
276
277 libmdoc.a: $(MDOCOBJS)
278 $(AR) rs $@ $(MDOCOBJS)
279
280 libman.a: $(MANOBJS)
281 $(AR) rs $@ $(MANOBJS)
282
283 libmandoc.a: $(MANDOCOBJS)
284 $(AR) rs $@ $(MANDOCOBJS)
285
286 libroff.a: $(ROFFOBJS)
287 $(AR) rs $@ $(ROFFOBJS)
288
289 mandoc: $(MAINOBJS) libroff.a libmdoc.a libman.a libmandoc.a
290 $(CC) $(CFLAGS) -o $@ $(MAINOBJS) libroff.a libmdoc.a libman.a libmandoc.a
291
292 .sgml.html:
293 validate --warn $<
294 sed -e "s!@VERSION@!$(VERSION)!" -e "s!@VDATE@!$(VDATE)!" $< > $@
295
296 .1.1.txt .3.3.txt .7.7.txt:
297 ./mandoc $(MANDOCFLAGS) $< | col -b > $@
298
299 .1.1.sgml .3.3.sgml .7.7.sgml:
300 ./mandoc $(MANDOCFLAGS) $(MANDOCHTML) $< > $@
301
302 .tar.gz.md5:
303 md5 $< > $@
304
305 .h.h.html:
306 highlight -I $< >$@
307
308 config.h: config.h.pre config.h.post
309 rm -f config.log
310 ( cat config.h.pre; \
311 echo; \
312 if $(CC) $(CFLAGS) -Werror -c test-strlcat.c >> config.log 2>&1; then \
313 echo '#define HAVE_STRLCAT'; \
314 rm test-strlcat.o; \
315 fi; \
316 if $(CC) $(CFLAGS) -Werror -c test-strlcpy.c >> config.log 2>&1; then \
317 echo '#define HAVE_STRLCPY'; \
318 rm test-strlcpy.o; \
319 fi; \
320 echo; \
321 cat config.h.post \
322 ) > $@