summaryrefslogtreecommitdiff
path: root/test/compression/Makefile
blob: e35e1a1c14c7cd23b44a4aefd12a5ffd1662309d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
include ../../Makefile.config

CC=../../ccomp 
CFLAGS=-U__GNUC__ -stdlib ../../runtime -dclight -dasm
LIBS=
TIME=xtime -o /dev/null -mintime 1.0
ifeq ($(CCHECKLINK),true)
CCHECK=../../cchecklink
CFLAGS+= -sdump
endif

EXE=arcode lzw lzss

COMMON_OBJS=optlist.o bitfile.o

all: $(EXE)

ARCODE_OBJS=$(COMMON_OBJS) arcode.o armain.o

arcode: $(ARCODE_OBJS)
	$(CC) $(CFLAGS) -o $@ $(ARCODE_OBJS) $(LIBS)

LZW_OBJS=$(COMMON_OBJS) lzwencode.o lzwdecode.o lzwmain.o

lzw: $(LZW_OBJS)
	$(CC) $(CFLAGS) -o $@ $(LZW_OBJS) $(LIBS)

LZSS_OBJS=$(COMMON_OBJS) lzvars.o lzhash.o lzencode.o lzdecode.o lzssmain.o

lzss: $(LZSS_OBJS)
	$(CC) $(CFLAGS) -o $@ $(LZSS_OBJS) $(LIBS)

TESTFILE:=$(firstword $(wildcard /usr/share/dict/words) ./lzss)
TESTCOMPR=/tmp/testcompr.out
TESTEXPND=/tmp/testexpnd.out

test:
	rm -f $(TESTCOMPR) $(TESTEXPND)
	@echo "Test data: $(TESTFILE)"
	@for i in $(EXE); do \
          echo "$$i: compression..."; \
          ./$$i -c -i $(TESTFILE) -o $(TESTCOMPR); \
          echo "$$i: decompression..."; \
          ./$$i -d -i $(TESTCOMPR) -o $(TESTEXPND); \
          if cmp $(TESTFILE) $(TESTEXPND); \
          then echo "$$i: passed"; \
          else echo "$$i: FAILED"; \
          fi; \
        done
	rm -f $(TESTCOMPR) $(TESTEXPND)

bench:
	rm -f $(TESTCOMPR)
	@for i in $(EXE); do \
          echo -n "$$i "; \
          $(TIME) sh -c "./$$i -c -i $(TESTFILE) -o $(TESTCOMPR) && ./$$i -d -i $(TESTCOMPR) -o /dev/null"; \
         done
	rm -f $(TESTCOMPR)

ccheck:
	@echo "---- arcode"
	@$(CCHECK) -exe arcode $(ARCODE_OBJS:.o=.sdump)
	@echo "---- lzw"
	@$(CCHECK) -exe lzw $(LZW_OBJS:.o=.sdump)
	@echo "---- lzss"
	@$(CCHECK) -exe lzss $(LZSS_OBJS:.o=.sdump)

include .depend

clean:
	rm -f *.o *.light.c *.s *.sdump $(EXE)

depend:
	gcc -MM *.c > .depend