make/common/shared/Defs.gmk

changeset 1
55540e827aef
child 4
a51017b6ba6d
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/make/common/shared/Defs.gmk	Sat Dec 01 00:00:00 2007 +0000
     1.3 @@ -0,0 +1,325 @@
     1.4 +#
     1.5 +# Copyright 2005-2007 Sun Microsystems, Inc.  All Rights Reserved.
     1.6 +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     1.7 +#
     1.8 +# This code is free software; you can redistribute it and/or modify it
     1.9 +# under the terms of the GNU General Public License version 2 only, as
    1.10 +# published by the Free Software Foundation.  Sun designates this
    1.11 +# particular file as subject to the "Classpath" exception as provided
    1.12 +# by Sun in the LICENSE file that accompanied this code.
    1.13 +#
    1.14 +# This code is distributed in the hope that it will be useful, but WITHOUT
    1.15 +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    1.16 +# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    1.17 +# version 2 for more details (a copy is included in the LICENSE file that
    1.18 +# accompanied this code).
    1.19 +#
    1.20 +# You should have received a copy of the GNU General Public License version
    1.21 +# 2 along with this work; if not, write to the Free Software Foundation,
    1.22 +# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    1.23 +#
    1.24 +# Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
    1.25 +# CA 95054 USA or visit www.sun.com if you need additional information or
    1.26 +# have any questions.
    1.27 +#
    1.28 +
    1.29 +#
    1.30 +# Defnitions for all platforms.
    1.31 +#
    1.32 +# Normally the convention is that these alternate definitions of
    1.33 +#   primary make variables are never defined inside the Makefiles anywhere
    1.34 +#   but are defined via environment variables or set on the make command
    1.35 +#   line. So you should never see an ALT_* variable defined in any
    1.36 +#   makefiles, just used. This is the convention and there are some
    1.37 +#   exceptions, either mistakes or unusual circumstances.
    1.38 +#
    1.39 +# The naming convention for the default value of one of these variables
    1.40 +#   that has an ALT_* override capability is to name the default value with a
    1.41 +#   leading underscore (_). So for XXX you would have:
    1.42 +#      _XXX      default value
    1.43 +#      ALT_XXX   any override the user is providing if any
    1.44 +#      XXX       the final value, either the default _XXX or the ALT_XXX value.
    1.45 +#
    1.46 +
    1.47 +# On Directory names. In very rare cases should the Windows directory
    1.48 +#    names use the backslash, please use the C:/ style of windows paths.
    1.49 +#    Avoid duplicating the // characters in paths, this has known to cause
    1.50 +#    strange problems with jar and other utilities, e.g. /a//b/ != /a/b/.
    1.51 +#    Some of these variables have an explicit trailing / character, but in
    1.52 +#    general, they should NOT have the trailing / character.
    1.53 +
    1.54 +# Get shared system utilities macros defined
    1.55 +include $(BUILDDIR)/common/shared/Defs-utils.gmk
    1.56 +
    1.57 +# Assumes ARCH, PLATFORM, ARCH_VM_SUBDIR, etc. have been defined.
    1.58 +
    1.59 +# Simple pwd path
    1.60 +define PwdPath
    1.61 +$(shell cd $1 2> $(DEV_NULL) && pwd)
    1.62 +endef
    1.63 +
    1.64 +# Checks an ALT value for spaces (should be one word), 
    1.65 +#       warns and returns Check_ALT_$1 if spaces
    1.66 +define AltCheckSpaces
    1.67 +$(if $(word 2,$($1)),$(warning "WARNING: Value of $1 contains a space: '$($1)', check or set ALT_$1")Check_ALT_$1,$($1))
    1.68 +endef
    1.69 +
    1.70 +# Checks an ALT value for empty, warns and returns Check_ALT_$1 if empty
    1.71 +define AltCheckValue
    1.72 +$(if $($1),$($1),$(warning "WARNING: Value of $1 cannot be empty, check or set ALT_$1")Check_ALT_$1)
    1.73 +endef
    1.74 +
    1.75 +# Checks any value for empty, warns and returns $2 if empty
    1.76 +define CheckValue
    1.77 +$(if $($1),$($1),$(warning "WARNING: Value of $1 cannot be empty, will use '$2'")$2)
    1.78 +endef
    1.79 +
    1.80 +# Prefix for a utility prefix path, if empty leave alone, otherwise end with a /
    1.81 +define PrefixPath
    1.82 +$(if $1,$(subst //,/,$1/),)
    1.83 +endef
    1.84 +
    1.85 +# Select a directory if it exists, or the alternate 2 or the alternate 3
    1.86 +define DirExists
    1.87 +$(shell \
    1.88 +  if [ -d "$1" ]; then  \
    1.89 +    echo "$1"; \
    1.90 +  elif [ -d "$2" ]; then \
    1.91 +    echo "$2"; \
    1.92 +  else \
    1.93 +    echo "$3"; \
    1.94 +  fi)
    1.95 +endef
    1.96 +
    1.97 +# Select a writable directory if it exists and is writable, or the alternate
    1.98 +define WriteDirExists
    1.99 +$(shell \
   1.100 +  if [ -d "$1" -a -w "$1" ]; then  \
   1.101 +    echo "$1"; \
   1.102 +  else \
   1.103 +    echo "$2"; \
   1.104 +  fi)
   1.105 +endef
   1.106 +
   1.107 +# Select a file if it exists, or the alternate 1, or the alternate 2
   1.108 +define FileExists
   1.109 +$(shell \
   1.110 +  if [ -r "$1" ]; then \
   1.111 +    echo "$1"; \
   1.112 +  elif [ -r "$2" ]; then \
   1.113 +    echo "$2"; \
   1.114 +  else \
   1.115 +    echo "NO_FILE_EXISTS"; \
   1.116 +  fi)
   1.117 +endef
   1.118 +
   1.119 +# Given a line of text, get the major.minor version number from it
   1.120 +define GetVersion
   1.121 +$(shell echo $1 | sed -e 's@[^1-9]*\([1-9][0-9]*\.[0-9][0-9]*\).*@\1@' )
   1.122 +endef
   1.123 +
   1.124 +# Given a major.minor.micro version, return the major, minor, or micro number
   1.125 +define MajorVersion
   1.126 +$(if $(word 1, $(subst ., ,$1)),$(word 1, $(subst ., ,$1)),0)
   1.127 +endef
   1.128 +define MinorVersion
   1.129 +$(if $(word 2, $(subst ., ,$1)),$(word 2, $(subst ., ,$1)),0)
   1.130 +endef
   1.131 +define MicroVersion
   1.132 +$(if $(word 3, $(subst ., ,$1)),$(word 3, $(subst ., ,$1)),0)
   1.133 +endef
   1.134 +
   1.135 +# Macro that returns missing, same, newer, or older $1=version $2=required
   1.136 +#  (currently does not check the micro number)
   1.137 +define CheckVersions
   1.138 +$(shell \
   1.139 +  if [ "$1" = "" -o "$2" = "" ]; then \
   1.140 +    echo missing; \
   1.141 +  else \
   1.142 +    if [ "$1" = "$2" ]; then \
   1.143 +      echo same; \
   1.144 +    else \
   1.145 +      if [ $(call MajorVersion,$1) -lt $(call MajorVersion,$2) ] ; then \
   1.146 +        echo older; \
   1.147 +      else \
   1.148 +	if [ $(call MajorVersion,$1) -eq $(call MajorVersion,$2) -a \
   1.149 +	     $(call MinorVersion,$1) -lt $(call MinorVersion,$2) ]; then \
   1.150 +          echo older; \
   1.151 +        else \
   1.152 +          echo newer; \
   1.153 +        fi; \
   1.154 +      fi; \
   1.155 +    fi; \
   1.156 +  fi)
   1.157 +endef
   1.158 +
   1.159 +# Make sure certain variables are non-empty at this point
   1.160 +_check_values:=\
   1.161 +$(call CheckValue,ARCH,),\
   1.162 +$(call CheckValue,ARCH_DATA_MODEL,),\
   1.163 +$(call CheckValue,ARCH_VM_SUBDIR,),\
   1.164 +$(call CheckValue,VARIANT,),\
   1.165 +$(call CheckValue,PLATFORM,)
   1.166 +
   1.167 +# Misc common settings for all workspaces
   1.168 +#   This determines the version of the product, and the previous version or boot
   1.169 +ifndef JDK_MAJOR_VERSION
   1.170 +  JDK_MAJOR_VERSION      = 1
   1.171 +  PREVIOUS_MAJOR_VERSION = 1
   1.172 +endif
   1.173 +
   1.174 +ifndef JDK_MINOR_VERSION
   1.175 +  JDK_MINOR_VERSION      = 7
   1.176 +  PREVIOUS_MINOR_VERSION = 6
   1.177 +endif
   1.178 +
   1.179 +ifndef JDK_MICRO_VERSION
   1.180 +  JDK_MICRO_VERSION      = 0
   1.181 +  PREVIOUS_MICRO_VERSION = 0
   1.182 +endif
   1.183 +
   1.184 +ifndef MILESTONE
   1.185 +  MILESTONE = internal
   1.186 +endif
   1.187 +
   1.188 +ifndef BUILD_NUMBER
   1.189 +  JDK_BUILD_NUMBER = b00
   1.190 +else
   1.191 +  ifndef JDK_BUILD_NUMBER
   1.192 +    JDK_BUILD_NUMBER = $(BUILD_NUMBER)
   1.193 +  endif
   1.194 +endif
   1.195 +
   1.196 +# Default variant is the optimized version of everything
   1.197 +#    can be OPT or DBG,  default is OPT
   1.198 +#    Determine the extra pattern to add to the release name for debug/fastdebug.
   1.199 +#    Determine the JDK_IMPORT_VARIANT, so we get the right VM files copied over.
   1.200 +#    Determine suffix for obj directory or OBJDIR, for .o files.
   1.201 +#    (by keeping .o files separate, just .o files, they don't clobber each
   1.202 +#     other, however, the library files will clobber each other).
   1.203 +#
   1.204 +ifeq ($(VARIANT), DBG)
   1.205 +  BUILD_VARIANT_RELEASE=-debug
   1.206 +  OBJDIRNAME_SUFFIX=_g
   1.207 +else
   1.208 +  BUILD_VARIANT_RELEASE=
   1.209 +  OBJDIRNAME_SUFFIX=
   1.210 +endif
   1.211 +ifeq ($(FASTDEBUG), true)
   1.212 +  VARIANT=DBG
   1.213 +  BUILD_VARIANT_RELEASE=-fastdebug
   1.214 +  OBJDIRNAME_SUFFIX=_gO
   1.215 +  _JDK_IMPORT_VARIANT=/fastdebug
   1.216 +endif
   1.217 +
   1.218 +# Depending on the flavor of the build, add a -debug or -fastdebug to the name
   1.219 +ifdef DEBUG_NAME
   1.220 +  BUILD_VARIANT_RELEASE=-$(DEBUG_NAME)
   1.221 +endif
   1.222 +
   1.223 +JDK_VERSION  = $(JDK_MAJOR_VERSION).$(JDK_MINOR_VERSION).$(JDK_MICRO_VERSION)
   1.224 +JDK_UNDERSCORE_VERSION =  $(subst .,_,$(JDK_VERSION))
   1.225 +
   1.226 +# RELEASE is JDK_VERSION and -MILESTONE if MILESTONE is set
   1.227 +ifneq ($(MILESTONE),fcs)
   1.228 +  RELEASE      = $(JDK_VERSION)-$(MILESTONE)$(BUILD_VARIANT_RELEASE)
   1.229 +else
   1.230 +  RELEASE      = $(JDK_VERSION)$(BUILD_VARIANT_RELEASE)
   1.231 +endif
   1.232 +
   1.233 +# FULL_VERSION is RELEASE and -BUILD_NUMBER if BUILD_NUMBER is set
   1.234 +ifdef BUILD_NUMBER
   1.235 +  FULL_VERSION = $(RELEASE)-$(BUILD_NUMBER)
   1.236 +else
   1.237 +  BUILD_NUMBER = b00
   1.238 +  USER_RELEASE_SUFFIX := $(shell echo $(USER)_`date '+%d_%b_%Y_%H_%M' | tr "A-Z" "a-z"`)
   1.239 +  FULL_VERSION = $(RELEASE)-$(USER_RELEASE_SUFFIX)-$(BUILD_NUMBER)
   1.240 +endif
   1.241 +
   1.242 +# Promoted build location
   1.243 +PROMOTED_RE_AREA = $(SLASH_JAVA)/re/jdk/$(JDK_VERSION)/promoted
   1.244 +PROMOTED_BUILD_LATEST = latest
   1.245 +PROMOTED_BUILD_BASEDIR = $(PROMOTED_RE_AREA)/$(PROMOTED_BUILD_LATEST)
   1.246 +PROMOTED_BUILD_BINARIES = $(PROMOTED_BUILD_BASEDIR)/binaries
   1.247 +
   1.248 +# OPT: Changes what the optimizations settings (in _OPT)
   1.249 +POPT = $(_OPT$(ALT_OPT))$(ALT_OPT)
   1.250 +
   1.251 +# PARALLEL_COMPILE_JOBS: is the number of compiles done in parallel.
   1.252 +#  If the user sets ALT_PARALLEL_COMPILE_JOBS, then COMPILE_APPROACH is set
   1.253 +#  to parallel.
   1.254 +#
   1.255 +#  Recommended setting: 2 seems to be ideal for single cpu machines,
   1.256 +#                       2 times the number of CPU's is a basic formula, 
   1.257 +#                       but probably not more than 4 if the machine is 
   1.258 +#                       being shared by others, or the machine is limited 
   1.259 +#                       in RAM or swap.
   1.260 +#
   1.261 +ifdef ALT_PARALLEL_COMPILE_JOBS
   1.262 +  PARALLEL_COMPILE_JOBS=$(ALT_PARALLEL_COMPILE_JOBS)
   1.263 +else
   1.264 +  PARALLEL_COMPILE_JOBS=2
   1.265 +endif
   1.266 +
   1.267 +# Previous JDK release (version of BOOTDIR version)
   1.268 +ifdef ALT_PREVIOUS_JDK_VERSION
   1.269 +  PREVIOUS_JDK_VERSION = $(ALT_PREVIOUS_JDK_VERSION)
   1.270 +else
   1.271 +  PREVIOUS_JDK_VERSION  = $(PREVIOUS_MAJOR_VERSION).$(PREVIOUS_MINOR_VERSION).$(PREVIOUS_MICRO_VERSION)
   1.272 +endif
   1.273 +export PREVIOUS_JDK_VERSION
   1.274 +PREVIOUS_JDK_VERSION:=$(call AltCheckSpaces,PREVIOUS_JDK_VERSION)
   1.275 +PREVIOUS_JDK_VERSION:=$(call AltCheckValue,PREVIOUS_JDK_VERSION)
   1.276 +
   1.277 +# Version with _ instead of . in number
   1.278 +ifeq ($(PREVIOUS_MINOR_VERSION),5)
   1.279 +  PREVIOUS_JDK_UNDERSCORE_VERSION =  $(subst .,_,$(PREVIOUS_JDK_VERSION))
   1.280 +else
   1.281 +  PREVIOUS_JDK_UNDERSCORE_VERSION = $(PREVIOUS_MINOR_VERSION)
   1.282 +endif
   1.283 +
   1.284 +# Get platform specific settings
   1.285 +include $(BUILDDIR)/common/shared/Defs-$(PLATFORM).gmk
   1.286 +
   1.287 +# These are the same on all platforms but require the above platform include 1st
   1.288 +
   1.289 +# BOOTDIR: Bootstrap JDK, previous released JDK.
   1.290 +#   _BOOTDIR1 and _BOOTDIR2 picked by platform
   1.291 +ifdef ALT_BOOTDIR
   1.292 +  BOOTDIR =$(ALT_BOOTDIR)
   1.293 +else
   1.294 +  BOOTDIR  :=$(call DirExists,$(_BOOTDIR1),$(_BOOTDIR2),/NO_BOOTDIR)
   1.295 +endif
   1.296 +export BOOTDIR
   1.297 +BOOTDIR:=$(call AltCheckSpaces,BOOTDIR)
   1.298 +BOOTDIR:=$(call AltCheckValue,BOOTDIR)
   1.299 +
   1.300 +# OUTPUTDIR: Location of all output for the build
   1.301 +_BACKUP_OUTPUTDIR = $(TEMP_DISK)/$(USER)/jdk-outputdir
   1.302 +ifdef ALT_OUTPUTDIR
   1.303 +  _POSSIBLE_OUTPUTDIR =$(subst \,/,$(ALT_OUTPUTDIR))
   1.304 +else
   1.305 +  ifndef _OUTPUTDIR
   1.306 +    _OUTPUTDIR = $(_BACKUP_OUTPUTDIR)
   1.307 +  endif
   1.308 +  _POSSIBLE_OUTPUTDIR =$(_OUTPUTDIR)
   1.309 +endif
   1.310 +_create_outputdir1:=$(shell mkdir -p $(_POSSIBLE_OUTPUTDIR) > $(DEV_NULL) 2>&1)
   1.311 +OUTPUTDIR:=$(call WriteDirExists,$(_POSSIBLE_OUTPUTDIR),$(_BACKUP_OUTPUTDIR))
   1.312 +_create_outputdir2:=$(shell mkdir -p $(OUTPUTDIR) > $(DEV_NULL) 2>&1)
   1.313 +ifeq "$(OUTPUTDIR)" "$(_BACKUP_OUTPUTDIR)"
   1.314 +  _outputdir_warning:=$(warning "WARNING: OUTPUTDIR '$(_POSSIBLE_OUTPUTDIR)' not writable, will use '$(_BACKUP_OUTPUTDIR)'")
   1.315 +endif
   1.316 +OUTPUTDIR:=$(call AltCheckSpaces,OUTPUTDIR)
   1.317 +OUTPUTDIR:=$(call AltCheckValue,OUTPUTDIR)
   1.318 +
   1.319 +# Bin directory
   1.320 +#   NOTE: ISA_DIR is usually empty, on Solaris it might be /sparcv9 or /amd64
   1.321 +BINDIR      = $(OUTPUTDIR)/bin$(ISA_DIR)
   1.322 +  
   1.323 +# Absolute path to output directory
   1.324 +ABS_OUTPUTDIR:=$(call FullPath,$(OUTPUTDIR))
   1.325 +
   1.326 +# Get shared compiler settings
   1.327 +include $(BUILDDIR)/common/shared/Compiler.gmk
   1.328 +

mercurial