small fixes and add "gmake test"
[tedtools.git] / Makefile
1 CC=gcc
2 AR=ar rcv
3 RANLIB=ranlib
4 LD=ld -x -shared 
5
6 INCLUDE=-I.
7 CFLAGS=-Wall -g -O2 -pedantic -ansi -DASSERT_CORE -D_GNU_SOURCE -DHAVE_POLL_H -DHAVE_SYS_POLL_H -DHAVE_HSTRERROR
8 LIB=-g -L. -ltedtools -lm
9
10 OBJS=tlog.o tmalloc.o tools.o prs_hmap.o sfxstr.o \
11         regis.o prs_inf.o shmem.o tcp.o udp.o connpool.o \
12         psort.o flatdb.o tbtree.o
13 PROGS=sfxtest hextest inftest kilter psortex flatdbtest tbtreetest gendata
14
15 .SUFFIXES: .o.c
16
17 all: libtedtools.a $(PROGS)
18
19 $(PROGS): %: %.o
20         $(CC) -o $@ $< $(LIB)
21
22 $(PROGS): libtedtools.a
23
24 libtedtools.a: $(OBJS)
25         $(AR) $@ $?
26         $(RANLIB) $@
27
28 .c.o:
29         $(CC) $(CFLAGS) $(INCLUDE) -c $<
30
31
32 test: all
33         @[ -d results ] || mkdir results  
34         @[ -d diffs ] || mkdir diffs  
35         @[ -d temp ] || mkdir temp  
36         @for FILE in `ls  tests/* | sed -e 's#^tests/##'` ; do \
37                 echo -n $$FILE "        ........ " ; \
38                 if sh tests/$$FILE > results/$$FILE 2>results/$$FILE.errout && diff -c expected/$$FILE results/$$FILE > diffs/$$FILE ; then \
39                         echo ok ; \
40                 else \
41                         echo FAILED ; \
42                 fi ; \
43         done
44
45 clean:
46         rm -rf $(OBJS)
47         rm -rf $(PROGS) *.o
48         rm -rf libtedtools.a
49         rm -rf *core *gmon* nohup.out
50         rm -rf sfxtest.log BTREE
51         rm -rf results diffs temp
52