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_))
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
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 ./$< tests/Array1 | grep "printstream"
68 @printf "should be: 0x%08x 0x%08x\n" 0x264 0x8
69 ./$< tests/Integer1 | grep mainresult
70 @printf "should be: 0x%08x\n" 0x1337
71 ./$< tests/VarArgs1 | grep mainresult
76 ffi/native.o: ffi/native.c
77 ghc -Wall -O2 -c $< -o $@
79 mate: Mate.hs ffi/trap.c $(HS_FILES) $(HS_BOOT) ffi/native.o
80 ghc --make $(GHC_OPT) Mate.hs ffi/trap.c -o $@ $(GHC_LD)
83 rm -f {Mate/,}*.hi {Mate/,ffi/,}*.o Mate/*.{hi,o}-boot mate tests/*.class
86 ghci $(PACKAGES) $(O_FILES) Mate.hs $(GHC_LD)
89 @# @-fforce-recomp, see
90 @# http://stackoverflow.com/questions/7137414/how-do-i-force-interpretation-in-hint
91 ghc -fforce-recomp -e :ctags $(PACKAGES) $(HS_FILES) $(O_FILES) Mate.hs