1CFLAGS += -g -W -Wall -Wstrict-prototypes -Wno-unused-parameter -Wwrite-strings
2OBJS = main.o util.o
3SRCS = main.c util.c
4VERSIONS = version_0_1_1.xml \
5	   version_0_1_2.xml
6VERSION = 0.1.2
7PREFIX = /usr/local
8
9all: texi2mdoc
10
11www: index.html texi2mdoc.1.html texi2mdoc.tgz texi2mdoc.tgz.sha512
12
13afl: afl/texi2mdoc
14
15texi2mdoc: $(OBJS)
16	$(CC) -o $@ $(OBJS)
17
18install: all
19	mkdir -p $(DESTDIR)$(PREFIX)/bin
20	mkdir -p $(DESTDIR)$(PREFIX)/man/man1
21	install -m 0755 texi2mdoc $(DESTDIR)$(PREFIX)/bin
22	install -m 0444 texi2mdoc.1 $(DESTDIR)$(PREFIX)/man/man1
23
24installwww: www
25	mkdir -p $(PREFIX)/snapshots
26	install -m 0444 index.html texi2mdoc.1.html $(PREFIX)
27	install -m 0444 texi2mdoc.tgz texi2mdoc.tgz.sha512 $(PREFIX)/snapshots
28	install -m 0444 texi2mdoc.tgz $(PREFIX)/snapshots/texi2mdoc-$(VERSION).tgz
29	install -m 0444 texi2mdoc.tgz.sha512 $(PREFIX)/snapshots/texi2mdoc-$(VERSION).tgz.sha512
30
31$(OBJS): extern.h
32
33afl/texi2mdoc: extern.h $(SRCS)
34	afl-clang -o $@ $(SRCS)
35
36index.html: index.xml $(VERSIONS)
37	sblg -o- -t index.xml $(VERSIONS) | sed "s!@VERSION@!$(VERSION)!g" >$@
38
39texi2mdoc.1.html: texi2mdoc.1
40	mandoc -Thtml texi2mdoc.1 >$@
41
42texi2mdoc.tgz:
43	mkdir -p .dist/texi2mdoc-$(VERSION)
44	install -m 0444 $(SRCS) extern.h Makefile texi2mdoc.1 .dist/texi2mdoc-$(VERSION)
45	(cd .dist && tar zcf ../$@ texi2mdoc-$(VERSION))
46	rm -rf .dist
47
48texi2mdoc.tgz.sha512: texi2mdoc.tgz
49	openssl dgst -sha512 texi2mdoc.tgz >$@
50
51clean:
52	rm -f $(OBJS)
53	rm -f texi2mdoc afl/texi2mdoc
54	rm -rf texi2mdoc.dSYM afl/texi2mdoc.dSYM
55	rm -f index.html texi2mdoc.1.html texi2mdoc.tgz texi2mdoc.tgz.sha512
56