1 # 2 # Copyright 2007-2009 Sun Microsystems, Inc. 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. Sun designates this 8 # particular file as subject to the "Classpath" exception as provided 9 # by Sun 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 22 # CA 95054 USA or visit www.sun.com if you need additional information or 23 # have any questions. 24 # 25 26 # Makefile wrapper around Ant build.xml file 27 28 # 29 # On Solaris, the 'make' utility from Sun will not work with these makefiles. 30 # This little rule is only understood by Sun's make, and is harmless 31 # when seen by the GNU make tool. If using Sun's make, this causes the 32 # make command to fail. 33 # 34 SUN_MAKE_TEST:sh = @echo "ERROR: PLEASE USE GNU VERSION OF MAKE"; exit 33 35 36 ifdef QUIET 37 ANT_OPTIONS += -quiet 38 endif 39 40 ifdef VERBOSE 41 ANT_OPTIONS += -verbose 42 endif 43 44 ifeq ($(VARIANT), OPT) 45 ifneq ($(DEBUG_CLASSFILES), true) 46 ANT_OPTIONS += -Djavac.debug=false 47 endif 48 endif 49 50 # Note: jdk/make/common/Defs.gmk uses LANGUAGE_VERSION (-source NN) 51 # and the somewhat misnamed CLASS_VERSION (-target NN) 52 ifdef TARGET_CLASS_VERSION 53 ANT_OPTIONS += -Djavac.target=$(TARGET_CLASS_VERSION) 54 else 55 ifdef JAVAC_TARGET_ARG 56 ANT_OPTIONS += -Djavac.target=$(JAVAC_TARGET_ARG) 57 endif 58 endif 59 60 ifdef SOURCE_LANGUAGE_VERSION 61 ANT_OPTIONS += -Djavac.source=$(SOURCE_LANGUAGE_VERSION) 62 else 63 ifdef JAVAC_SOURCE_ARG 64 ANT_OPTIONS += -Djavac.source=$(JAVAC_SOURCE_ARG) 65 endif 66 endif 67 68 # Figure out the platform we are using 69 _SYSTEM_UNAME := $(shell uname) 70 _PLATFORM_KIND = unix 71 ifeq ($(_SYSTEM_UNAME), Windows_NT) 72 _PLATFORM_KIND = windows 73 endif 74 ifneq (,$(findstring CYGWIN,$(_SYSTEM_UNAME))) 75 _PLATFORM_KIND = windows 76 endif 77 78 # Where is /java in case we need it 79 ifdef ALT_SLASH_JAVA 80 _SLASHJAVA = $(ALT_SLASH_JAVA) 81 else 82 ifeq ($(_PLATFORM_KIND), windows) 83 _SLASHJAVA=J:/ 84 else 85 _SLASHJAVA=/java 86 endif 87 endif 88 89 # Where is /java/devtools in case we need it 90 ifdef ALT_DROPS_DIR 91 DROPS_DIR = $(ALT_DROPS_DIR) 92 else 93 ifdef ALT_JDK_DEVTOOLS_DIR 94 DROPS_DIR = $(ALT_JDK_DEVTOOLS_DIR)/share/jdk7-drops 95 else 96 DROPS_DIR = $(_SLASHJAVA)/devtools/share/jdk7-drops 97 endif 98 endif 99 100 # Add in path to devtools 101 ANT_OPTIONS += -Ddrops.dir=$(DROPS_DIR) 102 103 ifdef ALT_OUTPUTDIR 104 OUTPUTDIR = $(ALT_OUTPUTDIR) 105 ANT_OPTIONS += -Doutput.dir=$(ALT_OUTPUTDIR) 106 else 107 OUTPUTDIR = .. 108 endif 109 110 ifdef ALT_LANGTOOLS_DIST 111 ifdef ALT_BOOTDIR 112 ANT_JAVA_HOME = JAVA_HOME=$(ALT_BOOTDIR) 113 endif 114 ANT_OPTIONS += -Dbootstrap.dir=$(ALT_LANGTOOLS_DIST)/bootstrap 115 else 116 ifdef ALT_JDK_IMPORT_PATH 117 ANT_JAVA_HOME = JAVA_HOME=$(ALT_JDK_IMPORT_PATH) 118 endif 119 endif 120 121 ifdef ANT_HOME 122 ANT = $(ANT_HOME)/bin/ant 123 ifneq ($(shell test -x $(ANT); echo $$?), 0) 124 $(error "$(ANT) not found; please update ANT_HOME") 125 endif 126 else 127 ANT = ant 128 ifneq ($(shell which $(ANT) > /dev/null; echo $$?), 0) 129 $(error "\"ant\" not found; please set ANT_HOME or put \"ant\" on your PATH") 130 endif 131 endif 132 133 # Default target and expected 'do everything' target 134 default: all 135 136 # All ant targets of interest 137 ANT_TARGETS = all source drop_included build dist clobber clean sanity 138 139 # Create a make target for each 140 $(ANT_TARGETS): 141 cd .. && $(ANT_JAVA_HOME) $(ANT) -version 142 cd .. && $(ANT_JAVA_HOME) $(ANT) $(ANT_OPTIONS) $@ 143 144 # Help target 145 define helpenvline 146 @echo " $1";echo " $2" 147 endef 148 help: 149 @echo "----------------------------------------------------------" 150 @echo " " 151 @echo "Help information for this Makefile:" 152 @echo " " 153 @echo " Targets (see ant project information for descriptions):" 154 @echo " $(ANT_TARGETS)" 155 @echo " " 156 @echo " Environment or command line variables (all optional):" 157 $(call helpenvline, ALT_BOOTDIR,\ 158 "JAVA_HOME to use when running ant") 159 $(call helpenvline, ALT_LANGTOOLS_DIST,\ 160 "path to langtools repository dist directory") 161 $(call helpenvline, ALT_OUTPUTDIR,\ 162 "path to root of output") 163 $(call helpenvline, DEBUG_CLASSFILES,\ 164 "if set makes sure ant property javac.debug is true") 165 $(call helpenvline, JAVAC_SOURCE_ARG,\ 166 "if SOURCE_LANGUAGE_VERSION not set uses this to set ant property javac.source") 167 $(call helpenvline, JAVAC_TARGET_ARG,\ 168 "if TARGET_CLASS_VERSION not set uses this to set ant property javac.target") 169 $(call helpenvline, SOURCE_LANGUAGE_VERSION,\ 170 "if set uses this to set ant property javac.source") 171 $(call helpenvline, QUIET,\ 172 "if set will pass -quiet to ant") 173 $(call helpenvline, TARGET_CLASS_VERSION,\ 174 "JAVA_HOME to use when running ant") 175 $(call helpenvline, VARIANT,\ 176 "if set to OPT means optimized build will set javac.debug to false") 177 $(call helpenvline, VERBOSE,\ 178 "if set will pass -verbose to ant") 179 @echo " " 180 @echo "----------------------------------------------------------" 181 @echo " " 182 @echo "Ant project file help information:" 183 @echo " " 184 @$(ANT_JAVA_HOME) cd .. && $(ANT) $(ANT_OPTIONS) -p 185 @echo " " 186 @echo "----------------------------------------------------------" 187 188 # Targets for Sun's internal JPRT build system 189 JPRT_ARCHIVE_BUNDLE=$(OUTPUTDIR)/jprt.zip 190 jprt_build_product jprt_build_debug jprt_build_fastdebug: all 191 $(RM) $(JPRT_ARCHIVE_BUNDLE) 192 ( cd $(OUTPUTDIR)/dist && \ 193 zip -q -r $(JPRT_ARCHIVE_BUNDLE) . ) 194 195 # Declare these phony (not filenames) 196 .PHONY: $(ANT_TARGETS) \ 197 jprt_build_product jprt_build_debug jprt_build_fastdebug