tests: don't use `pop' hack anymore, but System.out.printf \o/
[mate.git] / Makefile
1 SHELL := bash
2
3 JAVAC := javac
4 JAVA_FILES := $(wildcard tests/*.java java/lang/*.java java/io/*.java)
5 CLASS_FILES := $(JAVA_FILES:.java=.class)
6 HS_FILES := $(wildcard Mate/*.hs)
7 HS_BOOT := $(wildcard Mate/*.hs-boot)
8 O_FILES = $(shell ls Mate/*.o) $(wildcard ffi/*.o)
9 PACKAGES_ := bytestring harpy hs-java
10 PACKAGES := $(addprefix -package ,$(PACKAGES_))
11
12 GHC_OPT := -dynamic -Wall -O0 -fno-warn-unused-do-bind
13 GHC_LD := -optl-Xlinker -optl-x
14
15
16 .PHONY: all test clean ghci
17
18 all: mate $(CLASS_FILES)
19
20 test: mate $(CLASS_FILES)
21         ./$< tests/While | grep -e "^result"
22         @printf "should be:  0x%08x 0x%08x\n" 0x19 0x19
23         ./$< tests/Fib | grep -e "^result"
24         @printf "should be:  0x%08x\n" 0x2ac2
25         ./$< tests/Fac | grep -e "^result"
26         @printf "should be:  0x%08x\n" 0x63e1a
27         ./$< tests/ArgumentPassing1 | grep -e "^result"
28         @printf "should be:  0x%08x 0x%08x\n" 0x92 $$(((0 - 0x1337) & 0xffffffff))
29         ./$< tests/DifferentClass1 | grep -e "^result"
30         @printf "should be:  0x%08x 0x%08x\n" 8 13
31         ./$< tests/Static1 | grep -e "^result"
32         @printf "should be:  0x%08x\n" 0x33
33         ./$< tests/Static2 | grep -e "^result"
34         @printf "should be:  0x%08x\n" 0x55
35         ./$< tests/Static3 | grep -e "^result"
36         @printf "should be:  0x%08x\n" 0x6dd
37         ./$< tests/Static4 | grep -e "^result"
38         @printf "should be:  0x%08x 0x%08x\n" 0x33 0x77
39         ./$< tests/Static5 | grep -e "^result"
40         @printf "should be:  0x%08x 0x%08x\n" 0x33 0x33
41         ./$< tests/Static6 | grep -e "^result"
42         @printf "should be:  0x%08x\n" 0x33
43         ./$< tests/Static7 | grep -e "^result"
44         @printf "should be:  0x%08x\n" $$((0x1337 + 0x555))
45         ./$< tests/Static8 | grep -e "^result"
46         @printf "should be:  0x%08x 0x%08x\n" 0x33 $$((0x1337 + 0x555))
47         ./$< tests/CallConv1 | grep -e "^result"
48         @printf "should be:  0x%08x\n" 0x1337
49         ./$< tests/CallConv2 | grep -e "^result"
50         @printf "should be:  0x%08x\n" 0x1337
51         ./$< tests/CallConv3 | grep -e "^result"
52         @printf "should be:  0x%08x 0x%08x 0x%08x 0x%08x\n" 0x1000 0x300 0x30 0x7
53         ./$< tests/Instance1 | grep -e "^result"
54         @printf "should be:  0x%08x 0x%08x\n" 0x55 0x11
55         ./$< tests/Instance2 | grep -e "^result"
56         @printf "should be:  0x%08x 0x%08x\n" 0x198 0x22
57         ./$< tests/Instance3 | grep -e "^result"
58         @printf "should be:  0x%08x 0x%08x\n" 0x33 0x44
59         ./$< tests/Native2 | grep -e "^result"
60         @printf "should be:   0x%08x\n" 0x1337
61         ./$< tests/Native3 | egrep -e "^result"
62         @printf "should be: %s\n" "Hello World"
63         ./$< tests/Strings1 | egrep -c -e "^result"
64         @printf "should be: %d\n" 3
65         ./$< tests/Array1 | grep -e "^result"
66         @printf "should be:   0x%08x 0x%08x\n" 0x264 0x8
67         ./$< tests/Integer1 | grep -e "^result"
68         @printf "should be:  0x%08x\n" 0x1337
69         ./$< tests/VarArgs1 | grep -e "^result"
70
71 %.class: %.java
72         $(JAVAC) $<
73
74 ffi/native.o: ffi/native.c
75         ghc -Wall -O2 -c $< -o $@
76
77 mate: Mate.hs ffi/trap.c $(HS_FILES) $(HS_BOOT) ffi/native.o
78         ghc --make $(GHC_OPT) Mate.hs ffi/trap.c -o $@ $(GHC_LD)
79
80 clean:
81         rm -f {Mate/,}*.hi {Mate/,ffi/,}*.o Mate/*.{hi,o}-boot mate tests/*.class
82
83 ghci: mate
84         ghci $(PACKAGES) $(O_FILES) Mate.hs $(GHC_LD)
85
86 tags: mate
87         @# @-fforce-recomp, see
88         @# http://stackoverflow.com/questions/7137414/how-do-i-force-interpretation-in-hint
89         ghc -fforce-recomp -e :ctags $(PACKAGES) $(HS_FILES) $(O_FILES) Mate.hs