1 #
   2 # Copyright (c) 1995, 2010, Oracle and/or its affiliates. All rights reserved.
   3 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4 #
   5 # This code is free software; you can redistribute it and/or modify it
   6 # under the terms of the GNU General Public License version 2 only, as
   7 # published by the Free Software Foundation.  Oracle designates this
   8 # particular file as subject to the "Classpath" exception as provided
   9 # by Oracle in the LICENSE file that accompanied this code.
  10 #
  11 # This code is distributed in the hope that it will be useful, but WITHOUT
  12 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13 # FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14 # version 2 for more details (a copy is included in the LICENSE file that
  15 # accompanied this code).
  16 #
  17 # You should have received a copy of the GNU General Public License version
  18 # 2 along with this work; if not, write to the Free Software Foundation,
  19 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20 #
  21 # Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22 # or visit www.oracle.com if you need additional information or have any
  23 # questions.
  24 #
  25 
  26 #
  27 # Common java/javac/jdk variables used by all the Java makefiles.
  28 # This file should not contain rules.
  29 #
  30 
  31 #
  32 # Memory related -J flags that all uses of java tools should use.
  33 #
  34 JAVA_MEM_FLAGS   = -Xmx$(MAX_VM_MEMORY)m
  35 ifeq ($(ARCH), ia64)
  36   # Special flags for javac on ia64 to work around a VM problem with
  37   #   bad code generation during inlining (what version had this problem?):
  38   #   Suspect this may not be needed anymore.
  39   JAVA_MEM_FLAGS   += -Xms$(MAX_VM_MEMORY)m -XX:-Inline
  40 else
  41   JAVA_MEM_FLAGS   += -Xms$(MIN_VM_MEMORY)m -XX:PermSize=32m -XX:MaxPermSize=160m
  42 endif
  43 
  44 # 
  45 # All java tools (javac and javadoc) run faster with certain java
  46 #    options, this macro should be used with all these tools.
  47 #    In particular, the client VM makes these tools run faster when
  48 #    it's available.
  49 #
  50 ADD_CLIENT_VM_OPTION = false
  51 ifeq ($(PLATFORM), solaris)
  52   ADD_CLIENT_VM_OPTION = true
  53 else
  54   ifeq ($(ARCH_DATA_MODEL), 32)
  55     ADD_CLIENT_VM_OPTION = true
  56   endif
  57 endif
  58 
  59 # Options for hotspot to turn off printing of options with fastdebug version
  60 #   and creating the hotspot.log file.
  61 JAVA_HOTSPOT_DISABLE_PRINT_VMOPTIONS = \
  62    -XX:-PrintVMOptions -XX:+UnlockDiagnosticVMOptions -XX:-LogVMOutput
  63 
  64 # JVM options
  65 JAVA_JVM_FLAGS = $(JAVA_HOTSPOT_DISABLE_PRINT_VMOPTIONS)
  66 
  67 ifeq ($(ADD_CLIENT_VM_OPTION), true)
  68   JAVA_JVM_FLAGS += -client
  69 endif
  70 ifdef USE_HOTSPOT_INTERPRETER_MODE
  71   JAVA_JVM_FLAGS += -Xint
  72 endif
  73 
  74 # Various VM flags
  75 JAVA_TOOLS_FLAGS  = $(JAVA_JVM_FLAGS) $(JAVA_MEM_FLAGS)
  76 
  77 # The VM flags for javac
  78 JAVAC_JVM_FLAGS =
  79 
  80 # 64-bit builds require a larger thread stack size.
  81 ifeq ($(ARCH_DATA_MODEL), 32)
  82   JAVAC_JVM_FLAGS    += -J-XX:ThreadStackSize=768
  83 else
  84   JAVAC_JVM_FLAGS    += -J-XX:ThreadStackSize=1536
  85 endif
  86 JAVAC_JVM_FLAGS    += $(JAVA_TOOLS_FLAGS:%=-J%)
  87 
  88 # The jar -J options are special, must be added at the end of the command line
  89 JAR_JFLAGS       = $(JAVA_TOOLS_FLAGS:%=-J%)
  90 
  91 # JAVA_TOOLS_DIR is the default location to find Java tools to run, if
  92 #    langtools is not available.
  93 #    This should be the latest promoted JDK javac.
  94 ifndef JAVA_TOOLS_DIR
  95   JAVA_TOOLS_DIR = $(JDK_IMPORT_PATH)/bin
  96 endif
  97 
  98 #
  99 # Invoking the Java compiler.   In leaf makefiles, choose as follows:
 100 #  -- Use JAVAC if you want to take full control of what options get
 101 #     passed to javac.
 102 #  -- Use JAVAC_CMD if you want to take the defaults given to you.
 103 #
 104 
 105 ifndef DEBUG_CLASSFILES
 106   ifeq ($(VARIANT), DBG)
 107     DEBUG_CLASSFILES = true
 108   endif
 109 endif
 110 JAVACFLAGS =
 111 ifeq ($(DEBUG_CLASSFILES),true)
 112   JAVACFLAGS += -g
 113 endif
 114 ifeq ($(JAVAC_MAX_WARNINGS), true)
 115   JAVACFLAGS  += -Xlint:all
 116 endif
 117 ifeq ($(JAVAC_WARNINGS_FATAL), true)
 118   JAVACFLAGS  += -Werror
 119 endif
 120 
 121 NO_PROPRIETARY_API_WARNINGS = -XDignore.symbol.file=true
 122 JAVACFLAGS  += $(NO_PROPRIETARY_API_WARNINGS)
 123 
 124 # Add the source level
 125 SOURCE_LANGUAGE_VERSION = 7
 126 LANGUAGE_VERSION = -source $(SOURCE_LANGUAGE_VERSION)
 127 JAVACFLAGS  += $(LANGUAGE_VERSION)
 128 
 129 # Add the class version we want
 130 TARGET_CLASS_VERSION = 7
 131 CLASS_VERSION = -target $(TARGET_CLASS_VERSION)
 132 JAVACFLAGS  += $(CLASS_VERSION)
 133 JAVACFLAGS  += -encoding ascii
 134 JAVACFLAGS  += -classpath $(BOOTDIR)/lib/tools.jar
 135 JAVACFLAGS  += $(OTHER_JAVACFLAGS)
 136 
 137 # Langtools
 138 ifdef LANGTOOLS_DIST
 139   JAVAC_JAR   = $(LANGTOOLS_DIST)/bootstrap/lib/javac.jar
 140   JAVADOC_JAR = $(LANGTOOLS_DIST)/bootstrap/lib/javadoc.jar
 141   DOCLETS_JAR = $(LANGTOOLS_DIST)/bootstrap/lib/doclets.jar
 142   JAVAC_CMD   = $(BOOT_JAVA_CMD) \
 143                 "-Xbootclasspath/p:$(JAVAC_JAR)" \
 144                 -jar $(JAVAC_JAR) $(JAVACFLAGS)
 145   JAVADOC_CMD = $(BOOT_JAVA_CMD) \
 146                 "-Xbootclasspath/p:$(JAVADOC_JAR)$(CLASSPATH_SEPARATOR)$(JAVAC_JAR)$(CLASSPATH_SEPARATOR)$(DOCLETS_JAR)" \
 147                 -jar $(JAVADOC_JAR)
 148 else
 149   # If no explicit tools, use boot tools (add VM flags in this case)
 150   JAVAC_CMD     = $(JAVA_TOOLS_DIR)/javac $(JAVAC_JVM_FLAGS) \
 151                   $(JAVACFLAGS)
 152   JAVADOC_CMD   = $(JAVA_TOOLS_DIR)/javadoc $(JAVA_TOOLS_FLAGS:%=-J%)
 153 endif
 154 
 155 # Override of what javac to use (see deploy workspace)
 156 ifdef JAVAC
 157   JAVAC_CMD     = $(JAVAC)
 158 endif
 159 
 160 #
 161 # The bootstrap java compiler (defined as the javac in the ALT_BOOTDIR jdk).
 162 #   Will be used to compile java code used to build the jdk, e.g. class files
 163 #   created by this compiler will NOT become part of this built jdk, but just
 164 #   used to build this jdk, e.g. run with the java in the ALT_BOOTDIR jdk.
 165 #
 166 # The javac supplied with the LANGTOOLS_DIST should be used to build the
 167 #   classes that will be put into the built jdk. But note that this javac
 168 #   will use the ALT_BOOTDIR java runtime. Any classes created by the
 169 #   LANGTOOLS_DIST javac should not be run during this jdk build and indeed
 170 #   may not even run with the ALT_BOOTDIR jdk because they may be a newer
 171 #   class file version that the ALT_BOOTDIR jdk doesn't understand.
 172 #
 173 # The important observation here is that the built jdk is NOT run during
 174 #   the build. If the built jdk needs to be verified that it can build this
 175 #   same jdk, then it should be supplied to the build process as the ALT_BOOTDIR
 176 #   jdk, and this resulting built jdk should be compared to the first one.
 177 #   (They should be the same). Re-using this built jdk as the ALT_BOOTDIR
 178 #   jdk will be the only way and the recommeneded way to verify the built jdk
 179 #   can bootstrap itself.
 180 #
 181 
 182 # The javac options supplied to the boot javac is limited. This compiler
 183 #   should only be used to build the 'make/tools' sources, which are not
 184 #   class files that end up in the classes directory.
 185 ifeq ($(JAVAC_MAX_WARNINGS), true)
 186   BOOT_JAVACFLAGS  += -Xlint:all
 187 endif
 188 ifeq ($(JAVAC_WARNINGS_FATAL), true)
 189   BOOT_JAVACFLAGS  += -Werror
 190 endif
 191 
 192 BOOT_SOURCE_LANGUAGE_VERSION = 6
 193 BOOT_TARGET_CLASS_VERSION = 6
 194 BOOT_JAVACFLAGS  += -encoding ascii -source $(BOOT_SOURCE_LANGUAGE_VERSION) -target $(BOOT_TARGET_CLASS_VERSION)
 195 BOOT_JAR_JFLAGS += $(JAR_JFLAGS)
 196 
 197 BOOT_JAVA_CMD      = $(BOOTDIR)/bin/java $(JAVA_TOOLS_FLAGS)
 198 BOOT_JAVAC_CMD     = $(BOOTDIR)/bin/javac $(JAVAC_JVM_FLAGS) $(BOOT_JAVACFLAGS)
 199 BOOT_JAR_CMD       = $(BOOTDIR)/bin/jar
 200 BOOT_JARSIGNER_CMD = $(BOOTDIR)/bin/jarsigner
 201 
 202 # Various tools we need to run (FIXUP: Are these the right ones?)
 203 NATIVE2ASCII    = $(BOOTDIR)/bin/native2ascii $(JAVA_TOOLS_FLAGS:%=-J%)
 204 RMIC            = $(BOOTDIR)/bin/rmic $(JAVA_TOOLS_FLAGS:%=-J%)
 205 IDLJ            = $(BOOTDIR)/bin/idlj $(JAVA_TOOLS_FLAGS:%=-J%)
 206 
 207 # Should not be used
 208 JAVA            = /should/not/be/used
 209