fields: use offsets from ClassInfo in codegen
[mate.git] / Makefile
1 SHELL := bash
2
3 JAVAC := javac
4 JAVA_FILES := $(wildcard tests/*.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/Instance1 | grep mainresult
52         @printf "should be:  0x%08x 0x%08x\n" 0x55 0x11
53         ./$< tests/Instance2 | grep mainresult
54         @printf "should be:  0x%08x\n" 0x198
55
56 %.class: %.java
57         $(JAVAC) $<
58
59 ffi/native.o: ffi/native.c
60         ghc -Wall -O2 -c $< -o $@
61
62 mate: Mate.hs ffi/trap.c $(HS_FILES) $(HS_BOOT) ffi/native.o
63         ghc --make $(GHC_OPT) Mate.hs ffi/trap.c -o $@ $(GHC_LD)
64
65 clean:
66         rm -f {Mate/,}*.hi {Mate/,ffi/,}*.o Mate/*.{hi,o}-boot mate tests/*.class
67
68 ghci: mate
69         ghci $(PACKAGES) $(O_FILES) Mate.hs $(GHC_LD)
70
71 tags: mate
72         @# @-fforce-recomp, see
73         @# http://stackoverflow.com/questions/7137414/how-do-i-force-interpretation-in-hint
74         ghc -fforce-recomp -e :ctags $(PACKAGES) $(HS_FILES) $(O_FILES) Mate.hs