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_))
12 GHC_OPT := -dynamic -Wall -O0 -fno-warn-unused-do-bind
13 GHC_LD := -optl-Xlinker -optl-x
16 .PHONY: all test clean ghci
18 all: mate $(CLASS_FILES)
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
55 ffi/native.o: ffi/native.c
56 ghc -Wall -O2 -c $< -o $@
58 mate: Mate.hs ffi/trap.c $(HS_FILES) $(HS_BOOT) ffi/native.o
59 ghc --make $(GHC_OPT) Mate.hs ffi/trap.c -o $@ $(GHC_LD)
62 rm -f {Mate/,}*.hi {Mate/,ffi/,}*.o Mate/*.{hi,o}-boot mate tests/*.class
65 ghci $(PACKAGES) $(O_FILES) Mate.hs $(GHC_LD)
68 @# @-fforce-recomp, see
69 @# http://stackoverflow.com/questions/7137414/how-do-i-force-interpretation-in-hint
70 ghc -fforce-recomp -e :ctags $(PACKAGES) $(HS_FILES) $(O_FILES) Mate.hs