2007-06-03 23:16:07 +00:00
|
|
|
#MAKEFLAGS = -s
|
|
|
|
|
2007-06-29 16:43:25 +00:00
|
|
|
arch = $(shell uname -m)
|
|
|
|
ifeq ($(arch),i586)
|
|
|
|
arch = i386
|
|
|
|
endif
|
|
|
|
ifeq ($(arch),i686)
|
|
|
|
arch = i386
|
|
|
|
endif
|
2007-06-29 16:42:39 +00:00
|
|
|
|
|
|
|
bld = build/$(arch)
|
2007-06-03 23:16:07 +00:00
|
|
|
src = src
|
2007-06-25 01:34:07 +00:00
|
|
|
classpath = classpath
|
2007-06-03 23:16:07 +00:00
|
|
|
|
|
|
|
cxx = g++
|
|
|
|
cc = gcc
|
|
|
|
vg = nice valgrind --leak-check=full --num-callers=32 --db-attach=yes \
|
|
|
|
--freelist-vol=100000000
|
2007-06-21 01:38:02 +00:00
|
|
|
javac = javac
|
2007-06-03 23:16:07 +00:00
|
|
|
|
|
|
|
warnings = -Wall -Wextra -Werror -Wold-style-cast -Wunused-parameter \
|
|
|
|
-Winit-self -Wconversion
|
|
|
|
|
|
|
|
slow = -O0 -g3
|
|
|
|
fast = -Os -DNDEBUG
|
|
|
|
|
|
|
|
#thread-cflags = -DNO_THREADS
|
|
|
|
thread-cflags = -pthread
|
|
|
|
thread-lflags = -lpthread
|
|
|
|
|
|
|
|
cflags = $(warnings) -fPIC -fno-rtti -fno-exceptions -fvisibility=hidden \
|
|
|
|
-I$(src) -I$(bld) $(thread-cflags)
|
2007-06-25 01:34:07 +00:00
|
|
|
lflags = $(thread-lflags) -ldl
|
2007-06-03 23:16:07 +00:00
|
|
|
test-cflags = -DDEBUG_MEMORY
|
|
|
|
stress-cflags = -DDEBUG_MEMORY -DDEBUG_MEMORY_MAJOR
|
|
|
|
|
|
|
|
cpp-objects = $(foreach x,$(1),$(patsubst $(2)/%.cpp,$(bld)/%.o,$(x)))
|
2007-06-29 17:45:14 +00:00
|
|
|
asm-objects = $(foreach x,$(1),$(patsubst $(2)/%.S,$(bld)/%.o,$(x)))
|
2007-06-30 02:38:16 +00:00
|
|
|
java-classes = \
|
|
|
|
$(foreach x,$(1),$(patsubst $(2)/%.java,$(bld)/classes/%.class,$(x)))
|
2007-06-03 23:16:07 +00:00
|
|
|
|
|
|
|
stdcpp-sources = $(src)/stdc++.cpp
|
|
|
|
stdcpp-objects = $(call cpp-objects,$(stdcpp-sources),$(src))
|
|
|
|
stdcpp-cflags = $(fast) $(cflags)
|
|
|
|
|
2007-06-25 01:34:07 +00:00
|
|
|
jni-sources = $(classpath)/java/lang/System.cpp
|
|
|
|
jni-objects = $(call cpp-objects,$(jni-sources),$(classpath))
|
2007-06-29 16:42:39 +00:00
|
|
|
jni-cflags = -I$(JAVA_HOME)/include -I$(JAVA_HOME)/include/linux \
|
|
|
|
$(slow) $(cflags)
|
2007-06-25 01:34:07 +00:00
|
|
|
jni-library = $(bld)/libnatives.so
|
|
|
|
|
2007-06-18 19:23:44 +00:00
|
|
|
generated-code = \
|
2007-06-18 21:13:21 +00:00
|
|
|
$(bld)/type-enums.cpp \
|
2007-06-18 19:23:44 +00:00
|
|
|
$(bld)/type-declarations.cpp \
|
|
|
|
$(bld)/type-constructors.cpp \
|
2007-06-24 19:57:00 +00:00
|
|
|
$(bld)/type-initializations.cpp \
|
|
|
|
$(bld)/type-java-initializations.cpp
|
2007-06-18 19:23:44 +00:00
|
|
|
interpreter-depends = \
|
|
|
|
$(generated-code) \
|
2007-06-18 21:13:21 +00:00
|
|
|
$(src)/common.h \
|
|
|
|
$(src)/system.h \
|
2007-06-04 23:39:59 +00:00
|
|
|
$(src)/heap.h \
|
2007-06-25 02:02:24 +00:00
|
|
|
$(src)/class-finder.h \
|
2007-06-18 21:13:21 +00:00
|
|
|
$(src)/stream.h \
|
|
|
|
$(src)/constants.h \
|
|
|
|
$(src)/vm.h
|
2007-06-03 23:16:07 +00:00
|
|
|
interpreter-sources = \
|
2007-06-20 16:58:35 +00:00
|
|
|
$(src)/vm.cpp \
|
2007-06-20 19:20:25 +00:00
|
|
|
$(src)/heap.cpp \
|
|
|
|
$(src)/main.cpp
|
2007-06-29 02:58:48 +00:00
|
|
|
|
|
|
|
ifeq ($(arch),i386)
|
2007-06-29 17:45:14 +00:00
|
|
|
interpreter-asm-sources = $(src)/cdecl.S
|
2007-06-29 02:58:48 +00:00
|
|
|
endif
|
|
|
|
ifeq ($(arch),x86_64)
|
2007-06-29 17:45:14 +00:00
|
|
|
interpreter-asm-sources = $(src)/amd64.S
|
2007-06-29 02:58:48 +00:00
|
|
|
endif
|
|
|
|
|
|
|
|
interpreter-cpp-objects = \
|
|
|
|
$(call cpp-objects,$(interpreter-sources),$(src))
|
2007-06-29 17:45:14 +00:00
|
|
|
interpreter-asm-objects = \
|
|
|
|
$(call asm-objects,$(interpreter-asm-sources),$(src))
|
2007-06-29 02:58:48 +00:00
|
|
|
interpreter-objects = \
|
|
|
|
$(interpreter-cpp-objects) \
|
2007-06-29 17:45:14 +00:00
|
|
|
$(interpreter-asm-objects)
|
2007-06-03 23:16:07 +00:00
|
|
|
interpreter-cflags = $(slow) $(cflags)
|
|
|
|
|
2007-06-04 23:39:59 +00:00
|
|
|
generator-headers = \
|
|
|
|
$(src)/input.h \
|
|
|
|
$(src)/output.h
|
2007-06-03 23:16:07 +00:00
|
|
|
generator-sources = \
|
|
|
|
$(src)/type-generator.cpp
|
|
|
|
generator-objects = $(call cpp-objects,$(generator-sources),$(src))
|
|
|
|
generator-executable = $(bld)/generator
|
|
|
|
generator-cflags = $(slow) $(cflags)
|
|
|
|
|
|
|
|
executable = $(bld)/vm
|
|
|
|
|
2007-06-29 17:45:14 +00:00
|
|
|
test-cpp-objects = \
|
|
|
|
$(patsubst $(bld)/%,$(bld)/test-%,$(interpreter-cpp-objects))
|
|
|
|
test-asm-objects = \
|
|
|
|
$(patsubst $(bld)/%,$(bld)/test-%,$(interpreter-asm-objects))
|
|
|
|
test-objects = \
|
|
|
|
$(test-cpp-objects) \
|
|
|
|
$(test-asm-objects)
|
2007-06-03 23:16:07 +00:00
|
|
|
test-executable = $(bld)/test-vm
|
|
|
|
|
2007-06-29 17:45:14 +00:00
|
|
|
stress-cpp-objects = \
|
|
|
|
$(patsubst $(bld)/%,$(bld)/stress-%,$(interpreter-cpp-objects))
|
|
|
|
stress-asm-objects = \
|
|
|
|
$(patsubst $(bld)/%,$(bld)/stress-%,$(interpreter-asm-objects))
|
|
|
|
stress-objects = \
|
|
|
|
$(stress-cpp-objects) \
|
|
|
|
$(stress-asm-objects)
|
2007-06-03 23:16:07 +00:00
|
|
|
stress-executable = $(bld)/stress-vm
|
|
|
|
|
2007-06-29 17:45:14 +00:00
|
|
|
fast-cpp-objects = \
|
|
|
|
$(patsubst $(bld)/%,$(bld)/fast-%,$(interpreter-cpp-objects))
|
|
|
|
fast-asm-objects = \
|
|
|
|
$(patsubst $(bld)/%,$(bld)/fast-%,$(interpreter-asm-objects))
|
|
|
|
fast-objects = \
|
|
|
|
$(fast-cpp-objects) \
|
|
|
|
$(fast-asm-objects)
|
2007-06-03 23:16:07 +00:00
|
|
|
fast-executable = $(bld)/fast-vm
|
|
|
|
fast-cflags = $(fast) $(cflags)
|
|
|
|
|
2007-06-30 02:38:16 +00:00
|
|
|
classpath-sources = $(shell find $(classpath)/java -name '*.java')
|
2007-06-30 02:39:01 +00:00
|
|
|
classpath-classes = $(call java-classes,$(classpath-sources),$(classpath))
|
|
|
|
|
2007-07-04 18:15:03 +00:00
|
|
|
input = $(bld)/classes/Hello.class
|
2007-06-30 02:39:01 +00:00
|
|
|
input-depends = \
|
2007-06-30 02:38:16 +00:00
|
|
|
$(classpath-classes) \
|
2007-06-30 02:39:01 +00:00
|
|
|
$(jni-library)
|
2007-06-21 01:38:02 +00:00
|
|
|
|
|
|
|
gen-run-arg = $(shell echo $(1) | sed -e 's:$(bld)/classes/\(.*\)\.class:\1:')
|
2007-06-22 22:47:57 +00:00
|
|
|
args = -cp $(bld)/classes -hs 67108864 $(call gen-run-arg,$(input))
|
2007-06-21 01:38:02 +00:00
|
|
|
|
2007-06-03 23:16:07 +00:00
|
|
|
.PHONY: build
|
|
|
|
build: $(executable)
|
|
|
|
|
2007-06-21 01:38:02 +00:00
|
|
|
$(input): $(input-depends)
|
|
|
|
|
2007-06-03 23:16:07 +00:00
|
|
|
.PHONY: run
|
2007-06-21 01:38:02 +00:00
|
|
|
run: $(executable) $(input)
|
2007-06-29 14:52:03 +00:00
|
|
|
LD_LIBRARY_PATH=$(bld) $(<) $(args)
|
2007-06-03 23:16:07 +00:00
|
|
|
|
|
|
|
.PHONY: debug
|
2007-06-21 01:38:02 +00:00
|
|
|
debug: $(executable) $(input)
|
2007-06-29 14:52:03 +00:00
|
|
|
LD_LIBRARY_PATH=$(bld) gdb --args $(<) $(args)
|
2007-06-03 23:16:07 +00:00
|
|
|
|
|
|
|
.PHONY: fast
|
|
|
|
fast: $(fast-executable)
|
|
|
|
ls -lh $(<)
|
|
|
|
|
|
|
|
.PHONY: vg
|
2007-06-21 01:38:02 +00:00
|
|
|
vg: $(executable) $(input)
|
2007-06-29 14:52:03 +00:00
|
|
|
LD_LIBRARY_PATH=$(bld) $(vg) $(<) $(args)
|
2007-06-03 23:16:07 +00:00
|
|
|
|
|
|
|
.PHONY: test
|
2007-06-21 01:38:02 +00:00
|
|
|
test: $(test-executable) $(input)
|
2007-06-29 14:52:03 +00:00
|
|
|
LD_LIBRARY_PATH=$(bld) $(vg) $(<) $(args)
|
2007-06-03 23:16:07 +00:00
|
|
|
|
|
|
|
.PHONY: stress
|
2007-06-21 01:38:02 +00:00
|
|
|
stress: $(stress-executable) $(input)
|
2007-06-29 14:52:03 +00:00
|
|
|
LD_LIBRARY_PATH=$(bld) $(vg) $(<) $(args)
|
2007-06-03 23:16:07 +00:00
|
|
|
|
|
|
|
.PHONY: run-all
|
|
|
|
run-all: $(executable)
|
|
|
|
set -e; for x in $(all-input); do echo "$$x:"; $(<) $$x; echo; done
|
|
|
|
|
|
|
|
.PHONY: vg-all
|
|
|
|
vg-all: $(executable)
|
|
|
|
set -e; for x in $(all-input); do echo "$$x:"; $(vg) -q $(<) $$x; done
|
|
|
|
|
|
|
|
.PHONY: test-all
|
|
|
|
test-all: $(test-executable)
|
|
|
|
set -e; for x in $(all-input); do echo "$$x:"; $(vg) -q $(<) $$x; done
|
|
|
|
|
|
|
|
.PHONY: stress-all
|
|
|
|
stress-all: $(stress-executable)
|
|
|
|
set -e; for x in $(all-input); do echo "$$x:"; $(vg) -q $(<) $$x; done
|
|
|
|
|
|
|
|
.PHONY: clean
|
|
|
|
clean:
|
2007-06-29 16:42:39 +00:00
|
|
|
@echo "removing build"
|
|
|
|
rm -rf build
|
2007-06-03 23:16:07 +00:00
|
|
|
|
2007-06-18 19:23:44 +00:00
|
|
|
gen-arg = $(shell echo $(1) | sed -e 's:$(bld)/type-\(.*\)\.cpp:\1:')
|
|
|
|
$(generated-code): %.cpp: $(src)/types.def $(generator-executable)
|
2007-06-03 23:16:07 +00:00
|
|
|
@echo "generating $(@)"
|
|
|
|
$(generator-executable) $(call gen-arg,$(@)) < $(<) > $(@)
|
|
|
|
|
2007-06-04 23:39:59 +00:00
|
|
|
$(bld)/type-generator.o: \
|
|
|
|
$(generator-headers)
|
2007-06-03 23:16:07 +00:00
|
|
|
|
2007-06-25 01:34:07 +00:00
|
|
|
$(bld)/classes/%.class: $(classpath)/%.java
|
2007-06-21 01:38:02 +00:00
|
|
|
@echo "compiling $(@)"
|
|
|
|
@mkdir -p $(dir $(@))
|
2007-06-25 01:34:07 +00:00
|
|
|
$(javac) -bootclasspath $(classpath) -classpath $(classpath) \
|
|
|
|
-d $(bld)/classes $(<)
|
2007-06-21 01:38:02 +00:00
|
|
|
|
2007-06-03 23:16:07 +00:00
|
|
|
$(stdcpp-objects): $(bld)/%.o: $(src)/%.cpp
|
|
|
|
@echo "compiling $(@)"
|
|
|
|
@mkdir -p $(dir $(@))
|
|
|
|
$(cxx) $(stdcpp-cflags) -c $(<) -o $(@)
|
|
|
|
|
2007-06-29 02:58:48 +00:00
|
|
|
$(interpreter-cpp-objects): $(bld)/%.o: $(src)/%.cpp $(interpreter-depends)
|
|
|
|
@echo "compiling $(@)"
|
|
|
|
@mkdir -p $(dir $(@))
|
|
|
|
$(cxx) $(interpreter-cflags) -c $(<) -o $(@)
|
|
|
|
|
2007-06-29 17:45:14 +00:00
|
|
|
$(interpreter-asm-objects): $(bld)/%.o: $(src)/%.S
|
2007-06-03 23:16:07 +00:00
|
|
|
@echo "compiling $(@)"
|
|
|
|
@mkdir -p $(dir $(@))
|
|
|
|
$(cxx) $(interpreter-cflags) -c $(<) -o $(@)
|
|
|
|
|
2007-06-29 17:45:14 +00:00
|
|
|
$(test-cpp-objects): $(bld)/test-%.o: $(src)/%.cpp $(interpreter-depends)
|
2007-06-03 23:16:07 +00:00
|
|
|
@echo "compiling $(@)"
|
|
|
|
@mkdir -p $(dir $(@))
|
|
|
|
$(cxx) $(interpreter-cflags) $(test-cflags) -c $(<) -o $(@)
|
|
|
|
|
2007-06-29 17:45:14 +00:00
|
|
|
$(test-asm-objects): $(bld)/test-%.o: $(src)/%.S
|
|
|
|
@echo "compiling $(@)"
|
|
|
|
@mkdir -p $(dir $(@))
|
|
|
|
$(cxx) $(interpreter-cflags) $(test-cflags) -c $(<) -o $(@)
|
|
|
|
|
|
|
|
$(stress-cpp-objects): $(bld)/stress-%.o: $(src)/%.cpp $(interpreter-depends)
|
|
|
|
@echo "compiling $(@)"
|
|
|
|
@mkdir -p $(dir $(@))
|
|
|
|
$(cxx) $(interpreter-cflags) $(stress-cflags) -c $(<) -o $(@)
|
|
|
|
|
|
|
|
$(stress-asm-objects): $(bld)/stress-%.o: $(src)/%.S
|
2007-06-03 23:16:07 +00:00
|
|
|
@echo "compiling $(@)"
|
|
|
|
@mkdir -p $(dir $(@))
|
|
|
|
$(cxx) $(interpreter-cflags) $(stress-cflags) -c $(<) -o $(@)
|
|
|
|
|
|
|
|
$(generator-objects): $(bld)/%.o: $(src)/%.cpp
|
|
|
|
@echo "compiling $(@)"
|
|
|
|
@mkdir -p $(dir $(@))
|
|
|
|
$(cxx) $(generator-cflags) -c $(<) -o $(@)
|
|
|
|
|
2007-06-29 17:45:14 +00:00
|
|
|
$(fast-cpp-objects): $(bld)/fast-%.o: $(src)/%.cpp $(interpreter-depends)
|
|
|
|
@echo "compiling $(@)"
|
|
|
|
@mkdir -p $(dir $(@))
|
|
|
|
$(cxx) $(fast-cflags) -c $(<) -o $(@)
|
|
|
|
|
|
|
|
$(fast-asm-objects): $(bld)/fast-%.o: $(src)/%.S
|
2007-06-03 23:16:07 +00:00
|
|
|
@echo "compiling $(@)"
|
|
|
|
@mkdir -p $(dir $(@))
|
|
|
|
$(cxx) $(fast-cflags) -c $(<) -o $(@)
|
|
|
|
|
2007-06-25 01:34:07 +00:00
|
|
|
$(jni-objects): $(bld)/%.o: $(classpath)/%.cpp
|
|
|
|
@echo "compiling $(@)"
|
|
|
|
@mkdir -p $(dir $(@))
|
|
|
|
$(cxx) $(jni-cflags) -c $(<) -o $(@)
|
|
|
|
|
|
|
|
$(jni-library): $(jni-objects)
|
|
|
|
@echo "linking $(@)"
|
|
|
|
$(cc) $(lflags) -shared $(^) -o $(@)
|
|
|
|
|
2007-06-03 23:16:07 +00:00
|
|
|
$(executable): $(interpreter-objects) $(stdcpp-objects)
|
|
|
|
@echo "linking $(@)"
|
|
|
|
$(cc) $(lflags) $(^) -o $(@)
|
|
|
|
|
|
|
|
$(test-executable): $(test-objects) $(stdcpp-objects)
|
|
|
|
@echo "linking $(@)"
|
|
|
|
$(cc) $(lflags) $(^) -o $(@)
|
|
|
|
|
|
|
|
$(stress-executable): $(stress-objects) $(stdcpp-objects)
|
|
|
|
@echo "linking $(@)"
|
|
|
|
$(cc) $(lflags) $(^) -o $(@)
|
|
|
|
|
|
|
|
$(fast-executable): $(fast-objects) $(stdcpp-objects)
|
|
|
|
@echo "linking $(@)"
|
|
|
|
$(cc) $(lflags) $(^) -o $(@)
|
|
|
|
strip --strip-all $(@)
|
|
|
|
|
|
|
|
.PHONY: generator
|
|
|
|
generator: $(generator-executable)
|
|
|
|
|
|
|
|
.PHONY: run-generator
|
|
|
|
run-generator: $(generator-executable)
|
|
|
|
$(<) < $(src)/types.def
|
|
|
|
|
|
|
|
.PHONY: vg-generator
|
|
|
|
vg-generator: $(generator-executable)
|
|
|
|
$(vg) $(<) < $(src)/types.def
|
|
|
|
|
|
|
|
$(generator-executable): $(generator-objects) $(stdcpp-objects)
|
|
|
|
@echo "linking $(@)"
|
|
|
|
$(cc) $(lflags) $(^) -o $(@)
|