SetupJavaCompilers.gmk revision 1169:980f315286b9
1249261Sdim# 2249261Sdim# Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved. 3249261Sdim# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4249261Sdim# 5249261Sdim# This code is free software; you can redistribute it and/or modify it 6249261Sdim# under the terms of the GNU General Public License version 2 only, as 7249261Sdim# published by the Free Software Foundation. Oracle designates this 8249261Sdim# particular file as subject to the "Classpath" exception as provided 9249261Sdim# by Oracle in the LICENSE file that accompanied this code. 10249261Sdim# 11263508Sdim# This code is distributed in the hope that it will be useful, but WITHOUT 12249261Sdim# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13249261Sdim# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 14249261Sdim# version 2 for more details (a copy is included in the LICENSE file that 15249261Sdim# accompanied this code). 16249261Sdim# 17263508Sdim# You should have received a copy of the GNU General Public License version 18249261Sdim# 2 along with this work; if not, write to the Free Software Foundation, 19263508Sdim# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 20263508Sdim# 21263508Sdim# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22249261Sdim# or visit www.oracle.com if you need additional information or have any 23263508Sdim# questions. 24249261Sdim# 25249261Sdim 26263508Sdimifndef _SETUP_GMK 27263508Sdim_SETUP_GMK := 1 28249261Sdim 29249261Sdiminclude JavaCompilation.gmk 30263508Sdim 31263508SdimDISABLE_WARNINGS := -Xlint:all,-deprecation,-unchecked,-rawtypes,-cast,-serial,-dep-ann,-static,-fallthrough,-try,-varargs,-empty,-finally 32263508Sdim 33263508Sdim# To build with all warnings enabled, do the following: 34249261Sdim# make JAVAC_WARNINGS="-Xlint:all -Xmaxwarns 10000" 35263508SdimJAVAC_WARNINGS := -Xlint:all,-deprecation -Werror 36263508Sdim 37263508Sdim# The BOOT_JAVAC setup uses the boot jdk compiler to compile the tools 38263508Sdim# and the interim javac, to be run by the boot jdk. 39263508Sdim$(eval $(call SetupJavaCompiler,BOOT_JAVAC, \ 40263508Sdim JAVAC := $(JAVAC), \ 41249261Sdim FLAGS := -XDignore.symbol.file=true -g -Xlint:all$(COMMA)-deprecation -Werror)) 42263508Sdim 43263508Sdim# Any java code executed during a JDK build to build other parts of the JDK must be 44263508Sdim# executed by the bootstrap JDK (probably with -Xbootclasspath/p: ) and for this 45263508Sdim# purpose must be built with -target PREVIOUS for bootstrapping purposes, which 46263508Sdim# requires restricting to language level and api of previous JDK. 47263508Sdim# 48263508Sdim# The generate old bytecode javac setup uses the new compiler to compile for the 49263508Sdim# boot jdk to generate tools that need to be run with the boot jdk. 50263508Sdim# Thus we force the target bytecode to the previous JDK version. 51263508Sdim$(eval $(call SetupJavaCompiler,GENERATE_OLDBYTECODE, \ 52263508Sdim JVM := $(JAVA_SMALL), \ 53263508Sdim JAVAC := $(NEW_JAVAC), \ 54263508Sdim FLAGS := $(BOOT_JDK_SOURCETARGET) -bootclasspath $(BOOT_RTJAR) $(DISABLE_WARNINGS), \ 55263508Sdim SERVER_DIR := $(SJAVAC_SERVER_DIR), \ 56263508Sdim SERVER_JVM := $(SJAVAC_SERVER_JAVA))) 57263508Sdim 58263508Sdim# The generate new bytecode javac setup uses the new compiler to compile for the 59263508Sdim# new jdk. This new bytecode might only be possible to run using the new jvm. 60263508Sdim$(eval $(call SetupJavaCompiler,GENERATE_JDKBYTECODE, \ 61263508Sdim JVM := $(JAVA), \ 62263508Sdim JAVAC := $(NEW_JAVAC), \ 63263508Sdim FLAGS := -source 9 -target 9 \ 64263508Sdim -encoding ascii -XDignore.symbol.file=true $(JAVAC_WARNINGS) \ 65263508Sdim $(GENERATE_JDKBYTECODE_EXTRA_FLAGS), \ 66263508Sdim SERVER_DIR := $(SJAVAC_SERVER_DIR), \ 67263508Sdim SERVER_JVM := $(SJAVAC_SERVER_JAVA))) 68263508Sdim 69263508Sdim# The generate new bytecode javac setup uses the new compiler to compile for the 70263508Sdim# new jdk. This new bytecode might only be possible to run using the new jvm. 71263508Sdim$(eval $(call SetupJavaCompiler,GENERATE_JDKBYTECODE_NOWARNINGS, \ 72263508Sdim JVM := $(JAVA), \ 73263508Sdim JAVAC := $(NEW_JAVAC), \ 74263508Sdim FLAGS := -source 9 -target 9 \ 75263508Sdim -encoding ascii -XDignore.symbol.file=true $(DISABLE_WARNINGS) \ 76263508Sdim $(GENERATE_JDKBYTECODE_EXTRA_FLAGS), \ 77263508Sdim SERVER_DIR := $(SJAVAC_SERVER_DIR), \ 78263508Sdim SERVER_JVM := $(SJAVAC_SERVER_JAVA))) 79263508Sdim 80263508SdimJDK_BOOTCLASSPATH := $(subst $(SPACE),$(PATH_SEP),\ 81263508Sdim $(filter-out $(JDK_OUTPUTDIR)/modules/_%, $(wildcard $(JDK_OUTPUTDIR)/modules/*))) 82263508Sdim 83263508Sdim# After the jdk is built, we want to build demos using only the recently 84263508Sdim# generated jdk classes and nothing else, no jdk source, etc etc. 85263508Sdim# I.e. the rt.jar, but since rt.jar has not yet been generated 86263508Sdim# (it will be in "make images") therefore we use classes instead. 87263508Sdim$(eval $(call SetupJavaCompiler,GENERATE_USINGJDKBYTECODE, \ 88263508Sdim JVM := $(JAVA_SMALL), \ 89263508Sdim JAVAC := $(NEW_JAVAC), \ 90263508Sdim FLAGS := -bootclasspath "$(JDK_BOOTCLASSPATH)" $(DISABLE_WARNINGS), \ 91263508Sdim SERVER_DIR := $(SJAVAC_SERVER_DIR), \ 92263508Sdim SERVER_JVM := $(SJAVAC_SERVER_JAVA))) 93263508Sdim 94263508Sdimendif # _SETUP_GMK 95263508Sdim