1 #
   2 # Copyright (c) 2005, 2010, 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 # WARNING: This file is shared with other workspaces.
  28 #
  29 
  30 #
  31 # Shared sanity rules for the JDK builds.
  32 #
  33 
  34 .SUFFIXES: .hdiffs
  35 
  36 # All files created during sanity checking
  37 
  38 SANITY_FILES =  $(ERROR_FILE) $(WARNING_FILE) $(MESSAGE_FILE)
  39 
  40 # Build readme
  41 BUILD_README=http://hg.openjdk.java.net/jdk7/build/raw-file/tip/README-builds.html
  42 define BuildReadme # section
  43 "See $(BUILD_README)#$1 (or file:/$(call FullPath,$(JDK_TOPDIR)/../README-builds.html)#$1)."
  44 endef
  45 
  46 # How to say "The Release Engineering people use this"
  47 THE_OFFICIAL_USES=The official $(PLATFORM) builds use
  48 
  49 # Warning about using different versions
  50 MAY_PRODUCE=This may produce binaries incorrectly or cause the build to fail.
  51 
  52 # If a comma is needed in the sentence, use ${comma}
  53 comma=,
  54 
  55 # How to say "You are using:"
  56 YOU_ARE_USING=You appear to be using
  57 
  58 # Error message
  59 define SanityError # primary secondary
  60 $(PRINTF) "\nERROR: %s\n" $1   >> $(ERROR_FILE); \
  61 $(PRINTF)   "       %s\n" $2   >> $(ERROR_FILE)
  62 endef
  63 
  64 # Warning message
  65 define SanityWarning # primary secondary
  66 $(PRINTF) "\nWARNING: %s\n" $1   >> $(WARNING_FILE); \
  67 $(PRINTF)   "         %s\n" $2   >> $(WARNING_FILE)
  68 endef
  69 
  70 # Issue unset variable warning
  71 define UnsetSanityWarning # name envname extraLines
  72 $(call SanityWarning, "You do not have a $(strip $1) setting.", \
  73 "We recommend that you set $(strip $2)." $3)
  74 endef
  75 
  76 # Issue unset variable error
  77 define UnsetSanityError # name envname extraLines
  78 $(call SanityError, "You must have a $(strip $1) setting.", \
  79 "We recommend that you set $(strip $2)." $3)
  80 endef
  81 
  82 # Issue bad variable setting error
  83 define BadPathSanityError # name envname extraLines
  84 $(call SanityError, "You do not have a valid $(strip $1) setting.", \
  85 "Please check your access to $(strip $1)=$($(strip $1)) and/or check your value of $(strip $2)." $3)
  86 endef
  87 
  88 # Must be set and must exist and be a file
  89 define VarFileSanityCheck # name extraLines
  90 if [ ! -f "$($(strip $1))" -o ! -r "$($(strip $1))" ]; then \
  91 $(call SanityError, "Missing file $(strip $1)=$($(strip $1)).",$2); \
  92 fi
  93 endef
  94 
  95 # Must be set and must exist and be readable
  96 define VarPathSanityCheck # name envname extraLines
  97 if [ "$($(strip $1))" = "" ]; then \
  98 $(call UnsetSanityError,$(strip $1),$(strip $2),$3); \
  99 elif [ ! -d "$($(strip $1))" -o ! -r "$($(strip $1))" ]; then \
 100 $(call BadPathSanityError,$(strip $1),$(strip $2),$3); \
 101 fi
 102 endef
 103 
 104 # Unset is just a warning, if set must exist and be readable
 105 define OptionalVarPathSanityCheck # name envname extraLines
 106 if [ "$($(strip $1))" = "" ]; then \
 107 $(call UnsetSanityWarning,$(strip $1),$(strip $2),$3); \
 108 elif [ ! -d "$($(strip $1))" -o ! -r "$($(strip $1))" ]; then \
 109 $(call BadPathSanityError,$(strip $1),$(strip $2),$3); \
 110 fi
 111 endef
 112 
 113 # Common error, never set this environment variable
 114 define NeverSetSanityCheck # variableName
 115 $(if $($(strip $1)),$(call SanityError, \
 116 "Your $(strip $1) environment variable is set.", \
 117 "$(MAY_PRODUCE)" \
 118 "Please unset $(strip $1) and start your build again."),)
 119 endef
 120 
 121 define VarPathFileSanityCheck # name envname filepath extraLines
 122 if [ ! -f "$(strip $3)" -o ! -r  "$(strip $3)" ]; then \
 123 $(call SanityError, "File $(strip $3) does not exist.",\
 124 "You do not have a valid $(strip $1) setting." \
 125 "Please check your access to $(strip $1)=$($(strip $1)) and/or check your value of $(strip $2)." $4); \
 126 fi
 127 endef
 128 
 129 define OptionalVarPathFileSanityCheck # name envname filepath extraLines
 130 if [ ! -f "$(strip $3)" -o ! -r  "$(strip $3)" ]; then \
 131 $(call SanityWarning, "File $(strip $3) does not exist.",\
 132 "You do not have a valid $(strip $1) setting." \
 133 "Please check your access to $(strip $1)=$($(strip $1)) and/or check your value of $(strip $2)." $4); \
 134 fi
 135 endef
 136 
 137 # Common error, version too old, silent to be same or newer
 138 define VersionSanityCheck # toolName foundVer reqVer extraLines
 139 $(if $(subst newer,,$(subst same,,$(call CheckVersions,$(strip $2),$(strip $3)))),\
 140 $(call SanityError, \
 141 "$(YOU_ARE_USING) $(strip $1) $(strip $2) which is a $(call CheckVersions,$(strip $2),$(strip $3)) version.", \
 142 "$(THE_OFFICIAL_USES) $(strip $1) $(strip $3)." \
 143 "$(MAY_PRODUCE)" \
 144  $4)\
 145 ,)
 146 endef
 147 
 148 # Common error, version too old, and warn if not an exact match
 149 define SameVersionSanityCheck # toolName foundVer reqVer extraLines
 150 $(if $(subst newer,,$(call CheckVersions,$(strip $2),$(strip $3))),\
 151 $(call VersionSanityCheck,$(strip $1),$(strip $2),$(strip $3),$4),\
 152 $(call SanityWarning, \
 153 "$(YOU_ARE_USING) $(strip $1) $(strip $2) which is a $(call CheckVersions,$(strip $2),$(strip $3)) version.", \
 154 "$(THE_OFFICIAL_USES) $(strip $1) $(strip $3)." \
 155 "$(MAY_PRODUCE)" \
 156  $4))
 157 endef
 158 
 159 # Settings and rules to validate the JDK build environment.
 160 
 161 ifeq ($(PLATFORM), solaris)
 162   FREE_SPACE := $(shell $(DF) -b $(OUTPUTDIR) | $(TAIL) -1 | $(NAWK) '{print $$2;}')
 163   TEMP_FREE_SPACE := $(shell $(DF) -b $(TEMP_DISK) | $(TAIL) -1 | $(NAWK) '{print $$2;}')
 164   # What kind of system we are using (Variations are Solaris and OpenSolaris)
 165   OS_VERSION := $(shell uname -r)
 166   OS_VARIANT_NAME := $(strip $(shell head -1 /etc/release | awk '{print $$1;}') )
 167   OS_VARIANT_VERSION := $(OS_VERSION)
 168   REQ_PATCH_LIST = $(JDK_TOPDIR)/make/PatchList.solaris
 169   ifeq ($(ARCH_FAMILY), sparc)
 170     PATCH_POSITION = $$4
 171   else
 172     PATCH_POSITION = $$6
 173   endif
 174   ifndef OPENJDK
 175     _GCC_VER :=$(shell $(GCC) -dumpversion 2>&1 )
 176     GCC_VER  :=$(call GetVersion,"$(_GCC_VER)")
 177   endif
 178 endif
 179 
 180 ifeq ($(PLATFORM), linux)
 181   FREE_SPACE := $(shell $(DF) --sync -kP $(OUTPUTDIR) | $(TAIL) -1 | $(NAWK) '{print $$4;}')
 182   TEMP_FREE_SPACE := $(shell $(DF) --sync -kP $(TEMP_DISK) | $(TAIL) -1 | $(NAWK) '{print $$4;}')
 183   # What kind of system we are using (Variation is the Linux vendor)
 184   OS_VERSION := $(shell uname -r)
 185   OS_VARIANT_NAME := $(shell \
 186     if [ -f /etc/fedora-release ]; then \
 187       echo "Fedora"; \
 188     elif [ -f /etc/redhat-release ]; then \
 189       echo "RedHat"; \
 190     elif [ -f /etc/SuSE-release ]; then \
 191       echo "SuSE"; \
 192     else \
 193       echo "Unknown"; \
 194     fi)
 195   OS_VARIANT_VERSION := $(shell \
 196     if [ "$(OS_VARIANT_NAME)" = "Fedora" ]; then \
 197       $(CAT) /etc/fedora-release | $(HEAD) -1 | $(NAWK) '{ print $$3; }' ; \
 198     fi)
 199   ALSA_INCLUDE=/usr/include/alsa/version.h
 200   ALSA_LIBRARY=/usr/lib/libasound.so
 201   _ALSA_VERSION := $(shell $(EGREP) SND_LIB_VERSION_STR $(ALSA_INCLUDE) | \
 202            $(SED) -e 's@.*\"\(.*\)\".*@\1@' )
 203   ALSA_VERSION := $(call GetVersion,$(_ALSA_VERSION))
 204 endif
 205 
 206 ifeq ($(PLATFORM), windows)
 207   FREE_SPACE := $(shell $(DF) -kP $(OUTPUTDIR) | $(TAIL) -1 | $(NAWK) '{print $$4;}')
 208   TEMP_FREE_SPACE := $(shell $(DF) -kP $(TEMP_DISK) | $(TAIL) -1 | $(NAWK) '{print $$4;}')
 209   # Windows 2000 is 5.0, Windows XP is 5.1, Windows 2003 is 5.2
 210   #    Assume 5.0 (Windows 2000) if systeminfo does not help
 211   WINDOWS_MAPPING-5.0 := Windows2000
 212   WINDOWS_MAPPING-5.1 := WindowsXP
 213   WINDOWS_MAPPING-5.2 := Windows2003
 214   # What kind of system we are using (Variation is the common name)
 215   _OS_VERSION := \
 216     $(shell systeminfo 2> $(DEV_NULL) | \
 217             egrep '^OS Version:' | \
 218             awk '{print $$3;}' )
 219   ifeq ($(_OS_VERSION),)
 220     OS_VERSION = 5.0
 221   else
 222     OS_VERSION = $(call MajorVersion,$(_OS_VERSION)).$(call MinorVersion,$(_OS_VERSION))
 223   endif
 224   OS_VARIANT_NAME := $(WINDOWS_MAPPING-$(OS_VERSION))
 225   OS_VARIANT_VERSION := $(OS_VERSION)
 226   ifdef USING_CYGWIN
 227     # CYGWIN version
 228     _CYGWIN_VER := $(SYSTEM_UNAME)
 229     CYGWIN_VER  :=$(call GetVersion,$(_CYGWIN_VER))
 230   endif
 231   DXSDK_VER := $(shell $(EGREP) DIRECT3D_VERSION $(DXSDK_INCLUDE_PATH)/d3d9.h 2>&1 | \
 232     $(EGREP) "\#define" | $(NAWK) '{print $$3}')
 233 endif
 234 
 235 # Get the version numbers of what we are using
 236 _MAKE_VER  :=$(shell $(MAKE) --version 2>&1 | $(HEAD) -n 1)
 237 _ZIP_VER   :=$(shell $(ZIPEXE) -help 2>&1 | $(HEAD) -n 4 | $(EGREP) '^Zip')
 238 _UNZIP_VER :=$(shell $(UNZIP)  -help 2>&1 | $(HEAD) -n 4 | $(EGREP) '^UnZip')
 239 _BOOT_VER  :=$(shell $(BOOTDIR)/bin/java -version 2>&1 | $(HEAD) -n 1)
 240 MAKE_VER   :=$(call GetVersion,"$(_MAKE_VER)")
 241 ZIP_VER    :=$(call GetVersion,"$(_ZIP_VER)")
 242 UNZIP_VER  :=$(call GetVersion,"$(_UNZIP_VER)")
 243 BOOT_VER   :=$(call GetVersion,"$(_BOOT_VER)")
 244 
 245 _ANT_VER:=$(shell $(ANT) -version 2>&1 )
 246 ANT_VER:=$(call GetVersion,"$(_ANT_VER)")
 247 
 248 ifdef ALT_BINDIR
 249   ALT_BINDIR_VERSION := $(shell $(ALT_BINDIR)/java$(EXE_SUFFIX) -version 2>&1  | $(NAWK) -F'"' '{ print $$2 }')
 250   ALT_BINDIR_OK := $(shell $(ECHO) $(ALT_BINDIR_VERSION) | $(EGREP) -c '^$(JDK_MAJOR_VERSION).$(JDK_MINOR_VERSION)')
 251 endif
 252 
 253 INSTALL_PATCHES_FILE = $(TEMPDIR)/installed.patches
 254 
 255 # Get ALL_SETTINGS defined
 256 include $(JDK_MAKE_SHARED_DIR)/Sanity-Settings.gmk
 257 
 258 .PHONY: \
 259         sane-copyrightyear\
 260         sane-settings \
 261         sane-insane \
 262         sane-build_number \
 263         sane-os_version \
 264         sane-memory_check \
 265         sane-windows \
 266         sane-locale \
 267         sane-linux \
 268         sane-cygwin \
 269         sane-cygwin-shell \
 270         sane-mks \
 271         sane-arch_data_model \
 272         sane-os_patch_level \
 273         sane-classpath \
 274         sane-java_home \
 275         sane-fonts \
 276         sane-binary-plugs \
 277         sane-variant \
 278         sane-ld_library_path \
 279         sane-ld_library_path_64 \
 280         sane-ld_options \
 281         sane-ld_run_path \
 282         sane-makeflags \
 283         sane-alt_outputdir \
 284         sane-outputdir \
 285         sane-alt_bootdir \
 286         sane-bootdir \
 287         sane-local-bootdir \
 288         sane-cups \
 289         sane-devtools_path \
 290         sane-compiler_path \
 291         sane-unixcommand_path \
 292         sane-usrbin_path \
 293         sane-unixccs_path \
 294         sane-docs_import \
 295         sane-math_iso \
 296         sane-libCrun \
 297         sane-odbcdir \
 298         sane-msdevtools_path \
 299         sane-hotspot_binaries \
 300         sane-hotspot_import \
 301         sane-hotspot_import_dir \
 302         sane-hotspot_import_include \
 303         sane-compiler \
 304         sane-link \
 305         sane-cacerts \
 306         sane-alsa-headers \
 307         sane-ant_version \
 308         sane-zip_version \
 309         sane-unzip_version \
 310         sane-msvcrt_path \
 311         sane-freetype \
 312         sane-build_modules
 313 
 314 ######################################################
 315 # check for COPYRIGHT_YEAR variable
 316 ######################################################
 317 sane-copyrightyear:
 318 ifdef ALT_COPYRIGHT_YEAR
 319         @$(call SanityWarning, \
 320 "ALT_COPYRIGHT_YEAR but not the current year will be used for copyright year.",)
 321 endif
 322 
 323 ######################################################
 324 # check for INSANE variable
 325 ######################################################
 326 sane-insane:
 327 ifdef INSANE
 328         @$(call SanityWarning, \
 329 "You are building in 'INSANE' mode${comma} this is not a supported option.", \
 330 "Builds can be unpredictable and should not be trusted.")
 331 endif
 332 
 333 ######################################################
 334 # check for GNU Make version
 335 ######################################################
 336 sane-make:
 337         @$(call VersionSanityCheck,make,\
 338                 $(MAKE_VER),$(REQUIRED_MAKE_VER),)
 339 
 340 ######################################################
 341 # Check the BUILD_NUMBER to make sure it contains bNN
 342 ######################################################
 343 sane-build_number: 
 344         @if [ "`$(ECHO) $(BUILD_NUMBER) | $(SED) 's@.*b[0-9][0-9]*.*@bNN@'`" != "bNN" ]; then \
 345             $(call SanityWarning, \
 346 "The BUILD_NUMBER needs to contain b[0-9][0-9]*.", \
 347 "Currently BUILD_NUMBER=$(BUILD_NUMBER). \
 348 This has been known to cause build failures.") ; \
 349         fi
 350 
 351 ######################################################
 352 # Check the ARCH_DATA_MODEL setting
 353 ######################################################
 354 sane-arch_data_model:
 355 ifneq ($(ARCH_DATA_MODEL),32)
 356   ifneq ($(ARCH_DATA_MODEL),64)
 357         @$(call SanityError, \
 358 "The setting of ARCH_DATA_MODEL must be 32 or 64.", \
 359 "$(YOU_ARE_USING) ARCH_DATA_MODEL=$(ARCH_DATA_MODEL).")
 360   endif
 361 endif
 362 
 363 ######################################################
 364 # Check the OS version
 365 #   NOTE: OPENJDK explicitly does not check for OS release information.
 366 #         Unless we know for sure that it will not build somewhere, we cannot
 367 #         generate a fatal sanity error, and a warning about the official
 368 #         build platform just becomes clutter.
 369 ######################################################
 370 sane-os_version:: sane-arch_data_model sane-memory_check sane-locale sane-os_patch_level
 371 ifndef OPENJDK
 372   ifeq ($(OS_VARIANT_NAME),$(REQUIRED_OS_VARIANT_NAME))
 373         @$(call SameVersionSanityCheck,$(OS_VARIANT_NAME) version, \
 374                 $(OS_VARIANT_VERSION),$(REQUIRED_OS_VARIANT_VERSION),)
 375   else
 376         @$(call SanityWarning,\
 377 "$(OS_VARIANT_NAME) is not the required or expected $(REQUIRED_OS_VARIANT_NAME) variation.", )
 378         @$(call SameVersionSanityCheck,$(PLATFORM) version,\
 379                 $(OS_VERSION),$(REQUIRED_OS_VERSION),)
 380   endif
 381 else
 382   ifeq ($(OS_VARIANT_NAME),$(REQUIRED_OS_VARIANT_NAME))
 383         @$(call VersionSanityCheck,$(OS_VARIANT_NAME) version,\
 384                 $(OS_VARIANT_VERSION),$(REQUIRED_OS_VARIANT_VERSION),)
 385   else
 386         @$(call SanityWarning,\
 387 "$(OS_VARIANT_NAME) is not the required $(REQUIRED_OS_VARIANT_NAME)", )
 388         @$(call VersionSanityCheck,$(PLATFORM) version,\
 389                 $(OS_VERSION),$(REQUIRED_OS_VERSION),)
 390   endif
 391 endif # OPENJDK
 392 
 393 ifeq ($(PLATFORM), windows)
 394   sane-os_version:: sane-cygwin sane-mks sane-cygwin-shell
 395 endif
 396 
 397 ######################################################
 398 # Check the memory available on this machine
 399 ######################################################
 400 sane-memory_check:
 401         @if [ "$(LOW_MEMORY_MACHINE)" = "true" ]; then \
 402           $(call SanityWarning, \
 403 "This machine appears to only have $(MB_OF_MEMORY)Mb of physical memory.", \
 404 "Builds on this machine could be slow.") ; \
 405         fi
 406 
 407 ######################################################
 408 # Check the locale (value of LC_ALL, not being empty or ==C can be a problem)
 409 ######################################################
 410 sane-locale:
 411 ifneq ($(PLATFORM), windows)
 412         @if [ "$(LC_ALL)" != "" -a "$(LC_ALL)" != "C" ]; then \
 413           $(call SanityWarning, \
 414 "LC_ALL has been set to $(LC_ALL)${comma} this can cause build failures.", \
 415 "Try setting LC_ALL to \"C\"."); \
 416         fi
 417         @if [ "$(LANG)" != "" -a "$(LANG)" != "C" ]; then \
 418           $(call SanityWarning, \
 419 "LANG has been set to $(LANG)${comma} this can cause build failures.", \
 420 "Try setting LANG to \"C\".") ; \
 421         fi
 422 endif
 423 
 424 ######################################################
 425 # Check the Windows cygwin version
 426 ######################################################
 427 ifeq ($(PLATFORM), windows)
 428 sane-cygwin:
 429   ifdef USING_CYGWIN
 430         @$(call VersionSanityCheck,CYGWIN,\
 431                 $(CYGWIN_VER),$(REQUIRED_CYGWIN_VER),)
 432   endif
 433 endif
 434 
 435 ######################################################
 436 # Check the cygwin shell is used, not cmd.exe
 437 ######################################################
 438 ifeq ($(PLATFORM), windows)
 439 sane-cygwin-shell:
 440   ifdef USING_CYGWIN
 441         @if [ "$(SHLVL)" = "" -a "$(_)" = "" ]; then \
 442           $(call SanityError, \
 443 "You are using an unsupported shell.", \
 444 "Use either sh${comma} bash${comma} ksh${comma} zsh${comma} or tcsh." \
 445 "Using the cmd.exe utility is not supported." \
 446 "If you still want to try your current shell${comma} \
 447  please export SHLVL=1 when running $(MAKE)."); \
 448         fi
 449   endif
 450 endif
 451 
 452 ######################################################
 453 # Check the Windows mks version
 454 ######################################################
 455 ifeq ($(PLATFORM), windows)
 456 sane-mks:
 457   ifndef USING_CYGWIN
 458         @$(call VersionSanityCheck,MKS,\
 459                 $(MKS_VER),$(REQUIRED_MKS_VER),)
 460   endif
 461 endif
 462 
 463 ######################################################
 464 # Get list of installed patches (this file has a particular format)
 465 ######################################################
 466 $(INSTALL_PATCHES_FILE):
 467         @$(prep-target)
 468 ifeq ($(PLATFORM), solaris)
 469   ifeq ($(OS_VERSION),$(REQUIRED_OS_VERSION))
 470         $(SHOWREV) -p > $@ 2>&1
 471   endif
 472 endif
 473         @$(ECHO) "" >> $@
 474 
 475 ######################################################
 476 # Check list of Solaris patches
 477 ######################################################
 478 sane-os_patch_level: $(INSTALL_PATCHES_FILE)
 479 ifeq ($(PLATFORM), solaris)
 480   ifeq ($(OS_VERSION),$(REQUIRED_OS_VERSION))
 481         @$(NAWK) 'BEGIN { \
 482     readingInstallPatches = 0; \
 483     requiredCount = 0; \
 484     installCount = 0; \
 485 } \
 486 { \
 487     if (readingInstallPatches) { \
 488         if ($$1=="Patch:") { \
 489             ns = split($$2,parts,"-");  \
 490             installPatchNo[installCount]=parts[1]; \
 491             installPatchRev[installCount]=parts[2]; \
 492             installCount++; \
 493         } \
 494     } \
 495      \
 496     if (!readingInstallPatches) { \
 497         if (index($$1,"#") != 0) continue; \
 498         if (match($$1,"BUILD") > 0 \
 499         && $$2 == $(OS_VERSION) \
 500         && ($$7 == "REQ" || $$7 == "req") \
 501         && $(PATCH_POSITION) != "none" \
 502         && $(PATCH_POSITION) != "NONE") { \
 503             ns = split($(PATCH_POSITION),parts,"-");  \
 504             requiredPatchNo[requiredCount]=parts[1]; \
 505             requiredPatchRev[requiredCount]=parts[2]; \
 506             requiredCount++; \
 507        } \
 508     } \
 509 } \
 510 END { \
 511     errorCount=0; \
 512     for (i=0; i<requiredCount; i++) { \
 513         foundMatch = 0; \
 514         for (j=0; j<installCount; j++) { \
 515             if (installPatchNo[j] == requiredPatchNo[i] \
 516             && installPatchRev[j] >= requiredPatchRev[i]) { \
 517                 foundMatch = 1; \
 518                 break; \
 519             } \
 520         } \
 521         if ( foundMatch == 0) { \
 522             printf("WARNING: Your solaris install is missing the required patch %s-%s\n", requiredPatchNo[i], requiredPatchRev[i] ); \
 523             printf("         Please update your your system patches or build on a different machine.\n\n" ); \
 524             errorCount++; \
 525         } \
 526     } \
 527 }' $(REQ_PATCH_LIST) readingInstallPatches=1 $(INSTALL_PATCHES_FILE) >> $(WARNING_FILE)
 528   endif
 529 endif # PLATFORM
 530 
 531 ######################################################
 532 # CLASSPATH cannot be set, unless you are insane.
 533 ######################################################
 534 sane-classpath:
 535         @$(call NeverSetSanityCheck, CLASSPATH)
 536 
 537 ######################################################
 538 # JAVA_HOME cannot be set, unless you are insane.
 539 ######################################################
 540 sane-java_home:
 541         @$(call NeverSetSanityCheck, JAVA_HOME)
 542 
 543 ######################################################
 544 # Make sure the fonts are there
 545 # Exceptions are when explicitly building OPENJDK, or
 546 # when the entire CLOSED_SRC dir is excluded, so we are
 547 # implicitly building OPENJDK
 548 ######################################################
 549 FONT_FILE=$(CLOSED_SRC)/share/lib/fonts/LucidaTypewriterRegular.ttf
 550 sane-fonts:
 551 ifndef OPENJDK
 552         @if [ -d $(CLOSED_SRC) ]; then \
 553           $(call VarFileSanityCheck,FONT_FILE, \
 554 "Verify you have downloaded and overlayed on the source area all the binary files.") ; \
 555         fi
 556 endif
 557 
 558 ######################################################
 559 # If building OPENJDK check pre-built binaries are
 560 # available for binary plug source components.
 561 ######################################################
 562 ifdef OPENJDK
 563 sane-binary-plugs:
 564   ifeq ($(IMPORT_BINARY_PLUGS),true)
 565         @$(call OptionalVarPathSanityCheck,\
 566                 BINARY_PLUGS_PATH,ALT_BINARY_PLUGS_PATH, )
 567   endif
 568 endif
 569 
 570 ######################################################
 571 # VARIANT must be set to DBG or OPT
 572 ######################################################
 573 sane-variant:
 574 ifneq ($(VARIANT),DBG)
 575   ifneq ($(VARIANT),OPT)
 576         @$(call SanityError, \
 577 "Your VARIANT environment variable is set to VARIANT=$(VARIANT) \
 578  and needs to be set to DBG or OPT.",)
 579   endif
 580 endif
 581 
 582 ######################################################
 583 # LD_LIBRARY_PATH should not be set, unless you are insane.
 584 ######################################################
 585 sane-ld_library_path:
 586         @$(call NeverSetSanityCheck, LD_LIBRARY_PATH)
 587 
 588 ######################################################
 589 # LD_LIBRARY_PATH_64 should not be set, unless you are insane.
 590 ######################################################
 591 sane-ld_library_path_64:
 592         @$(call NeverSetSanityCheck, LD_LIBRARY_PATH_64)
 593 
 594 ######################################################
 595 # LD_OPTIONS should not be set, unless you are insane.
 596 ######################################################
 597 sane-ld_options:
 598         @$(call NeverSetSanityCheck, LD_OPTIONS)
 599 
 600 ######################################################
 601 # LD_RUN_PATH should not be set, unless you are insane.
 602 ######################################################
 603 sane-ld_run_path:
 604         @$(call NeverSetSanityCheck, LD_RUN_PATH)
 605 
 606 ######################################################
 607 # MAKEFLAGS cannot be set, unless you are insane.
 608 #   it is unacceptable  to have these in MAKEFLAGS
 609 #     -e or --environment-overrides
 610 #     -i or --ignore-errors
 611 #     -I or --include-dir
 612 #     -k or --keep-going
 613 #     -r or --nobuiltin-rules
 614 #     -o or --assume-old or --old-filevalue
 615 #     -t or --touch value in MAKEFLAGS
 616 #       Note - some may be processed out in GNU Make startup
 617 ######################################################
 618 sane-makeflags:
 619 ifeq ($(origin MAKEFLAGS),environment)
 620         @if [ `$(ECHO) $(MAKEFLAGS) | $(EGREP) -c '(^| )(e|--environment-overrides)( |$$)'` -ne 0 ]; then \
 621           $(call SanityError, \
 622 "Either the build was started with the flag -e or \
 623  --environment-overrides or the MAKEFLAGS variable has this value set.", \
 624 "This will cause any environment variables you have defined to override \
 625  the values defined by the makefiles." \
 626 "This practice is not recommemded by the authors of GNU Make \
 627  and will lead to an improper build." \
 628 "Please fix and restart the build.") ; \
 629         fi
 630         @if [ `$(ECHO) $(MAKEFLAGS) | $(EGREP) -c '(^| )(i|--ignore-errors)( |$$)'` -ne 0 ]; then \
 631           $(call SanityError, \
 632 "Either the build was started with the flag -i or \
 633  --ignore-errors or the MAKEFLAGS environment variable has this value set.", \
 634 "You will be unable to determine if the build is broken or not." \
 635 "Please fix and restart the build.") ; \
 636         fi
 637         @if [ `$(ECHO) $(MAKEFLAGS) | $(EGREP) -c '(^| )(I|--include-dir)( |$$)'` -ne 0 ]; then \
 638           $(call SanityError, \
 639 "Either the build was started with the flag -I or --include-dir \
 640  or the MAKEFLAGS environment variable has this value set.", \
 641 "This will render your build questionable as not all the rules and \
 642  dependencies are captured by the build." \
 643 "Please fix and restart the build.") ; \
 644         fi
 645         @if [ `$(ECHO) $(MAKEFLAGS) | $(EGREP) -c '(^| )(k|--keep-going)( |$$)'` -ne 0 ]; then \
 646           $(call SanityError, \
 647 "Either the build was started with the flag -k or --keep-going \
 648  or the MAKEFLAGS environment variable has this value set.", \
 649 "You will be unable to determine if the build is broken or not." \
 650 "Please fix and restart the build.") ; \
 651         fi
 652         @if [ `$(ECHO) $(MAKEFLAGS) | $(EGREP) -c '(^| )(o|--assume-old|--old-file)( |$$)'` -ne 0 ]; then \
 653           $(call SanityError, \
 654 "Either the build was started with the flag -o or --assume-old or --old-file \
 655  or the MAKEFLAGS environment variable has this value set.", \
 656 "This could prevent the build from executing rules it should \
 657  thus rendering a questionable result." \
 658 "Please fix and restart the build.") ; \
 659         fi
 660         @if [ `$(ECHO) $(MAKEFLAGS) | $(EGREP) -c '(^| )(r|--no-builtin-rules)( |$$)'` -ne 0 ]; then \
 661           $(call SanityError, \
 662 "Either the build was started with the flag -r or --no-builtin-rules \
 663  or the MAKEFLAGS environment variable has this value set.", \
 664 "This may break the build by not allowing builtin rules that may be required." \
 665 "Please fix and restart the build.") ; \
 666         fi
 667         @if [ `$(ECHO) $(MAKEFLAGS) | $(EGREP) -c '(^| )(t|--touch)( |$$)'` -ne 0 ]; then \
 668           $(call SanityError, \
 669 "Either the build was started with the flag -t or --touch \
 670  or the MAKEFLAGS environment variable has this value set.", \
 671 "This will leave the build in a unclear state and could lead to not \
 672  executing rules which should be executed." \
 673 "Please fix and restart the build.") ; \
 674         fi
 675         @$(call NeverSetSanityCheck, MAKEFLAGS)
 676 endif
 677 
 678 ######################################################
 679 # if specified, ALT_OUTPUTDIR must point to non-relative path if set
 680 ######################################################
 681 sane-alt_outputdir:
 682 ifdef ALT_OUTPUTDIR
 683         @if [ `$(ECHO) $(subst \,/,$(ALT_OUTPUTDIR)) | $(EGREP) -c '^([A-Za-z]:)?/'` -ne 1 ]; then \
 684           $(call SanityError, \
 685 "ALT_OUTPUTDIR must be an Absolute Path Name not a Relative Path Name.",) ; \
 686         fi
 687   ifeq ($(PLATFORM), windows)
 688         @if [ `$(ECHO) $(subst \,/,$(ALT_OUTPUTDIR)) | $(EGREP) -c '^([A-Za-z]:)'` -ne 1 ]; then \
 689           $(call SanityError, \
 690 "On windows ALT_OUTPUTDIR must contain the drive letter.",) ; \
 691         fi
 692   endif
 693 endif
 694 
 695 ######################################################
 696 # OUTPUTDIR tests
 697 ######################################################
 698 sane-outputdir:
 699         @$(call VarPathSanityCheck,OUTPUTDIR,ALT_OUTPUTDIR, )
 700         @if [ ! -w "$(OUTPUTDIR)" ]; then \
 701           $(call SanityError, \
 702 "You must have write permissions to OUTPUTDIR.", \
 703 "The current value of OUTPUTDIR is $(OUTPUTDIR)." \
 704 "Either obtain these permissions or set ALT_OUTPUTDIR.") ; \
 705         fi
 706         @if [ $(FREE_SPACE) -lt $(REQUIRED_FREE_SPACE) ]; then \
 707           $(call SanityWarning, \
 708 "You may not have enough free space in your OUTPUTDIR.", \
 709 "The current value of OUTPUTDIR is $(OUTPUTDIR)." \
 710 "You need '$(REQUIRED_FREE_SPACE)' Kbytes free on this device to build \
 711 and it appears that only '$(FREE_SPACE)' Kbytes are free." \
 712 "Either obtain more space or set ALT_OUTPUTDIR to a larger disk.") ; \
 713         fi
 714 
 715 ######################################################
 716 # if specified, ALT_BOOTDIR must point to non-relative path if set
 717 ######################################################
 718 sane-alt_bootdir:
 719 ifdef ALT_BOOTDIR
 720         @if [ `$(ECHO) $(subst \,/,$(ALT_BOOTDIR)) | $(EGREP) -c '^([A-Za-z]:)?/'` -ne 1 ]; then \
 721           $(call SanityError, \
 722 "ALT_BOOTDIR must be an Absolute Path Name${comma} not a Relative Path Name.", \
 723 "The current value of ALT_BOOTDIR is $(ALT_BOOTDIR)." \
 724 "Please fix this and continue your build.") ; \
 725         fi
 726 endif
 727 
 728 ######################################################
 729 # BOOTDIR must point to a valid JDK.
 730 ######################################################
 731 sane-bootdir:
 732         @$(call VersionSanityCheck,boot JDK,\
 733                 $(BOOT_VER),$(REQUIRED_BOOT_VER), \
 734 "Your ALT_BOOTDIR environment variable does not point to a valid JDK \
 735  for bootstrapping this build." \
 736 "A JDK $(JDK_MINOR_VERSION) $(MARKET_NAME) build must be bootstrapped using \
 737  JDK $(PREVIOUS_JDK_VERSION) fcs (or later).")
 738 
 739 ######################################################
 740 # BOOTDIR is recommended to reside on a local drive
 741 ######################################################
 742 sane-local-bootdir:
 743 ifeq ($(PLATFORM), windows)
 744         @if [ `$(ECHO) $(BOOTDIR) | $(EGREP) -c '^[jJ]:'` -ne 0 ]; then \
 745           $(call SanityWarning, \
 746 "Your BOOTDIR is located on the J: drive.", \
 747 "Often the J: drive is mapped over a network." \
 748 "Using a mapped drive for the BOOTDIR may significantly slow down the build process." \
 749 "You may want to consider using the ALT_BOOTDIR variable to point the build \
 750  to another location for the BOOTDIR instead." \
 751 "Your current BOOTDIR is: $(BOOTDIR)") ; \
 752         fi
 753 endif
 754 
 755 ######################################################
 756 # CACERTS_FILE must be absoulte path and readable
 757 ######################################################
 758 sane-cacerts:
 759   ifdef ALT_CACERTS_FILE
 760         @if [ `$(ECHO) $(subst \,/,$(ALT_CACERTS_FILE)) | $(EGREP) -c '^([A-Za-z]:)?/'` -ne 1 ]; then \
 761           $(call SanityError, \
 762 "ALT_CACERTS_FILE must be an Absolute Path Name not a Relative Path Name.", \
 763 "The current value of ALT_CACERTS_FILE is $(ALT_CACERTS_FILE)." \
 764 "Please fix this and continue your build.") ; \
 765         fi
 766   endif
 767         @#
 768         @# CACERTS_FILE must be readable
 769         @#
 770         @if [ ! -r "$(subst \,/,$(CACERTS_FILE))" ]; then \
 771           $(call SanityError, \
 772 "You do not have access to a valid cacerts file.", \
 773 "Please check your access to $(subst \,/,$(CACERTS_FILE)) \
 774  and/or check your value of ALT_CACERTS_FILE.") ; \
 775         fi
 776         @#
 777         @# CACERTS_FILE must be a file
 778         @#
 779         @if [ -d "$(subst \,/,$(CACERTS_FILE))" ]; then \
 780           $(call SanityError, \
 781 "You do not have access to a valid cacerts file.", \
 782 "The value of CACERTS_FILE must point to a normal file." \
 783 "Please check your access to $(subst \,/,$(CACERTS_FILE)) \
 784  and/or check your value of ALT_CACERTS_FILE.") ; \
 785         fi
 786 
 787 
 788 ######################################################
 789 # Check for availability of FreeType (OpenJDK specific)
 790 ######################################################
 791 
 792 ifdef OPENJDK
 793 
 794 # The freetypecheck Makefile prints out "Failed" if not good enough
 795 $(TEMPDIR)/freetypeinfo: FRC
 796         @$(prep-target)
 797         @(($(CD) $(BUILDDIR)/tools/freetypecheck && $(MAKE)) || \
 798             $(ECHO) "Failed to build freetypecheck." ) > $@
 799 
 800 sane-freetype: $(TEMPDIR)/freetypeinfo
 801         @if [ "`$(CAT) $< | $(GREP) Fail`" != "" ]; then \
 802           $(call SanityError, \
 803 "FreeType version $(REQUIRED_FREETYPE_VERSION) or higher is required.", \
 804 "`$(CAT) $<`") ; \
 805         fi
 806 
 807 else
 808 #do nothing  (not OpenJDK)
 809 sane-freetype: 
 810 endif
 811 
 812 ######################################################
 813 # if specified, BUILD_MODULES must contain valid values.
 814 ######################################################
 815 MODULES_REGEX="all|base|desktop|management|enterprise|misc|tools"
 816 sane-build_modules:
 817 ifdef BUILD_MODULES
 818         @for m in $(BUILD_MODULES) ; do \
 819             valid=`$(ECHO) $$m | $(EGREP) $(MODULES_REGEX)`; \
 820             if [ "x$$valid" = "x" ]; then \
 821                 $(call SanityError, \
 822 "$$m set in the BUILD_MODULES variable is invalid.", ) ; \
 823             fi \
 824         done
 825 endif
 826 
 827 ######################################################
 828 # CUPS_HEADERS_PATH must be valid
 829 ######################################################
 830 sane-cups:
 831 ifneq ($(PLATFORM), windows)
 832         @$(call VarPathFileSanityCheck,\
 833                 CUPS_HEADERS_PATH,ALT_CUPS_HEADERS_PATH,\
 834                 $(CUPS_HEADERS_PATH)/cups/cups.h,$(call BuildReadme,cups))
 835 endif
 836 
 837 ######################################################
 838 # Check for existence of DEVTOOLS_PATH
 839 ######################################################
 840 sane-devtools_path:
 841         @$(call VarPathSanityCheck,DEVTOOLS_PATH,ALT_DEVTOOLS_PATH, )
 842 
 843 ######################################################
 844 # Check for existence of MS_RUNTIME_LIBRARIES
 845 ######################################################
 846 sane-msvcrt_path:
 847 ifeq ($(PLATFORM), windows)
 848         @$(call VarPathFileSanityCheck,\
 849                 MSVCRT_DLL_PATH,ALT_MSVCRT_DLL_PATH,\
 850                 $(MSVCRT_DLL_PATH)/msvcrt.dll, )
 851   ifneq ($(MSVCRNN_DLL),)
 852         @$(call VarPathFileSanityCheck,\
 853                 MSVCRNN_DLL_PATH,ALT_MSVCRNN_DLL_PATH,\
 854                 $(MSVCRNN_DLL_PATH)/$(MSVCRNN_DLL), )
 855   endif
 856 endif
 857 
 858 ######################################################
 859 # Check for existence of COMPILER_PATH
 860 ######################################################
 861 sane-compiler_path:
 862         @$(call VarPathSanityCheck,COMPILER_PATH,ALT_COMPILER_PATH, )
 863 
 864 ######################################################
 865 # Check for existence of UNIXCOMMAND_PATH
 866 ######################################################
 867 sane-unixcommand_path:
 868         @$(call VarPathSanityCheck,UNIXCOMMAND_PATH,ALT_UNIXCOMMAND_PATH, )
 869 ifeq ($(PLATFORM), windows)
 870         @for utility in cpio ar file m4 ; do \
 871           if [ ! -r "`$(WHICH) $${utility}`" ]; then \
 872             $(call SanityWarning, \
 873 "You do not have the utility $${utility} in the directory $(UNIXCOMMAND_PATH).", \
 874 "The utilities cpio${comma} ar${comma} file${comma} and m4 are required."); \
 875           fi; \
 876         done
 877 endif
 878 
 879 ######################################################
 880 # Check for existence of USRBIN_PATH on linux
 881 ######################################################
 882 sane-usrbin_path:
 883 ifeq ($(PLATFORM), linux)
 884         @$(call VarPathSanityCheck,USRBIN_PATH,ALT_USRBIN_PATH, )
 885 endif
 886 
 887 ######################################################
 888 # Check for existence of UNIXCCS_PATH on solaris
 889 ######################################################
 890 sane-unixccs_path:
 891 ifeq ($(PLATFORM), solaris)
 892         @$(call VarPathSanityCheck,UNIXCCS_PATH,ALT_UNIXCCS_PATH, )
 893 endif
 894 
 895 ######################################################
 896 # Verify the docs directory exists
 897 ######################################################
 898 sane-docs_import:
 899         @$(call OptionalVarPathSanityCheck,\
 900                 HOTSPOT_DOCS_IMPORT_PATH,ALT_HOTSPOT_DOCS_IMPORT_PATH, )
 901 
 902 ######################################################
 903 # Check for possible problem regarding __fabsf,  math_iso.h and the libm patch.
 904 #    Hotspot should have been changed in Mustang 6.0 Build 47 to not depend
 905 #    on __fabsf, this is just checking that fact now.
 906 ######################################################
 907 sane-math_iso:
 908 ifeq ($(PLATFORM), solaris)
 909         @if [ -f $(HOTSPOT_SERVER_PATH)/$(LIB_PREFIX)jvm.$(LIBRARY_SUFFIX) ]; then \
 910           if [ "`$(NM) $(HOTSPOT_SERVER_PATH)/$(LIB_PREFIX)jvm.$(LIBRARY_SUFFIX) | $(GREP) __fabsf`" != "" ]; then \
 911             $(call SanityWarning, \
 912 "This version of hotspot relies on __fabsf which is not always available \
 913  on Solaris 8 and 9 machines unless they have the latest libm patch \
 914  and the file /usr/include/iso/math_iso.h which can trigger this dependency.", \
 915 "Hotspot should NOT be dependent on this extern${comma} check the \
 916  version of the hotspot library you are using.") ; \
 917             fi; \
 918         fi
 919 endif
 920 
 921 ######################################################
 922 # Check for possible patch problem regarding /usr/lib/libCrun.so
 923 ######################################################
 924 sane-libCrun:
 925 ifeq ($(PLATFORM), solaris)
 926         @if [ "`$(NM) /usr/lib/libCrun.so.1 | $(GREP) __1c2n6FIpv_0_`" = "" ]; then \
 927           $(call SanityWarning, \
 928 "The file /usr/lib/libCrun.so.1 is missing the extern __1c2n6FIpv_0_ \
 929  which indicates that the system is missing a required Solaris patch \
 930  or you are using a pre-FCS release of Solaris 10.", \
 931 "You need the latest /usr/lib/libCrun.so.1 which comes with the \
 932  FCS release of Solaris 10 and available through the latest \
 933  Solaris 8 or 9 C++ runtime patches.") ; \
 934         fi
 935 endif
 936 
 937 ######################################################
 938 # Check for existence of MSDEVTOOLS_PATH on windows
 939 ######################################################
 940 sane-msdevtools_path:
 941 ifeq ($(PLATFORM), windows)
 942         @$(call VarPathSanityCheck,MSDEVTOOLS_PATH,ALT_MSDEVTOOLS_PATH, )
 943 endif
 944 
 945 ######################################################
 946 # Check for existence of Hotspot binaries
 947 ######################################################
 948 sane-hotspot_binaries:
 949 ifeq ($(ARCH_DATA_MODEL), 32)
 950         @$(call VarPathFileSanityCheck,\
 951                 HOTSPOT_CLIENT_PATH,ALT_HOTSPOT_CLIENT_PATH,\
 952                 $(HOTSPOT_CLIENT_PATH)/$(LIB_PREFIX)jvm.$(LIBRARY_SUFFIX),\
 953 "The ALT_HOTSPOT_IMPORT_PATH may also be used.")
 954 endif
 955         @$(call VarPathFileSanityCheck,\
 956                 HOTSPOT_SERVER_PATH,ALT_HOTSPOT_SERVER_PATH,\
 957                 $(HOTSPOT_SERVER_PATH)/$(LIB_PREFIX)jvm.$(LIBRARY_SUFFIX),\
 958 "The ALT_HOTSPOT_IMPORT_PATH may also be used.")
 959 ifeq ($(PLATFORM), windows)
 960         @$(call VarPathFileSanityCheck,\
 961                 HOTSPOT_LIB_PATH,ALT_HOTSPOT_LIB_PATH,\
 962                 $(HOTSPOT_LIB_PATH)/jvm.lib, )
 963   ifeq ($(ARCH_DATA_MODEL), 32)
 964         @$(call OptionalVarPathFileSanityCheck,\
 965                 HOTSPOT_CLIENT_PATH,ALT_HOTSPOT_CLIENT_PATH,\
 966                 $(HOTSPOT_CLIENT_PATH)/jvm.map, \
 967 "These map files are optional and aid in the debugging of the JVM.")
 968         @$(call OptionalVarPathFileSanityCheck,\
 969                 HOTSPOT_CLIENT_PATH,ALT_HOTSPOT_CLIENT_PATH,\
 970                 $(HOTSPOT_CLIENT_PATH)/jvm.pdb, \
 971 "These pdb files are optional and aid in the debugging of the JVM.")
 972   endif
 973         @$(call OptionalVarPathFileSanityCheck,\
 974                 HOTSPOT_SERVER_PATH,ALT_HOTSPOT_SERVER_PATH,\
 975                 $(HOTSPOT_SERVER_PATH)/jvm.map, \
 976 "These map files are optional and aid in the debugging of the JVM.")
 977         @$(call OptionalVarPathFileSanityCheck,\
 978                 HOTSPOT_SERVER_PATH,ALT_HOTSPOT_SERVER_PATH,\
 979                 $(HOTSPOT_SERVER_PATH)/jvm.pdb, \
 980 "These pdb files are optional and aid in the debugging of the JVM.")
 981 endif   
 982 
 983 
 984 ######################################################
 985 # Check for existence of misc Hotspot imported files
 986 ######################################################
 987 HOTSPOT_INCLUDE_FILE_LIST  = jvmti.h
 988 HOTSPOT_INCLUDE_FILE_LIST  += jvmticmlr.h
 989 #HOTSPOT_INCLUDE_FILE_LIST += jni.h jni_md.h
 990 #HOTSPOT_INCLUDE_FILE_LIST += jvm.h jvm_md.h
 991 #HOTSPOT_INCLUDE_FILE_LIST += jmm.h
 992 TMP_SDK_INCLUDE_FILE_LIST=$(HOTSPOT_INCLUDE_FILE_LIST:%.h=$(TEMPDIR)/%.h)
 993 TMP_SDK_INCLUDE_FILE_DIFFS=$(HOTSPOT_INCLUDE_FILE_LIST:%.h=$(TEMPDIR)/%.hdiffs)
 994 
 995 # These include files must have a pattern: 'version: MAJOR.MINOR.MICRO'
 996 #    where MACRO, MINOR, and MICRO are numbers, e.g. 1.0.1, 0.2.90, etc.
 997 #    The critical version we are checking is MAJOR.MINOR, we print all three
 998 #    when we detect an error.
 999 
1000 TMP_SDK_INCLUDE_FIND_VERSION= $(EGREP) 'version:'
1001 TMP_SDK_INCLUDE_GET_VERSION= $(TMP_SDK_INCLUDE_FIND_VERSION) | \
1002                 $(SED) -e 's@.*\([0-9][0-9]*\.[0-9][0-9]*\)\.[0-9].*@\1@'
1003 TMP_SDK_INCLUDE_GET_FULL_VERSION= $(TMP_SDK_INCLUDE_FIND_VERSION) | \
1004                 $(SED) -e 's@.*\([0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*\).*@\1@'
1005 
1006 # Compare an interface file (Rule creates 2 temp files: %.h and %.h.IMPORT)
1007 #    Files jvm.h, jvm_md.h and jmm.h are special in that they are not publicly 
1008 #    exported but do represent VM interfaces used by the rest of the jdk.
1009 #    So these 3 will not be found in a promoted build and can only
1010 #    be checked when this represents a full control build (i.e. the
1011 #    HOTSPOT_IMPORT_PATH includes these files in it's 'include' directory).
1012 $(TEMPDIR)/%.h: $(SHARE_SRC)/javavm/export/%.h
1013         @$(install-non-module-file)
1014         @$(RM) $@.IMPORT
1015         @if [ -r $(HOTSPOT_IMPORT_PATH)/include/$(@F) ]; then \
1016           $(CP) $(HOTSPOT_IMPORT_PATH)/include/$(@F) $@.IMPORT ; \
1017         elif [ "$(@F)" != "jvm.h" -a "$(@F)" != "jmm.h" ]; then \
1018           $(call SanityWarning, \
1019 "HOTSPOT_IMPORT_PATH does not contain the interface file $(@F).", \
1020 "Check your value of ALT_HOTSPOT_IMPORT_PATH."); \
1021           $(CP) $< $@.IMPORT; \
1022         else \
1023           $(CP) $< $@.IMPORT; \
1024         fi
1025 
1026 $(TEMPDIR)/%.h: $(PLATFORM_SRC)/javavm/export/%.h
1027         @$(install-non-module-file)
1028         @$(RM) $@.IMPORT
1029         @if [ -r $(HOTSPOT_IMPORT_PATH)/include/$(PLATFORM_INCLUDE_NAME)/$(@F) ]; then \
1030           $(CP) $(HOTSPOT_IMPORT_PATH)/include/$(PLATFORM_INCLUDE_NAME)/$(@F) $@.IMPORT ; \
1031         elif [ "$(@F)" != "jvm_md.h" ]; then \
1032           $(call SanityWarning, \
1033 "HOTSPOT_IMPORT_PATH does not contain the interface file $(@F).", \
1034 "Check your value of ALT_HOTSPOT_IMPORT_PATH."); \
1035           $(CP) $< $@.IMPORT; \
1036         else \
1037           $(CP) $< $@.IMPORT; \
1038         fi
1039 
1040 # Compares the two tempfiles: %.h and %.h.IMPORT, answer in %.hdiffs
1041 #   Note: Putting anything into the hdiffs file will trigger generic IMPORT
1042 #         warning message in hotspot_import_include.
1043 #   First checks the major.minor versions, the micro number can differ.
1044 #   Second checks the full version.
1045 #   Lastly does a full diff if the full version differs or it has no version
1046 $(TEMPDIR)/%.hdiffs: $(TEMPDIR)/%.h
1047         @$(prep-target)
1048         @$(TOUCH) $@
1049         @if [ "`$(CAT) $<        | $(TMP_SDK_INCLUDE_GET_VERSION)`" != \
1050               "`$(CAT) $<.IMPORT | $(TMP_SDK_INCLUDE_GET_VERSION)`" ]; then \
1051           $(call SanityWarning, \
1052 "The file $(<F) is not the same interface as the VM version.", \
1053 "This source has $(<F) `$(CAT) $< | $(TMP_SDK_INCLUDE_GET_FULL_VERSION)` and \
1054  HOTSPOT_IMPORT_PATH contains $(<F) `$(CAT) $<.IMPORT | $(TMP_SDK_INCLUDE_GET_FULL_VERSION)`"); \
1055              $(ECHO) "Version mis-match" > $@ ; \
1056         fi
1057         @if [ "`$(CAT) $<        | $(TMP_SDK_INCLUDE_GET_FULL_VERSION)`" != \
1058                "`$(CAT) $<.IMPORT | $(TMP_SDK_INCLUDE_GET_FULL_VERSION)`" ]; then \
1059           $(RM) $<.filtered  $<.IMPORT.filtered; \
1060           $(EGREP) -v 'VERSION' $< > $<.filtered; \
1061           $(EGREP) -v 'VERSION' $<.IMPORT > $<.IMPORT.filtered; \
1062           ($(DIFF) -w $<.filtered $<.IMPORT.filtered || exit 0) >> $@ ; \
1063         elif [ "`$(CAT) $< | $(TMP_SDK_INCLUDE_FIND_VERSION)`" = "" ]; then \
1064           $(RM) $<.filtered  $<.IMPORT.filtered; \
1065           $(EGREP) -v '@\(#\)' $< > $<.filtered; \
1066           $(EGREP) -v '@\(#\)' $<.IMPORT > $<.IMPORT.filtered; \
1067           ($(DIFF) -w $<.filtered $<.IMPORT.filtered || exit 0) >> $@ ; \
1068         fi
1069 
1070 # Verify all imported hotspot files
1071 sane-hotspot_import:: sane-hotspot_import_dir sane-hotspot_import_include
1072 
1073 # Verify the base directory exists
1074 sane-hotspot_import_dir:
1075         @$(RM) $(TMP_SDK_INCLUDE_FILE_DIFFS)
1076         @$(RM) $(TMP_SDK_INCLUDE_FILE_LIST)
1077         @$(call OptionalVarPathSanityCheck,\
1078                 HOTSPOT_IMPORT_PATH,ALT_HOTSPOT_IMPORT_PATH, )
1079 
1080 # Verify hotspot include files
1081 sane-hotspot_import_include: $(TMP_SDK_INCLUDE_FILE_LIST) $(TMP_SDK_INCLUDE_FILE_DIFFS)
1082         @if [ "`$(CAT) $(TMP_SDK_INCLUDE_FILE_DIFFS)`" != "" ]; then \
1083           $(call SanityWarning, \
1084 "Possible HotSpot VM interface conflict.", \
1085 "HOTSPOT_IMPORT_PATH is used to import files from the VM build." \
1086 "It is also used to verify that any copied files are consistent between \
1087  these two components." \
1088 "It has been detected that one or more of the VM interface files inside \
1089  this workspace may not match the interfaces exported by the VM \
1090  or the VM versions could not be found." \
1091 "The list of VM interface files is: \
1092  $(HOTSPOT_INCLUDE_FILE_LIST)." \
1093 "This workspace has copies of these files at: \
1094  $(SHARE_SRC)/javavm/export and $(PLATFORM_SRC)/javavm/export \
1095  for build purposes and they should contain the same interfaces \
1096  as the VM versions imported from:" \
1097 "\$$(HOTSPOT_IMPORT_PATH)/include" \
1098 "(i.e. $(HOTSPOT_IMPORT_PATH)/include)" \
1099 "If an interface indeed doesn't match then the use of this interface \
1100  at JDK runtime could cause serious errors.") ; \
1101             for i in $(TMP_SDK_INCLUDE_FILE_DIFFS); do \
1102                 if [ -s $$i ]; then \
1103                   $(PRINTF) "\n\n%s\n" "VM Interface Differences: $$i" \
1104                     >> $(WARNING_FILE); \
1105                   $(CAT) $$i >> $(WARNING_FILE); \
1106                   $(PRINTF) "\n" >> $(WARNING_FILE); \
1107                 fi; \
1108             done; \
1109         fi
1110         @$(RM) $(TMP_SDK_INCLUDE_FILE_DIFFS)
1111         @$(RM) $(TMP_SDK_INCLUDE_FILE_LIST)
1112 
1113 # The JDI-SA feature is not currently released on some platforms.
1114 # See the Defs-<arch>.gmk files.
1115 
1116 ifeq ($(INCLUDE_SA), true)
1117 # Verify that hotspot Serviceability Agent files are present.  To keep 
1118 # it simple, we will just check for one of them.  The others have arch 
1119 # dependent paths.
1120 
1121 sane-hotspot_import::
1122         @$(call OptionalVarPathFileSanityCheck,\
1123                 HOTSPOT_IMPORT_PATH,ALT_HOTSPOT_IMPORT_PATH,\
1124                 $(HOTSPOT_IMPORT_PATH)/lib/sa-jdi.jar,\
1125 "The JDI binding for the Serviceability Agent will not be included in the build.")
1126 endif
1127 
1128 ######################################################
1129 # Check the ant version
1130 ######################################################
1131 sane-ant_version:
1132         @$(call VersionSanityCheck,ant,\
1133                 $(ANT_VER),$(REQUIRED_ANT_VER),)
1134 
1135 ######################################################
1136 # Check the zip file version
1137 ######################################################
1138 sane-zip_version: sane-unzip_version
1139         @$(call VersionSanityCheck,zip,\
1140                 $(ZIP_VER),$(REQUIRED_ZIP_VER),)
1141 
1142 ######################################################
1143 # Check the unzip file version
1144 ######################################################
1145 sane-unzip_version:
1146         @$(call VersionSanityCheck,unzip,\
1147                 $(UNZIP_VER),$(REQUIRED_UNZIP_VER),)
1148 
1149 ######################################################
1150 # Check for windows DirectX sdk directory
1151 ######################################################
1152 sane-dxsdk:
1153 ifeq ($(PLATFORM), windows)
1154         @$(call VersionSanityCheck,dxsdk,\
1155                 $(DXSDK_VER),$(REQUIRED_DXSDK_VER),\
1156 $(call BuildReadme,dxsdk))
1157         @$(call VarPathFileSanityCheck,\
1158                 DXSDK_INCLUDE_PATH,ALT_DXSDK_INCLUDE_PATH,\
1159                 $(DXSDK_INCLUDE_PATH)/d3d9.h,\
1160 $(call BuildReadme,dxsdk))
1161         @if [ -r $(DXSDK_INCLUDE_PATH)/basetsd.h ]; then \
1162           if [ `$(EGREP) -c __int3264 $(DXSDK_INCLUDE_PATH)/basetsd.h` -ne 0 ]; then \
1163             $(call SanityWarning, \
1164 "The DirectX SDK Include directory contains a newer basetsd.h \
1165  which may indicate that you're using an incorrect version of DirectX SDK.", \
1166 "This may result in a build failure." \
1167 "The DirectX SDK Include dir was obtained from the following location: \
1168  $(DXSDK_INCLUDE_PATH)" \
1169 $(call BuildReadme,dxsdk))
1170           fi \
1171         fi
1172 endif
1173 
1174 ######################################################
1175 # Check the linker version(s)
1176 ######################################################
1177 sane-link:
1178 ifeq ($(PLATFORM), windows)
1179   ifdef LINK_VER
1180         @$(call SameVersionSanityCheck,link.exe,\
1181                 $(LINK_VER),$(REQUIRED_LINK_VER),\
1182 "To build JDK $(JDK_VERSION) you need \
1183  $(REQUIRED_COMPILER_VERSION) - link.exe version $(REQUIRED_LINK_VER)." \
1184 "Specifically the $(REQUIRED_COMPILER_NAME) link.exe.")
1185   endif
1186 endif
1187 
1188 ######################################################
1189 # Check the compiler version(s)
1190 ######################################################
1191 sane-compiler: sane-link
1192 ifndef OPENJDK
1193         @$(call SameVersionSanityCheck,C/C++ compiler,\
1194                 $(CC_VER),$(REQUIRED_CC_VER), \
1195 "The $(PLATFORM) compiler is not the $(REQUIRED_COMPILER_NAME) compiler." \
1196 "The compiler was obtained from the following location: $(COMPILER_PATH)")
1197 else
1198         @$(call VersionSanityCheck,C/C++ compiler,,\
1199                 $(CC_VER),$(REQUIRED_CC_VER), \
1200 "The $(PLATFORM) compiler is not the $(REQUIRED_COMPILER_NAME) compiler." \
1201 "The compiler was obtained from the following location: $(COMPILER_PATH)")
1202 endif
1203 
1204 ######################################################
1205 # Check that ALSA headers and libs are installed and 
1206 # that the header has the right version. We only
1207 # need /usr/include/alsa/version.h and /usr/lib/libasound.so
1208 ######################################################
1209 
1210 sane-alsa-headers:
1211 ifdef REQUIRED_ALSA_VERSION
1212         @$(call VersionSanityCheck,alsa,\
1213                 $(ALSA_VERSION),$(REQUIRED_ALSA_VERSION), \
1214 "Please install or reinstall the ALSA packages (drivers and lib)." \
1215 $(call BuildReadme,alsa))
1216 endif
1217 
1218 ######################################################
1219 # If a sanity file doesn't exist, just make sure it's dir exists
1220 $(SANITY_FILES):
1221         -@$(prep-target)
1222 
1223 ######################################################
1224 # dump out the variable settings...
1225 ######################################################
1226 sane-settings::
1227         @$(ECHO)  >> $(MESSAGE_FILE)
1228         @$(ECHO) $(ALL_SETTINGS)  >> $(MESSAGE_FILE)
1229         @$(ECHO)  >> $(MESSAGE_FILE)
1230 
1231 ######################################################
1232 # Check for existence of DEPLOY_MSSDK on windows
1233 ######################################################
1234 sane-mssdk_path:
1235 ifeq ($(PLATFORM), windows)
1236         @$(call OptionalVarPathSanityCheck,\
1237                 DEPLOY_MSSDK,ALT_DEPLOY_MSSDK, )
1238 endif
1239 
1240 ######################################################
1241 # Check for existence of INSTALL_MSSDK on windows
1242 ######################################################
1243 sane-install-mssdk_path:
1244 ifeq ($(PLATFORM), windows)
1245         @$(call OptionalVarPathSanityCheck,\
1246                 INSTALL_MSSDK,ALT_INSTALL_MSSDK, )
1247 endif
1248 
1249 ######################################################
1250 # Check for existence of INSTALL_MSIVAL2 on windows
1251 ######################################################
1252 sane-install-msival2_path:
1253 ifeq ($(PLATFORM), windows)
1254         @$(call OptionalVarPathSanityCheck,\
1255                 INSTALL_MSIVAL2,ALT_INSTALL_MSIVAL2, )
1256 endif
1257 
1258 ######################################################
1259 # Check the Solaris GNU c++ compiler for solaris plugin
1260 ######################################################
1261 sane-gcc-compiler:
1262 ifeq ($(PLATFORM), solaris)
1263   ifndef OPENJDK
1264     @if [ -r $(GCC_COMPILER_PATH) ]; then \
1265           if [ ! "$(GCC_VER)" = $(REQUIRED_GCC_VERSION) ]; then \
1266             $(call SanityError, \
1267 "The Solaris GCC compiler version must be $(REQUIRED_GCC_VERSION).", \
1268 "You are using the following compiler version: $(GCC_VER)" \
1269 "The compiler was obtained from the following location: \
1270  $(GCC_COMPILER_PATH)" \
1271 "Please change your compiler.") ; \
1272     fi \
1273         else \
1274           $(call SanityError, \
1275 "You do not have a valid GCC_COMPILER_PATH setting.", \
1276 "Please check your access to $(GCC_COMPILER_PATH) \
1277  and/or check your value of ALT_GCC_COMPILER_PATH." \
1278 "This will affect you if you build the plugin target.") ; \
1279         fi
1280   endif
1281 
1282   ifeq ($(PLATFORM), linux)
1283     ifdef ALT_GCC29_COMPILER_PATH
1284         @if [ ! -x $(ALT_GCC29_COMPILER_PATH)/bin/gcc ]; then \
1285             $(call SanityError, \
1286 "You do not have a valid ALT_GCC29_COMPILER_PATH setting.", \
1287 "Please check your access to $(ALT_GCC29_COMPILER_PATH)/bin/gcc" \
1288 "This will affect you if you build the plugin target.") ; \
1289     fi
1290     endif
1291     ifdef ALT_GCC29_PLUGIN_LIB_PATH
1292         @if [ ! -r $(ALT_GCC29_PLUGIN_LIB_PATH)/libjavaplugin_oji.so ]; then \
1293             $(call SanityError, \
1294 "You do not have a valid ALT_GCC29_PLUGIN_LIB_PATH setting.", \
1295 "Please check your access to \
1296   $(ALT_GCC29_PLUGIN_LIB_PATH)/libjavaplugin_oji.so" \
1297 "This will affect you if you build the plugin target \
1298  specifically for gcc 2.9 version of OJI plugin library.") ; \
1299         fi
1300     else
1301         @$(call VarPathSanityCheck,GCC29_COMPILER_PATH,ALT_GCC29_COMPILER_PATH, \
1302 "This will affect you if you build the plugin target.")
1303     endif
1304   endif
1305 endif
1306 
1307 
1308 ######################################################
1309 # MOZILLA_HEADERS_PATH must be valid
1310 ######################################################
1311 sane-mozilla:
1312 ifeq ($(ARCH_DATA_MODEL), 32)
1313   ifdef ALT_MOZILLA_HEADERS_PATH
1314         @if [ `$(ECHO) $(subst \,/,$(ALT_MOZILLA_HEADERS_PATH)) | $(EGREP) -c '^([A-Za-z]:)?/'` -ne 1 ]; then \
1315           $(call SanityError, \
1316 "ALT_MOZILLA_HEADERS_PATH must be an Absolute Path Name not a Relative Path Name.", \
1317 "The current value of ALT_MOZILLA_HEADERS_PATH is $(ALT_MOZILLA_HEADERS_PATH)" \
1318 "Please fix this and continue your build.") ; \
1319         fi
1320   endif
1321   ifeq ($(PLATFORM), windows)
1322         @$(call VarPathFileSanityCheck,\
1323                 MOZILLA_HEADERS_PATH,ALT_MOZILLA_HEADERS_PATH,\
1324                 $(MOZILLA_HEADERS_PATH)/mozilla_headers_18.win32/java/bool.h, \
1325 "Or check your value of ALT_JDK_DEVTOOLS_DIR.")
1326   else
1327         @$(call VarPathFileSanityCheck,\
1328                 MOZILLA_HEADERS_PATH,ALT_MOZILLA_HEADERS_PATH,\
1329                 $(MOZILLA_HEADERS_PATH)/mozilla_headers_18/java/bool.h, \
1330 "Or check your value of ALT_JDK_DEVTOOLS_DIR.")
1331   endif
1332         @$(call VarPathFileSanityCheck,\
1333                 MOZILLA_HEADERS_PATH,ALT_MOZILLA_HEADERS_PATH,\
1334                 $(MOZILLA_HEADERS_PATH)/plugin2_mozilla_headers/npapi.h, \
1335 "Or check your value of ALT_JDK_DEVTOOLS_DIR." \
1336 "This file is needed for plugin2.")
1337 endif
1338 
1339 
1340 ######################################################
1341 # Make sure Java Kernel VM is accessible
1342 ######################################################
1343 sane-kernel-vm:
1344 ifeq ($(PLATFORM), windows)
1345   ifeq ($(ARCH_DATA_MODEL), 32)
1346         @$(call OptionalVarPathFileSanityCheck,\
1347                 HOTSPOT_KERNEL_PATH,ALT_HOTSPOT_IMPORT_PATH,\
1348                 $(HOTSPOT_KERNEL_PATH)/jvm.dll,\
1349 "Your HOTSPOT_IMPORT_PATH does not include a Kernel VM." \
1350 "The kernel installer may not be built (unless hotspot is also).")
1351   endif
1352 endif
1353 
1354 
1355 ######################################################
1356 # SECURITY_BASELINE_131 test
1357 ######################################################
1358 security_baseline_131:
1359 ifeq ($(PLATFORM), windows)
1360         @$(call OptionalVarPathSanityCheck,\
1361                 SECURITY_BASELINE_131,SECURITY_BASELINE_131, )
1362 endif
1363 
1364 ######################################################
1365 # SECURITY_BASELINE_142 test
1366 ######################################################
1367 security_baseline_142:
1368 ifeq ($(PLATFORM), windows)
1369         @$(call OptionalVarPathSanityCheck,\
1370                 SECURITY_BASELINE_142,SECURITY_BASELINE_142, )
1371 endif
1372 
1373 ######################################################
1374 # SECURITY_BASELINE_150 test
1375 ######################################################
1376 security_baseline_150:
1377 ifeq ($(PLATFORM), windows)
1378         @$(call OptionalVarPathSanityCheck,\
1379                 SECURITY_BASELINE_150,SECURITY_BASELINE_150, )
1380 endif
1381 
1382 ######################################################
1383 # SECURITY_BASELINE_160 test
1384 ######################################################
1385 security_baseline_160:
1386 ifeq ($(PLATFORM), windows)
1387         @$(call OptionalVarPathSanityCheck,\
1388                 SECURITY_BASELINE_160,SECURITY_BASELINE_160, )
1389 endif
1390 
1391 
1392 ######################################################
1393 # this should be the last rule in any target's sanity rule.
1394 ######################################################
1395 sane-lastrule:
1396 ifndef EXTERNALSANITYCONTROL
1397         @if [ -r $(MESSAGE_FILE) ]; then \
1398           $(CAT) $(MESSAGE_FILE) ; \
1399         fi
1400         @if [ -r $(WARNING_FILE) ]; then \
1401           $(CAT) $(WARNING_FILE) ; \
1402         fi
1403         @if [ "x$(INSANE)" != x ]; then \
1404           $(PRINTF) "\n%s\n%s\n\n" "INSANE mode requested." \
1405             "Sanity will not force a build termination, even with errors." \
1406             >> $(ERROR_FILE); \
1407         fi
1408         @if [ -r $(ERROR_FILE) ]; then \
1409           if [ "x$(INSANE)" = x ]; then \
1410             $(PRINTF) "\n%s\n\n" "Exiting because of the above error(s)." \
1411               >> $(ERROR_FILE); \
1412           fi ; \
1413           $(CAT) $(ERROR_FILE) ; \
1414           if [ "x$(INSANE)" = x ]; then \
1415             exit 1 ; \
1416           fi ; \
1417         fi
1418 ifdef PEDANTIC
1419         @if [ -r $(WARNING_FILE) ]; then \
1420           $(PRINTF) "\n%s\n%s\n\n" "PEDANTIC mode requested." \
1421             "Exiting because of the above warning(s)." \
1422             >> $(ERROR_FILE); \
1423           $(CAT) $(ERROR_FILE) ; \
1424           exit 1 ; \
1425         fi
1426 endif # PEDANTIC
1427         @if [ ! -r $(ERROR_FILE) ]; then \
1428           $(PRINTF) "\n%s\n" "Sanity check passed." ; \
1429         fi
1430 endif #  EXTERNALSANITYCONTROL
1431