jdk/makefiles/common/shared/Defs-java.gmk
changeset 13254 529a896a6b36
parent 13251 58f0a0823496
parent 13220 086271e35b0a
child 13255 2a310dd80800
equal deleted inserted replaced
13251:58f0a0823496 13254:529a896a6b36
     1 #
       
     2 # Copyright (c) 2007, 2012, 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 # WARNING: This file is shared with other workspaces.
       
    32 #          So when it includes other files, it must use JDK_TOPDIR.
       
    33 #
       
    34 
       
    35 -include $(SPEC)
       
    36 
       
    37 #
       
    38 # Memory related -J flags that all uses of java tools should use.
       
    39 #
       
    40 #JAVA_MEM_FLAGS   = -Xmx$(MAX_VM_MEMORY)m
       
    41 #ifeq ($(ARCH), ia64)
       
    42   # Special flags for javac on ia64 to work around a VM problem with
       
    43   #   bad code generation during inlining (what version had this problem?):
       
    44   #   Suspect this may not be needed anymore.
       
    45 #  JAVA_MEM_FLAGS   += -Xms$(MAX_VM_MEMORY)m -XX:-Inline
       
    46 #else
       
    47 #  JAVA_MEM_FLAGS   += -Xms$(MIN_VM_MEMORY)m -XX:PermSize=32m -XX:MaxPermSize=160m
       
    48 #endif
       
    49 
       
    50 #
       
    51 # All java tools (javac, javah, and javadoc) run faster with certain java
       
    52 #    options, this macro should be used with all these tools.
       
    53 #    In particular, the client VM makes these tools run faster when
       
    54 #    it's available.
       
    55 #
       
    56 ADD_CLIENT_VM_OPTION = false
       
    57 ifeq ($(PLATFORM), solaris)
       
    58   ADD_CLIENT_VM_OPTION = true
       
    59 else
       
    60   ifeq ($(ARCH_DATA_MODEL), 32)
       
    61     ADD_CLIENT_VM_OPTION = true
       
    62   endif
       
    63 endif
       
    64 
       
    65 # Options for hotspot to turn off printing of options with fastdebug version
       
    66 #   and creating the hotspot.log file.
       
    67 #JAVA_HOTSPOT_DISABLE_PRINT_VMOPTIONS = \
       
    68 #   -XX:-PrintVMOptions -XX:+UnlockDiagnosticVMOptions -XX:-LogVMOutput
       
    69 
       
    70 # JVM options
       
    71 ifeq ($(PLATFORM), macosx)
       
    72   JAVA_JVM_FLAGS = $(JAVA_HOTSPOT_DISABLE_PRINT_VMOPTIONS) -Djava.awt.headless=true
       
    73 else
       
    74   JAVA_JVM_FLAGS = $(JAVA_HOTSPOT_DISABLE_PRINT_VMOPTIONS)
       
    75 endif
       
    76 
       
    77 #ifeq ($(ADD_CLIENT_VM_OPTION), true)
       
    78 #  JAVA_JVM_FLAGS += -client
       
    79 #endif
       
    80 #ifdef USE_HOTSPOT_INTERPRETER_MODE
       
    81 #  JAVA_JVM_FLAGS += -Xint
       
    82 #endif
       
    83 
       
    84 # Various VM flags
       
    85 JAVA_TOOLS_FLAGS  = $(JAVA_JVM_FLAGS) $(JAVA_MEM_FLAGS)
       
    86 
       
    87 # The VM flags for javac
       
    88 JAVAC_JVM_FLAGS =
       
    89 
       
    90 # 64-bit builds require a larger thread stack size.
       
    91 #ifeq ($(ARCH_DATA_MODEL), 32)
       
    92 #  JAVAC_JVM_FLAGS    += -J-XX:ThreadStackSize=768
       
    93 #else
       
    94 #  JAVAC_JVM_FLAGS    += -J-XX:ThreadStackSize=1536
       
    95 #endif
       
    96 JAVAC_JVM_FLAGS    += $(JAVA_TOOLS_FLAGS:%=-J%)
       
    97 
       
    98 # The jar -J options are special, must be added at the end of the command line
       
    99 JAR_JFLAGS       = $(JAVA_TOOLS_FLAGS:%=-J%)
       
   100 
       
   101 # JAVA_TOOLS_DIR is the default location to find Java tools to run, if
       
   102 #    langtools is not available.
       
   103 #    This should be the latest promoted JDK javac.
       
   104 ifndef JAVA_TOOLS_DIR
       
   105   JAVA_TOOLS_DIR = $(JDK_IMPORT_PATH)/bin
       
   106 endif
       
   107 
       
   108 #
       
   109 # Invoking the Java compiler.   In leaf makefiles, choose as follows:
       
   110 #  -- Use JAVAC if you want to take full control of what options get
       
   111 #     passed to javac.
       
   112 #  -- Use JAVAC_CMD if you want to take the defaults given to you.
       
   113 #
       
   114 
       
   115 ifndef DEBUG_CLASSFILES
       
   116   ifeq ($(VARIANT), DBG)
       
   117     DEBUG_CLASSFILES = true
       
   118   endif
       
   119 endif
       
   120 JAVACFLAGS =
       
   121 ifeq ($(DEBUG_CLASSFILES),true)
       
   122   JAVACFLAGS += -g
       
   123 endif
       
   124 ifeq ($(JAVAC_MAX_WARNINGS), true)
       
   125   JAVAC_LINT_OPTIONS += -Xlint:all
       
   126 endif
       
   127 ifeq ($(JAVAC_WARNINGS_FATAL), true)
       
   128   JAVACFLAGS  += -Werror
       
   129 endif
       
   130 
       
   131 # TODO: Workaround for CR 7063027. Remove -path eventually.
       
   132 JAVAC_LINT_OPTIONS += -Xlint:-path
       
   133 
       
   134 JAVACFLAGS += $(JAVAC_LINT_OPTIONS)
       
   135 
       
   136 #
       
   137 # Some licensees do not get the Security Source bundles.  We will
       
   138 # fall back on the prebuilt jce.jar so that we can do a best
       
   139 # attempt at building.  If sources exist, we always want to
       
   140 # build/use the most recent source instead of an older jce.jar, whether
       
   141 # built implicitly/explicitly.
       
   142 #
       
   143 ifeq ($(wildcard $(SHARE_SRC)/classes/javax/crypto/Cipher.java),)
       
   144   JCE_PATH = $(CLASSPATH_SEPARATOR)$(LIBDIR)/jce.jar
       
   145 endif
       
   146 
       
   147 # Add the source level
       
   148 SOURCE_LANGUAGE_VERSION = 7
       
   149 LANGUAGE_VERSION = -source $(SOURCE_LANGUAGE_VERSION)
       
   150 JAVACFLAGS  += $(LANGUAGE_VERSION)
       
   151 
       
   152 # Add the class version we want
       
   153 TARGET_CLASS_VERSION = 7
       
   154 CLASS_VERSION = -target $(TARGET_CLASS_VERSION)
       
   155 JAVACFLAGS  += $(CLASS_VERSION)
       
   156 JAVACFLAGS  += -encoding ascii
       
   157 JAVACFLAGS  += "-Xbootclasspath:$(CLASSBINDIR)$(JCE_PATH)"
       
   158 JAVACFLAGS  += $(OTHER_JAVACFLAGS)
       
   159 
       
   160 # Needed for javah
       
   161 JAVAHFLAGS += -bootclasspath "$(CLASSBINDIR)$(JCE_PATH)"
       
   162 
       
   163 # Needed for javadoc to ensure it builds documentation
       
   164 # against the newly built classes
       
   165 JAVADOCFLAGS += -bootclasspath $(CLASSBINDIR)
       
   166 
       
   167 # Needed for JAVADOC and BOOT_JAVACFLAGS
       
   168 NO_PROPRIETARY_API_WARNINGS = -XDignore.symbol.file=true
       
   169 
       
   170 # Langtools
       
   171 LANGTOOLS_DIST ?= $(ALT_LANGTOOLS_DIST)
       
   172 
       
   173 ifdef LANGTOOLS_DIST
       
   174   JAVAC_JAR   = $(LANGTOOLS_DIST)/bootstrap/lib/javac.jar
       
   175   JAVAH_JAR   = $(LANGTOOLS_DIST)/bootstrap/lib/javah.jar
       
   176   JAVADOC_JAR = $(LANGTOOLS_DIST)/bootstrap/lib/javadoc.jar
       
   177   DOCLETS_JAR = $(LANGTOOLS_DIST)/bootstrap/lib/doclets.jar
       
   178   JAVAC_CMD   = $(BOOT_JAVA_CMD) \
       
   179 		"-Xbootclasspath/p:$(JAVAC_JAR)" \
       
   180 		-jar $(JAVAC_JAR) $(JAVACFLAGS)
       
   181   JAVAH_CMD   = $(BOOT_JAVA_CMD) \
       
   182 		"-Xbootclasspath/p:$(JAVAH_JAR)$(CLASSPATH_SEPARATOR)$(JAVAC_JAR)"  \
       
   183 		-jar $(JAVAH_JAR) $(JAVAHFLAGS)
       
   184   JAVADOC_CMD = $(BOOT_JAVA_CMD) \
       
   185 		"-Xbootclasspath/p:$(JAVADOC_JAR)$(CLASSPATH_SEPARATOR)$(JAVAC_JAR)$(CLASSPATH_SEPARATOR)$(DOCLETS_JAR)" \
       
   186 		-jar $(JAVADOC_JAR) $(JAVADOCFLAGS)
       
   187 else
       
   188   # If no explicit tools, use boot tools (add VM flags in this case)
       
   189   JAVAC_CMD     = $(UNCYGDRIVE) $(JAVA_TOOLS_DIR)/javac $(JAVAC_JVM_FLAGS) \
       
   190 		  $(JAVACFLAGS)
       
   191   JAVAH_CMD     = $(UNCYGDRIVE) $(JAVA_TOOLS_DIR)/javah \
       
   192 		  $(JAVAHFLAGS)
       
   193   JAVADOC_CMD   = $(UNCYGDRIVE) $(JAVA_TOOLS_DIR)/javadoc $(JAVA_TOOLS_FLAGS:%=-J%) \
       
   194 		  $(JAVADOCFLAGS)
       
   195 endif
       
   196 
       
   197 # Override of what javac to use (see deploy workspace)
       
   198 #ifdef JAVAC
       
   199 #  JAVAC_CMD     = $(JAVAC)
       
   200 #endif
       
   201 
       
   202 #
       
   203 # The bootstrap java compiler (defined as the javac in the ALT_BOOTDIR jdk).
       
   204 #   Will be used to compile java code used to build the jdk, e.g. class files
       
   205 #   created by this compiler will NOT become part of this built jdk, but just
       
   206 #   used to build this jdk, e.g. run with the java in the ALT_BOOTDIR jdk.
       
   207 #
       
   208 # The javac supplied with the LANGTOOLS_DIST should be used to build the
       
   209 #   classes that will be put into the built jdk. But note that this javac
       
   210 #   will use the ALT_BOOTDIR java runtime. Any classes created by the
       
   211 #   LANGTOOLS_DIST javac should not be run during this jdk build and indeed
       
   212 #   may not even run with the ALT_BOOTDIR jdk because they may be a newer
       
   213 #   class file version that the ALT_BOOTDIR jdk doesn't understand.
       
   214 #
       
   215 # The important observation here is that the built jdk is NOT run during
       
   216 #   the build. If the built jdk needs to be verified that it can build this
       
   217 #   same jdk, then it should be supplied to the build process as the ALT_BOOTDIR
       
   218 #   jdk, and this resulting built jdk should be compared to the first one.
       
   219 #   (They should be the same). Re-using this built jdk as the ALT_BOOTDIR
       
   220 #   jdk will be the only way and the recommeneded way to verify the built jdk
       
   221 #   can bootstrap itself.
       
   222 #
       
   223 
       
   224 # The javac options supplied to the boot javac is limited. This compiler
       
   225 #   should only be used to build the 'make/tools' sources, which are not
       
   226 #   class files that end up in the classes directory.
       
   227 BOOT_JAVACFLAGS += $(JAVAC_LINT_OPTIONS)
       
   228 ifeq ($(JAVAC_WARNINGS_FATAL), true)
       
   229   BOOT_JAVACFLAGS  += -Werror
       
   230 endif
       
   231 
       
   232 BOOT_JAVACFLAGS  += -encoding ascii
       
   233 BOOT_JAR_JFLAGS += $(JAR_JFLAGS)
       
   234 
       
   235 BOOT_JAVACFLAGS  += $(NO_PROPRIETARY_API_WARNINGS)
       
   236 
       
   237 BOOT_JAVA_CMD      = $(UNCYGDRIVE) $(BOOTDIR)/bin/java $(JAVA_TOOLS_FLAGS)
       
   238 BOOT_JAVAC_CMD     = $(UNCYGDRIVE) $(BOOTDIR)/bin/javac $(JAVAC_JVM_FLAGS) $(BOOT_JAVACFLAGS)
       
   239 BOOT_JAR_CMD       = $(UNCYGDRIVE) $(BOOTDIR)/bin/jar
       
   240 BOOT_JARSIGNER_CMD = $(UNCYGDRIVE) $(BOOTDIR)/bin/jarsigner
       
   241 
       
   242 # Various tools we need to run (FIXUP: Are these the right ones?)
       
   243 NATIVE2ASCII    = $(UNCYGDRIVE) $(BOOTDIR)/bin/native2ascii $(JAVA_TOOLS_FLAGS:%=-J%)
       
   244 RMIC		= $(UNCYGDRIVE) $(BOOTDIR)/bin/rmic $(JAVA_TOOLS_FLAGS:%=-J%)
       
   245 IDLJ		= $(UNCYGDRIVE) $(BOOTDIR)/bin/idlj $(JAVA_TOOLS_FLAGS:%=-J%)
       
   246 
       
   247 # Should not be used
       
   248 #JAVA		= /should/not/be/used
       
   249