]> pd.if.org Git - hexagon/blobdiff - Makefile
move astar to lib
[hexagon] / Makefile
index e0789e5ba9888d6286f8dec34dfd107911e8f0f1..a5e35a1315a072383b226bf77cc5268e2046d2a5 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -2,24 +2,44 @@
 # build.  This means you Mac users.
 # ARCH= -arch x386 -arch x86_64
 
-LDFLAGS= $(ARCH) -lm
+LDFLAGS= $(ARCH) -lm -L.
 CFLAGS=        -Wall -Wno-parentheses $(ARCH) -I. -I..
-OBJS= hexagon.o astar.o
+OBJS= lib/hexagon.o lib/astar.o lib/cantor.o
 SRC=$(OBJS:.o=.c)
 TESTS= t/cantor.t t/distance.t t/adjacency.t t/range.t t/hexbin.t \
-       t/gridsize.t t/center.t t/astar.t
+       t/gridsize.t t/center.t t/polar.t
 PREFIX=/usr/local
+RELEASE = $(shell git tag | tail -1)
 
-all:   libhexagon.a docs
+all:   libhexagon.a docs testfiles hexagon
+
+hexagon: cli/hexagon.o libhexagon.a
+       $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $< -lhexagon
 
 clean:
        rm -f $(OBJS) libhexagon.a $(TESTS)
+       rm -f doc/hexagon.3 doc/hexagon.pdf doc/hexagon.tex doc/hexagon.txt \
+               doc/hexagon.idx doc/hexagon.aux doc/hexagon.log doc/hexagon.toc
 
-t/%.t:  t/%.o t/tap.o $(OBJS)
+t/%.t:  t/%.o t/ctap.o t/ctap.h $(OBJS)
        $(CC) -I.. -I. -o $@ $+ $(LDFLAGS)
 
-test:   libhexagon.a $(TESTS)
-       @prove --exec '' 2>/dev/null
+testfiles: $(TESTS)
+
+test:   libhexagon.a prove $(TESTS)
+       @./prove $(TESTS) 2>/dev/null
+
+ptest:   libhexagon.a $(TESTS)
+       @prove --exec '' $(TESTS) 2>/dev/null
+
+t/ctap.c: ctap/ctap.c
+       cp $< $@
+
+t/ctap.h: ctap/ctap.h
+       cp $< $@
+
+prove.c: ctap/prove.c
+       cp $< $@
 
 libhexagon.a:  $(OBJS)
        ar r $@ $+
@@ -30,10 +50,23 @@ install: libhexagon.a hexagon.h doc/hexagon.3
        cp hexagon.h $(PREFIX)/include
        cp doc/hexagon.3 $(PREFIX)/share/man/man3
 
-docs:
-       make -C doc
+docs: doc/hexagon.3 doc/hexagon.txt
+
+doc/hexagon.3: doc/hexagon.pod
+       pod2man --center='hexagon library' --section=3 --release='Version $(RELEASE)' $+ > $@
+
+doc/hexagon.txt: doc/hexagon.pod
+       pod2text -l $+ > $@
+
+doc/hexagon.pdf:       doc/hexagon.pod
+       pod2latex -full $+
+       pdflatex hexagon.tex
+       pdflatex hexagon.tex
+       pdflatex hexagon.tex
+       rm -f hexagon.tex hexagon.idx hexagon.aux hexagon.toc hexagon.log
 
 .c.o:
        $(CC) $(CFLAGS) -c -o $@ $<
 
 .SUFFIXES:     .c .h 
+