make/linux/makefiles/vm.make

Wed, 15 Dec 2010 05:43:54 -0800

author
stefank
date
Wed, 15 Dec 2010 05:43:54 -0800
changeset 2368
e7ad5f6f4d29
parent 2326
2968675b413e
child 2508
b92c45f2bc75
permissions
-rw-r--r--

7006659: temporary adlc files are added to the build variables
Summary: Don't recurse into sub-directories when looking for source files.
Reviewed-by: never, brutisso

duke@435 1 #
twisti@2047 2 # Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved.
duke@435 3 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
duke@435 4 #
duke@435 5 # This code is free software; you can redistribute it and/or modify it
duke@435 6 # under the terms of the GNU General Public License version 2 only, as
duke@435 7 # published by the Free Software Foundation.
duke@435 8 #
duke@435 9 # This code is distributed in the hope that it will be useful, but WITHOUT
duke@435 10 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
duke@435 11 # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
duke@435 12 # version 2 for more details (a copy is included in the LICENSE file that
duke@435 13 # accompanied this code).
duke@435 14 #
duke@435 15 # You should have received a copy of the GNU General Public License version
duke@435 16 # 2 along with this work; if not, write to the Free Software Foundation,
duke@435 17 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
duke@435 18 #
trims@1907 19 # Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
trims@1907 20 # or visit www.oracle.com if you need additional information or have any
trims@1907 21 # questions.
duke@435 22 #
duke@435 23 #
duke@435 24
duke@435 25 # Rules to build JVM and related libraries, included from vm.make in the build
duke@435 26 # directory.
duke@435 27
duke@435 28 # Common build rules.
kamg@526 29 MAKEFILES_DIR=$(GAMMADIR)/make/$(Platform_os_family)/makefiles
duke@435 30 include $(MAKEFILES_DIR)/rules.make
duke@435 31
duke@435 32 default: build
duke@435 33
duke@435 34 #----------------------------------------------------------------------
duke@435 35 # Defs
duke@435 36
duke@435 37 GENERATED = ../generated
stefank@2314 38 DEP_DIR = $(GENERATED)/dependencies
duke@435 39
stefank@2314 40 # reads the generated files defining the set of .o's and the .o .h dependencies
stefank@2314 41 -include $(DEP_DIR)/*.d
duke@435 42
duke@435 43 # read machine-specific adjustments (%%% should do this via buildtree.make?)
never@1445 44 ifeq ($(ZERO_BUILD), true)
never@1445 45 include $(MAKEFILES_DIR)/zeroshark.make
never@1445 46 else
never@1445 47 include $(MAKEFILES_DIR)/$(BUILDARCH).make
never@1445 48 endif
duke@435 49
duke@435 50 # set VPATH so make knows where to look for source files
stefank@2314 51 # Src_Dirs_V is everything in src/share/vm/*, plus the right os/*/vm and cpu/*/vm
duke@435 52 # The adfiles directory contains ad_<arch>.[ch]pp.
duke@435 53 # The jvmtifiles directory contains jvmti*.[ch]pp
stefank@2314 54 Src_Dirs_V += $(GENERATED)/adfiles $(GENERATED)/jvmtifiles
stefank@2314 55 VPATH += $(Src_Dirs_V:%=%:)
duke@435 56
stefank@2314 57 # set INCLUDES for C preprocessor.
stefank@2314 58 Src_Dirs_I += $(GENERATED)
stefank@2314 59 # The order is important for the precompiled headers to work.
stefank@2314 60 INCLUDES += $(PRECOMPILED_HEADER_DIR:%=-I%) $(Src_Dirs_I:%=-I%)
duke@435 61
duke@435 62 ifeq (${VERSION}, debug)
duke@435 63 SYMFLAG = -g
duke@435 64 else
duke@435 65 SYMFLAG =
duke@435 66 endif
duke@435 67
duke@435 68 # HOTSPOT_RELEASE_VERSION and HOTSPOT_BUILD_VERSION are defined
duke@435 69 # in $(GAMMADIR)/make/defs.make
duke@435 70 ifeq ($(HOTSPOT_BUILD_VERSION),)
duke@435 71 BUILD_VERSION = -DHOTSPOT_RELEASE_VERSION="\"$(HOTSPOT_RELEASE_VERSION)\""
duke@435 72 else
duke@435 73 BUILD_VERSION = -DHOTSPOT_RELEASE_VERSION="\"$(HOTSPOT_RELEASE_VERSION)-$(HOTSPOT_BUILD_VERSION)\""
duke@435 74 endif
duke@435 75
duke@435 76 # The following variables are defined in the generated flags.make file.
duke@435 77 BUILD_VERSION = -DHOTSPOT_RELEASE_VERSION="\"$(HS_BUILD_VER)\""
duke@435 78 JRE_VERSION = -DJRE_RELEASE_VERSION="\"$(JRE_RELEASE_VER)\""
jrose@535 79 HS_LIB_ARCH = -DHOTSPOT_LIB_ARCH=\"$(LIBARCH)\"
duke@435 80 BUILD_TARGET = -DHOTSPOT_BUILD_TARGET="\"$(TARGET)\""
duke@435 81 BUILD_USER = -DHOTSPOT_BUILD_USER="\"$(HOTSPOT_BUILD_USER)\""
duke@435 82 VM_DISTRO = -DHOTSPOT_VM_DISTRO="\"$(HOTSPOT_VM_DISTRO)\""
duke@435 83
duke@435 84 CPPFLAGS = \
duke@435 85 ${SYSDEFS} \
duke@435 86 ${INCLUDES} \
duke@435 87 ${BUILD_VERSION} \
duke@435 88 ${BUILD_TARGET} \
duke@435 89 ${BUILD_USER} \
jrose@535 90 ${HS_LIB_ARCH} \
duke@435 91 ${JRE_VERSION} \
duke@435 92 ${VM_DISTRO}
duke@435 93
duke@435 94 # CFLAGS_WARN holds compiler options to suppress/enable warnings.
duke@435 95 CFLAGS += $(CFLAGS_WARN/BYFILE)
duke@435 96
duke@435 97 # Do not use C++ exception handling
duke@435 98 CFLAGS += $(CFLAGS/NOEX)
duke@435 99
duke@435 100 # Extra flags from gnumake's invocation or environment
duke@435 101 CFLAGS += $(EXTRA_CFLAGS)
bobv@2036 102 LFLAGS += $(EXTRA_CFLAGS)
duke@435 103
duke@435 104 LIBS += -lm -ldl -lpthread
duke@435 105
duke@435 106 # By default, link the *.o into the library, not the executable.
duke@435 107 LINK_INTO$(LINK_INTO) = LIBJVM
duke@435 108
duke@435 109 JDK_LIBDIR = $(JAVA_HOME)/jre/lib/$(LIBARCH)
duke@435 110
duke@435 111 #----------------------------------------------------------------------
duke@435 112 # jvm_db & dtrace
duke@435 113 include $(MAKEFILES_DIR)/dtrace.make
duke@435 114
duke@435 115 #----------------------------------------------------------------------
duke@435 116 # JVM
duke@435 117
phh@1558 118 JVM = jvm
phh@1558 119 LIBJVM = lib$(JVM).so
phh@1558 120 LIBJVM_G = lib$(JVM)$(G_SUFFIX).so
duke@435 121
stefank@2314 122 CORE_PATHS := $(shell find $(GAMMADIR)/src/share/vm/* -type d \! \( -name adlc -o -name c1 -o -name gc_implementation -o -name opto -o -name shark -o -name libadt \))
stefank@2314 123 CORE_PATHS += $(GAMMADIR)/src/os/$(Platform_os_family)/vm
stefank@2314 124 CORE_PATHS += $(GAMMADIR)/src/cpu/$(Platform_arch)/vm
stefank@2314 125 CORE_PATHS += $(GAMMADIR)/src/os_cpu/$(Platform_os_arch)/vm
stefank@2314 126 CORE_PATHS += $(GENERATED)/jvmtifiles
stefank@2314 127
stefank@2314 128 COMPILER1_PATHS := $(GAMMADIR)/src/share/vm/c1
stefank@2314 129
stefank@2314 130 COMPILER2_PATHS := $(GAMMADIR)/src/share/vm/opto
stefank@2314 131 COMPILER2_PATHS += $(GAMMADIR)/src/share/vm/libadt
stefank@2314 132 COMPILER2_PATHS += $(GENERATED)/adfiles
stefank@2314 133
stefank@2314 134 # Include dirs per type.
stefank@2314 135 Src_Dirs/CORE := $(CORE_PATHS)
stefank@2314 136 Src_Dirs/COMPILER1 := $(CORE_PATHS) $(COMPILER1_PATHS)
stefank@2314 137 Src_Dirs/COMPILER2 := $(CORE_PATHS) $(COMPILER2_PATHS)
stefank@2314 138 Src_Dirs/TIERED := $(CORE_PATHS) $(COMPILER1_PATHS) $(COMPILER2_PATHS)
stefank@2314 139 Src_Dirs/ZERO := $(CORE_PATHS)
stefank@2314 140 Src_Dirs/SHARK := $(CORE_PATHS)
stefank@2314 141 Src_Dirs := $(Src_Dirs/$(TYPE))
stefank@2314 142
stefank@2314 143 COMPILER2_SPECIFIC_FILES := opto libadt bcEscapeAnalyzer.cpp chaitin\* c2_\* runtime_\*
stefank@2314 144 COMPILER1_SPECIFIC_FILES := c1_\*
stefank@2314 145 SHARK_SPECIFIC_FILES := shark
stefank@2314 146 ZERO_SPECIFIC_FILES := zero
stefank@2314 147
stefank@2314 148 # Always exclude these.
stefank@2314 149 Src_Files_EXCLUDE := jsig.c jvmtiEnvRecommended.cpp jvmtiEnvStub.cpp
stefank@2314 150
stefank@2314 151 # Exclude per type.
stefank@2314 152 Src_Files_EXCLUDE/CORE := $(COMPILER1_SPECIFIC_FILES) $(COMPILER2_SPECIFIC_FILES) $(ZERO_SPECIFIC_FILES) $(SHARK_SPECIFIC_FILES) ciTypeFlow.cpp
stefank@2314 153 Src_Files_EXCLUDE/COMPILER1 := $(COMPILER2_SPECIFIC_FILES) $(ZERO_SPECIFIC_FILES) $(SHARK_SPECIFIC_FILES) ciTypeFlow.cpp
stefank@2314 154 Src_Files_EXCLUDE/COMPILER2 := $(COMPILER1_SPECIFIC_FILES) $(ZERO_SPECIFIC_FILES) $(SHARK_SPECIFIC_FILES)
stefank@2314 155 Src_Files_EXCLUDE/TIERED := $(ZERO_SPECIFIC_FILES) $(SHARK_SPECIFIC_FILES)
stefank@2314 156 Src_Files_EXCLUDE/ZERO := $(COMPILER1_SPECIFIC_FILES) $(COMPILER2_SPECIFIC_FILES) $(SHARK_SPECIFIC_FILES) ciTypeFlow.cpp
stefank@2314 157 Src_Files_EXCLUDE/SHARK := $(COMPILER1_SPECIFIC_FILES) $(COMPILER2_SPECIFIC_FILES) $(ZERO_SPECIFIC_FILES)
stefank@2314 158
stefank@2314 159 Src_Files_EXCLUDE += $(Src_Files_EXCLUDE/$(TYPE))
stefank@2314 160
stefank@2314 161 # Special handling of arch model.
stefank@2314 162 ifeq ($(Platform_arch_model), x86_32)
stefank@2314 163 Src_Files_EXCLUDE += \*x86_64\*
stefank@2314 164 endif
stefank@2314 165 ifeq ($(Platform_arch_model), x86_64)
stefank@2314 166 Src_Files_EXCLUDE += \*x86_32\*
stefank@2314 167 endif
stefank@2314 168
stefank@2314 169 # Locate all source files in the given directory, excluding files in Src_Files_EXCLUDE.
stefank@2314 170 define findsrc
stefank@2368 171 $(notdir $(shell find $(1)/. ! -name . -prune \
stefank@2368 172 -a \( -name \*.c -o -name \*.cpp -o -name \*.s \) \
stefank@2368 173 -a ! \( -name DUMMY $(addprefix -o -name ,$(Src_Files_EXCLUDE)) \)))
stefank@2314 174 endef
stefank@2314 175
stefank@2314 176 Src_Files := $(foreach e,$(Src_Dirs),$(call findsrc,$(e)))
stefank@2314 177
stefank@2326 178 Obj_Files = $(sort $(addsuffix .o,$(basename $(Src_Files))))
stefank@2314 179
duke@435 180 JVM_OBJ_FILES = $(Obj_Files)
duke@435 181
duke@435 182 vm_version.o: $(filter-out vm_version.o,$(JVM_OBJ_FILES))
duke@435 183
never@1729 184 mapfile : $(MAPFILE) vm.def
duke@435 185 rm -f $@
never@1729 186 awk '{ if ($$0 ~ "INSERT VTABLE SYMBOLS HERE") \
never@1729 187 { system ("cat vm.def"); } \
never@1729 188 else \
never@1729 189 { print $$0 } \
never@1729 190 }' > $@ < $(MAPFILE)
duke@435 191
duke@435 192 mapfile_reorder : mapfile $(REORDERFILE)
duke@435 193 rm -f $@
duke@435 194 cat $^ > $@
duke@435 195
never@1729 196 vm.def: $(Res_Files) $(Obj_Files)
never@1729 197 sh $(GAMMADIR)/make/linux/makefiles/build_vm_def.sh *.o > $@
never@1729 198
twisti@2047 199 ifeq ($(SHARK_BUILD), true)
never@1445 200 STATIC_CXX = false
never@1445 201 else
twisti@2047 202 ifeq ($(ZERO_LIBARCH), ppc64)
twisti@2047 203 STATIC_CXX = false
twisti@2047 204 else
twisti@2047 205 STATIC_CXX = true
twisti@2047 206 endif
never@1445 207 endif
duke@435 208
duke@435 209 ifeq ($(LINK_INTO),AOUT)
duke@435 210 LIBJVM.o =
duke@435 211 LIBJVM_MAPFILE =
duke@435 212 LIBS_VM = $(LIBS)
duke@435 213 else
duke@435 214 LIBJVM.o = $(JVM_OBJ_FILES)
duke@435 215 LIBJVM_MAPFILE$(LDNOMAP) = mapfile_reorder
duke@435 216 LFLAGS_VM$(LDNOMAP) += $(MAPFLAG:FILENAME=$(LIBJVM_MAPFILE))
duke@435 217 LFLAGS_VM += $(SONAMEFLAG:SONAME=$(LIBJVM))
duke@435 218
duke@435 219 # JVM is statically linked with libgcc[_s] and libstdc++; this is needed to
duke@435 220 # get around library dependency and compatibility issues. Must use gcc not
duke@435 221 # g++ to link.
duke@435 222 ifeq ($(STATIC_CXX), true)
duke@435 223 LFLAGS_VM += $(STATIC_LIBGCC)
duke@435 224 LIBS_VM += $(STATIC_STDCXX)
duke@435 225 else
duke@435 226 LIBS_VM += -lstdc++
duke@435 227 endif
duke@435 228
duke@435 229 LIBS_VM += $(LIBS)
duke@435 230 endif
never@1445 231 ifeq ($(ZERO_BUILD), true)
never@1445 232 LIBS_VM += $(LIBFFI_LIBS)
never@1445 233 endif
twisti@2047 234 ifeq ($(SHARK_BUILD), true)
twisti@2047 235 LFLAGS_VM += $(LLVM_LDFLAGS)
twisti@2047 236 LIBS_VM += $(LLVM_LIBS)
twisti@2047 237 endif
duke@435 238
duke@435 239 LINK_VM = $(LINK_LIB.c)
duke@435 240
duke@435 241 # rule for building precompiled header
stefank@2314 242 $(PRECOMPILED_HEADER):
duke@435 243 $(QUIETLY) echo Generating precompiled header $@
stefank@2314 244 $(QUIETLY) mkdir -p $(PRECOMPILED_HEADER_DIR)
stefank@2314 245 $(QUIETLY) $(COMPILE.CC) $(DEPFLAGS) -x c++-header $(PRECOMPILED_HEADER_SRC) -o $@ $(COMPILE_DONE)
duke@435 246
duke@435 247 # making the library:
duke@435 248
duke@435 249 ifneq ($(JVM_BASE_ADDR),)
duke@435 250 # By default shared library is linked at base address == 0. Modify the
duke@435 251 # linker script if JVM prefers a different base location. It can also be
duke@435 252 # implemented with 'prelink -r'. But 'prelink' is not (yet) available on
duke@435 253 # our build platform (AS-2.1).
duke@435 254 LD_SCRIPT = libjvm.so.lds
duke@435 255 $(LD_SCRIPT): $(LIBJVM_MAPFILE)
duke@435 256 $(QUIETLY) { \
duke@435 257 rm -rf $@; \
duke@435 258 $(LINK_VM) -Wl,--verbose $(LFLAGS_VM) 2>&1 | \
duke@435 259 sed -e '/^======/,/^======/!d' \
duke@435 260 -e '/^======/d' \
duke@435 261 -e 's/0\( + SIZEOF_HEADERS\)/$(JVM_BASE_ADDR)\1/' \
duke@435 262 > $@; \
duke@435 263 }
duke@435 264 LD_SCRIPT_FLAG = -Wl,-T,$(LD_SCRIPT)
duke@435 265 endif
duke@435 266
duke@435 267 # With more recent Redhat releases (or the cutting edge version Fedora), if
duke@435 268 # SELinux is configured to be enabled, the runtime linker will fail to apply
duke@435 269 # the text relocation to libjvm.so considering that it is built as a non-PIC
duke@435 270 # DSO. To workaround that, we run chcon to libjvm.so after it is built. See
duke@435 271 # details in bug 6538311.
duke@435 272 $(LIBJVM): $(LIBJVM.o) $(LIBJVM_MAPFILE) $(LD_SCRIPT)
duke@435 273 $(QUIETLY) { \
duke@435 274 echo Linking vm...; \
duke@435 275 $(LINK_LIB.CC/PRE_HOOK) \
duke@435 276 $(LINK_VM) $(LD_SCRIPT_FLAG) \
duke@435 277 $(LFLAGS_VM) -o $@ $(LIBJVM.o) $(LIBS_VM); \
duke@435 278 $(LINK_LIB.CC/POST_HOOK) \
duke@435 279 rm -f $@.1; ln -s $@ $@.1; \
phh@1558 280 [ -f $(LIBJVM_G) ] || { ln -s $@ $(LIBJVM_G); ln -s $@.1 $(LIBJVM_G).1; }; \
bobv@2036 281 if [ \"$(CROSS_COMPILE_ARCH)\" = \"\" ] ; then \
bobv@2036 282 if [ -x /usr/sbin/selinuxenabled ] ; then \
bobv@2036 283 /usr/sbin/selinuxenabled; \
bobv@2036 284 if [ $$? = 0 ] ; then \
bobv@2036 285 /usr/bin/chcon -t textrel_shlib_t $@; \
bobv@2036 286 if [ $$? != 0 ]; then \
bobv@2036 287 echo "ERROR: Cannot chcon $@"; \
bobv@2036 288 fi \
bobv@2036 289 fi \
bobv@2036 290 fi \
bobv@2036 291 fi \
duke@435 292 }
duke@435 293
duke@435 294 DEST_JVM = $(JDK_LIBDIR)/$(VM_SUBDIR)/$(LIBJVM)
duke@435 295
duke@435 296 install_jvm: $(LIBJVM)
duke@435 297 @echo "Copying $(LIBJVM) to $(DEST_JVM)"
duke@435 298 $(QUIETLY) cp -f $(LIBJVM) $(DEST_JVM) && echo "Done"
duke@435 299
duke@435 300 #----------------------------------------------------------------------
duke@435 301 # Other files
duke@435 302
duke@435 303 # Gamma launcher
duke@435 304 include $(MAKEFILES_DIR)/launcher.make
duke@435 305
duke@435 306 # Signal interposition library
duke@435 307 include $(MAKEFILES_DIR)/jsig.make
duke@435 308
duke@435 309 # Serviceability agent
duke@435 310 include $(MAKEFILES_DIR)/saproc.make
duke@435 311
duke@435 312 #----------------------------------------------------------------------
duke@435 313
stefank@2314 314 build: $(LIBJVM) $(LAUNCHER) $(LIBJSIG) $(LIBJVM_DB) $(BUILDLIBSAPROC)
duke@435 315
duke@435 316 install: install_jvm install_jsig install_saproc
duke@435 317
duke@435 318 .PHONY: default build install install_jvm

mercurial