-
Notifications
You must be signed in to change notification settings - Fork 29
/
Copy pathMakefile
124 lines (99 loc) · 2.93 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
# Indicates to sub-Makefiles that it was invoked by this one.
export TOP_LEVEL_MAKEFILE_INVOKED := true
# Platform-specific flags; these defaults can be overriden in defs.<platform> files,
# where <platform> is the result of `uname` in bash.
export SHARED_LIB_EXT := so
# Submodules.
POLYGLOT := lib/polyglot/
JAVACPP_PRESETS := lib/javacpp-presets/
SUBMODULES := $(addsuffix .git,$(POLYGLOT) $(JAVACPP_PRESETS))
# JLang
export PLC := $(realpath bin/jlangc)
# Hack to allow dependency on PolyLLVM source.
export PLC_SRC := $(realpath $(shell find compiler/src -name "*.java"))
# System JDK.
ifndef JDK7
$(error Please point the JDK7 environment variable to your system JDK 7)
endif
export JDK7 := $(realpath $(JDK7))
export JAVAC := $(JDK7)/bin/javac
export JNI_INCLUDES := \
-I"$(JDK7)/include" \
-I"$(JDK7)/include/darwin" \
-I"$(JDK7)/include/linux"
export JDK7_LIB_PATH := $(JDK7)/jre/lib
JDK ?= jdk
export JDK := $(realpath $(JDK))
export JDK_CLASSES := $(JDK)/out/classes
# Runtime.
export RUNTIME := $(realpath runtime)
export RUNTIME_CLASSES := $(RUNTIME)/out/classes
# Clang.
ifndef CLANG_VERSION
export CLANG_VERSION :=
else
export CLANG_VERSION := -$(CLANG_VERSION)
endif
export CLANG := clang++$(CLANG_VERSION)
export LLC := llc$(CLANG_VERSION)
export SHARED_LIB_FLAGS := -g -lgc -shared -rdynamic
# JDK lib.
export LIBJDK = $(JDK)/out/libjdk.$(SHARED_LIB_EXT)
export LIBJDK_FLAGS = $(SHARED_LIB_FLAGS) -Wl,-rpath,$(RUNTIME)/out
# Runtime lib.
export LIBJVM = $(RUNTIME)/out/libjvm.$(SHARED_LIB_EXT)
export LIBJVM_FLAGS = $(SHARED_LIB_FLAGS)
# Test Dir.
export TESTDIR := $(realpath tests/isolated)
# Example Application Dir.
export EXAMPLEDIR := $(realpath examples)
# Platform-specific overrides.
sinclude defs.$(shell uname)
all: setup compiler runtime jdk
setup:
@echo "--- Checking setup ---"
@./bin/check-setup.sh
# Compiler.
compiler: polyglot
@echo "--- Building compiler ---"
@ant -S
@echo
runtime: compiler jdk-classes
@echo "--- Building runtime ---"
@$(MAKE) -C $(RUNTIME)
@echo
jdk-classes:
@echo "--- Building $(notdir $(JDK)) classes ---"
@$(MAKE) -C $(JDK) classes
@echo
jdk: compiler runtime
@echo "--- Building $(notdir $(JDK)) ---"
@$(MAKE) -C $(JDK)
@echo
polyglot: | $(SUBMODULES)
@echo "--- Building Polyglot ---"
@cd $(POLYGLOT); ant -S jar
@echo
$(SUBMODULES):
git submodule update --init
tests: setup compiler runtime jdk
@echo "--- Running Test Suite ---"
@$(MAKE) -s -C $(TESTDIR)
@echo
cup: setup compiler runtime jdk
@echo "--- Building the CUP Parser Generator ---"
@$(MAKE) -s -C $(EXAMPLEDIR)/cup
@echo
clean:
@echo "Cleaning compiler, runtime, and jdk"
@ant -q -S clean
@$(MAKE) -s -C $(RUNTIME) clean
@$(MAKE) -s -C $(JDK) clean
@$(MAKE) -s -C $(TESTDIR) clean
@$(MAKE) -s -C $(EXAMPLEDIR)/cup clean
clean-test:
@echo "Cleaning compiler, runtime, and tests"
@ant -q -S clean
@$(MAKE) -s -C $(RUNTIME) clean
@$(MAKE) -s -C $(TESTDIR) clean
.PHONY: compiler runtime jdk-classes jdk clean-test