]> pd.if.org Git - hexagon/blobdiff - Makefile
move astar to lib
[hexagon] / Makefile
index 20f36fcc9bef418facf5aa03cc2cec85fee79fb1..a5e35a1315a072383b226bf77cc5268e2046d2a5 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -2,32 +2,71 @@
 # 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= hexmap.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/gridsize.t t/center.t t/polar.t
+PREFIX=/usr/local
+RELEASE = $(shell git tag | tail -1)
 
-all:   test libhexmap.a
+all:   libhexagon.a docs testfiles hexagon
+
+hexagon: cli/hexagon.o libhexagon.a
+       $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $< -lhexagon
 
 clean:
-       rm -f $(OBJS) libhexmap.a $(TESTS)
+       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:   $(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
 
-hextest:       hextest.c libhexmap.a
-       $(CC) $(CFLAGS) -o $@ hextest.c -L. -lhexmap
+t/ctap.c: ctap/ctap.c
+       cp $< $@
 
-libhexmap.a:   $(OBJS)
+t/ctap.h: ctap/ctap.h
+       cp $< $@
+
+prove.c: ctap/prove.c
+       cp $< $@
+
+libhexagon.a:  $(OBJS)
        ar r $@ $+
        ranlib $@
 
+install: libhexagon.a hexagon.h doc/hexagon.3
+       cp libhexagon.a $(PREFIX)/lib
+       cp hexagon.h $(PREFIX)/include
+       cp doc/hexagon.3 $(PREFIX)/share/man/man3
+
+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 
+