methodpool: also call native methods
[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 O_FILES = $(shell ls Mate/*.o) $(wildcard ffi/*.o)
8 PACKAGES_ := bytestring harpy hs-java
9 PACKAGES := $(addprefix -package ,$(PACKAGES_))
10
11 GHC_OPT := -dynamic -Wall -O0 -fno-warn-unused-do-bind
12 GHC_LD := -optl-Xlinker -optl-x
13
14
15 .PHONY: all test clean ghci
16
17 all: mate $(CLASS_FILES)
18
19 test: mate $(CLASS_FILES)
20         ./$< tests/Fib.class | grep mainresult
21         @printf "should be:  0x%08x\n" 0x09de8d6d
22         ./$< tests/Fac.class | grep mainresult
23         @printf "should be:  0x%08x\n" 0x58980
24         ./$< tests/ArgumentPassing1.class | grep mainresult
25         @printf "should be:  0x%08x\n" 0x92
26         @printf "should be:  0x%08x\n" $$(((0 - 0x1337) & 0xffffffff))
27         ./$< tests/DifferentClass1.class | grep mainresult
28         @printf "should be:  0x%08x\n" 8
29         @printf "should be:  0x%08x\n" 13
30         ./$< tests/Native1.class | egrep -i -e '^printsomething: '
31
32 %.class: %.java
33         $(JAVAC) $<
34
35 ffi/native.o: ffi/native.c
36         ghc -Wall -O2 -c $< -o $@
37
38 mate: Mate.hs ffi/trap.c $(HS_FILES) ffi/native.o
39         ghc --make $(GHC_OPT) Mate.hs ffi/trap.c -o $@ $(GHC_LD)
40
41 clean:
42         rm -f {Mate/,}*.hi {Mate/,ffi/,}*.o mate tests/*.class
43
44 ghci: mate
45         ghci $(PACKAGES) $(O_FILES) Mate.hs $(GHC_LD)
46
47 tags: mate
48         @# @-fforce-recomp, see
49         @# http://stackoverflow.com/questions/7137414/how-do-i-force-interpretation-in-hint
50         ghc -fforce-recomp -e :ctags $(PACKAGES) $(HS_FILES) $(O_FILES) Mate.hs