make/common/shared/Defs.gmk

Tue, 28 Dec 2010 15:52:36 -0800

author
ohair
date
Tue, 28 Dec 2010 15:52:36 -0800
changeset 240
f90b3e014e83
parent 194
0f60cf26c5b5
permissions
-rw-r--r--

6962318: Update copyright year
Reviewed-by: xdono

duke@1 1 #
ohair@240 2 # Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
duke@1 3 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
duke@1 4 #
duke@1 5 # This code is free software; you can redistribute it and/or modify it
duke@1 6 # under the terms of the GNU General Public License version 2 only, as
ohair@158 7 # published by the Free Software Foundation. Oracle designates this
duke@1 8 # particular file as subject to the "Classpath" exception as provided
ohair@158 9 # by Oracle in the LICENSE file that accompanied this code.
duke@1 10 #
duke@1 11 # This code is distributed in the hope that it will be useful, but WITHOUT
duke@1 12 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
duke@1 13 # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
duke@1 14 # version 2 for more details (a copy is included in the LICENSE file that
duke@1 15 # accompanied this code).
duke@1 16 #
duke@1 17 # You should have received a copy of the GNU General Public License version
duke@1 18 # 2 along with this work; if not, write to the Free Software Foundation,
duke@1 19 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
duke@1 20 #
ohair@158 21 # Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
ohair@158 22 # or visit www.oracle.com if you need additional information or have any
ohair@158 23 # questions.
duke@1 24 #
duke@1 25
duke@1 26 #
duke@1 27 # Defnitions for all platforms.
duke@1 28 #
duke@1 29 # Normally the convention is that these alternate definitions of
duke@1 30 # primary make variables are never defined inside the Makefiles anywhere
duke@1 31 # but are defined via environment variables or set on the make command
duke@1 32 # line. So you should never see an ALT_* variable defined in any
duke@1 33 # makefiles, just used. This is the convention and there are some
duke@1 34 # exceptions, either mistakes or unusual circumstances.
duke@1 35 #
duke@1 36 # The naming convention for the default value of one of these variables
duke@1 37 # that has an ALT_* override capability is to name the default value with a
duke@1 38 # leading underscore (_). So for XXX you would have:
duke@1 39 # _XXX default value
duke@1 40 # ALT_XXX any override the user is providing if any
duke@1 41 # XXX the final value, either the default _XXX or the ALT_XXX value.
duke@1 42 #
duke@1 43
duke@1 44 # On Directory names. In very rare cases should the Windows directory
duke@1 45 # names use the backslash, please use the C:/ style of windows paths.
duke@1 46 # Avoid duplicating the // characters in paths, this has known to cause
duke@1 47 # strange problems with jar and other utilities, e.g. /a//b/ != /a/b/.
duke@1 48 # Some of these variables have an explicit trailing / character, but in
duke@1 49 # general, they should NOT have the trailing / character.
duke@1 50
duke@1 51 # Get shared system utilities macros defined
duke@1 52 include $(BUILDDIR)/common/shared/Defs-utils.gmk
duke@1 53
ohair@194 54 # Assumes ARCH, PLATFORM, etc. have been defined.
duke@1 55
duke@1 56 # Simple pwd path
duke@1 57 define PwdPath
duke@1 58 $(shell cd $1 2> $(DEV_NULL) && pwd)
duke@1 59 endef
duke@1 60
duke@1 61 # Checks an ALT value for spaces (should be one word),
duke@1 62 # warns and returns Check_ALT_$1 if spaces
duke@1 63 define AltCheckSpaces
duke@1 64 $(if $(word 2,$($1)),$(warning "WARNING: Value of $1 contains a space: '$($1)', check or set ALT_$1")Check_ALT_$1,$($1))
duke@1 65 endef
duke@1 66
duke@1 67 # Checks an ALT value for empty, warns and returns Check_ALT_$1 if empty
duke@1 68 define AltCheckValue
duke@1 69 $(if $($1),$($1),$(warning "WARNING: Value of $1 cannot be empty, check or set ALT_$1")Check_ALT_$1)
duke@1 70 endef
duke@1 71
duke@1 72 # Checks any value for empty, warns and returns $2 if empty
duke@1 73 define CheckValue
duke@1 74 $(if $($1),$($1),$(warning "WARNING: Value of $1 cannot be empty, will use '$2'")$2)
duke@1 75 endef
duke@1 76
duke@1 77 # Prefix for a utility prefix path, if empty leave alone, otherwise end with a /
duke@1 78 define PrefixPath
duke@1 79 $(if $1,$(subst //,/,$1/),)
duke@1 80 endef
duke@1 81
duke@1 82 # Select a directory if it exists, or the alternate 2 or the alternate 3
duke@1 83 define DirExists
duke@1 84 $(shell \
duke@1 85 if [ -d "$1" ]; then \
duke@1 86 echo "$1"; \
duke@1 87 elif [ -d "$2" ]; then \
duke@1 88 echo "$2"; \
duke@1 89 else \
duke@1 90 echo "$3"; \
duke@1 91 fi)
duke@1 92 endef
duke@1 93
duke@1 94 # Select a writable directory if it exists and is writable, or the alternate
duke@1 95 define WriteDirExists
duke@1 96 $(shell \
duke@1 97 if [ -d "$1" -a -w "$1" ]; then \
duke@1 98 echo "$1"; \
duke@1 99 else \
duke@1 100 echo "$2"; \
duke@1 101 fi)
duke@1 102 endef
duke@1 103
duke@1 104 # Select a file if it exists, or the alternate 1, or the alternate 2
duke@1 105 define FileExists
duke@1 106 $(shell \
duke@1 107 if [ -r "$1" ]; then \
duke@1 108 echo "$1"; \
duke@1 109 elif [ -r "$2" ]; then \
duke@1 110 echo "$2"; \
duke@1 111 else \
duke@1 112 echo "NO_FILE_EXISTS"; \
duke@1 113 fi)
duke@1 114 endef
duke@1 115
duke@1 116 # Given a line of text, get the major.minor version number from it
duke@1 117 define GetVersion
duke@1 118 $(shell echo $1 | sed -e 's@[^1-9]*\([1-9][0-9]*\.[0-9][0-9]*\).*@\1@' )
duke@1 119 endef
duke@1 120
duke@1 121 # Given a major.minor.micro version, return the major, minor, or micro number
duke@1 122 define MajorVersion
duke@1 123 $(if $(word 1, $(subst ., ,$1)),$(word 1, $(subst ., ,$1)),0)
duke@1 124 endef
duke@1 125 define MinorVersion
duke@1 126 $(if $(word 2, $(subst ., ,$1)),$(word 2, $(subst ., ,$1)),0)
duke@1 127 endef
duke@1 128 define MicroVersion
duke@1 129 $(if $(word 3, $(subst ., ,$1)),$(word 3, $(subst ., ,$1)),0)
duke@1 130 endef
duke@1 131
duke@1 132 # Macro that returns missing, same, newer, or older $1=version $2=required
duke@1 133 # (currently does not check the micro number)
duke@1 134 define CheckVersions
duke@1 135 $(shell \
duke@1 136 if [ "$1" = "" -o "$2" = "" ]; then \
duke@1 137 echo missing; \
duke@1 138 else \
duke@1 139 if [ "$1" = "$2" ]; then \
duke@1 140 echo same; \
duke@1 141 else \
duke@1 142 if [ $(call MajorVersion,$1) -lt $(call MajorVersion,$2) ] ; then \
duke@1 143 echo older; \
duke@1 144 else \
duke@1 145 if [ $(call MajorVersion,$1) -eq $(call MajorVersion,$2) -a \
duke@1 146 $(call MinorVersion,$1) -lt $(call MinorVersion,$2) ]; then \
duke@1 147 echo older; \
duke@1 148 else \
duke@1 149 echo newer; \
duke@1 150 fi; \
duke@1 151 fi; \
duke@1 152 fi; \
duke@1 153 fi)
duke@1 154 endef
duke@1 155
duke@1 156 # Make sure certain variables are non-empty at this point
duke@1 157 _check_values:=\
duke@1 158 $(call CheckValue,ARCH,),\
duke@1 159 $(call CheckValue,ARCH_DATA_MODEL,),\
duke@1 160 $(call CheckValue,VARIANT,),\
duke@1 161 $(call CheckValue,PLATFORM,)
duke@1 162
duke@1 163 # Misc common settings for all workspaces
duke@1 164 # This determines the version of the product, and the previous version or boot
duke@1 165 ifndef JDK_MAJOR_VERSION
duke@1 166 JDK_MAJOR_VERSION = 1
duke@1 167 PREVIOUS_MAJOR_VERSION = 1
duke@1 168 endif
duke@1 169
duke@1 170 ifndef JDK_MINOR_VERSION
duke@1 171 JDK_MINOR_VERSION = 7
duke@1 172 PREVIOUS_MINOR_VERSION = 6
duke@1 173 endif
duke@1 174
duke@1 175 ifndef JDK_MICRO_VERSION
duke@1 176 JDK_MICRO_VERSION = 0
duke@1 177 PREVIOUS_MICRO_VERSION = 0
duke@1 178 endif
duke@1 179
duke@1 180 ifndef MILESTONE
duke@1 181 MILESTONE = internal
duke@1 182 endif
duke@1 183
duke@1 184 ifndef BUILD_NUMBER
duke@1 185 JDK_BUILD_NUMBER = b00
duke@1 186 else
duke@1 187 ifndef JDK_BUILD_NUMBER
duke@1 188 JDK_BUILD_NUMBER = $(BUILD_NUMBER)
duke@1 189 endif
duke@1 190 endif
duke@1 191
duke@1 192 # Default variant is the optimized version of everything
duke@1 193 # can be OPT or DBG, default is OPT
duke@1 194 # Determine the extra pattern to add to the release name for debug/fastdebug.
duke@1 195 # Determine the JDK_IMPORT_VARIANT, so we get the right VM files copied over.
duke@1 196 #
duke@1 197 ifeq ($(VARIANT), DBG)
duke@1 198 BUILD_VARIANT_RELEASE=-debug
duke@1 199 else
duke@1 200 BUILD_VARIANT_RELEASE=
duke@1 201 endif
duke@1 202 ifeq ($(FASTDEBUG), true)
duke@1 203 VARIANT=DBG
duke@1 204 BUILD_VARIANT_RELEASE=-fastdebug
duke@1 205 _JDK_IMPORT_VARIANT=/fastdebug
duke@1 206 endif
duke@1 207
duke@1 208 # Depending on the flavor of the build, add a -debug or -fastdebug to the name
duke@1 209 ifdef DEBUG_NAME
duke@1 210 BUILD_VARIANT_RELEASE=-$(DEBUG_NAME)
duke@1 211 endif
duke@1 212
duke@1 213 JDK_VERSION = $(JDK_MAJOR_VERSION).$(JDK_MINOR_VERSION).$(JDK_MICRO_VERSION)
duke@1 214 JDK_UNDERSCORE_VERSION = $(subst .,_,$(JDK_VERSION))
duke@1 215
duke@1 216 # RELEASE is JDK_VERSION and -MILESTONE if MILESTONE is set
duke@1 217 ifneq ($(MILESTONE),fcs)
duke@1 218 RELEASE = $(JDK_VERSION)-$(MILESTONE)$(BUILD_VARIANT_RELEASE)
duke@1 219 else
duke@1 220 RELEASE = $(JDK_VERSION)$(BUILD_VARIANT_RELEASE)
duke@1 221 endif
duke@1 222
duke@1 223 # FULL_VERSION is RELEASE and -BUILD_NUMBER if BUILD_NUMBER is set
ohair@114 224 ifndef FULL_VERSION
ohair@114 225 ifdef BUILD_NUMBER
ohair@114 226 FULL_VERSION = $(RELEASE)-$(BUILD_NUMBER)
ohair@114 227 else
ohair@114 228 BUILD_NUMBER = b00
ohair@114 229 USER_RELEASE_SUFFIX := $(shell echo $(USER)_`date '+%d_%b_%Y_%H_%M' | tr "A-Z" "a-z"`)
ohair@114 230 FULL_VERSION = $(RELEASE)-$(USER_RELEASE_SUFFIX)-$(BUILD_NUMBER)
ohair@114 231 endif
ohair@114 232 export FULL_VERSION
duke@1 233 endif
duke@1 234
duke@1 235 # Promoted build location
duke@1 236 PROMOTED_RE_AREA = $(SLASH_JAVA)/re/jdk/$(JDK_VERSION)/promoted
duke@1 237 PROMOTED_BUILD_LATEST = latest
duke@1 238 PROMOTED_BUILD_BASEDIR = $(PROMOTED_RE_AREA)/$(PROMOTED_BUILD_LATEST)
duke@1 239 PROMOTED_BUILD_BINARIES = $(PROMOTED_BUILD_BASEDIR)/binaries
duke@1 240
duke@1 241 # OPT: Changes what the optimizations settings (in _OPT)
duke@1 242 POPT = $(_OPT$(ALT_OPT))$(ALT_OPT)
duke@1 243
duke@1 244 # PARALLEL_COMPILE_JOBS: is the number of compiles done in parallel.
duke@1 245 # If the user sets ALT_PARALLEL_COMPILE_JOBS, then COMPILE_APPROACH is set
duke@1 246 # to parallel.
duke@1 247 #
duke@1 248 # Recommended setting: 2 seems to be ideal for single cpu machines,
duke@1 249 # 2 times the number of CPU's is a basic formula,
duke@1 250 # but probably not more than 4 if the machine is
duke@1 251 # being shared by others, or the machine is limited
duke@1 252 # in RAM or swap.
duke@1 253 #
duke@1 254 ifdef ALT_PARALLEL_COMPILE_JOBS
duke@1 255 PARALLEL_COMPILE_JOBS=$(ALT_PARALLEL_COMPILE_JOBS)
duke@1 256 else
duke@1 257 PARALLEL_COMPILE_JOBS=2
duke@1 258 endif
duke@1 259
duke@1 260 # Previous JDK release (version of BOOTDIR version)
duke@1 261 ifdef ALT_PREVIOUS_JDK_VERSION
duke@1 262 PREVIOUS_JDK_VERSION = $(ALT_PREVIOUS_JDK_VERSION)
duke@1 263 else
duke@1 264 PREVIOUS_JDK_VERSION = $(PREVIOUS_MAJOR_VERSION).$(PREVIOUS_MINOR_VERSION).$(PREVIOUS_MICRO_VERSION)
duke@1 265 endif
duke@1 266 export PREVIOUS_JDK_VERSION
duke@1 267 PREVIOUS_JDK_VERSION:=$(call AltCheckSpaces,PREVIOUS_JDK_VERSION)
duke@1 268 PREVIOUS_JDK_VERSION:=$(call AltCheckValue,PREVIOUS_JDK_VERSION)
duke@1 269
duke@1 270 # Version with _ instead of . in number
duke@1 271 ifeq ($(PREVIOUS_MINOR_VERSION),5)
duke@1 272 PREVIOUS_JDK_UNDERSCORE_VERSION = $(subst .,_,$(PREVIOUS_JDK_VERSION))
duke@1 273 else
duke@1 274 PREVIOUS_JDK_UNDERSCORE_VERSION = $(PREVIOUS_MINOR_VERSION)
duke@1 275 endif
duke@1 276
duke@1 277 # Get platform specific settings
duke@1 278 include $(BUILDDIR)/common/shared/Defs-$(PLATFORM).gmk
duke@1 279
ohair@4 280 # Components
ohair@4 281 ifdef ALT_LANGTOOLS_DIST
ohair@4 282 LANGTOOLS_DIST :=$(call FullPath,$(ALT_LANGTOOLS_DIST))
ohair@4 283 else
ohair@4 284 LANGTOOLS_DIST =
ohair@4 285 endif
ohair@4 286
duke@1 287 # These are the same on all platforms but require the above platform include 1st
duke@1 288
duke@1 289 # BOOTDIR: Bootstrap JDK, previous released JDK.
duke@1 290 # _BOOTDIR1 and _BOOTDIR2 picked by platform
duke@1 291 ifdef ALT_BOOTDIR
duke@1 292 BOOTDIR =$(ALT_BOOTDIR)
duke@1 293 else
duke@1 294 BOOTDIR :=$(call DirExists,$(_BOOTDIR1),$(_BOOTDIR2),/NO_BOOTDIR)
duke@1 295 endif
duke@1 296 export BOOTDIR
duke@1 297 BOOTDIR:=$(call AltCheckSpaces,BOOTDIR)
duke@1 298 BOOTDIR:=$(call AltCheckValue,BOOTDIR)
duke@1 299
duke@1 300 # OUTPUTDIR: Location of all output for the build
duke@1 301 _BACKUP_OUTPUTDIR = $(TEMP_DISK)/$(USER)/jdk-outputdir
duke@1 302 ifdef ALT_OUTPUTDIR
duke@1 303 _POSSIBLE_OUTPUTDIR =$(subst \,/,$(ALT_OUTPUTDIR))
duke@1 304 else
duke@1 305 ifndef _OUTPUTDIR
duke@1 306 _OUTPUTDIR = $(_BACKUP_OUTPUTDIR)
duke@1 307 endif
duke@1 308 _POSSIBLE_OUTPUTDIR =$(_OUTPUTDIR)
duke@1 309 endif
duke@1 310 _create_outputdir1:=$(shell mkdir -p $(_POSSIBLE_OUTPUTDIR) > $(DEV_NULL) 2>&1)
duke@1 311 OUTPUTDIR:=$(call WriteDirExists,$(_POSSIBLE_OUTPUTDIR),$(_BACKUP_OUTPUTDIR))
duke@1 312 _create_outputdir2:=$(shell mkdir -p $(OUTPUTDIR) > $(DEV_NULL) 2>&1)
duke@1 313 ifeq "$(OUTPUTDIR)" "$(_BACKUP_OUTPUTDIR)"
duke@1 314 _outputdir_warning:=$(warning "WARNING: OUTPUTDIR '$(_POSSIBLE_OUTPUTDIR)' not writable, will use '$(_BACKUP_OUTPUTDIR)'")
duke@1 315 endif
duke@1 316 OUTPUTDIR:=$(call AltCheckSpaces,OUTPUTDIR)
duke@1 317 OUTPUTDIR:=$(call AltCheckValue,OUTPUTDIR)
duke@1 318
duke@1 319 # Bin directory
duke@1 320 # NOTE: ISA_DIR is usually empty, on Solaris it might be /sparcv9 or /amd64
duke@1 321 BINDIR = $(OUTPUTDIR)/bin$(ISA_DIR)
duke@1 322
duke@1 323 # Absolute path to output directory
duke@1 324 ABS_OUTPUTDIR:=$(call FullPath,$(OUTPUTDIR))
duke@1 325
duke@1 326

mercurial