Defs-java.gmk 8.5 KB
Newer Older
D
duke 已提交
1
#
2
# Copyright (c) 2007, 2012, Oracle and/or its affiliates. All rights reserved.
D
duke 已提交
3 4 5 6
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License version 2 only, as
7
# published by the Free Software Foundation.  Oracle designates this
D
duke 已提交
8
# particular file as subject to the "Classpath" exception as provided
9
# by Oracle in the LICENSE file that accompanied this code.
D
duke 已提交
10 11 12 13 14 15 16 17 18 19 20
#
# This code is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
# version 2 for more details (a copy is included in the LICENSE file that
# accompanied this code).
#
# You should have received a copy of the GNU General Public License version
# 2 along with this work; if not, write to the Free Software Foundation,
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
#
21 22 23
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
# or visit www.oracle.com if you need additional information or have any
# questions.
D
duke 已提交
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
#

#
# Common java/javac/jdk variables used by all the Java makefiles.
# This file should not contain rules.
#

# WARNING: This file is shared with other workspaces.
#          So when it includes other files, it must use JDK_TOPDIR.
#

#
# Memory related -J flags that all uses of java tools should use.
#
JAVA_MEM_FLAGS   = -Xmx$(MAX_VM_MEMORY)m
ifeq ($(ARCH), ia64)
  # Special flags for javac on ia64 to work around a VM problem with
  #   bad code generation during inlining (what version had this problem?):
  #   Suspect this may not be needed anymore.
  JAVA_MEM_FLAGS   += -Xms$(MAX_VM_MEMORY)m -XX:-Inline
else
  JAVA_MEM_FLAGS   += -Xms$(MIN_VM_MEMORY)m -XX:PermSize=32m -XX:MaxPermSize=160m
endif

48
#
D
duke 已提交
49 50 51 52 53 54 55 56 57 58 59 60 61
# All java tools (javac, javah, and javadoc) run faster with certain java
#    options, this macro should be used with all these tools.
#    In particular, the client VM makes these tools run faster when
#    it's available.
#
ADD_CLIENT_VM_OPTION = false
ifeq ($(PLATFORM), solaris)
  ADD_CLIENT_VM_OPTION = true
else
  ifeq ($(ARCH_DATA_MODEL), 32)
    ADD_CLIENT_VM_OPTION = true
  endif
endif
62 63 64 65 66 67 68

# Options for hotspot to turn off printing of options with fastdebug version
#   and creating the hotspot.log file.
JAVA_HOTSPOT_DISABLE_PRINT_VMOPTIONS = \
   -XX:-PrintVMOptions -XX:+UnlockDiagnosticVMOptions -XX:-LogVMOutput

# JVM options
69 70 71 72 73
ifeq ($(PLATFORM), macosx)
  JAVA_JVM_FLAGS = $(JAVA_HOTSPOT_DISABLE_PRINT_VMOPTIONS) -Djava.awt.headless=true
else
  JAVA_JVM_FLAGS = $(JAVA_HOTSPOT_DISABLE_PRINT_VMOPTIONS)
endif
74

D
duke 已提交
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
ifeq ($(ADD_CLIENT_VM_OPTION), true)
  JAVA_JVM_FLAGS += -client
endif
ifdef USE_HOTSPOT_INTERPRETER_MODE
  JAVA_JVM_FLAGS += -Xint
endif

# Various VM flags
JAVA_TOOLS_FLAGS  = $(JAVA_JVM_FLAGS) $(JAVA_MEM_FLAGS)

# The VM flags for javac
JAVAC_JVM_FLAGS =

# 64-bit builds require a larger thread stack size.
ifeq ($(ARCH_DATA_MODEL), 32)
  JAVAC_JVM_FLAGS    += -J-XX:ThreadStackSize=768
else
  JAVAC_JVM_FLAGS    += -J-XX:ThreadStackSize=1536
endif
JAVAC_JVM_FLAGS    += $(JAVA_TOOLS_FLAGS:%=-J%)

# The jar -J options are special, must be added at the end of the command line
JAR_JFLAGS       = $(JAVA_TOOLS_FLAGS:%=-J%)

# JAVA_TOOLS_DIR is the default location to find Java tools to run, if
#    langtools is not available.
#    This should be the latest promoted JDK javac.
ifndef JAVA_TOOLS_DIR
  JAVA_TOOLS_DIR = $(JDK_IMPORT_PATH)/bin
endif

#
# Invoking the Java compiler.   In leaf makefiles, choose as follows:
#  -- Use JAVAC if you want to take full control of what options get
#     passed to javac.
#  -- Use JAVAC_CMD if you want to take the defaults given to you.
#

ifndef DEBUG_CLASSFILES
  ifeq ($(VARIANT), DBG)
    DEBUG_CLASSFILES = true
  endif
endif
JAVACFLAGS =
ifeq ($(DEBUG_CLASSFILES),true)
  JAVACFLAGS += -g
endif
122
ifeq ($(JAVAC_MAX_WARNINGS), true)
123
  JAVAC_LINT_OPTIONS += -Xlint:all
124 125
endif
ifeq ($(JAVAC_WARNINGS_FATAL), true)
D
duke 已提交
126 127 128
  JAVACFLAGS  += -Werror
endif

129 130 131 132 133
# TODO: Workaround for CR 7063027. Remove -path eventually.
JAVAC_LINT_OPTIONS += -Xlint:-path

JAVACFLAGS += $(JAVAC_LINT_OPTIONS)

134 135 136 137 138 139 140 141
#
# Some licensees do not get the Security Source bundles.  We will
# fall back on the prebuilt jce.jar so that we can do a best
# attempt at building.  If sources exist, we always want to
# build/use the most recent source instead of an older jce.jar, whether
# built implicitly/explicitly.
#
ifeq ($(wildcard $(SHARE_SRC)/classes/javax/crypto/Cipher.java),)
142
  JCE_PATH = $(CLASSPATH_SEPARATOR)$(LIBDIR)/jce.jar
143 144
endif

145 146
# Add the source level
SOURCE_LANGUAGE_VERSION = 7
147
LANGUAGE_VERSION = -source $(SOURCE_LANGUAGE_VERSION)
D
duke 已提交
148 149
JAVACFLAGS  += $(LANGUAGE_VERSION)

150 151
# Add the class version we want
TARGET_CLASS_VERSION = 7
D
duke 已提交
152 153 154
CLASS_VERSION = -target $(TARGET_CLASS_VERSION)
JAVACFLAGS  += $(CLASS_VERSION)
JAVACFLAGS  += -encoding ascii
155
JAVACFLAGS  += "-Xbootclasspath:$(CLASSBINDIR)$(JCE_PATH)"
D
duke 已提交
156 157 158
JAVACFLAGS  += $(OTHER_JAVACFLAGS)

# Needed for javah
159
JAVAHFLAGS += -bootclasspath "$(CLASSBINDIR)$(JCE_PATH)"
D
duke 已提交
160

161 162 163 164
# Needed for javadoc to ensure it builds documentation
# against the newly built classes
JAVADOCFLAGS += -bootclasspath $(CLASSBINDIR)

165 166 167
# Needed for JAVADOC and BOOT_JAVACFLAGS
NO_PROPRIETARY_API_WARNINGS = -XDignore.symbol.file=true

D
duke 已提交
168 169 170 171 172 173 174 175 176 177
# Langtools
ifdef LANGTOOLS_DIST
  JAVAC_JAR   = $(LANGTOOLS_DIST)/bootstrap/lib/javac.jar
  JAVAH_JAR   = $(LANGTOOLS_DIST)/bootstrap/lib/javah.jar
  JAVADOC_JAR = $(LANGTOOLS_DIST)/bootstrap/lib/javadoc.jar
  DOCLETS_JAR = $(LANGTOOLS_DIST)/bootstrap/lib/doclets.jar
  JAVAC_CMD   = $(BOOT_JAVA_CMD) \
		"-Xbootclasspath/p:$(JAVAC_JAR)" \
		-jar $(JAVAC_JAR) $(JAVACFLAGS)
  JAVAH_CMD   = $(BOOT_JAVA_CMD) \
178
		"-Xbootclasspath/p:$(JAVAH_JAR)$(CLASSPATH_SEPARATOR)$(JAVAC_JAR)"  \
D
duke 已提交
179 180 181
		-jar $(JAVAH_JAR) $(JAVAHFLAGS)
  JAVADOC_CMD = $(BOOT_JAVA_CMD) \
		"-Xbootclasspath/p:$(JAVADOC_JAR)$(CLASSPATH_SEPARATOR)$(JAVAC_JAR)$(CLASSPATH_SEPARATOR)$(DOCLETS_JAR)" \
182
		-jar $(JAVADOC_JAR) $(JAVADOCFLAGS)
D
duke 已提交
183 184 185 186 187 188
else
  # If no explicit tools, use boot tools (add VM flags in this case)
  JAVAC_CMD     = $(JAVA_TOOLS_DIR)/javac $(JAVAC_JVM_FLAGS) \
		  $(JAVACFLAGS)
  JAVAH_CMD     = $(JAVA_TOOLS_DIR)/javah \
		  $(JAVAHFLAGS)
189 190
  JAVADOC_CMD   = $(JAVA_TOOLS_DIR)/javadoc $(JAVA_TOOLS_FLAGS:%=-J%) \
  		  $(JAVADOCFLAGS)
D
duke 已提交
191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222
endif

# Override of what javac to use (see deploy workspace)
ifdef JAVAC
  JAVAC_CMD     = $(JAVAC)
endif

#
# The bootstrap java compiler (defined as the javac in the ALT_BOOTDIR jdk).
#   Will be used to compile java code used to build the jdk, e.g. class files
#   created by this compiler will NOT become part of this built jdk, but just
#   used to build this jdk, e.g. run with the java in the ALT_BOOTDIR jdk.
#
# The javac supplied with the LANGTOOLS_DIST should be used to build the
#   classes that will be put into the built jdk. But note that this javac
#   will use the ALT_BOOTDIR java runtime. Any classes created by the
#   LANGTOOLS_DIST javac should not be run during this jdk build and indeed
#   may not even run with the ALT_BOOTDIR jdk because they may be a newer
#   class file version that the ALT_BOOTDIR jdk doesn't understand.
#
# The important observation here is that the built jdk is NOT run during
#   the build. If the built jdk needs to be verified that it can build this
#   same jdk, then it should be supplied to the build process as the ALT_BOOTDIR
#   jdk, and this resulting built jdk should be compared to the first one.
#   (They should be the same). Re-using this built jdk as the ALT_BOOTDIR
#   jdk will be the only way and the recommeneded way to verify the built jdk
#   can bootstrap itself.
#

# The javac options supplied to the boot javac is limited. This compiler
#   should only be used to build the 'make/tools' sources, which are not
#   class files that end up in the classes directory.
223
BOOT_JAVACFLAGS += $(JAVAC_LINT_OPTIONS)
224
ifeq ($(JAVAC_WARNINGS_FATAL), true)
D
duke 已提交
225 226
  BOOT_JAVACFLAGS  += -Werror
endif
227

J
jjg 已提交
228
BOOT_JAVACFLAGS  += -encoding ascii
229
BOOT_JAR_JFLAGS += $(JAR_JFLAGS)
D
duke 已提交
230

231 232
BOOT_JAVACFLAGS  += $(NO_PROPRIETARY_API_WARNINGS)

D
duke 已提交
233 234 235 236 237 238 239 240 241 242 243 244 245
BOOT_JAVA_CMD      = $(BOOTDIR)/bin/java $(JAVA_TOOLS_FLAGS)
BOOT_JAVAC_CMD     = $(BOOTDIR)/bin/javac $(JAVAC_JVM_FLAGS) $(BOOT_JAVACFLAGS)
BOOT_JAR_CMD       = $(BOOTDIR)/bin/jar
BOOT_JARSIGNER_CMD = $(BOOTDIR)/bin/jarsigner

# Various tools we need to run (FIXUP: Are these the right ones?)
NATIVE2ASCII    = $(BOOTDIR)/bin/native2ascii $(JAVA_TOOLS_FLAGS:%=-J%)
RMIC		= $(BOOTDIR)/bin/rmic $(JAVA_TOOLS_FLAGS:%=-J%)
IDLJ		= $(BOOTDIR)/bin/idlj $(JAVA_TOOLS_FLAGS:%=-J%)

# Should not be used
JAVA		= /should/not/be/used