diff --git build/custom/gnumake/Makefile build/custom/gnumake/Makefile new file mode 100644 index 0000000..0c2842a --- /dev/null +++ build/custom/gnumake/Makefile @@ -0,0 +1,77 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +# +# Run 'make help' for help on using build system +# + +# Include common variable definitions, like OSTAG, ARCHTAG etc. +export TOP := $(abspath ../../..) +include makevars.inc + +# List of submodules in the dependency order +SUBDIRS := \ + port \ + encoder \ + thread \ + vmcore \ + em \ + gc_cc \ + gc_gen \ + interpreter \ + jitrino \ + +ifeq ($(ARCHTAG),ia32) +SUBDIRS += vmi +endif + +#----------------- + +.PHONY: all clean distclean build deploy +all: build deploy + +build: + # building for $(OS)/$(ARCH)/$(CC)/$(CFG) + $(Q)set -e; for i in $(SUBDIRS); do $(MAKE) -C $$i; done + +deploy: build + $(Q)cp -uv $(BIN)/* $(DEPLOY)/jdk/jre/bin/default + +clean distclean: + $(Q)set -e; for i in $(SUBDIRS); do $(MAKE) -C $$i $@; done + +help: + # Make system requires GNU Make, sed, coreutils (cp, uname etc.), + # makedepend, /bin/sh + # + # Supported targets + # make all - build all libraries and executables + # make clean - clean object files and libraries + # make distclean - clean all make artifacts (configuration) + # + # make -j2 - parallel make is supported + # make V=1 - verbose make mode, prints full commands + +#----------------- +# fix dependencies for parallel make +ifneq ($(filter clean,$(MAKECMDGOALS)),) +build: clean +endif +ifneq ($(filter distclean,$(MAKECMDGOALS)),) +build: distclean +endif + diff --git build/custom/gnumake/em/Makefile build/custom/gnumake/em/Makefile new file mode 100644 index 0000000..74b4696 --- /dev/null +++ build/custom/gnumake/em/Makefile @@ -0,0 +1,44 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +NAME = em +TYPE = shared + +DEFINES = BUILDING_EM + +INCLUDES = \ + $(SEMIS)/extra/apr/include/apr-1 \ + $(VM)/port/include \ + $(VM)/include \ + $(VM)/vmcore/include \ + $(VM)/em/src \ + +lnx_INCLUDES = $(VM)/vmcore/src/util/linux/include +win_INCLUDES = $(VM)/vmcore/src/util/win/include + +SOURCES = $(wildcard $(VM)/em/src/*.cpp) + +lnx_CXXFLAGS = -Wno-deprecated -fno-exceptions +lnx_LDFLAGS += --export-dynamic + +SODEPENDS = harmonyvm hythr +LIBDEPENDS = encoder +LIBS = apr-1 m dl stdc++ z xml2 pthread +LIBDIRS = \ + $(SEMIS)/extra/apr/_bin \ + +include ../makerules.inc diff --git build/custom/gnumake/encoder/Makefile build/custom/gnumake/encoder/Makefile new file mode 100644 index 0000000..25e5a7d --- /dev/null +++ build/custom/gnumake/encoder/Makefile @@ -0,0 +1,30 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +NAME = encoder +TYPE = library + +DEFINES = APR_DECLARE_EXPORT NO_EBCODER_INLINE + +INCLUDES = \ + $(VM)/include \ + +ia32_SOURCES = $(wildcard $(VM)/port/src/encoder/ia32_em64t/*.cpp) +em64t_SOURCES = $(wildcard $(VM)/port/src/encoder/ia32_em64t/*.cpp) +ipf_SOURCES = $(wildcard $(VM)/port/src/encoder/ipf/*.cpp) + +include ../makerules.inc diff --git build/custom/gnumake/gc_cc/Makefile build/custom/gnumake/gc_cc/Makefile new file mode 100644 index 0000000..0af5533 --- /dev/null +++ build/custom/gnumake/gc_cc/Makefile @@ -0,0 +1,47 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +NAME = gc_cc +TYPE = shared + +DEFINES = BUILDING_GC + +INCLUDES = \ + $(SEMIS)/extra/apr/include/apr-1 \ + $(VM)/port/include \ + $(VM)/include \ + $(VM)/vmcore/include \ + +lnx_INCLUDES = $(VM)/vmcore/src/util/linux/include +win_INCLUDES = $(VM)/vmcore/src/util/win/include + +SOURCES = $(wildcard $(VM)/gc_cc/src/*.cpp) +ipf_SOURCES = $(wildcard $(VM)/gc_cc/src/*_ipf_*.asm) + +release_win_icl_CFLAGS = -Qip + +lnx_LDFLAGS = -Bsymbolic + +SODEPENDS = hythr + +LIBS = apr-1 +LIBDIRS = \ + $(SEMIS)/extra/apr/_bin \ + +win_LIBS = advapi32 odbc32 ws2_32 mswsock + +include ../makerules.inc diff --git build/custom/gnumake/gc_gen/Makefile build/custom/gnumake/gc_gen/Makefile new file mode 100644 index 0000000..3247fe9 --- /dev/null +++ build/custom/gnumake/gc_gen/Makefile @@ -0,0 +1,38 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +NAME = gc_gen +TYPE = shared + +DEFINES = BUILDING_GC + +INCLUDES = \ + $(SEMIS)/extra/apr/include/apr-1 \ + $(VM)/port/include \ + $(VM)/include \ + $(VM)/vmcore/include \ + +lnx_INCLUDES = $(VM)/vmcore/src/util/linux/include +win_INCLUDES = $(VM)/vmcore/src/util/win/include + +SOURCES = $(shell /usr/bin/find $(VM)/gc_gen -name '*.cpp') + +release_win_icl_CXXFLAGS = -Qip +lnx_LDFLAGS = -Bsymbolic +SODEPENDS = hythr + +include ../makerules.inc diff --git build/custom/gnumake/gen-sources-list build/custom/gnumake/gen-sources-list new file mode 100755 index 0000000..b51f68e --- /dev/null +++ build/custom/gnumake/gen-sources-list @@ -0,0 +1,73 @@ +#!/bin/sh + +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +# +# Generates includable makefile with compilation rules +# for C, C++ and assembler sources +# +# Usage: +# gen-sources-list ... +# +# Notes on the constructed make file: +# * object files are placed in flat $(OBJ) directory +# * $(OBJ) depends on $(OBJ)/.stamp in order to mkdir $(OBJ) if needed +# * it collects object file list suitable for linker in $(OBJECTS) +# * it collects dependencies list suitable for '-include' in $(DEPENDS) +# + +die () { + echo "$@" >&2 + exit 1 +} + +echo "OBJECTS :=" +echo "DEPENDS :=" + +for i in "$@"; do + echo + case "$i" in + *.c) + o='$(OBJ)/'`basename "$i" .c`.o + d='$(OBJ)/'`basename "$i" .c`.d + echo "OBJECTS += $o" + echo "DEPENDS += $d" + echo "$o: $i" '$(OBJ)/.stamp $(CFLAGS_FILE)' + echo ' $(Q)makedepend -f - -Y $(CPPFLAGS) $< 2>/dev/null | sed -r' "'"'s#^[^:]*:#'"$o $d"':#; s#: (.*)$$#: $$(wildcard \1)#'"'" '> $(subst .o,.d,$@)' + echo ' $(QUIET_CC)$(CC) -c -o $@ $(CFLAGS) $(CPPFLAGS) $<' + ;; + *.cpp) + o='$(OBJ)/'`basename "$i" .cpp`.o + d='$(OBJ)/'`basename "$i" .cpp`.d + echo "OBJECTS += $o" + echo "DEPENDS += $d" + echo "$o: $i" '$(OBJ)/.stamp $(CXXFLAGS_FILE)' + echo ' $(Q)makedepend -f - -Y $(CPPFLAGS) $< 2>/dev/null | sed -r' "'"'s#^[^:]*:#'"$o $d"':#; s#: (.*)$$#: $$(wildcard \1)#'"'" '> $(subst .o,.d,$@)' + echo ' $(QUIET_CXX)$(CXX) -c -o $@ $(CXXFLAGS) $(CPPFLAGS) $<' + ;; + *.asm) + o='$(OBJ)/'`basename "$i" .asm`.o + echo "OBJECTS += $o" + echo "$o: $i" '$(OBJ)/.stamp' + echo ' $(QUIET_AS)$(AS) -o $@ $(ASFLAGS) $<' + ;; + *) + die "Error: unsupported source file: $i" + ;; + esac +done diff --git build/custom/gnumake/interpreter/Makefile build/custom/gnumake/interpreter/Makefile new file mode 100644 index 0000000..8ae0538 --- /dev/null +++ build/custom/gnumake/interpreter/Makefile @@ -0,0 +1,45 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +NAME = interpreter +TYPE = shared + +DEFINES = USE_DLL_JIT BUILDING_JIT + +INCLUDES = \ + $(SEMIS)/extra/apr/include/apr-1 \ + $(VM)/port/include \ + $(VM)/port/src/encoder/ia32_em64t \ + $(VM)/port/src/lil/ia32/pim/include \ + $(VM)/include \ + $(VM)/vmcore/include \ + $(VM)/vmcore/src/util/linux/include \ + $(VM)/vmcore/src/util/ia32/base_natives \ + +VM := ../../../../vm +SOURCES := $(wildcard $(VM)/interpreter/src/*.cpp) +ia32_SOURCES := $(wildcard $(VM)/interpreter/src/*_ia32.asm) + +em64t_SOURCES := $(filter %_em64t.cpp,$(SOURCES)) +SOURCES := $(filter-out $(em64t_SOURCES),$(SOURCES)) +ipf_SOURCES := $(filter %_ipf.cpp,$(SOURCES)) +SOURCES := $(filter-out $(ipf_SOURCES),$(SOURCES)) + +lnx_LDFLAGS = --export-dynamic +SODEPENDS = hythr harmonyvm + +include ../makerules.inc diff --git build/custom/gnumake/jitrino/Makefile build/custom/gnumake/jitrino/Makefile new file mode 100644 index 0000000..b0e0ba9 --- /dev/null +++ build/custom/gnumake/jitrino/Makefile @@ -0,0 +1,64 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +NAME = jitrino +TYPE = shared + +DEFINES = BUILDING_JIT PROJECT_JITRINO +lnx_CXXFLAGS = -fmessage-length=0 -Wall -Werror -fno-exceptions + +INCLUDES = \ + $(SEMIS)/extra/apr/include/apr-1 \ + $(VM)/port/src/encoder/ia32_em64t \ + $(VM)/port/include \ + $(VM)/include \ + $(VM)/vmcore/include \ + $(VM)/vmcore/src/util/linux/include \ + $(VM)/jitrino/src/dynopt \ + $(VM)/jitrino/src/main \ + $(VM)/jitrino/src/shared \ + $(VM)/jitrino/src/optimizer \ + $(VM)/jitrino/src/optimizer/ssa \ + $(VM)/jitrino/src/optimizer/abcd \ + $(VM)/jitrino/src/translator \ + $(VM)/jitrino/src/translator/java \ + $(VM)/jitrino/src/vm \ + $(VM)/jitrino/src/vm/drl \ + $(VM)/jitrino/src/codegenerator \ + $(VM)/jitrino/src/codegenerator/ia32 \ + $(VM)/jitrino/src/jet \ + +SOURCES = \ + $(wildcard $(VM)/jitrino/src/dynopt/*.cpp) \ + $(wildcard $(VM)/jitrino/src/main/*.cpp) \ + $(wildcard $(VM)/jitrino/src/shared/*.cpp) \ + $(wildcard $(VM)/jitrino/src/optimizer/*.cpp) \ + $(wildcard $(VM)/jitrino/src/optimizer/ssa/*.cpp) \ + $(wildcard $(VM)/jitrino/src/optimizer/abcd/*.cpp) \ + $(wildcard $(VM)/jitrino/src/translator/*.cpp) \ + $(wildcard $(VM)/jitrino/src/translator/java/*.cpp) \ + $(wildcard $(VM)/jitrino/src/vm/*.cpp) \ + $(wildcard $(VM)/jitrino/src/vm/drl/*.cpp) \ + $(wildcard $(VM)/jitrino/src/codegenerator/*.cpp) \ + $(wildcard $(VM)/jitrino/src/codegenerator/ia32/*.cpp) \ + $(wildcard $(VM)/jitrino/src/jet/*.cpp) \ + +LIBDEPENDS = encoder +SODEPENDS = harmonyvm hythr +lnx_LIBS = dl m + +include ../makerules.inc diff --git build/custom/gnumake/makelocal.inc.example build/custom/gnumake/makelocal.inc.example new file mode 100644 index 0000000..331954e --- /dev/null +++ build/custom/gnumake/makelocal.inc.example @@ -0,0 +1,23 @@ +# Copy this file to makelocal.inc and adjust as needed. +# (variables from makevars.inc can be used) + +CLASSLIB := $(abspath $(TOP)/../classlib.$(ARCH)) + +#-------------------------------------------------------------- +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + diff --git build/custom/gnumake/makerules.inc build/custom/gnumake/makerules.inc new file mode 100644 index 0000000..60074a2 --- /dev/null +++ build/custom/gnumake/makerules.inc @@ -0,0 +1,335 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +#------------- +# Author: Salikh Zakirov +# Credits: some tricks taken from prior work +# by John Graham­Cumming and Tom Tromey. +# +# This file is intended for inclusion into subcomponent makefiles. +# Subcomponent makefile is responsible for building exactly one +# executable, library, or shared library +# +# Usage: +# +# 0) Each buildable artifact (shared or static library, or executable) +# needs to have its own dedicated Makefile in a separate directory. +# +# 1) Makefile should define following variables +# +# TYPE = executable | library | shared - type of the target +# NAME - base name of the target file +# SOURCES - list of source files +# +# 2) optionally define following compilation variables +# (all lists space-separated) +# +# INCLUDES - list of include directories, it will end up in +# $(CPPFLAGS) with -I added automatically +# DEFINES - list of macros, it will end up in $(CPPFLAGS), +# with -D added automatically +# +# 3) Link time dependencies (space separated list of non-decorated names, +# i.e. without 'lib' prefix or '.so' suffix) +# +# Dependencies on libraries built earlier +# (as they were specified in NAME variable in respective Makefile): +# LIBDEPENDS - list of static libraries this target depends on (built by +# this make system, supposed to be in $(LIB)) +# SODEPENDS - list of shared libraries this target depends on (built by +# this make system, supposed to be in $(BIN)) +# +# Dependencies on system or 3rd-party libraries +# LIBS - list of 3rd-party libraries to link +# LIBDIRS - list of directories to search 3rd-party libraries +# +# Note, that you need not put -l or -L either, as it will be added +# by the makefile automatically. +# +# 4) include rules.inc at the end of Makefile +# +# The following targets are provided: +# +# make all - build the target +# make clean - clean the compilation artifacts (object files and target) +# make distclean - clean all build artifacts, including build system +# configuration +# +# The following variables control the placement of build artifacts: +# +# $(BIN) - a place for executables and shared libraries +# $(LIB) - a place for static libraries +# $(OBJ) - a place for object files +# +# * Note: both $(BIN) and $(LIB) are supposed to be the same for all +# targets built by this system, while $(OBJ) is target-specific +# in order to prevent conflicts of object files with the same name. +# +# This file also defines some DEFINES and compilation flags common for the +# DRLVM project +# + +#------------- +# Build variables setup + +# some predefined build flags +# NB Using '+=' is important, as this file is included) +debug_DEFINES += _DEBUG VM_STATS +release_DEFINES += NDEBUG +ia32_DEFINES += _IA32_ + +lnx_DEFINES += PLATFORM_POSIX LINUX __SMP__ _REENTRANT \ + LINUX_TLS_OPT _LARGEFILE64_SOURCE +win_DEFINES += _USRDLL + +lnx_CXXFLAGS += -fPIC +lnx_CFLAGS += -fPIC + +release_lnx_CFLAGS ?= -O2 +release_lnx_CXXLFAGS ?= -O2 + +debug_lnx_CFGLAGS ?= -O0 -g +debug_lnx_CXXFGLAGS ?= -O0 -g + +ifndef TOP +# this is a guess, using knowledge on the directory layout, +# if somehow TOP was not defined (e.g. component Makefile run +# directly rather than from top-level Makefile) +TOP := $(abspath $(wildcard ../vm/vmcore \ + ../../vm/vmcore \ + ../../../vm/vmcore \ + ../../../../vm/vmcore)/../..) +endif + +# global variables, shared between subcomponents, +# and maybe with top-level makefile, go to makevars.inc +include $(TOP)/build/custom/gnumake/makevars.inc + +#------------- +# build directories +# +# NB: $(BIN) and $(LIB) should be the same for all components +# in order to component interdependencies to function, +# so they are defined in makevars.inc +# +# $(OBJ) is advisably separate for components to reduce the probablity +# for object file name conflict, so include /$(NAME)/ path component +OBJ := $(SEMIS)/obj/$(NAME) + +ifndef NAME +$(error Makefile must define NAME, see makerules.inc for instruction) +endif + +#------------- +# (variable names based off unix conventions) + +ifeq ($(OS),Linux) +# .exe suffix (with dot) +exe := +# library prefix +lib := lib +# shared library suffix (without dot) +so := so +# static library suffix (without dot) +a := a +else +# not linux supposed to be windows +exe := .exe +lib := +so := dll +a := lib +endif + +#------------- +# platform and configuration specific amendments + +DEFINES += $($(OSTAG)_DEFINES) $($(ARCHTAG)_DEFINES) $($(CFG)_DEFINES) \ + $($(OSTAG)_$(ARCHTAG)_DEFINES) + +INCLUDES += $($(OSTAG)_INCLUDES) $($(ARCHTAG)_INCLUDES) + +CFLAGS += $($(OSTAG)_CFLAGS) $($(ARCHTAG)_CFLAGS) $($(CFG)_CFLAGS) \ + $($(OSTAG)_$(ARCHTAG)_CFLAGS) $($(CFG)_$(OSTAG)_CFLAGS) \ + $($(CFG)_$(OSTAG)_$(CC)_CFLAGS) + +CXXFLAGS += $($(OSTAG)_CXXFLAGS) $($(ARCHTAG)_CXXFLAGS) $($(CFG)_CXXFLAGS) \ + $($(OSTAG)_$(ARCHTAG)_CXXFLAGS) $($(CFG)_$(OSTAG)_CXXFLAGS) \ + $($(CFG)_$(OSTAG)_$(CC)_CXXFLAGS) + +LDFLAGS += $($(OSTAG)_LDFLAGS) $($(ARCHTAG)_LDFLAGS) \ + $($(CFG)_$(OSTAG)_LDFLAGS) + +LIBS += $($(OSTAG)_LIBS) $($(ARCHTAG)_LIBS) \ + $($(CFG)_$(OSTAG)_LIBS) + +LIBDIRS += $($(OSTAG)_LIBDIRS) $($(ARCHTAG)_LIBDIRS) \ + $($(CFG)_$(OSTAG)_LIBDIRS) + +SOURCES += $($(OSTAG)_SOURCES) $($(ARCHTAG)_SOURCES) \ + $($(OSTAG)_$(ARCHTAG)_SOURCES) + +#------------- +# main target + +ifeq ($(TYPE),executable) +PROGRAM := $(NAME)$(exe) +TARGET := $(BIN)/$(PROGRAM) +else ifeq ($(TYPE),shared) +SHARED := $(lib)$(NAME).$(so) +TARGET := $(BIN)/$(SHARED) +else ifeq ($(TYPE),library) +LIBRARY := $(lib)$(NAME).$(a) +TARGET := $(LIB)/$(LIBRARY) +endif + +ifndef TYPE +$(error Makefile must define TYPE = executable | library | shared) +endif + +# additional recursive make invocation is not really needed, +# but it provides for nice messages like '.../libport.a is up to date' +# instead of non-informative 'all is up to date' +.PHONY: all +all: + $(Q)$(MAKE) $(TARGET) + +#------------- +# target dependencies on other targets (static or shared libraries) +ifdef LIBDEPENDS +$(TARGET): $(addprefix $(LIB)/$(lib),$(addsuffix .$(a),$(LIBDEPENDS))) +LIBDIRS += $(LIB) +endif +ifdef SODEPENDS +$(TARGET): $(addprefix $(BIN)/$(lib),$(addsuffix .$(so),$(SODEPENDS))) +LIBDIRS += $(BIN) +endif +# order is important, system libs should be last, static libraries next, +# and shared libraries first, meaning the least priority (last has highest priority) +LIBS := $(SODEPENDS) $(LIBDEPENDS) $(LIBS) +LDLIBS += $(addprefix -l,$(LIBS)) $(addprefix -L,$(LIBDIRS)) + +# FIXME: linux-specific decoration for linker flags passed through cc +LDFLAGS := $(strip $(LDFLAGS)) +ifneq ($(LDFLAGS),) +# ugly workaround for inability to put ',' directly into $(addprefix) +COMMA := , +LDFLAGS := $(addprefix -Wl$(COMMA),$(LDFLAGS)) +endif +#------------- +# compilation flags + +CPPFLAGS := $(addprefix -D,$(DEFINES)) $(addprefix -I,$(INCLUDES)) + +#------------- +# include stored configuration +SOURCES_LIST := $(OBJ)/sources.list +CFLAGS_FILE := $(OBJ)/CFLAGS +CXXFLAGS_FILE := $(OBJ)/CXXFLAGS +LDFLAGS_FILE := $(OBJ)/LDFLAGS +-include $(SOURCES_LIST) +-include $(CFLAGS_FILE) +-include $(CXXFLAGS_FILE) +-include $(LDFLAGS_FILE) +-include $(DEPENDS) + +#------------- +# sources.list and other stored config generation + +# detect the changes in sources by storing a fingerprint (may use hash) +SOURCES := $(strip $(SOURCES)) +ifneq ($(SOURCES),$(OLD_SOURCES)) +#$(warning '$(SOURCES)' != '$(OLD_SOURCES)', regenerating source list...) +# this to force regeneration if source list changed +.PHONY: $(SOURCES_LIST) +endif + +# this is to force relinking if source list changed +$(TARGET): $(SOURCES_LIST) + +$(SOURCES_LIST): Makefile $(MAKEDIR)/gen-sources-list $(OBJ)/.stamp + $(Q)echo "OLD_SOURCES = $(SOURCES)" > $@ + $(QUIET_GEN_SOURCES_LIST)$(MAKEDIR)/gen-sources-list $(SOURCES) >> $@ + +LDFLAGS_CONF := $(strip $(strip $(LDFLAGS)) $(strip $(LDLIBS))) +ifneq ($(LDFLAGS_CONF),$(OLD_LDFLAGS_CONF)) +#$(warning '$(LDFLAGS_CONF)' != '$(OLD_LDFLAGS_CONF)', forcing relink...) +# this is to force relinking if link flags changed +.PHONY: $(LDFLAGS_FILE) +endif + +$(LDFLAGS_FILE): $(OBJ)/.stamp + $(QLDFLAGS)echo "OLD_LDFLAGS_CONF = $(LDFLAGS_CONF)" > $@ + +CFLAGS_CONF := $(strip $(strip $(CFLAGS)) $(strip $(CPPFLAGS))) +ifneq ($(CFLAGS_CONF),$(OLD_CFLAGS_CONF)) +# this is to force recompilation if C flags changed +.PHONY: $(CFLAGS_FILE) +endif + +$(CFLAGS_FILE): $(OBJ)/.stamp + $(QCFLAGS)echo "OLD_CFLAGS_CONF = $(CFLAGS_CONF)" > $@ + +CXXFLAGS_CONF := $(strip $(strip $(CXXFLAGS)) $(strip $(CPPFLAGS))) +ifneq ($(CXXFLAGS_CONF),$(OLD_CXXFLAGS_CONF)) +# this is to force recompilation if C++ flags changed +.PHONY: $(CXXFLAGS_FILE) +endif + +$(CXXFLAGS_FILE): $(OBJ)/.stamp + $(QCXXFLAGS)echo "OLD_CXXFLAGS_CONF = $(CXXFLAGS_CONF)" > $@ + +#------------- +# build rules + +ifeq ($(TYPE),executable) +$(TARGET): $(OBJECTS) $(dir $(TARGET))/.stamp $(LDFLAGS_FILE) + $(QUIET_LD)$(CC) -o $@ $(LDFLAGS) $(OBJECTS) $(LDLIBS) +else ifeq ($(TYPE),shared) +$(TARGET): $(OBJECTS) $(dir $(TARGET))/.stamp $(LDFLAGS_FILE) + $(QUIET_LD)$(CC) -shared -o $@ $(LDFLAGS) $(OBJECTS) $(LDLIBS) +else ifeq ($(TYPE),library) +$(TARGET): $(OBJECTS) $(dir $(TARGET))/.stamp + $(QUIET_AR)$(AR) rcs $@ $(OBJECTS) +endif + +#------------- +# directory and stamp creation rules +%.stamp: + $(Q)mkdir -p $(@D) && touch $@ + +#------------- +# clean and distclean rules + +# make sure compilation does not start before clean is complete +# 'all: ; make $(TARGET)' comes in handy for this trick, +# as it ensures no compilation target will start simultaneously with clean +ifneq ($(filter $(MAKECMDGOALS),clean),) +all: clean +endif +.PHONY: clean +clean: + $(RM) $(TARGET) $(OBJECTS) + +ifneq ($(filter $(MAKECMDGOALS),distclean),) +all: distclean +endif +.PHONY: distclean +distclean: + $(RM) -r $(TARGET) $(OBJ) + +#------------- +# vim:ft=make diff --git build/custom/gnumake/makevars.inc build/custom/gnumake/makevars.inc new file mode 100644 index 0000000..0df37aa --- /dev/null +++ build/custom/gnumake/makevars.inc @@ -0,0 +1,85 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +# This file is included both to the top-level Makefile +# and to the subcomponent Makefiles (via makerules.inc) +# +# All global variabled definitions go here. + +#------------- +# configuration + +CC := gcc +CFG := debug + +# skip shell commands if we already have the identifiers +ifndef OSTAG +# platform identifiers +export OS := $(shell uname -s) +export OSTAG := $(shell echo $(OS) | sed 's/Linux/lnx/; s/Cygwin.*/win/i; s/Windows.*/win/i;') +export ARCH := $(shell uname -m) +export ARCHTAG := $(shell echo $(ARCH) | sed 's/x86_64/em64t/; s/ia64/ipf/; s/i686/ia32/;') +endif + + +ifeq ($(wildcard $(TOP)/vm/vmcore),) +$(error TOP ($(TOP)) must point to the DRLVM source directory) +endif + +# common paths +VM := $(TOP)/vm +BUILD := $(TOP)/build +MAKEDIR := $(TOP)/build/custom/gnumake +SEMIS := $(BUILD)/$(OSTAG)_$(ARCHTAG)_$(CC)_$(CFG)/semis +DEPLOY:= $(BUILD)/$(OSTAG)_$(ARCHTAG)_$(CC)_$(CFG)/deploy + +# include local overrides file +-include $(MAKEDIR)/makelocal.inc +# this is a default, overridable in makelocal.inc +CLASSLIB ?= $(abspath $(TOP)/../classlib) + +# Project-wide build artifact directories, shared between +# subcomponents. +# +BIN := $(SEMIS)/bin +LIB := $(SEMIS)/lib + +# $(OBJ) is subcomponent-specific, defined in makerules.inc + +ifeq ($(wildcard $(CLASSLIB)/deploy/lib),) +$(error CLASSLIB ($(CLASSLIB)) must point to the built classlib workspace) +endif + +#------------- +# provide silent mode unless user runs 'make V=1' +ifeq ($(findstring s,$(MAKEFLAGS)),) +ifndef V + QUIET_CC = @echo 'CC ' $(@F); + QUIET_CXX = @echo 'CXX ' $(@F); + QUIET_LD = @echo 'LD ' $(@F); + QUIET_AS = @echo 'AS ' $(@F); + QUIET_AR = @echo 'AR ' $(@F); + QUIET_GEN_SOURCES_LIST = @echo 'Regenerating $(NAME) source list...'; + QLDFLAGS = @test -f $@ && echo 'new LDFLAGS'; + QCFLAGS = @test -f $@ && echo 'new CFLAGS'; + QCXXFLAGS = @test -f $@ && echo 'new CXXFLAGS'; + MAKEFLAGS += --no-print-directory + Q = @ +endif +endif + +# vim:ft=make diff --git build/custom/gnumake/port/Makefile build/custom/gnumake/port/Makefile new file mode 100644 index 0000000..8d67794 --- /dev/null +++ build/custom/gnumake/port/Makefile @@ -0,0 +1,48 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +NAME = port +TYPE = library + +DEFINES = APR_DECLARE_EXPORT BUILDING_PORTLIB BUILDING_VM +lnx_CXXFLAGS += -fexceptions +lnx_CFLAGS += -fexceptions + +INCLUDES = \ + $(VM)/include \ + $(VM)/port/include \ + $(SEMIS)/extra/apr/include/apr-1 \ + $(SEMIS)/extra/log4cxx/src/include \ + $(CLASSLIB)/deploy/include \ + +VM := ../../../../vm +SOURCES := $(wildcard \ + $(VM)/port/src/logger/*.cpp \ + $(VM)/port/src/tl/*.cpp \ + $(VM)/port/src/time/*.cpp \ +) + +lnx_SOURCES := $(wildcard \ + $(VM)/port/src/disasm/linux/*.c \ + $(VM)/port/src/file_io/linux/*.c \ + $(VM)/port/src/misc/linux/*.c \ + $(VM)/port/src/vmem/linux/*.c \ + $(VM)/port/src/thread/linux/*.c \ + $(VM)/port/src/atomic/linux/*.c \ +) + +include ../makerules.inc diff --git build/custom/gnumake/thread/Makefile build/custom/gnumake/thread/Makefile new file mode 100644 index 0000000..820fa33 --- /dev/null +++ build/custom/gnumake/thread/Makefile @@ -0,0 +1,44 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +NAME = hythr +TYPE = shared + +DEFINES = APR_DECLARE_STATIC + +INCLUDES = \ + $(SEMIS)/extra/apr/include/apr-1 \ + $(VM)/include \ + $(VM)/thread/src \ + $(VM)/port/include \ + $(VM)/port/src/encoder/ia32_em64t \ + +SOURCES = \ + $(wildcard $(VM)/thread/src/*.c) \ + $(wildcard $(VM)/thread/src/linux/*.c) \ + +lnx_LDFLAGS = -init hythread_library_init --version-script,$(VM)/thread/src/hythr.exp +# dependencies on other built libraries +LIBDEPENDS = port +# 3rd-party libraries +LIBS = apr-1 aprutil-1 log4cxx stdc++ rt pthread +LIBDIRS = \ + $(SEMIS)/extra/apr/_bin \ + $(SEMIS)/extra/aprutil/_bin \ + $(SEMIS)/extra/log4cxx/_bin \ + +include ../makerules.inc diff --git build/custom/gnumake/vmcore/Makefile build/custom/gnumake/vmcore/Makefile new file mode 100644 index 0000000..53652f0 --- /dev/null +++ build/custom/gnumake/vmcore/Makefile @@ -0,0 +1,92 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +NAME = harmonyvm +TYPE = shared + +DEFINES = BUILDING_VM USE_DLL_JIT APR_DECLARE_STATIC + +INCLUDES = \ + $(SEMIS)/extra/apr/include/apr-1 \ + $(SEMIS)/extra/log4cxx/src/include \ + $(CLASSLIB)/deploy/include/icu4c \ + $(VM)/include \ + $(VM)/vmcore/src/thread \ + $(VM)/port/include \ + $(VM)/port/src/encoder/ia32_em64t \ + $(VM)/port/src/lil/ia32/pim/include \ + $(VM)/vmcore/src/util/linux/include \ + $(VM)/vmcore/src/util/ia32/base_natives \ + $(VM)/vmcore/include \ + +VM := ../../../../vm +SOURCES := $(wildcard \ + $(VM)/vmcore/src/class_support/*.cpp \ + $(VM)/vmcore/src/exception/*.cpp \ + $(VM)/vmcore/src/init/*.cpp \ + $(VM)/vmcore/src/gc/*.cpp \ + $(VM)/vmcore/src/interpreter/*.cpp \ + $(VM)/vmcore/src/jit/*.cpp \ + $(VM)/vmcore/src/jni/*.cpp \ + $(VM)/vmcore/src/jvmti/*.cpp \ + $(VM)/vmcore/src/object/*.cpp \ + $(VM)/vmcore/src/reflection/*.cpp \ + $(VM)/vmcore/src/stack/*.cpp \ + $(VM)/vmcore/src/thread/*.cpp \ + $(VM)/vmcore/src/util/*.cpp \ + $(VM)/vmcore/src/verifier-3363/*/*.cpp \ + $(VM)/vmcore/src/kernel_classes/native/*.cpp \ + $(VM)/port/src/lil/*.cpp \ + $(VM)/port/src/lil/pim/*.cpp \ + $(VM)/port/src/lil/ia32/pim/*.cpp \ + $(VM)/vmstart/src/compmgr/*.cpp \ + $(VM)/vmcore/src/util/ia32/base/*.cpp \ + $(VM)/vmcore/src/util/ia32/base_natives/*.cpp \ + $(VM)/vmcore/src/thread/linux/*.cpp \ + $(VM)/vmcore/src/util/linux/os_wrapper.cpp \ + $(VM)/vmcore/src/util/linux/stubs.cpp \ + $(VM)/vmcore/src/util/linux/crash_handler.cpp \ + $(VM)/vmcore/src/util/linux/native_modules.cpp \ + $(VM)/vmcore/src/util/linux/signals_ia32.cpp \ + $(VM)/vmcore/src/util/linux/native_modules_ia32.cpp \ + $(VM)/vmcore/src/util/ia32/base/*.asm \ + $(VM)/vmcore/src/thread/helpers/thread_helpers.cpp \ + $(VM)/vmcore/src/thread/helpers/thread_helpers_ia32.cpp \ +) + +ia32_SOURCES := $(filter %_ia32.cpp %_ia32.asm,$(SOURCES)) +ipf_SOURCES := $(filter %_ipf.cpp %_ipf.asm,$(SOURCES)) +em64t_SOURCES := $(filter %_em64t.cpp,$(SOURCES)) +win_SOURCES := $(filter %_win.cpp,$(SOURCES)) +SOURCES := $(filter-out $(ipf_SOURCES) $(em64t_SOURCES) $(ia32_SOURCES),$(SOURCES)) +SOURCES := $(filter-out $(win_SOURCES),$(SOURCES)) + +lnx_LDFLAGS = --export-dynamic +LIBDEPENDS = port encoder +SODEPENDS = hythr +LIBS = log4cxx aprutil-1 apr-1 icuuc +LIBDIRS = \ + $(SEMIS)/extra/apr/_bin \ + $(SEMIS)/extra/aprutil/_bin \ + $(SEMIS)/extra/log4cxx/_bin \ + +lnx_LIBDIRS = \ + $(CLASSLIB)/depends/libs/linux.x86 \ + +lnx_LIBS = stdc++ rt m dl z xml2 pthread gcc_s + +include ../makerules.inc diff --git build/custom/gnumake/vmi/Makefile build/custom/gnumake/vmi/Makefile new file mode 100644 index 0000000..1de1db2 --- /dev/null +++ build/custom/gnumake/vmi/Makefile @@ -0,0 +1,39 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +NAME = vmi +TYPE = shared + +DEFINES = + +INCLUDES = \ + $(SEMIS)/extra/apr/include/apr-1 \ + $(CLASSLIB)/deploy/include \ + $(VM)/port/include \ + $(VM)/include \ + $(VM)/vmcore/include \ + $(VM)/vmcore/src/util/linux/include \ + +SOURCES = \ + $(wildcard $(VM)/vmi/src/*.cpp) \ + +lnx_LDFLAGS = --version-script,$(VM)/vmi/src/vmi.exp +SODEPENDS = harmonyvm +LIBS = hyzip hypool +LIBDIRS = $(CLASSLIB)/deploy/lib + +include ../makerules.inc