]> pd.if.org Git - hexagon/blob - Makefile
move astar to lib
[hexagon] / Makefile
1 # set ARCH in your environment if you want to do a multible architecture
2 # build.  This means you Mac users.
3 # ARCH= -arch x386 -arch x86_64
4
5 LDFLAGS= $(ARCH) -lm -L.
6 CFLAGS= -Wall -Wno-parentheses $(ARCH) -I. -I..
7 OBJS= lib/hexagon.o lib/astar.o lib/cantor.o
8 SRC=$(OBJS:.o=.c)
9 TESTS= t/cantor.t t/distance.t t/adjacency.t t/range.t t/hexbin.t \
10        t/gridsize.t t/center.t t/polar.t
11 PREFIX=/usr/local
12 RELEASE = $(shell git tag | tail -1)
13
14 all:    libhexagon.a docs testfiles hexagon
15
16 hexagon: cli/hexagon.o libhexagon.a
17         $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $< -lhexagon
18
19 clean:
20         rm -f $(OBJS) libhexagon.a $(TESTS)
21         rm -f doc/hexagon.3 doc/hexagon.pdf doc/hexagon.tex doc/hexagon.txt \
22                 doc/hexagon.idx doc/hexagon.aux doc/hexagon.log doc/hexagon.toc
23
24 t/%.t:  t/%.o t/ctap.o t/ctap.h $(OBJS)
25         $(CC) -I.. -I. -o $@ $+ $(LDFLAGS)
26
27 testfiles: $(TESTS)
28
29 test:   libhexagon.a prove $(TESTS)
30         @./prove $(TESTS) 2>/dev/null
31
32 ptest:   libhexagon.a $(TESTS)
33         @prove --exec '' $(TESTS) 2>/dev/null
34
35 t/ctap.c: ctap/ctap.c
36         cp $< $@
37
38 t/ctap.h: ctap/ctap.h
39         cp $< $@
40
41 prove.c: ctap/prove.c
42         cp $< $@
43
44 libhexagon.a:   $(OBJS)
45         ar r $@ $+
46         ranlib $@
47
48 install: libhexagon.a hexagon.h doc/hexagon.3
49         cp libhexagon.a $(PREFIX)/lib
50         cp hexagon.h $(PREFIX)/include
51         cp doc/hexagon.3 $(PREFIX)/share/man/man3
52
53 docs: doc/hexagon.3 doc/hexagon.txt
54
55 doc/hexagon.3:  doc/hexagon.pod
56         pod2man --center='hexagon library' --section=3 --release='Version $(RELEASE)' $+ > $@
57
58 doc/hexagon.txt: doc/hexagon.pod
59         pod2text -l $+ > $@
60
61 doc/hexagon.pdf:        doc/hexagon.pod
62         pod2latex -full $+
63         pdflatex hexagon.tex
64         pdflatex hexagon.tex
65         pdflatex hexagon.tex
66         rm -f hexagon.tex hexagon.idx hexagon.aux hexagon.toc hexagon.log
67
68 .c.o:
69         $(CC) $(CFLAGS) -c -o $@ $<
70
71 .SUFFIXES:      .c .h 
72