4 JAVA_FILES := $(wildcard tests/*.java java/lang/*.java java/io/*.java)
5 CLASS_FILES := $(JAVA_FILES:.java=.class)
6 TEST_JAVA_FILES := $(wildcard tests/*.java)
7 TEST_CLASS_FILES := $(TEST_JAVA_FILES:.java=.test)
8 HS_FILES := $(wildcard Mate/*.hs)
9 HS_BOOT := $(wildcard Mate/*.hs-boot)
10 O_FILES = $(shell ls Mate/*.o) $(wildcard ffi/*.o)
11 PACKAGES_ := bytestring harpy hs-java
12 PACKAGES := $(addprefix -package ,$(PACKAGES_))
14 GHC_OPT := -I. -dynamic -Wall -O0 -fno-warn-unused-do-bind
15 GHC_LD := -optl-Xlinker -optl-x
18 .PHONY: all test clean ghci
20 all: mate $(CLASS_FILES)
26 tests: mate $(TEST_CLASS_FILES)
28 CALLF = $(basename $@).call
29 testcase = ./tools/openjdktest.sh "$(1) $(basename $@)"
31 @if [ -f $(CALLF) ]; \
32 then $(call testcase,`cat $(CALLF)`); \
33 else $(call testcase, ); fi
35 COMPILEF = $(basename $@).compile
37 @if [ -f $(COMPILEF) ]; \
38 then $(SHELL) $(COMPILEF); \
42 ffi/native.o: ffi/native.c
43 ghc -Wall -O2 -c $< -o $@
45 mate: Mate.hs ffi/trap.c $(HS_FILES) $(HS_BOOT) ffi/native.o
46 @mkdir -p build/release
47 ghc --make $(GHC_OPT) Mate.hs ffi/trap.c -o $@ $(GHC_LD) -outputdir build/release
49 %.dbg: %.class mate.dbg
50 ./mate.dbg $(basename $<)
53 DEBUGFLAGS = -DDBG_JIT -DDBG_MP
55 DEBUGFLAGS = ${DBGFLAGS}
57 mate.dbg: Mate.hs ffi/trap.c $(HS_FILES) $(HS_BOOT) ffi/native.o
58 @mkdir -p build/debug/{ffi,Mate,}
59 gcc -Wall $(DEBUGFLAGS) -O0 -c ffi/trap.c -o build/debug/ffi/trap.o
60 ghc --make $(DEBUGFLAGS) $(GHC_OPT) Mate.hs build/debug/ffi/trap.o -o $@ $(GHC_LD) -outputdir build/debug
63 rm -rf build mate mate.dbg ffi/native.o tests/*.class Mate/*_stub.*
66 ghci $(PACKAGES) $(O_FILES) Mate.hs $(GHC_LD)
69 @# @-fforce-recomp, see
70 @# http://stackoverflow.com/questions/7137414/how-do-i-force-interpretation-in-hint
71 ghc -fforce-recomp -e :ctags $(PACKAGES) $(HS_FILES) $(O_FILES) Mate.hs
74 @# hlint isn't able to evaluate CPP comments correctly *sigh*
75 @cp debug.h debug_tmp.h
76 @# so we remove them "by hand", for hlint
77 @gcc -E -x c -fpreprocessed -dD -E debug_tmp.h | grep -v 'debug_tmp.h' > debug.h
78 @# ignore error code from hlint
80 @mv debug_tmp.h debug.h