2007-10-23 17:22:48 +00:00
|
|
|
#MAKEFLAGS = -s
|
2007-06-03 23:16:07 +00:00
|
|
|
|
2007-10-22 20:56:27 +00:00
|
|
|
input = $(cls)/Memory.class
|
|
|
|
|
|
|
|
build-arch = $(shell uname -m)
|
|
|
|
ifeq ($(build-arch),i586)
|
|
|
|
build-arch = i386
|
2007-06-29 16:43:25 +00:00
|
|
|
endif
|
2007-10-22 20:56:27 +00:00
|
|
|
ifeq ($(build-arch),i686)
|
|
|
|
build-arch = i386
|
2007-06-29 16:43:25 +00:00
|
|
|
endif
|
2007-06-29 16:42:39 +00:00
|
|
|
|
2007-10-22 20:56:27 +00:00
|
|
|
build-platform = $(shell uname -s | tr [:upper:] [:lower:])
|
2007-09-21 14:16:43 +00:00
|
|
|
|
2007-10-23 17:22:48 +00:00
|
|
|
ifeq ($(build-platform),cygwin_nt-5.1)
|
|
|
|
build-platform = windows
|
|
|
|
endif
|
|
|
|
|
2007-10-22 20:56:27 +00:00
|
|
|
arch = $(build-arch)
|
|
|
|
|
|
|
|
platform = $(build-platform)
|
2007-09-19 16:22:19 +00:00
|
|
|
|
2007-09-26 14:43:40 +00:00
|
|
|
process = interpret
|
2007-09-25 23:53:11 +00:00
|
|
|
|
2007-07-16 01:03:02 +00:00
|
|
|
mode = debug
|
|
|
|
|
2007-10-22 20:56:27 +00:00
|
|
|
build-dir = build/$(build-platform)/$(build-arch)
|
2007-09-21 14:16:43 +00:00
|
|
|
bld = build/$(platform)/$(arch)/$(mode)
|
2007-07-16 01:03:02 +00:00
|
|
|
cls = build/classes
|
2007-06-03 23:16:07 +00:00
|
|
|
src = src
|
2007-06-25 01:34:07 +00:00
|
|
|
classpath = classpath
|
2007-07-16 01:03:02 +00:00
|
|
|
test = test
|
2007-06-03 23:16:07 +00:00
|
|
|
|
2007-10-22 20:56:27 +00:00
|
|
|
build-cxx = g++
|
|
|
|
build-cc = gcc
|
2007-07-17 01:55:49 +00:00
|
|
|
|
2007-10-22 20:56:27 +00:00
|
|
|
cxx = $(build-cxx)
|
|
|
|
cc = $(build-cc)
|
2007-09-14 23:04:08 +00:00
|
|
|
vg = nice valgrind --suppressions=valgrind.supp --undef-value-errors=no \
|
2007-09-13 16:43:33 +00:00
|
|
|
--num-callers=32 --db-attach=yes --freelist-vol=100000000
|
2007-08-19 19:45:51 +00:00
|
|
|
db = gdb --args
|
2007-06-21 01:38:02 +00:00
|
|
|
javac = javac
|
2007-08-19 19:45:51 +00:00
|
|
|
strip = :
|
|
|
|
show-size = :
|
2007-06-03 23:16:07 +00:00
|
|
|
|
2007-10-22 20:56:27 +00:00
|
|
|
rdynamic = -rdynamic
|
|
|
|
thread-cflags = -pthread
|
|
|
|
shared = -shared
|
2007-10-23 20:05:59 +00:00
|
|
|
so-prefix = lib
|
2007-10-22 20:56:27 +00:00
|
|
|
so-extension = so
|
|
|
|
ld-library-path = LD_LIBRARY_PATH
|
|
|
|
|
2007-10-08 19:29:40 +00:00
|
|
|
warnings = -Wall -Wextra -Werror -Wunused-parameter \
|
2007-06-03 23:16:07 +00:00
|
|
|
-Winit-self -Wconversion
|
|
|
|
|
|
|
|
cflags = $(warnings) -fPIC -fno-rtti -fno-exceptions -fvisibility=hidden \
|
2007-10-23 20:05:59 +00:00
|
|
|
-I$(JAVA_HOME)/include -I$(JAVA_HOME)/include/linux -I$(src) -I$(bld) \
|
2007-10-23 17:22:48 +00:00
|
|
|
$(thread-cflags) -D__STDC_LIMIT_MACROS
|
2007-07-16 01:03:02 +00:00
|
|
|
|
2007-10-22 20:56:27 +00:00
|
|
|
lflags = -lpthread -ldl -lm -lz
|
|
|
|
|
|
|
|
system = posix
|
2007-10-23 01:00:57 +00:00
|
|
|
asm = x86
|
2007-10-22 20:56:27 +00:00
|
|
|
|
|
|
|
ifeq ($(platform),darwin)
|
|
|
|
rdynamic =
|
|
|
|
thread-cflags =
|
|
|
|
shared = -dynamiclib
|
|
|
|
so-extension = jnilib
|
|
|
|
ld-library-path = DYLD_LIBRARY_PATH
|
|
|
|
endif
|
|
|
|
ifeq ($(platform),windows)
|
|
|
|
inc = ../6.0/shared/include/msw
|
|
|
|
lib = ../6.0/shared/lib/native/msw
|
|
|
|
|
|
|
|
system = windows
|
2007-10-23 20:05:59 +00:00
|
|
|
|
2007-10-22 20:56:27 +00:00
|
|
|
cxx = i586-mingw32msvc-g++
|
|
|
|
cc = i586-mingw32msvc-gcc
|
2007-10-23 20:05:59 +00:00
|
|
|
dlltool = i586-mingw32msvc-dlltool
|
|
|
|
|
|
|
|
rdynamic = -Wl,--export-dynamic
|
|
|
|
so-prefix =
|
2007-10-22 20:56:27 +00:00
|
|
|
so-extension = dll
|
|
|
|
thread-cflags =
|
2007-10-23 17:22:48 +00:00
|
|
|
lflags = -L$(lib) -lm -lz -lws2_32 -Wl,--kill-at
|
2007-10-23 20:05:59 +00:00
|
|
|
cflags = $(warnings) -fno-rtti -fno-exceptions $(thread-cflags) \
|
|
|
|
-D__STDC_LIMIT_MACROS -DBUILTIN_LIBRARIES=\"natives\" \
|
|
|
|
-I$(bld) -I$(JAVA_HOME)/include -I$(inc) -idirafter $(src)
|
2007-10-22 20:56:27 +00:00
|
|
|
endif
|
2007-08-18 22:42:11 +00:00
|
|
|
|
2007-07-16 01:03:02 +00:00
|
|
|
ifeq ($(mode),debug)
|
2007-10-22 20:56:27 +00:00
|
|
|
cflags += -O0 -g3
|
2007-07-16 01:03:02 +00:00
|
|
|
endif
|
|
|
|
ifeq ($(mode),stress)
|
2007-10-22 20:56:27 +00:00
|
|
|
cflags += -O0 -g3 -DVM_STRESS
|
2007-07-16 01:03:02 +00:00
|
|
|
endif
|
|
|
|
ifeq ($(mode),stress-major)
|
2007-10-22 20:56:27 +00:00
|
|
|
cflags += -O0 -g3 -DVM_STRESS -DVM_STRESS_MAJOR
|
2007-07-16 01:03:02 +00:00
|
|
|
endif
|
|
|
|
ifeq ($(mode),fast)
|
2007-10-22 20:56:27 +00:00
|
|
|
cflags += -O3 -DNDEBUG
|
|
|
|
strip = strip
|
|
|
|
show-size = ls -l
|
2007-08-18 22:42:11 +00:00
|
|
|
endif
|
2007-06-03 23:16:07 +00:00
|
|
|
|
2007-10-22 20:56:27 +00:00
|
|
|
ifeq ($(arch),i386)
|
|
|
|
pointer-size = 4
|
|
|
|
else
|
|
|
|
pointer-size = 8
|
|
|
|
endif
|
2007-06-03 23:16:07 +00:00
|
|
|
|
2007-10-22 20:56:27 +00:00
|
|
|
cpp-objects = $(foreach x,$(1),$(patsubst $(2)/%.cpp,$(3)/%.o,$(x)))
|
|
|
|
asm-objects = $(foreach x,$(1),$(patsubst $(2)/%.S,$(3)/%-asm.o,$(x)))
|
|
|
|
java-classes = $(foreach x,$(1),$(patsubst $(2)/%.java,$(cls)/%.class,$(x)))
|
2007-06-03 23:16:07 +00:00
|
|
|
|
2007-07-26 00:48:28 +00:00
|
|
|
jni-sources = $(shell find $(classpath) -name '*.cpp')
|
2007-10-22 20:56:27 +00:00
|
|
|
jni-objects = $(call cpp-objects,$(jni-sources),$(classpath),$(bld))
|
2007-10-23 17:22:48 +00:00
|
|
|
jni-cflags = $(cflags)
|
2007-10-23 20:05:59 +00:00
|
|
|
jni-library = $(bld)/$(so-prefix)natives.$(so-extension)
|
2007-06-25 01:34:07 +00:00
|
|
|
|
2007-06-18 19:23:44 +00:00
|
|
|
generated-code = \
|
2007-10-23 20:05:59 +00:00
|
|
|
$(bld)/type-enums.cpp \
|
|
|
|
$(bld)/type-declarations.cpp \
|
|
|
|
$(bld)/type-constructors.cpp \
|
|
|
|
$(bld)/type-initializations.cpp \
|
|
|
|
$(bld)/type-java-initializations.cpp
|
2007-07-06 23:50:26 +00:00
|
|
|
|
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-08-10 23:45:47 +00:00
|
|
|
$(src)/finder.h \
|
2007-09-24 01:39:03 +00:00
|
|
|
$(src)/processor.h \
|
2007-09-27 00:01:38 +00:00
|
|
|
$(src)/process.h \
|
2007-06-18 21:13:21 +00:00
|
|
|
$(src)/stream.h \
|
|
|
|
$(src)/constants.h \
|
2007-07-06 23:50:26 +00:00
|
|
|
$(src)/jnienv.h \
|
|
|
|
$(src)/machine.h
|
|
|
|
|
2007-06-03 23:16:07 +00:00
|
|
|
interpreter-sources = \
|
2007-10-22 20:56:27 +00:00
|
|
|
$(src)/$(system).cpp \
|
2007-08-10 23:45:47 +00:00
|
|
|
$(src)/finder.cpp \
|
2007-07-06 23:50:26 +00:00
|
|
|
$(src)/machine.cpp \
|
2007-06-20 19:20:25 +00:00
|
|
|
$(src)/heap.cpp \
|
2007-09-25 23:53:11 +00:00
|
|
|
$(src)/$(process).cpp \
|
2007-07-20 14:36:31 +00:00
|
|
|
$(src)/builtin.cpp \
|
|
|
|
$(src)/jnienv.cpp \
|
2007-06-20 19:20:25 +00:00
|
|
|
$(src)/main.cpp
|
2007-06-29 02:58:48 +00:00
|
|
|
|
2007-10-23 01:00:57 +00:00
|
|
|
interpreter-asm-sources = $(src)/$(asm).S
|
2007-10-22 20:56:27 +00:00
|
|
|
|
|
|
|
ifeq ($(process),compile)
|
|
|
|
interpreter-asm-sources += $(src)/compile.S
|
|
|
|
endif
|
2007-06-29 02:58:48 +00:00
|
|
|
|
|
|
|
interpreter-cpp-objects = \
|
2007-10-22 20:56:27 +00:00
|
|
|
$(call cpp-objects,$(interpreter-sources),$(src),$(bld))
|
2007-06-29 17:45:14 +00:00
|
|
|
interpreter-asm-objects = \
|
2007-10-22 20:56:27 +00:00
|
|
|
$(call asm-objects,$(interpreter-asm-sources),$(src),$(bld))
|
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
|
|
|
|
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
|
2007-10-22 20:56:27 +00:00
|
|
|
generator-objects = $(call \
|
|
|
|
cpp-objects,$(generator-sources),$(src),$(build-dir))
|
|
|
|
generator-executable = $(build-dir)/generator
|
2007-06-03 23:16:07 +00:00
|
|
|
|
|
|
|
executable = $(bld)/vm
|
|
|
|
|
2007-07-16 01:03:02 +00:00
|
|
|
classpath-sources = $(shell find $(classpath) -name '*.java')
|
2007-06-30 02:39:01 +00:00
|
|
|
classpath-classes = $(call java-classes,$(classpath-sources),$(classpath))
|
|
|
|
|
2007-07-16 01:03:02 +00:00
|
|
|
classpath-objects = $(classpath-classes) $(jni-library)
|
|
|
|
|
|
|
|
test-sources = $(shell find $(test) -name '*.java')
|
|
|
|
test-classes = $(call java-classes,$(test-sources),$(test))
|
|
|
|
|
|
|
|
class-name = $(patsubst $(cls)/%.class,%,$(1))
|
|
|
|
class-names = $(foreach x,$(1),$(call class-name,$(x)))
|
|
|
|
|
2007-08-18 21:24:29 +00:00
|
|
|
flags = -cp $(cls)
|
2007-07-16 01:03:02 +00:00
|
|
|
args = $(flags) $(call class-name,$(input))
|
2007-06-21 01:38:02 +00:00
|
|
|
|
2007-06-03 23:16:07 +00:00
|
|
|
.PHONY: build
|
2007-09-24 01:39:03 +00:00
|
|
|
build: $(executable) $(classpath-objects) $(test-classes)
|
2007-06-03 23:16:07 +00:00
|
|
|
|
2007-09-30 16:32:17 +00:00
|
|
|
$(input): $(classpath-classes)
|
2007-06-21 01:38:02 +00:00
|
|
|
|
2007-06-03 23:16:07 +00:00
|
|
|
.PHONY: run
|
2007-09-30 16:32:17 +00:00
|
|
|
run: build
|
|
|
|
$(ld-library-path)=$(bld) $(executable) $(args)
|
2007-06-03 23:16:07 +00:00
|
|
|
|
|
|
|
.PHONY: debug
|
2007-09-30 16:32:17 +00:00
|
|
|
debug: build
|
2007-10-22 20:56:27 +00:00
|
|
|
$(ld-library-path)=$(bld) gdb --args $(executable) $(args)
|
2007-06-03 23:16:07 +00:00
|
|
|
|
|
|
|
.PHONY: vg
|
2007-09-30 16:32:17 +00:00
|
|
|
vg: build
|
2007-10-22 20:56:27 +00:00
|
|
|
$(ld-library-path)=$(bld) $(vg) $(executable) $(args)
|
2007-06-03 23:16:07 +00:00
|
|
|
|
|
|
|
.PHONY: test
|
2007-10-23 20:18:42 +00:00
|
|
|
test:
|
2007-10-22 20:56:27 +00:00
|
|
|
$(ld-library-path)=$(bld) /bin/bash $(test)/test.sh 2>/dev/null \
|
2007-09-30 16:32:17 +00:00
|
|
|
$(executable) $(mode) "$(flags)" $(call class-names,$(test-classes))
|
2007-06-03 23:16:07 +00:00
|
|
|
|
|
|
|
.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-08-19 19:45:51 +00:00
|
|
|
.PHONY: clean-native
|
|
|
|
clean-native:
|
2007-10-22 20:56:27 +00:00
|
|
|
@echo "removing $(bld) and $(build-dir)"
|
|
|
|
rm -rf $(bld) $(build-dir)
|
2007-08-19 19:45:51 +00:00
|
|
|
|
2007-10-23 20:05:59 +00:00
|
|
|
gen-arg = $(shell echo $(1) | sed -e 's:$(bld)/type-\(.*\)\.cpp:\1:')
|
2007-06-18 19:23:44 +00:00
|
|
|
$(generated-code): %.cpp: $(src)/types.def $(generator-executable)
|
2007-06-03 23:16:07 +00:00
|
|
|
@echo "generating $(@)"
|
2007-10-23 20:05:59 +00:00
|
|
|
@mkdir -p -m 1777 $(dir $(@))
|
2007-06-03 23:16:07 +00:00
|
|
|
$(generator-executable) $(call gen-arg,$(@)) < $(<) > $(@)
|
|
|
|
|
2007-10-22 20:56:27 +00:00
|
|
|
$(build-dir)/type-generator.o: \
|
2007-06-04 23:39:59 +00:00
|
|
|
$(generator-headers)
|
2007-06-03 23:16:07 +00:00
|
|
|
|
2007-07-16 01:03:02 +00:00
|
|
|
define compile-class
|
2007-06-21 01:38:02 +00:00
|
|
|
@echo "compiling $(@)"
|
2007-10-23 17:22:48 +00:00
|
|
|
@mkdir -p -m 1777 $(dir $(@))
|
2007-09-19 14:16:49 +00:00
|
|
|
$(javac) -bootclasspath $(classpath) -classpath $(classpath) \
|
2007-09-13 00:21:37 +00:00
|
|
|
-d $(cls) $(<)
|
2007-09-30 16:32:17 +00:00
|
|
|
@touch $(@)
|
2007-07-16 01:03:02 +00:00
|
|
|
endef
|
2007-06-21 01:38:02 +00:00
|
|
|
|
2007-07-16 01:03:02 +00:00
|
|
|
$(cls)/%.class: $(classpath)/%.java
|
|
|
|
$(compile-class)
|
2007-06-29 02:58:48 +00:00
|
|
|
|
2007-07-16 01:03:02 +00:00
|
|
|
$(cls)/%.class: $(test)/%.java
|
|
|
|
$(compile-class)
|
2007-06-03 23:16:07 +00:00
|
|
|
|
2007-07-16 01:03:02 +00:00
|
|
|
define compile-object
|
2007-06-03 23:16:07 +00:00
|
|
|
@echo "compiling $(@)"
|
2007-10-23 17:22:48 +00:00
|
|
|
@mkdir -p -m 1777 $(dir $(@))
|
2007-07-16 01:03:02 +00:00
|
|
|
$(cxx) $(cflags) -c $(<) -o $(@)
|
|
|
|
endef
|
2007-06-03 23:16:07 +00:00
|
|
|
|
2007-07-16 01:03:02 +00:00
|
|
|
$(interpreter-cpp-objects): $(bld)/%.o: $(src)/%.cpp $(interpreter-depends)
|
|
|
|
$(compile-object)
|
2007-06-29 17:45:14 +00:00
|
|
|
|
2007-10-04 00:41:54 +00:00
|
|
|
$(interpreter-asm-objects): $(bld)/%-asm.o: $(src)/%.S
|
2007-07-16 01:03:02 +00:00
|
|
|
$(compile-object)
|
2007-06-03 23:16:07 +00:00
|
|
|
|
2007-10-22 20:56:27 +00:00
|
|
|
$(generator-objects): $(build-dir)/%.o: $(src)/%.cpp
|
|
|
|
@echo "compiling $(@)"
|
2007-10-23 17:22:48 +00:00
|
|
|
@mkdir -p -m 1777 $(dir $(@))
|
2007-10-23 20:05:59 +00:00
|
|
|
$(build-cxx) -DPOINTER_SIZE=$(pointer-size) $(cflags) -c $(<) -o $(@)
|
2007-06-03 23:16:07 +00:00
|
|
|
|
2007-06-25 01:34:07 +00:00
|
|
|
$(jni-objects): $(bld)/%.o: $(classpath)/%.cpp
|
|
|
|
@echo "compiling $(@)"
|
2007-10-23 17:22:48 +00:00
|
|
|
@mkdir -p -m 1777 $(dir $(@))
|
2007-06-25 01:34:07 +00:00
|
|
|
$(cxx) $(jni-cflags) -c $(<) -o $(@)
|
|
|
|
|
|
|
|
$(jni-library): $(jni-objects)
|
|
|
|
@echo "linking $(@)"
|
2007-10-22 20:56:27 +00:00
|
|
|
$(cc) $(^) $(lflags) $(shared) -o $(@)
|
2007-06-25 01:34:07 +00:00
|
|
|
|
2007-10-23 20:05:59 +00:00
|
|
|
ifeq ($(platform),windows)
|
|
|
|
$(executable): $(interpreter-objects) $(jni-objects)
|
|
|
|
@echo "linking $(@)"
|
|
|
|
$(dlltool) --export-all-symbols -z $(@).def $(^)
|
2007-10-23 20:18:42 +00:00
|
|
|
$(dlltool) -k -d $(@).def -e $(@).exp
|
2007-10-23 20:05:59 +00:00
|
|
|
$(cc) $(^) $(lflags) $(@).exp -o $(@)
|
|
|
|
@$(strip) --strip-all $(@)
|
|
|
|
@$(show-size) $(@)
|
|
|
|
else
|
|
|
|
$(executable): $(interpreter-objects)
|
2007-06-03 23:16:07 +00:00
|
|
|
@echo "linking $(@)"
|
2007-10-22 20:56:27 +00:00
|
|
|
$(cc) $(^) $(lflags) $(rdynamic) -o $(@)
|
2007-08-20 02:57:32 +00:00
|
|
|
@$(strip) --strip-all $(@)
|
|
|
|
@$(show-size) $(@)
|
2007-10-23 20:05:59 +00:00
|
|
|
endif
|
2007-06-03 23:16:07 +00:00
|
|
|
|
2007-10-22 20:56:27 +00:00
|
|
|
$(generator-executable): $(generator-objects)
|
2007-06-03 23:16:07 +00:00
|
|
|
@echo "linking $(@)"
|
2007-10-23 20:05:59 +00:00
|
|
|
$(build-cc) $(^) -o $(@)
|