static methods: add inheritance capability
[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 | grep mainresult
21         @printf "should be:  0x%08x\n" 0x2ac2
22         ./$< tests/Fac | grep mainresult
23         @printf "should be:  0x%08x\n" 0x63e1a
24         ./$< tests/ArgumentPassing1 | grep mainresult
25         @printf "should be:  0x%08x 0x%08x\n" 0x92 $$(((0 - 0x1337) & 0xffffffff))
26         ./$< tests/DifferentClass1 | grep mainresult
27         @printf "should be:  0x%08x 0x%08x\n" 8 13
28         ./$< tests/Native1 | egrep -i -e '^printsomething: '
29         @printf "should be:  woot 0x%08x 0x%08x woot 0x%08x\n" 0x1337 0x1338 0x15a5
30         ./$< tests/Static1 | grep mainresult
31         @printf "should be:  0x%08x\n" 0x33
32         ./$< tests/Static2 | grep mainresult
33         @printf "should be:  0x%08x\n" 0x55
34         ./$< tests/Static3 | grep mainresult
35         @printf "should be:  0x%08x\n" 0x6dd
36         ./$< tests/Static4 | grep mainresult
37         @printf "should be:  0x%08x 0x%08x\n" 0x33 0x77
38         ./$< tests/Static5 | grep mainresult
39         @printf "should be:  0x%08x 0x%08x\n" 0x33 0x33
40         ./$< tests/CallConv1 | grep mainresult
41         @printf "should be:  0x%08x\n" 0x1337
42         ./$< tests/CallConv2 | grep mainresult
43         @printf "should be:  0x%08x\n" 0x1337
44
45 %.class: %.java
46         $(JAVAC) $<
47
48 ffi/native.o: ffi/native.c
49         ghc -Wall -O2 -c $< -o $@
50
51 mate: Mate.hs ffi/trap.c $(HS_FILES) ffi/native.o
52         ghc --make $(GHC_OPT) Mate.hs ffi/trap.c -o $@ $(GHC_LD)
53
54 clean:
55         rm -f {Mate/,}*.hi {Mate/,ffi/,}*.o mate tests/*.class
56
57 ghci: mate
58         ghci $(PACKAGES) $(O_FILES) Mate.hs $(GHC_LD)
59
60 tags: mate
61         @# @-fforce-recomp, see
62         @# http://stackoverflow.com/questions/7137414/how-do-i-force-interpretation-in-hint
63         ghc -fforce-recomp -e :ctags $(PACKAGES) $(HS_FILES) $(O_FILES) Mate.hs