types: remove dirty Ord instance of MethodSignature
[mate.git] / Makefile
1 SHELL := bash
2
3 JAVAC := javac
4 JAVA_FILES := $(wildcard 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_))
13
14 GHC_OPT := -I. -dynamic -Wall -O0 -fno-warn-unused-do-bind
15 GHC_LD := -optl-Xlinker -optl-x
16
17
18 .PHONY: all test clean ghci
19
20 all: mate
21
22 %: %.class mate
23         ./mate $(basename $<)
24
25
26 tests: mate $(TEST_JAVA_FILES:.java=.class) $(TEST_CLASS_FILES)
27
28 CALLF = $(basename $@).call
29 testcase = ./tools/openjdktest.sh "$(1) $(basename $@)"
30 %.test: %.class mate
31         @if [ -f $(CALLF) ]; \
32                 then $(call testcase,`cat $(CALLF)`); \
33                 else $(call testcase, ); fi
34
35 COMPILEF = $(basename $@).compile
36 %.class: %.java
37         @if [ -f $(COMPILEF) ]; \
38                 then $(SHELL) $(COMPILEF); \
39                 else $(JAVAC) $<; fi
40         @echo "JAVAC $<"
41
42 ffi/native.o: ffi/native.c
43         ghc -Wall -O2 -c $< -o $@
44
45 mate: Mate.hs ffi/trap.c $(HS_FILES) $(HS_BOOT) ffi/native.o $(CLASS_FILES)
46         @mkdir -p build/release
47         ghc --make $(GHC_OPT) Mate.hs ffi/trap.c -o $@ $(GHC_LD) -outputdir build/release
48
49 %.dbg: %.class mate.dbg
50         ./mate.dbg $(basename $<)
51
52 ifeq (${DBGFLAGS},)
53 DEBUGFLAGS = -DDBG_JIT -DDBG_MP
54 else
55 DEBUGFLAGS = ${DBGFLAGS}
56 endif
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
61
62 clean:
63         rm -rf build mate mate.dbg ffi/native.o tests/*.class Mate/*_stub.*
64
65 ghci: mate
66         ghci $(PACKAGES) $(O_FILES) Mate.hs $(GHC_LD)
67
68 tags: mate
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
72
73 hlint:
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
79         -hlint Mate.hs Mate/
80         @mv debug_tmp.h debug.h