codegen: implement IF_ACMP
[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/Fib | grep mainresult
22         @printf "should be:  0x%08x\n" 0x2ac2
23         ./$< tests/Fac | grep mainresult
24         @printf "should be:  0x%08x\n" 0x63e1a
25         ./$< tests/ArgumentPassing1 | grep mainresult
26         @printf "should be:  0x%08x 0x%08x\n" 0x92 $$(((0 - 0x1337) & 0xffffffff))
27         ./$< tests/DifferentClass1 | grep mainresult
28         @printf "should be:  0x%08x 0x%08x\n" 8 13
29         ./$< tests/Native1 | egrep -i -e '^printsomething: '
30         @printf "should be:  woot 0x%08x 0x%08x woot 0x%08x\n" 0x1337 0x1338 0x15a5
31         ./$< tests/Static1 | grep mainresult
32         @printf "should be:  0x%08x\n" 0x33
33         ./$< tests/Static2 | grep mainresult
34         @printf "should be:  0x%08x\n" 0x55
35         ./$< tests/Static3 | grep mainresult
36         @printf "should be:  0x%08x\n" 0x6dd
37         ./$< tests/Static4 | grep mainresult
38         @printf "should be:  0x%08x 0x%08x\n" 0x33 0x77
39         ./$< tests/Static5 | grep mainresult
40         @printf "should be:  0x%08x 0x%08x\n" 0x33 0x33
41         ./$< tests/Static6 | grep mainresult
42         @printf "should be:  0x%08x\n" 0x33
43         ./$< tests/Static7 | grep mainresult
44         @printf "should be:  0x%08x\n" $$((0x1337 + 0x555))
45         ./$< tests/Static8 | grep mainresult
46         @printf "should be:  0x%08x 0x%08x\n" 0x33 $$((0x1337 + 0x555))
47         ./$< tests/CallConv1 | grep mainresult
48         @printf "should be:  0x%08x\n" 0x1337
49         ./$< tests/CallConv2 | grep mainresult
50         @printf "should be:  0x%08x\n" 0x1337
51         ./$< tests/CallConv3 | grep mainresult
52         @printf "should be:  0x%08x 0x%08x 0x%08x 0x%08x\n" 0x1000 0x300 0x30 0x7
53         ./$< tests/Instance1 | grep mainresult
54         @printf "should be:  0x%08x 0x%08x\n" 0x55 0x11
55         ./$< tests/Instance2 | grep mainresult
56         @printf "should be:  0x%08x 0x%08x\n" 0x198 0x22
57         ./$< tests/Instance3 | grep mainresult
58         @printf "should be:  0x%08x 0x%08x\n" 0x33 0x44
59         ./$< tests/Instance4 | grep mainresult
60         @printf "should be:  0x%08x 0x%08x\n" 0x1337 0x1337
61         ./$< tests/Native2 | grep "printstream"
62         @printf "should be:   0x%08x\n" 0x1337
63         ./$< tests/Native3 | egrep -e "^Hello World"
64         @printf "should be: %s\n" "Hello World"
65         ./$< tests/Strings1 | egrep -c -e "^okay :-\)"
66         @printf "should be: %d\n" 3
67
68 %.class: %.java
69         $(JAVAC) $<
70
71 ffi/native.o: ffi/native.c
72         ghc -Wall -O2 -c $< -o $@
73
74 mate: Mate.hs ffi/trap.c $(HS_FILES) $(HS_BOOT) ffi/native.o
75         ghc --make $(GHC_OPT) Mate.hs ffi/trap.c -o $@ $(GHC_LD)
76
77 clean:
78         rm -f {Mate/,}*.hi {Mate/,ffi/,}*.o Mate/*.{hi,o}-boot mate tests/*.class
79
80 ghci: mate
81         ghci $(PACKAGES) $(O_FILES) Mate.hs $(GHC_LD)
82
83 tags: mate
84         @# @-fforce-recomp, see
85         @# http://stackoverflow.com/questions/7137414/how-do-i-force-interpretation-in-hint
86         ghc -fforce-recomp -e :ctags $(PACKAGES) $(HS_FILES) $(O_FILES) Mate.hs