jdk/make/common/shared/Sanity.gmk
author mduigou
Tue, 30 Nov 2010 13:53:06 -0800
changeset 7302 7ae4b6b0226f
parent 7300 6a391a0ed0da
child 7481 81ec3c14c52c
child 7533 0e5344378b1b
permissions -rw-r--r--
7003544: backout of openjdk changeset 6a391a0ed0da Reviewed-by: ohair

#
# Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License version 2 only, as
# published by the Free Software Foundation.  Oracle designates this
# particular file as subject to the "Classpath" exception as provided
# by Oracle in the LICENSE file that accompanied this code.
#
# This code is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
# version 2 for more details (a copy is included in the LICENSE file that
# accompanied this code).
#
# You should have received a copy of the GNU General Public License version
# 2 along with this work; if not, write to the Free Software Foundation,
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
#
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
# or visit www.oracle.com if you need additional information or have any
# questions.
#

#
# WARNING: This file is shared with other workspaces.
#

#
# Shared sanity rules for the JDK builds.
#

.SUFFIXES: .hdiffs

# All files created during sanity checking

SANITY_FILES =  $(ERROR_FILE) $(WARNING_FILE) $(MESSAGE_FILE)

# How to say "The Release Engineering people use this"
THE_OFFICIAL_USES=The official builds on $(PLATFORM) use

# How to say "You are using:"
YOU_ARE_USING=You appear to be using

# Error message
define SanityError
$(ECHO) "ERROR: $1\n" >> $(ERROR_FILE)
endef

# Warning message
define SanityWarning
$(ECHO) "WARNING: $1\n" >> $(WARNING_FILE)
endef

# Official version error message: name version required_version
define OfficialErrorMessage
$(call SanityError,\
$(THE_OFFICIAL_USES) $1 $3. Your $1 $(if $2,undefined,$2) will not work.)
endef

# Official version warning message: name version required_version
define OfficialWarningMessage
$(call SanityWarning,\
$(THE_OFFICIAL_USES) $1 $3. $(YOU_ARE_USING) $1 $2.)
endef


# Settings and rules to validate the JDK build environment.

ifeq ($(PLATFORM), solaris)
  FREE_SPACE := $(shell $(DF) -b $(OUTPUTDIR) | $(TAIL) -1 | $(NAWK) '{print $$2;}')
  TEMP_FREE_SPACE := $(shell $(DF) -b $(TEMP_DISK) | $(TAIL) -1 | $(NAWK) '{print $$2;}')
  # What kind of system we are using (Variations are Solaris and OpenSolaris)
  OS_VERSION := $(shell uname -r)
  OS_VARIANT_NAME := $(strip $(shell head -1 /etc/release | awk '{print $$1;}') )
  OS_VARIANT_VERSION := $(OS_VERSION)
  REQ_PATCH_LIST = $(JDK_TOPDIR)/make/PatchList.solaris
  ifeq ($(ARCH_FAMILY), sparc)
    PATCH_POSITION = $$4
  else
    PATCH_POSITION = $$6
  endif
  ifndef OPENJDK
    _GCC_VER :=$(shell $(GCC) -dumpversion 2>&1 )
    GCC_VER  :=$(call GetVersion,"$(_GCC_VER)")
  endif
endif

ifeq ($(PLATFORM), linux)
  FREE_SPACE := $(shell $(DF) --sync -kP $(OUTPUTDIR) | $(TAIL) -1 | $(NAWK) '{print $$4;}')
  TEMP_FREE_SPACE := $(shell $(DF) --sync -kP $(TEMP_DISK) | $(TAIL) -1 | $(NAWK) '{print $$4;}')
  # What kind of system we are using (Variation is the Linux vendor)
  OS_VERSION := $(shell uname -r)
  OS_VARIANT_NAME := $(shell \
    if [ -f /etc/fedora-release ] ; then \
      echo "Fedora"; \
    elif [ -f /etc/redhat-release ] ; then \
      echo "RedHat"; \
    elif [ -f /etc/SuSE-release ] ; then \
      echo "SuSE"; \
    else \
      echo "Unknown"; \
    fi)
  OS_VARIANT_VERSION := $(shell \
    if [ "$(OS_VARIANT_NAME)" = "Fedora" ] ; then \
      $(CAT) /etc/fedora-release | $(HEAD) -1 | $(NAWK) '{ print $$3; }' ; \
    fi)
  ALSA_INCLUDE=/usr/include/alsa/version.h
  ALSA_LIBRARY=/usr/lib/libasound.so
  _ALSA_VERSION := $(shell $(EGREP) SND_LIB_VERSION_STR $(ALSA_INCLUDE) | \
           $(SED) -e 's@.*\"\(.*\)\".*@\1@' )
  ALSA_VERSION := $(call GetVersion,$(_ALSA_VERSION))
endif

ifeq ($(PLATFORM), windows)
  FREE_SPACE := $(shell $(DF) -kP $(OUTPUTDIR) | $(TAIL) -1 | $(NAWK) '{print $$4;}')
  TEMP_FREE_SPACE := $(shell $(DF) -kP $(TEMP_DISK) | $(TAIL) -1 | $(NAWK) '{print $$4;}')
  # Windows 2000 is 5.0, Windows XP is 5.1, Windows 2003 is 5.2
  #    Assume 5.0 (Windows 2000) if systeminfo does not help
  WINDOWS_MAPPING-5.0 := Windows2000
  WINDOWS_MAPPING-5.1 := WindowsXP
  WINDOWS_MAPPING-5.2 := Windows2003
  # What kind of system we are using (Variation is the common name)
  _OS_VERSION := \
    $(shell systeminfo 2> $(DEV_NULL) | \
            egrep '^OS Version:' | \
            awk '{print $$3;}' )
  ifeq ($(_OS_VERSION),)
    OS_VERSION = 5.0
  else
    OS_VERSION = $(call MajorVersion,$(_OS_VERSION)).$(call MinorVersion,$(_OS_VERSION))
  endif
  OS_VARIANT_NAME := $(WINDOWS_MAPPING-$(OS_VERSION))
  OS_VARIANT_VERSION := $(OS_VERSION)
  ifdef USING_CYGWIN
    # CYGWIN version
    _CYGWIN_VER := $(SYSTEM_UNAME)
    CYGWIN_VER  :=$(call GetVersion,$(_CYGWIN_VER))
  endif
  DXSDK_VER := $(shell $(EGREP) DIRECT3D_VERSION $(DXSDK_INCLUDE_PATH)/d3d9.h 2>&1 | \
    $(EGREP) "\#define" | $(NAWK) '{print $$3}')
endif

# Get the version numbers of what we are using
_MAKE_VER  :=$(shell $(MAKE) --version 2>&1 | $(HEAD) -n 1)
_ZIP_VER   :=$(shell $(ZIPEXE) -help 2>&1 | $(HEAD) -n 4 | $(EGREP) '^Zip')
_UNZIP_VER :=$(shell $(UNZIP)  -help 2>&1 | $(HEAD) -n 4 | $(EGREP) '^UnZip')
_BOOT_VER  :=$(shell $(BOOTDIR)/bin/java -version 2>&1 | $(HEAD) -n 1)
MAKE_VER   :=$(call GetVersion,"$(_MAKE_VER)")
ZIP_VER    :=$(call GetVersion,"$(_ZIP_VER)")
UNZIP_VER  :=$(call GetVersion,"$(_UNZIP_VER)")
BOOT_VER   :=$(call GetVersion,"$(_BOOT_VER)")

_ANT_VER:=$(shell $(ANT) -version 2>&1 )
ANT_VER:=$(call GetVersion,"$(_ANT_VER)")

ifdef ALT_BINDIR
  ALT_BINDIR_VERSION := $(shell $(ALT_BINDIR)/java$(EXE_SUFFIX) -version 2>&1  | $(NAWK) -F'"' '{ print $$2 }')
  ALT_BINDIR_OK := $(shell $(ECHO) $(ALT_BINDIR_VERSION) | $(EGREP) -c '^$(JDK_MAJOR_VERSION).$(JDK_MINOR_VERSION)')
endif

INSTALL_PATCHES_FILE = $(TEMPDIR)/installed.patches

# Get ALL_SETTINGS defined
include $(JDK_MAKE_SHARED_DIR)/Sanity-Settings.gmk

.PHONY: \
	sane-copyrightyear\
	sane-settings \
	sane-insane \
	sane-build_number \
	sane-os_version \
	sane-memory_check \
	sane-windows \
	sane-locale \
	sane-linux \
	sane-cygwin \
	sane-cygwin-shell \
	sane-mks \
	sane-arch_data_model \
	sane-os_patch_level \
	sane-classpath \
	sane-java_home \
	sane-fonts \
	sane-binary-plugs \
	sane-variant \
	sane-ld_library_path \
	sane-ld_library_path_64 \
	sane-ld_options \
	sane-ld_run_path \
	sane-makeflags \
	sane-alt_outputdir \
	sane-outputdir \
	sane-alt_bootdir \
	sane-bootdir \
	sane-local-bootdir \
	sane-cups \
	sane-devtools_path \
	sane-compiler_path \
	sane-unixcommand_path \
	sane-usrbin_path \
	sane-unixccs_path \
	sane-docs_import \
	sane-math_iso \
	sane-libCrun \
	sane-odbcdir \
	sane-msdevtools_path \
	sane-hotspot_binaries \
	sane-hotspot_import \
	sane-hotspot_import_dir \
	sane-hotspot_import_include \
	sane-compiler \
	sane-link \
	sane-cacerts \
	sane-alsa-headers \
	sane-ant_version \
	sane-zip_version \
	sane-unzip_version \
 	sane-msvcrt_path \
        sane-freetype \
        sane-build_modules

######################################################
# check for COPYRIGHT_YEAR variable
######################################################
sane-copyrightyear:
ifdef ALT_COPYRIGHT_YEAR
	@$(ECHO) "WARNING: ALT_COPYRIGHT_YEAR but not the current year\n" \
			 	 " will be used for copyright year.\n " \
		"" >>$(WARNING_FILE)
endif

######################################################
# check for INSANE variable
######################################################
sane-insane:
ifdef INSANE
	@$(ECHO) "WARNING: You are building in 'INSANE' mode. You \n" \
	   "        should not use this mode, and in fact, \n" \
	   "        it may be removed at any time. If you \n" \
	   "        have build problems as a result of using \n" \
	   "        INSANE mode, then you should not expect \n" \
	   "        assistance from anyone with the problems \n" \
	   "        or consequences you experience. \n" \
	   "" >> $(WARNING_FILE)
endif

######################################################
# check for GNU Make version
######################################################
MAKE_CHECK :=$(call CheckVersions,$(MAKE_VER),$(REQUIRED_MAKE_VER))
sane-make:
	@if [ "$(MAKE_CHECK)" != "same" -a "$(MAKE_CHECK)" != "newer" ]; then \
	  $(ECHO) "WARNING: The version of make being used is older than \n" \
	    "      the required version of '$(REQUIRED_MAKE_VER)'. \n" \
	    "      The version of make found was '$(MAKE_VER)'. \n" \
	    "" >> $(WARNING_FILE) ; \
	fi

######################################################
# Check the BUILD_NUMBER to make sure it contains bNN
######################################################
sane-build_number: 
	@if [ "`$(ECHO) $(BUILD_NUMBER) | $(SED) 's@.*b[0-9][0-9]*.*@bNN@'`" != "bNN" ] ; then \
	    $(ECHO) "WARNING: The BUILD_NUMBER needs to contain b[0-9][0-9]*. Currently BUILD_NUMBER=$(BUILD_NUMBER). \n" \
	      "        This has been known to cause build failures. \n" \
	      "" >> $(WARNING_FILE) ; \
	fi

######################################################
# Check the ARCH_DATA_MODEL setting
######################################################
sane-arch_data_model:
	@if [ "$(ARCH_DATA_MODEL)" != 32 -a "$(ARCH_DATA_MODEL)" != 64 ]; then \
	    $(ECHO) "ERROR: The setting of ARCH_DATA_MODEL must be 32 or 64.\n" \
	      "      $(YOU_ARE_USING) ARCH_DATA_MODEL=$(ARCH_DATA_MODEL). \n" \
	      "" >> $(ERROR_FILE) ; \
	fi

######################################################
# Check the OS version (windows and linus have release name checks)
#   NOTE: OPENJDK explicitly does not check for OS release information.
#         Unless we know for sure that it will not build somewhere, we cannot
#         generate a fatal sanity error, and a warning about the official
#         build platform just becomes clutter.
######################################################
ifndef OPENJDK
  OS_VERSION_CHECK := \
    $(call CheckVersions,$(OS_VERSION),$(REQUIRED_OS_VERSION))
  ifeq ($(OS_VARIANT_NAME),$(REQUIRED_OS_VARIANT_NAME))
    OS_VARIANT_VERSION_CHECK := \
      $(call CheckVersions,$(OS_VARIANT_VERSION),$(REQUIRED_OS_VARIANT_VERSION))
  endif
endif
sane-os_version:: sane-arch_data_model sane-memory_check sane-locale sane-os_patch_level
ifndef OPENJDK
  ifneq ($(OS_VARIANT_NAME),$(REQUIRED_OS_VARIANT_NAME))
    ifeq ($(OS_VERSION_CHECK),missing)
	@$(call OfficialErrorMessage,OS version,$(OS_VERSION),$(REQUIRED_OS_VERSION))
    endif
    ifneq ($(OS_VERSION_CHECK),same)
	@$(call OfficialWarningMessage,OS version,$(OS_VERSION),$(REQUIRED_OS_VERSION))
    endif
	@$(call OfficialWarningMessage,OS variant,$(OS_VARIANT_NAME),$(REQUIRED_OS_VARIANT_NAME))
  else
    ifneq ($(OS_VARIANT_VERSION_CHECK),same)
	@$(call OfficialWarningMessage,$(OS_VARIANT_NAME) version,$(OS_VARIANT_VERSION),$(REQUIRED_OS_VARIANT_VERSION))
    endif
  endif
endif # OPENJDK

ifeq ($(PLATFORM), windows)
  sane-os_version:: sane-cygwin sane-mks sane-cygwin-shell
endif

######################################################
# Check the memory available on this machine
######################################################
sane-memory_check:
	@if [ "$(LOW_MEMORY_MACHINE)" = "true" ]; then \
	  $(ECHO) "WARNING: This machine appears to only have $(MB_OF_MEMORY)Mb of physical memory, \n" \
	    "        builds on this machine could be slow. \n" \
	    "" >> $(WARNING_FILE) ; \
        fi

######################################################
# Check the locale (value of LC_ALL, not being empty or ==C can be a problem)
######################################################
sane-locale:
ifneq ($(PLATFORM), windows)
	@if [ "$(LC_ALL)" != "" -a "$(LC_ALL)" != "C" ]; then \
	  $(ECHO) "WARNING: LC_ALL has been set to $(LC_ALL), this can cause build failures. \n" \
	    "        Try setting LC_ALL to \"C\". \n" \
	    "" >> $(WARNING_FILE) ; \
        fi
	@if [ "$(LANG)" != "" -a "$(LANG)" != "C" ]; then \
	  $(ECHO) "WARNING: LANG has been set to $(LANG), this can cause build failures. \n" \
	    "        Try setting LANG to \"C\". \n" \
	    "" >> $(WARNING_FILE) ; \
        fi
endif

######################################################
# Check the Windows cygwin version
######################################################
ifeq ($(PLATFORM), windows)
  CYGWIN_CHECK :=$(call CheckVersions,$(CYGWIN_VER),$(REQUIRED_CYGWIN_VER))
sane-cygwin:
  ifdef USING_CYGWIN
    ifeq ($(CYGWIN_CHECK),missing)
	@$(call OfficialErrorMessage,CYGWIN version,$(CYGWIN_VER),$(REQUIRED_CYGWIN_VER))
    endif
    ifeq ($(CYGWIN_CHECK),older)
	@$(call OfficialWarningMessage,CYGWIN version,$(CYGWIN_VER),$(REQUIRED_CYGWIN_VER))
    endif
  endif
endif

######################################################
# Check the cygwin shell is used, not cmd.exe
######################################################
ifeq ($(PLATFORM), windows)
sane-cygwin-shell:
  ifdef USING_CYGWIN
	@if [ "$(SHLVL)" = "" -a "$(_)" = "" ]; then \
	  $(ECHO) "ERROR: You are using an unsupported shell. \n" \
	    "      Use either sh, bash, ksh, zsh, or tcsh. \n" \
	    "      Using the cmd.exe utility is not supported. \n" \
	    "      If you still want to try your current shell, \n" \
	    "      please export SHLVL=1 when running $(MAKE).  \n" \
	    "" >> $(ERROR_FILE) ; \
	fi
  endif
endif

######################################################
# Check the Windows mks version
######################################################
ifeq ($(PLATFORM), windows)
    MKS_CHECK :=$(call CheckVersions,$(MKS_VER),$(REQUIRED_MKS_VER))
sane-mks:
  ifndef USING_CYGWIN
    ifeq ($(MKS_CHECK),missing)
	@$(call OfficialErrorMessage,MKS version,$(MKS_VER),$(REQUIRED_MKS_VER))
    endif
    ifeq ($(MKS_CHECK),older)
	@$(call OfficialErrorMessage,MKS version,$(MKS_VER),$(REQUIRED_MKS_VER))
    endif
  endif
endif

######################################################
# Get list of installed patches (this file has a particular format)
######################################################
$(INSTALL_PATCHES_FILE):
	@$(prep-target)
ifeq ($(PLATFORM), solaris)
  ifeq ($(OS_VERSION),$(REQUIRED_OS_VERSION))
	$(SHOWREV) -p > $@ 2>&1
  endif
endif
	@$(ECHO) "" >> $@

######################################################
# Check list of Solaris patches
######################################################
sane-os_patch_level: $(INSTALL_PATCHES_FILE)
ifeq ($(PLATFORM), solaris)
  ifeq ($(OS_VERSION),$(REQUIRED_OS_VERSION))
	@$(NAWK) 'BEGIN { \
    readingInstallPatches = 0; \
    requiredCount = 0; \
    installCount = 0; \
} \
{ \
    if (readingInstallPatches) { \
        if ($$1=="Patch:") { \
            ns = split($$2,parts,"-");  \
            installPatchNo[installCount]=parts[1]; \
            installPatchRev[installCount]=parts[2]; \
            installCount++; \
        } \
    } \
     \
    if (!readingInstallPatches) { \
        if (index($$1,"#") != 0) continue; \
        if (match($$1,"BUILD") > 0 \
        && $$2 == $(OS_VERSION) \
        && ($$7 == "REQ" || $$7 == "req") \
        && $(PATCH_POSITION) != "none" \
        && $(PATCH_POSITION) != "NONE") { \
            ns = split($(PATCH_POSITION),parts,"-");  \
            requiredPatchNo[requiredCount]=parts[1]; \
            requiredPatchRev[requiredCount]=parts[2]; \
            requiredCount++; \
       } \
    } \
} \
END { \
    errorCount=0; \
    for (i=0; i<requiredCount; i++) { \
        foundMatch = 0; \
        for (j=0; j<installCount; j++) { \
            if (installPatchNo[j] == requiredPatchNo[i] \
            && installPatchRev[j] >= requiredPatchRev[i]) { \
                foundMatch = 1; \
                break; \
            } \
        } \
        if ( foundMatch == 0) { \
            printf("WARNING: Your solaris install is missing the required patch %s-%s\n", requiredPatchNo[i], requiredPatchRev[i] ); \
            printf("         Please update your your system patches or build on a different machine.\n\n" ); \
            errorCount++; \
        } \
    } \
}' $(REQ_PATCH_LIST) readingInstallPatches=1 $(INSTALL_PATCHES_FILE) >> $(WARNING_FILE)
  endif
endif # PLATFORM

######################################################
# CLASSPATH cannot be set, unless you are insane.
######################################################
sane-classpath:
ifdef CLASSPATH
	@$(ECHO) "ERROR: Your CLASSPATH environment variable is set.  This will \n" \
	   "      most likely cause the build to fail.  Please unset it \n" \
	   "      and start your build again. \n" \
	   "" >> $(ERROR_FILE)
endif

######################################################
# JAVA_HOME cannot be set, unless you are insane.
######################################################
sane-java_home:
ifdef JAVA_HOME
	@$(ECHO) "ERROR: Your JAVA_HOME environment variable is set.  This will \n" \
	   "      most likely cause the build to fail.  Please unset it \n" \
	   "      and start your build again. \n" \
	   "" >> $(ERROR_FILE)
endif

######################################################
# Make sure the fonts are there
# Exceptions are when explicitly building OPENJDK, or
# when the entire CLOSED_SRC dir is excluded, so we are
# implicitly building OPENJDK
######################################################
FONT_FILE=$(CLOSED_SRC)/share/lib/fonts/LucidaTypewriterRegular.ttf
sane-fonts:
ifndef OPENJDK
	@if [ -d $(CLOSED_SRC) ] ; then \
	 if [ ! -f $(FONT_FILE) ] ; then \
	  $(ECHO) "ERROR: Missing $(FONT_FILE). \n" \
	   "      Verify you have downloaded and overlayed on the source area all the binary files. \n" \
	   "" >> $(ERROR_FILE); \
	fi \
	fi
endif

######################################################
# If building OPENJDK check pre-built binaries are
# available for binary plug source components.
######################################################
ifdef OPENJDK
sane-binary-plugs:
  ifeq ($(IMPORT_BINARY_PLUGS),true)
	@if [ ! -d "$(BINARY_PLUGS_PATH)" ]; then \
	  $(ECHO) "WARNING: Can't locate pre-built libraries. \n" \
	    "      Please check your access to \n" \
	    "          $(BINARY_PLUGS_PATH) \n" \
	    "      and/or check your value of ALT_BINARY_PLUGS_PATH. \n" \
	   "" >> $(WARNING_FILE); \
	fi
  endif
endif

######################################################
# VARIANT must be set to DBG or OPT
######################################################
sane-variant:
	@if [ "$(VARIANT)" != DBG -a "$(VARIANT)" != OPT ] ; then \
	  $(ECHO) "ERROR: Your VARIANT environment variable is set to $(VARIANT). \n" \
	   "      Needs to be set to DBG or OPT \n" \
	   "" >> $(ERROR_FILE); \
	fi

######################################################
# LD_LIBRARY_PATH should not be set, unless you are insane.
######################################################
sane-ld_library_path:
ifdef LD_LIBRARY_PATH
	@$(ECHO) "ERROR: Your LD_LIBRARY_PATH environment variable is set.  This may \n" \
	   "      produce binaries binaries incorrectly.  Please unset it \n" \
	   "      and start your build again. \n" \
	   "" >> $(ERROR_FILE)
endif

######################################################
# LD_LIBRARY_PATH_64 should not be set, unless you are insane.
######################################################
sane-ld_library_path_64:
ifdef LD_LIBRARY_PATH_64
	@$(ECHO) "ERROR: Your LD_LIBRARY_PATH_64 environment variable is set.  This may \n" \
	   "      produce binaries binaries incorrectly.  Please unset it \n" \
	   "      and start your build again. \n" \
	   "" >> $(ERROR_FILE)
endif

######################################################
# LD_OPTIONS should not be set, unless you are insane.
######################################################
sane-ld_options:
ifdef LD_OPTIONS
	@$(ECHO) "ERROR: Your LD_OPTIONS environment variable is set.  This may \n" \
	   "      produce binaries binaries incorrectly.  Please unset it \n" \
	   "      and start your build again. \n" \
	   "" >> $(ERROR_FILE)
endif

######################################################
# LD_RUN_PATH should not be set, unless you are insane.
######################################################
sane-ld_run_path:
ifdef LD_RUN_PATH
	@$(ECHO) "ERROR: Your LD_RUN_PATH environment variable is set.  This may \n" \
	   "      produce binaries binaries incorrectly.  Please unset it \n" \
	   "      produce binaries binaries incorrectly.  Please unset it \n" \
	   "      and start your build again. \n" \
	   "" >> $(ERROR_FILE)
endif

######################################################
# MAKEFLAGS cannot be set, unless you are insane.
######################################################
ifeq ($(PLATFORM), windows)
ifdef USING_CYGWIN
REAL_MAKEFLAGS:=$(subst --unix,,$(MAKEFLAGS))
else
REAL_MAKEFLAGS:=$(MAKEFLAGS)
endif
else
REAL_MAKEFLAGS:=$(MAKEFLAGS)
endif
sane-makeflags:
# ifneq ($(strip $(REAL_MAKEFLAGS)),)
ifeq ($(origin MAKEFLAGS),environment)
	@#
	@# it is unacceptable to have the-e or --environment-overrides value in MAKEFLAGS
	@#
	@if [ `$(ECHO) $(MAKEFLAGS) | $(EGREP) -c '(^| )(e|--environment-overrides)( |$$)'` -ne 0 ]; then \
	  $(ECHO) "ERROR: Either the build was started with the flag -e or \n" \
	    "      --environment-overrides, or the MAKEFLAGS environment \n" \
	    "      variable has this value set.  This will cause any \n" \
	    "      environment variables you have defined to override \n" \
	    "      the values defined by the makefiles. This practice is \n" \
	    "      not recommemded by the authors of GNU Make, and \n" \
	    "      will lead to an improper build. \n" \
	    "      Please fix and restart the build. \n" \
	    "" >> $(ERROR_FILE) ; \
	fi
	@#
	@# it is unacceptable to havethe -i or --ignore-errors value in MAKEFLAGS
	@#
	@if [ `$(ECHO) $(MAKEFLAGS) | $(EGREP) -c '(^| )(i|--ignore-errors)( |$$)'` -ne 0 ]; then \
	  $(ECHO) "ERROR: Either the build was started with the flag -i or \n" \
	    "      --ignore-errors, or the MAKEFLAGS environment \n" \
	    "      variable has this value set. 1111 You will be unable \n" \
	    "      to determine if the build is broken or not. \n" \
	    "      Please fix and restart the build. \n" \
	    "" >> $(ERROR_FILE) ; \
	fi
	@#
	@# it is unacceptable to have the -I or --include-dir value in MAKEFLAGS
	@#
	@if [ `$(ECHO) $(MAKEFLAGS) | $(EGREP) -c '(^| )(I|--include-dir)( |$$)'` -ne 0 ]; then \
	  $(ECHO) "ERROR: Either the build was started with the flag -I or \n" \
	    "      --include-dir, or the MAKEFLAGS environment \n" \
	    "      variable has this value set.  This will render your \n" \
	    "      build questionable as not all the rules and depenencies \n" \
	    "      are captured by the build. \n" \
	    "      Please fix and restart the build. \n" \
	    "" >> $(ERROR_FILE) ; \
	fi
	@#
	@# it is unacceptable to have the -k or --keep-going value in MAKEFLAGS:
	@#
	@if [ `$(ECHO) $(MAKEFLAGS) | $(EGREP) -c '(^| )(k|--keep-going)( |$$)'` -ne 0 ]; then \
	  $(ECHO) "ERROR: Either the build was started with the flag -k or \n" \
	    "      --keep-going, or the MAKEFLAGS environment \n" \
	    "      variable has this value set. 222 You will be unable \n" \
	    "      to determine if the build is broken or not. \n" \
	    "      Please fix and restart the build.  \n" \
	    "" >> $(ERROR_FILE) ; \
	fi
	@#
	@# it is unacceptable to have the -o or --assume-old or --old-filevalue in MAKEFLAGS:
	@# Note - this rule never gets invoked because it is processed out
	@#        in GNU Make startup
	@#
	@if [ `$(ECHO) $(MAKEFLAGS) | $(EGREP) -c '(^| )(o|--assume-old|--old-file)( |$$)'` -ne 0 ]; then \
	  $(ECHO) "ERROR: Either the build was started with the flag -o or \n" \
	    "      --assume-old or --old-file, or the MAKEFLAGS environment \n" \
	    "      variable has this value set.  This could prevent the \n" \
	    "      build from executing rules it should, thus rendering a \n" \
	    "      questionable result. \n" \
	    "      Please fix and restart the build. \n" \
	    "" >> $(ERROR_FILE) ; \
	fi
	@#
	@# it is unacceptable to have the -r or --nobuiltin-rules value in MAKEFLAGS
	@#
	@if [ `$(ECHO) $(MAKEFLAGS) | $(EGREP) -c '(^| )(r|--no-builtin-rules)( |$$)'` -ne 0 ]; then \
	  $(ECHO) "ERROR: Either the build was started with the flag -r or \n" \
	    "      --no-builtin-rules, or the MAKEFLAGS environment \n" \
	    "      variable has this value set.  This may break the build \n" \
	    "      by not allowing builtin rules that may be required. \n" \
	    "      Please fix and restart the build. \n" \
	    "" >> $(ERROR_FILE) ; \
	fi
	@#
	@# it is unacceptable to have the -t or --touch value in MAKEFLAGS
	@# Note - this rule never gets invoked because it is processed out
	@#        in GNU Make startup
	@#
	@if [ `$(ECHO) $(MAKEFLAGS) | $(EGREP) -c '(^| )(t|--touch)( |$$)'` -ne 0 ]; then \
	  $(ECHO) "ERROR: Either the build was started with the flag -t or \n" \
	    "      --touch, or the MAKEFLAGS environment \n" \
	    "      variable has this value set.  This will leave the \n" \
	    "      build in a unclear state and could lead to not executing \n" \
	    "      rules which should be executed. \n" \
	    "      Please fix and restart the build. \n" \
	    "" >> $(ERROR_FILE) ; \
	fi
	@#
	@# show what is in MAKEFLAGS so the user is aware...
	@#
	@$(ECHO) "WARNING: Your MAKEFLAGS environment variable is set. \n" \
	   "        You should be very careful about the values set here. \n" \
	   "\n" \
	   "        MAKEFLAGS is set to =>$(MAKEFLAGS)<= \n" \
	   "" >> $(WARNING_FILE)
endif

######################################################
# if specified, ALT_OUTPUTDIR must point to non-relative path if set
######################################################
sane-alt_outputdir:
ifdef ALT_OUTPUTDIR
	@if [ `$(ECHO) $(subst \,/,$(ALT_OUTPUTDIR)) | $(EGREP) -c '^([A-Za-z]:)?/'` -ne 1 ]; then \
	  $(ECHO) "ERROR: ALT_OUTPUTDIR must be an Absolute Path Name, \n" \
	    "      not a Relative Path Name. \n" \
	    "" >> $(ERROR_FILE) ; \
	fi
  ifeq ($(PLATFORM), windows)
	@if [ `$(ECHO) $(subst \,/,$(ALT_OUTPUTDIR)) | $(EGREP) -c '^([A-Za-z]:)'` -ne 1 ]; then \
	  $(ECHO) "ERROR: On windows, ALT_OUTPUTDIR must contain the drive letter. \n" \
	    "" >> $(ERROR_FILE) ; \
	fi
  endif
endif

######################################################
# OUTPUTDIR tests
######################################################
sane-outputdir:
	@#
	@# OUTPUTDIR must be a directory...
	@#
	@if [ ! -d "$(OUTPUTDIR)" ]; then \
	  $(ECHO) "ERROR: OUTPUTDIR must be an existing directory. The current \n" \
	    "      value of OUTPUTDIR is \n" \
	    "          $(OUTPUTDIR) \n" \
	    "      Please check your value of ALT_OUTPUTDIR. \n" \
	    "" >> $(ERROR_FILE) ; \
	fi
	@#
	@# OUTPUTDIR must be writeable by user...
	@#
	@if [ ! -w "$(OUTPUTDIR)" ]; then \
	  $(ECHO) "ERROR: You must have write permissions to OUTPUTDIR. The \n" \
	    "      current value of OUTPUTDIR is \n" \
	    "          $(OUTPUTDIR) \n" \
	    "      Either obtain these permissions or set ALT_OUTPUTDIR. \n" \
	    "" >> $(ERROR_FILE) ; \
	fi
	@#
	@# OUTPUTDIR must have enough free space...
	@#
	@if [ $(FREE_SPACE) -lt $(REQUIRED_FREE_SPACE) ]; then \
	  $(ECHO) "WARNING: You may not have enough free space in your OUTPUTDIR. The \n" \
	    "        current value of OUTPUTDIR is \n" \
	    "            $(OUTPUTDIR) \n" \
	    "        You need "$(REQUIRED_FREE_SPACE)" Kbytes free on this device to build \n" \
	    "        and it appears that only "$(FREE_SPACE)" Kbytes are free. \n" \
	    "        Either obtain more space or set ALT_OUTPUTDIR to a larger disk. \n" \
	    "" >> $(WARNING_FILE) ; \
	fi

######################################################
# if specified, ALT_BOOTDIR must point to non-relative path if set
######################################################
sane-alt_bootdir:
ifdef ALT_BOOTDIR
	@if [ `$(ECHO) $(subst \,/,$(ALT_BOOTDIR)) | $(EGREP) -c '^([A-Za-z]:)?/'` -ne 1 ]; then \
	  $(ECHO) "ERROR: ALT_BOOTDIR must be an Absolute Path Name, \n" \
	    "      not a Relative Path Name. \n" \
	    "      The current value of ALT_BOOTDIR is \n" \
	    "          $(ALT_BOOTDIR) \n" \
	    "      Please fix this and continue your build. \n" \
	    "" >> $(ERROR_FILE) ; \
	fi
endif

######################################################
# BOOTDIR must point to a valid JDK.
######################################################
BOOT_CHECK :=$(call CheckVersions,$(BOOT_VER),$(REQUIRED_BOOT_VER))
sane-bootdir:
	@if [ "$(BOOT_CHECK)" != "same" -a "$(BOOT_CHECK)" != "newer" ]; then \
	  $(ECHO) "ERROR: Your BOOTDIR environment variable does not point \n" \
	    "      to a valid JDK for bootstrapping this build. \n" \
	    "      A JDK $(JDK_MINOR_VERSION) $(MARKET_NAME) build must be bootstrapped using  \n" \
	    "      JDK $(PREVIOUS_JDK_VERSION) fcs (or later). \n" \
	    "      Apparently, your bootstrap JDK is version $(BOOT_VER) \n" \
	    "      Please update your ALT_BOOTDIR setting and start your build again. \n" \
	    "" >> $(ERROR_FILE) ; \
	fi

######################################################
# BOOTDIR is recommended to reside on a local drive
######################################################
sane-local-bootdir:
ifeq ($(PLATFORM), windows)
	@if [ `$(ECHO) $(BOOTDIR) | $(EGREP) -c '^[jJ]:'` -ne 0 ]; then \
	  $(ECHO) "WARNING: Your BOOTDIR is located on the J: drive. Often the J:\n" \
	    "        drive is mapped over a network. Using a mapped drive for\n" \
	    "        the BOOTDIR may significantly slow down the build process.\n" \
	    "        You may want to consider using the ALT_BOOTDIR variable\n" \
	    "        to point the build to another location for the BOOTDIR instead. \n" \
	    "        Your current BOOTDIR is:\n" \
	    "           $(BOOTDIR) \n" \
	    "" >> $(WARNING_FILE) ; \
	fi
endif

######################################################
# CACERTS_FILE must be absoulte path and readable
######################################################
sane-cacerts:
  ifdef ALT_CACERTS_FILE
	@if [ `$(ECHO) $(subst \,/,$(ALT_CACERTS_FILE)) | $(EGREP) -c '^([A-Za-z]:)?/'` -ne 1 ]; then \
	  $(ECHO) "ERROR: ALT_CACERTS_FILE must be an Absolute Path Name, \n" \
	    "      not a Relative Path Name. \n" \
	    "      The current value of ALT_CACERTS_FILE is \n" \
	    "          $(ALT_CACERTS_FILE) \n" \
	    "      Please fix this and continue your build. \n" \
	    "" >> $(ERROR_FILE) ; \
	fi
  endif
	@#
	@# CACERTS_FILE must be readable
	@#
	@if [ ! -r "$(subst \,/,$(CACERTS_FILE))" ]; then \
	  $(ECHO) "ERROR: You do not have access to a valid cacerts file. \n" \
	    "      Please check your access to \n" \
	    "          $(subst \,/,$(CACERTS_FILE)) \n" \
	    "      and/or check your value of ALT_CACERTS_FILE. \n" \
	    "" >> $(ERROR_FILE) ; \
	fi
	@#
	@# CACERTS_FILE must be a file
	@#
	@if [ -d "$(subst \,/,$(CACERTS_FILE))" ]; then \
	  $(ECHO) "ERROR: You do not have access to a valid cacerts file.\n" \
	    "      The value of CACERTS_FILE must point to a normal file.\n" \
	    "      Please check your access to \n" \
	    "          $(subst \,/,$(CACERTS_FILE)) \n" \
	    "      and/or check your value of ALT_CACERTS_FILE. \n" \
	    "" >> $(ERROR_FILE) ; \
	fi


######################################################
# Check for availability of FreeType (OpenJDK specific)
######################################################

ifdef OPENJDK

# The freetypecheck Makefile prints out "Failed" if not good enough
$(TEMPDIR)/freetypeinfo: FRC
	@$(prep-target)
	@(($(CD) $(BUILDDIR)/tools/freetypecheck && $(MAKE)) || \
	    $(ECHO) "Failed to build freetypecheck." ) > $@

sane-freetype: $(TEMPDIR)/freetypeinfo
	@if [ "`$(CAT) $< | $(GREP) Fail`" != "" ]; then \
	  $(ECHO) "ERROR: FreeType version " $(REQUIRED_FREETYPE_VERSION) \
	          " or higher is required. \n" \
		  "`$(CAT) $<`  \n" >> $(ERROR_FILE) ; \
	fi

else
#do nothing  (not OpenJDK)
sane-freetype: 
endif

######################################################
# if specified, BUILD_MODULES must contain valid values.
######################################################
MODULES_REGEX="all|base|desktop|management|enterprise|misc|tools"
sane-build_modules:
ifdef BUILD_MODULES
	@for m in $(BUILD_MODULES) ; do \
            valid=`$(ECHO) $$m | $(EGREP) $(MODULES_REGEX)`; \
            if [ "x$$valid" = "x" ] ; then \
                $(ECHO) "ERROR: $$m set in the BUILD_MODULES variable is invalid.\n" \
                "" >> $(ERROR_FILE); \
            fi \
	done
endif

######################################################
# CUPS_HEADERS_PATH must be valid
######################################################
sane-cups:
ifneq ($(PLATFORM), windows)
	@if [ ! -r $(CUPS_HEADERS_PATH)/cups/cups.h ]; then \
	  $(ECHO) "ERROR: You do not have access to valid Cups header files. \n" \
	    "      Please check your access to \n" \
	    "          $(CUPS_HEADERS_PATH)/cups/cups.h \n" \
	    "      and/or check your value of ALT_CUPS_HEADERS_PATH, \n" \
	    "      CUPS is frequently pre-installed on many systems, \n" \
            "      or may be downloaded from http://www.cups.org \n" \
	    "" >> $(ERROR_FILE) ; \
	fi
endif

######################################################
# Check for existence of DEVTOOLS_PATH
######################################################
sane-devtools_path:
	@if [ "$(DEVTOOLS_PATH)" != "" -a ! -r "$(DEVTOOLS_PATH)" ]; then \
	  $(ECHO) "ERROR: You do not have a valid DEVTOOLS_PATH setting. \n" \
	    "      Please check your access to \n" \
	    "          $(DEVTOOLS_PATH) \n" \
	    "      and/or check your value of ALT_DEVTOOLS_PATH. \n" \
	    "" >> $(ERROR_FILE) ; \
	fi

######################################################
# Check for existence of MS_RUNTIME_LIBRARIES
######################################################
sane-msvcrt_path:
ifeq ($(PLATFORM), windows)
	@if [ ! -r "$(MSVCRT_DLL_PATH)/msvcrt.dll" ]; then \
	  $(ECHO) "ERROR: You do not have access to msvcrt.dll. \n" \
	    "      Please check your access to \n" \
	    "          $(MSVCRT_DLL_PATH) \n" \
	    "      and/or check your value of ALT_MSVCRT_DLL_PATH. \n" \
	    "" >> $(ERROR_FILE) ; \
	fi
  ifneq ($(MSVCRNN_DLL),)
	@if [ ! -r "$(MSVCRNN_DLL_PATH)/$(MSVCRNN_DLL)" ]; then \
	  $(ECHO) "ERROR: You do not have access to $(MSVCRNN_DLL). \n" \
	    "      Please check your access to \n" \
	    "          $(MSVCRNN_DLL_PATH) \n" \
	    "      and/or check your value of ALT_MSVCRNN_DLL_PATH. \n" \
	    "" >> $(ERROR_FILE) ; \
	fi
  endif
endif

######################################################
# Check for existence of COMPILER_PATH
######################################################
sane-compiler_path:
	@if [ "$(COMPILER_PATH)" != "" -a ! -r "$(COMPILER_PATH)" ]; then \
	  $(ECHO) "ERROR: You do not have a valid COMPILER_PATH setting. \n" \
	    "      Please check your access to \n" \
	    "          $(COMPILER_PATH) \n" \
	    "      and/or check your value of ALT_COMPILER_PATH. \n" \
	    "" >> $(ERROR_FILE) ; \
	fi

######################################################
# Check for existence of UNIXCOMMAND_PATH
######################################################
sane-unixcommand_path:
	@if [ "$(UNIXCOMMAND_PATH)" != "" -a ! -r "$(UNIXCOMMAND_PATH)" ]; then \
	  $(ECHO) "ERROR: You do not have a valid UNIXCOMMAND_PATH setting. \n" \
	    "      Please check your access to \n" \
	    "          $(UNIXCOMMAND_PATH) \n" \
	    "      and/or check your value of ALT_UNIXCOMMAND_PATH. \n" \
	    "" >> $(ERROR_FILE) ; \
	fi
ifeq ($(PLATFORM), windows)
	@for utility in cpio ar file m4 ; do \
	  if [ ! -r "`$(WHICH) $${utility}`" ]; then \
	    $(ECHO) "WARNING: You do not have the utility $${utility} in the \n" \
	      "      directory $(UNIXCOMMAND_PATH). \n" \
	      "      The utilities cpio, ar, file, and m4 are required. \n" \
	      "" >> $(WARNING_FILE) ; \
	  fi; \
	done
endif

######################################################
# Check for existence of USRBIN_PATH on linux
######################################################
sane-usrbin_path:
ifeq ($(PLATFORM), linux)
	@if [ "$(USRBIN_PATH)" != "" -a ! -r "$(USRBIN_PATH)" ]; then \
	    $(ECHO) "ERROR: You do not have a valid USRBIN_PATH setting. \n" \
	      "      Please check your access to \n" \
	      "          $(USRBIN_PATH)  \n" \
	      "      and/or check your value of ALT_USRBIN_PATH. \n" \
	      "" >> $(ERROR_FILE) ; \
	  fi
endif

######################################################
# Check for existence of UNIXCCS_PATH on solaris
######################################################
sane-unixccs_path:
ifeq ($(PLATFORM), solaris)
	@if [ "$(UNIXCCS_PATH)" != "" -a ! -r "$(UNIXCCS_PATH)" ]; then \
	  $(ECHO) "ERROR: You do not have a valid UNIXCCS_PATH setting. \n" \
	    "      Please check your access to \n" \
	    "          $(UNIXCCS_PATH) \n" \
	    "      and/or check your value of ALT_UNIXCCS_PATH. \n" \
	    "" >> $(ERROR_FILE) ; \
	  fi
endif

######################################################
# Verify the docs directory exists
######################################################
sane-docs_import:
	@if [ ! -d "$(HOTSPOT_DOCS_IMPORT_PATH)" ]; then \
	    $(ECHO) "WARNING: The directory HOTSPOT_DOCS_IMPORT_PATH=$(HOTSPOT_DOCS_IMPORT_PATH) \n" \
	      "      does not exist, check your value of ALT_HOTSPOT_DOCS_IMPORT_PATH. \n" \
	      "" >> $(WARNING_FILE) ; \
	fi

######################################################
# Check for possible problem regarding __fabsf,  math_iso.h and the libm patch.
#    Hotspot should have been changed in Mustang 6.0 Build 47 to not depend
#    on __fabsf, this is just checking that fact now.
######################################################
sane-math_iso:
ifeq ($(PLATFORM), solaris)
	@if [ -f $(HOTSPOT_SERVER_PATH)/$(LIB_PREFIX)jvm.$(LIBRARY_SUFFIX) ]; then \
	  if [ "`$(NM) $(HOTSPOT_SERVER_PATH)/$(LIB_PREFIX)jvm.$(LIBRARY_SUFFIX) | $(GREP) __fabsf`" != "" ]; then \
	    $(ECHO) "WARNING: This version of hotspot relies on __fabsf \n" \
	      "        which is not always available on Solaris 8 and 9 machines \n" \
	      "        unless they have the latest libm patch and the file \n" \
	      "        /usr/include/iso/math_iso.h which can trigger this dependency.\n" \
	      "        Hotspot should NOT be dependent on this extern, check the \n" \
	      "        version of the hotspot library you are using. \n" \
	      "" >> $(WARNING_FILE) ; \
	    fi; \
	fi
endif

######################################################
# Check for possible patch problem regarding /usr/lib/libCrun.so
######################################################
sane-libCrun:
ifeq ($(PLATFORM), solaris)
	@if [ "`$(NM) /usr/lib/libCrun.so.1 | $(GREP) __1c2n6FIpv_0_`" = "" ]; then \
	  $(ECHO) "WARNING: The file /usr/lib/libCrun.so.1 is missing the extern \n" \
	    "        __1c2n6FIpv_0_ which indicates that the system is missing \n" \
	    "        a required Solaris patch, or you are using a pre-FCS release \n" \
	    "        of Solaris 10. You need the latest /usr/lib/libCrun.so.1 \n" \
	    "        which comes with the FCS release of Solaris 10 and available \n" \
	    "        through the latest Solaris 8 or 9 C++ runtime patches. \n" \
	    "" >> $(WARNING_FILE) ; \
	fi
endif

######################################################
# Check for existence of MSDEVTOOLS_PATH on windows
######################################################
sane-msdevtools_path:
ifeq ($(PLATFORM), windows)
	@if [ "$(MSDEVTOOLS_PATH)" != "" -a ! -r "$(MSDEVTOOLS_PATH)" ]; then \
	  $(ECHO) "ERROR: You do not have a valid MSDEVTOOLS_PATH setting. \n" \
	    "      Please check your access to \n" \
	    "          $(MSDEVTOOLS_PATH) \n" \
	    "      and/or check your value of ALT_MSDEVTOOLS_PATH. \n" \
	    "" >> $(ERROR_FILE) ; \
	fi
endif

######################################################
# Check for existence of Hotspot binaries
######################################################
sane-hotspot_binaries:
ifeq ($(ARCH_DATA_MODEL), 32)
	@if [ ! -r $(HOTSPOT_CLIENT_PATH)/$(LIB_PREFIX)jvm.$(LIBRARY_SUFFIX) ]; then \
	  $(ECHO) "ERROR: HOTSPOT_CLIENT_PATH does not point to a valid HotSpot VM. \n" \
	    "      Please check your access to \n" \
	    "          $(HOTSPOT_CLIENT_PATH)/$(LIB_PREFIX)jvm.$(LIBRARY_SUFFIX) \n" \
	    "      and/or check your value of ALT_HOTSPOT_CLIENT_PATH. \n" \
	    "" >> $(ERROR_FILE) ; \
	fi
endif
	@if [ ! -r $(HOTSPOT_SERVER_PATH)/$(LIB_PREFIX)jvm.$(LIBRARY_SUFFIX) ]; then \
	  $(ECHO) "ERROR: HOTSPOT_SERVER_PATH does not point to a valid HotSpot VM. \n" \
	    "      Please check your access to \n" \
	    "          $(HOTSPOT_SERVER_PATH)/$(LIB_PREFIX)jvm.$(LIBRARY_SUFFIX) \n" \
	    "      and/or check your value of ALT_HOTSPOT_SERVER_PATH. \n" \
	    "" >> $(ERROR_FILE) ; \
	fi
	@#
	@# Check value of HOTSPOT_LIB_PATH
	@#
ifeq ($(PLATFORM), windows)
	@if [ ! -r $(HOTSPOT_LIB_PATH)/jvm.lib ]; then \
	  $(ECHO) "ERROR: HOTSPOT_LIB_PATH does not point to a valid HotSpot library. \n" \
	    "      Please check your access to \n" \
	    "          $(HOTSPOT_LIB_PATH)/jvm.lib \n" \
	    "      and/or check your value of ALT_HOTSPOT_LIB_PATH. \n" \
	    "" >> $(ERROR_FILE) ; \
	fi
	@#
	@# Check for the .map files - its OK if they are not there..
	@#
  ifeq ($(ARCH_DATA_MODEL), 32)
	@# There is no 64-bit HotSpot client VM
	@if [ ! -r $(HOTSPOT_CLIENT_PATH)/jvm.map ]; then \
	  $(ECHO) "WARNING: HOTSPOT_CLIENT_PATH does not point to valid HotSpot .map files. \n" \
	    "        These files are optional and aid in the debugging of the JVM. \n" \
	    "        Please check your access to \n" \
	    "          $(HOTSPOT_CLIENT_PATH)/jvm.map \n" \
	    "        and/or check your value of ALT_HOTSPOT_CLIENT_PATH. \n" \
	    "" >> $(WARNING_FILE) ; \
	fi
	@if [ ! -r $(HOTSPOT_CLIENT_PATH)/jvm.pdb ]; then \
	  $(ECHO) "WARNING: HOTSPOT_CLIENT_PATH does not point to valid HotSpot .pdb files. \n" \
	    "        These files are optional and aid in the debugging of the JVM. \n" \
	    "        Please check your access to \n" \
	    "          $(HOTSPOT_CLIENT_PATH)/jvm.pdb \n" \
	    "        and/or check your value of ALT_HOTSPOT_CLIENT_PATH. \n" \
	    "" >> $(WARNING_FILE) ; \
	fi
  endif
	@if [ ! -r $(HOTSPOT_SERVER_PATH)/jvm.map ]; then \
	  $(ECHO) "WARNING: HOTSPOT_SERVER_PATH does not point to valid HotSpot .map files. \n" \
	    "        These files are optional and aid in the debugging of the JVM. \n" \
	    "        Please check your access to \n" \
	    "          $(HOTSPOT_SERVER_PATH)/jvm.map \n" \
	    "        and/or check your value of ALT_HOTSPOT_SERVER_PATH. \n" \
	    "" >> $(WARNING_FILE) ; \
	fi
	@if [ ! -r $(HOTSPOT_SERVER_PATH)/jvm.pdb ]; then \
	  $(ECHO) "WARNING: HOTSPOT_SERVER_PATH does not point to valid HotSpot .pdb files. \n" \
	    "        These files are optional and aid in the debugging of the JVM. \n" \
	    "        Please check your access to \n" \
	    "          $(HOTSPOT_SERVER_PATH)/jvm.pdb \n" \
	    "        and/or check your value of ALT_HOTSPOT_SERVER_PATH. \n" \
	    "" >> $(WARNING_FILE) ; \
	fi
endif	


######################################################
# Check for existence of misc Hotspot imported files
######################################################
HOTSPOT_INCLUDE_FILE_LIST  = jvmti.h
HOTSPOT_INCLUDE_FILE_LIST  += jvmticmlr.h
#HOTSPOT_INCLUDE_FILE_LIST += jni.h jni_md.h
#HOTSPOT_INCLUDE_FILE_LIST += jvm.h jvm_md.h
#HOTSPOT_INCLUDE_FILE_LIST += jmm.h
TMP_SDK_INCLUDE_FILE_LIST=$(HOTSPOT_INCLUDE_FILE_LIST:%.h=$(TEMPDIR)/%.h)
TMP_SDK_INCLUDE_FILE_DIFFS=$(HOTSPOT_INCLUDE_FILE_LIST:%.h=$(TEMPDIR)/%.hdiffs)

# These include files must have a pattern: 'version: MAJOR.MINOR.MICRO'
#    where MACRO, MINOR, and MICRO are numbers, e.g. 1.0.1, 0.2.90, etc.
#    The critical version we are checking is MAJOR.MINOR, we print all three
#    when we detect an error.

TMP_SDK_INCLUDE_FIND_VERSION= $(EGREP) 'version:'
TMP_SDK_INCLUDE_GET_VERSION= $(TMP_SDK_INCLUDE_FIND_VERSION) | \
		$(SED) -e 's@.*\([0-9][0-9]*\.[0-9][0-9]*\)\.[0-9].*@\1@'
TMP_SDK_INCLUDE_GET_FULL_VERSION= $(TMP_SDK_INCLUDE_FIND_VERSION) | \
		$(SED) -e 's@.*\([0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*\).*@\1@'

# Compare an interface file (Rule creates 2 temp files: %.h and %.h.IMPORT)
#    Files jvm.h, jvm_md.h and jmm.h are special in that they are not publicly 
#    exported but do represent VM interfaces used by the rest of the jdk.
#    So these 3 will not be found in a promoted build and can only
#    be checked when this represents a full control build (i.e. the
#    HOTSPOT_IMPORT_PATH includes these files in it's 'include' directory).
$(TEMPDIR)/%.h: $(SHARE_SRC)/javavm/export/%.h
	@$(install-non-module-file)
	@$(RM) $@.IMPORT
	@if [ -r $(HOTSPOT_IMPORT_PATH)/include/$(@F) ]; then \
	  $(CP) $(HOTSPOT_IMPORT_PATH)/include/$(@F) $@.IMPORT ; \
	elif [ "$(@F)" != "jvm.h" -a "$(@F)" != "jmm.h" ] ; then \
	  $(ECHO) "WARNING: HOTSPOT_IMPORT_PATH does not contain the interface file $(@F). \n" \
	    "        Check your value of ALT_HOTSPOT_IMPORT_PATH. \n" \
	    "" >> $(WARNING_FILE) ; \
	  $(CP) $< $@.IMPORT; \
	else \
	  $(CP) $< $@.IMPORT; \
	fi

$(TEMPDIR)/%.h: $(PLATFORM_SRC)/javavm/export/%.h
	@$(install-non-module-file)
	@$(RM) $@.IMPORT
	@if [ -r $(HOTSPOT_IMPORT_PATH)/include/$(PLATFORM_INCLUDE_NAME)/$(@F) ]; then \
	  $(CP) $(HOTSPOT_IMPORT_PATH)/include/$(PLATFORM_INCLUDE_NAME)/$(@F) $@.IMPORT ; \
	elif [ "$(@F)" != "jvm_md.h" ] ; then \
	  $(ECHO) "WARNING: HOTSPOT_IMPORT_PATH does not contain the interface file $(@F). \n" \
	    "        Check your value of ALT_HOTSPOT_IMPORT_PATH. \n" \
	    "" >> $(WARNING_FILE) ; \
	  $(CP) $< $@.IMPORT; \
	else \
	  $(CP) $< $@.IMPORT; \
	fi

# Compares the two tempfiles: %.h and %.h.IMPORT, answer in %.hdiffs
#   Note: Putting anything into the hdiffs file will trigger generic IMPORT
#         warning message in hotspot_import_include.
#   First checks the major.minor versions, the micro number can differ.
#   Second checks the full version.
#   Lastly does a full diff if the full version differs or it has no version
$(TEMPDIR)/%.hdiffs: $(TEMPDIR)/%.h
	@$(prep-target)
	@$(TOUCH) $@
	@if [ "`$(CAT) $<        | $(TMP_SDK_INCLUDE_GET_VERSION)`" != \
	      "`$(CAT) $<.IMPORT | $(TMP_SDK_INCLUDE_GET_VERSION)`" ] ; then \
	    $(ECHO) "WARNING: The file $(<F) is not the same interface as the VM version.\n " \
	      "        this workspace has $(<F) `$(CAT) $< | $(TMP_SDK_INCLUDE_GET_FULL_VERSION)` and \n " \
	      "        HOTSPOT_IMPORT_PATH contains $(<F) `$(CAT) $<.IMPORT | $(TMP_SDK_INCLUDE_GET_FULL_VERSION)` \n" \
	    "" >> $(WARNING_FILE) ; \
	     $(ECHO) "Version mis-match" > $@ ; \
	fi
	@if [ "`$(CAT) $<        | $(TMP_SDK_INCLUDE_GET_FULL_VERSION)`" != \
               "`$(CAT) $<.IMPORT | $(TMP_SDK_INCLUDE_GET_FULL_VERSION)`" ] ; then \
          $(RM) $<.filtered  $<.IMPORT.filtered; \
          $(EGREP) -v 'VERSION' $< > $<.filtered; \
          $(EGREP) -v 'VERSION' $<.IMPORT > $<.IMPORT.filtered; \
          ($(DIFF) -w $<.filtered $<.IMPORT.filtered || exit 0) >> $@ ; \
        elif [ "`$(CAT) $< | $(TMP_SDK_INCLUDE_FIND_VERSION)`" = "" ] ; then \
          $(RM) $<.filtered  $<.IMPORT.filtered; \
          $(EGREP) -v '@\(#\)' $< > $<.filtered; \
          $(EGREP) -v '@\(#\)' $<.IMPORT > $<.IMPORT.filtered; \
          ($(DIFF) -w $<.filtered $<.IMPORT.filtered || exit 0) >> $@ ; \
	fi

# Verify all imported hotspot files
sane-hotspot_import:: sane-hotspot_import_dir sane-hotspot_import_include

# Verify the base directory exists
sane-hotspot_import_dir:
	@$(RM) $(TMP_SDK_INCLUDE_FILE_DIFFS)
	@$(RM) $(TMP_SDK_INCLUDE_FILE_LIST)
	@if [ ! -d "$(HOTSPOT_IMPORT_PATH)" ]; then \
	    $(ECHO) "WARNING: The directory HOTSPOT_IMPORT_PATH=$(HOTSPOT_IMPORT_PATH) \n" \
	      "      does not exist, check your value of ALT_HOTSPOT_IMPORT_PATH. \n" \
	      "" >> $(WARNING_FILE) ; \
	fi

# Verify hotspot include files
sane-hotspot_import_include: $(TMP_SDK_INCLUDE_FILE_LIST) $(TMP_SDK_INCLUDE_FILE_DIFFS)
	@if [ "`$(CAT) $(TMP_SDK_INCLUDE_FILE_DIFFS)`" != "" ] ; then \
	  $(ECHO) "WARNING: Possible HotSpot VM interface conflict. \n" \
	    "        HOTSPOT_IMPORT_PATH is used to import files from the VM build. \n" \
	    "        It is also used to verify that any copied files are consistent between \n" \
	    "        these two components. It has been detected that one or more of the \n" \
	    "        VM interface files inside this workspace may not match the interfaces \n" \
	    "        exported by the VM, or the VM versions could not be found. \n" \
	    "        The list of VM interface files is: \n" \
	    "            $(HOTSPOT_INCLUDE_FILE_LIST). \n" \
	    "        This workspace has copies of these files at: \n" \
	    "          $(SHARE_SRC)/javavm/export and $(PLATFORM_SRC)/javavm/export \n" \
	    "        for build purposes, and they should contain the same interfaces \n" \
	    "        as the VM versions imported from: \n" \
	    "          \$$(HOTSPOT_IMPORT_PATH)/include \n" \
	    "               (i.e. $(HOTSPOT_IMPORT_PATH)/include) \n" \
	    "        If an interface indeed doesn't match, then the use of this interface \n" \
	    "        at JDK runtime could cause serious errors. \n" \
	    "" >> $(WARNING_FILE) ; \
	    for i in $(TMP_SDK_INCLUDE_FILE_DIFFS); do \
		if [ -s $$i ] ; then \
		  $(ECHO) " " >> $(WARNING_FILE); \
		  $(ECHO) "VM Interface Differences: $$i" >> $(WARNING_FILE); \
		  $(CAT) $$i >> $(WARNING_FILE); \
		  $(ECHO) " " >> $(WARNING_FILE); \
		fi; \
	    done; \
	fi
	@$(RM) $(TMP_SDK_INCLUDE_FILE_DIFFS)
	@$(RM) $(TMP_SDK_INCLUDE_FILE_LIST)

# The JDI-SA feature is not currently released on some platforms.
# See the Defs-<arch>.gmk files.

ifeq ($(INCLUDE_SA), true)
# Verify that hotspot Serviceability Agent files are present.  To keep 
# it simple, we will just check for one of them.  The others have arch 
# dependent paths.

sane-hotspot_import::
	@if [ ! -r  $(HOTSPOT_IMPORT_PATH)/lib/sa-jdi.jar ] ; then \
	  $(ECHO) "WARNING: File $(HOTSPOT_IMPORT_PATH)/lib/sa-jdi.jar does not exist.\n" \
	    "        The JDI binding for the Serviceability Agent will not be included in the build.\n" \
	    "        Please check your access to\n" \
	    "          $(HOTSPOT_IMPORT_PATH)/lib/sa-jdi.jar\n" \
	    "        and/or check your value of ALT_HOTSPOT_IMPORT_PATH.\n" \
	    "" >> $(WARNING_FILE) ; \
	 fi
endif

######################################################
# Check the ant version
######################################################
ANT_CHECK :=$(call CheckVersions,$(ANT_VER),$(REQUIRED_ANT_VER))
sane-ant_version:
	@if [ "$(ANT_CHECK)" != "same" \
	      -a "$(ANT_CHECK)" != "newer" ]; then \
	  $(ECHO) "WARNING: The version of ant being used is older than \n" \
	    "      the required version of '$(REQUIRED_ANT_VER)'. \n" \
	    "      The version of ant found was '$(ANT_VER)'. \n" \
	    "" >> $(WARNING_FILE) ; \
	fi

######################################################
# Check the zip file version
######################################################
ZIP_CHECK :=$(call CheckVersions,$(ZIP_VER),$(REQUIRED_ZIP_VER))
sane-zip_version: sane-unzip_version
	@if [ "$(ZIP_CHECK)" != "same" -a "$(ZIP_CHECK)" != "newer" ]; then \
	  $(ECHO) "WARNING: The version of zip being used is older than \n" \
	    "      the required version of '$(REQUIRED_ZIP_VER)'. \n" \
	    "      The version of zip found was '$(ZIP_VER)'. \n" \
	    "" >> $(WARNING_FILE) ; \
	fi

######################################################
# Check the unzip file version
######################################################
UNZIP_CHECK :=$(call CheckVersions,$(UNZIP_VER),$(REQUIRED_UNZIP_VER))
sane-unzip_version:
	@if [ "$(UNZIP_CHECK)" != "same" -a "$(UNZIP_CHECK)" != "newer" ]; then \
	  $(ECHO) "WARNING: The version of unzip being used is older than \n" \
	    "      the required version of '$(REQUIRED_UNZIP_VER)'. \n" \
	    "      The version of unzip found was '$(UNZIP_VER)'. \n" \
	    "" >> $(WARNING_FILE) ; \
	fi

######################################################
# Check for windows DirectX sdk directory
######################################################
sane-dxsdk:
ifeq ($(PLATFORM), windows)
	@if [ ! -r $(DXSDK_INCLUDE_PATH)/d3d9.h  ]; then \
	$(ECHO) "ERROR: You do not have access to a valid DirectX SDK Include dir.\n" \
	  "      The value of DXSDK_INCLUDE_PATH must point a valid DX SDK dir.\n" \
	  "      Please check your access to \n" \
	  "          $(DXSDK_INCLUDE_PATH) \n" \
	  "      and/or check your value of ALT_DXSDK_PATH or ALT_DXSDK_INCLUDE_PATH.\n" \
	  "      Microsoft DirectX 9 SDK (Summer 2004 Update or newer) can be downloaded from the following location:\n" \
	  "          http://msdn.microsoft.com/library/default.asp?url=/downloads/list/directx.asp\n" \
	  "      Or  http://www.microsoft.com/directx\n" \
	  "" >> $(ERROR_FILE) ; \
	else \
	  if [ ! "$(DXSDK_VER)" = "$(REQUIRED_DXSDK_VER)" ]; then \
	  $(ECHO) "ERROR: The DirectX SDK must be version $(REQUIRED_DXSDK_VER).\n" \
	    "      $(YOU_ARE_USING) DirectX SDK version: $(DXSDK_VER)\n" \
	    "      The DirectX SDK was obtained from the following location: \n" \
	    "          $(DXSDK_PATH) \n" \
	    "      Please change your DirectX SDK. \n" \
	    "      Microsoft DirectX 9 SDK (Summer 2004 Update or newer) can be downloaded from the following location:\n" \
	    "          http://msdn.microsoft.com/library/default.asp?url=/downloads/list/directx.asp\n" \
	    "      Or  http://www.microsoft.com/directx\n" \
	    "" >> $(ERROR_FILE) ; \
	  else \
	    if [ -r $(DXSDK_INCLUDE_PATH)/basetsd.h ]; then \
              if [ `$(EGREP) -c __int3264 $(DXSDK_INCLUDE_PATH)/basetsd.h` -ne 0 ]; then \
	      $(ECHO) "WARNING: The DirectX SDK Include directory contains a newer basetsd.h,\n" \
		"      which may indicate that you're using an incorrect version of DirectX SDK.\n" \
		"      This may result in a build failure.\n" \
		"      The DirectX SDK Include dir was obtained from the following location:\n" \
		" 	  $(DXSDK_INCLUDE_PATH) \n" \
		"      Please change your DirectX SDK to version 9 (Summer 2004 Update or newer).\n" \
	        "      Microsoft DirectX 9 SDK can be downloaded from the following location:\n" \
	        "          http://msdn.microsoft.com/library/default.asp?url=/downloads/list/directx.asp\n" \
		"      Or  http://www.microsoft.com/directx\n" \
  		"" >> $(WARNING_FILE) ; \
	      fi \
	    fi \
	  fi \
	fi
endif

######################################################
# Check the linker version(s)
######################################################
ifeq ($(PLATFORM), windows)
  LINK_CHECK  :=$(call CheckVersions,$(LINK_VER),$(REQUIRED_LINK_VER))
endif
sane-link:
ifdef LINK_VER
	@if [ "$(LINK_CHECK)" = "missing" ]; then \
	  $(ECHO) "ERROR: The Linker version is undefined. \n" \
	    "" >> $(ERROR_FILE) ; \
	fi
	@if [ "$(LINK_CHECK)" != "same" ]; then \
	  $(ECHO) "WARNING: To build Java 2 SDK $(JDK_VERSION) you need : \n" \
	    "      $(REQUIRED_COMPILER_VERSION) - link.exe version \"$(REQUIRED_LINK_VER)\" \n" \
	      "      Specifically the $(REQUIRED_COMPILER_NAME) link.exe. \n " \
	    "      $(YOU_ARE_USING) Linker version \"$(LINK_VER)\" \n" \
	    "" >> $(WARNING_FILE) ; \
	fi
endif

######################################################
# Check the compiler version(s)
######################################################
CC_CHECK  :=$(call CheckVersions,$(CC_VER),$(REQUIRED_CC_VER))
sane-compiler: sane-link
	@if [ "$(CC_CHECK)" = "missing" ]; then \
	  $(ECHO) "ERROR: The Compiler version is undefined. \n" \
	    "" >> $(ERROR_FILE) ; \
	fi
ifndef OPENJDK
	@if [ "$(CC_CHECK)" != "same" ]; then \
	      $(ECHO) "WARNING: The $(PLATFORM) compiler is not version $(REQUIRED_COMPILER_VERSION) $(REQUIRED_CC_VER) \n" \
	      "      Specifically the $(REQUIRED_COMPILER_NAME) compiler. \n " \
	      "      $(YOU_ARE_USING) $(COMPILER_VERSION): $(CC_VER) \n" \
	      "      The compiler was obtained from the following location: \n" \
	      "          $(COMPILER_PATH) \n" \
	      "" >> $(WARNING_FILE) ; \
         fi
endif

######################################################
# Check that ALSA headers and libs are installed and 
# that the header has the right version. We only
# need /usr/include/alsa/version.h and /usr/lib/libasound.so
######################################################

ifdef REQUIRED_ALSA_VERSION
  ALSA_CHECK := $(call CheckVersions,$(ALSA_VERSION),$(REQUIRED_ALSA_VERSION))
endif
sane-alsa-headers:
ifdef REQUIRED_ALSA_VERSION
        if [ "$(ALSA_CHECK)" != "same" -a "$(ALSA_CHECK)" != "newer"  ] ; then \
	    $(ECHO) "ERROR: The ALSA version must be $(REQUIRED_ALSA_VERSION) or higher. \n" \
	      "      You have the following ALSA version installed: $${alsa_version) \n" \
	      "      Please reinstall ALSA (drivers and lib). You can download \n" \
	      "      the source distribution from http://www.alsa-project.org \n" \
	      "      or go to http://www.freshrpms.net/docs/alsa/ for precompiled RPM packages. \n" \
	      "" >> $(ERROR_FILE) ; \
	  fi \
	else \
	  $(ECHO) "ERROR: You seem to not have installed ALSA $(REQUIRED_ALSA_VERSION) or higher. \n" \
	  "      Please install ALSA (drivers and lib). You can download the \n" \
	  "      source distribution from http://www.alsa-project.org or go to \n" \
	  "      http://www.freshrpms.net/docs/alsa/ for precompiled RPM packages. \n" \
	  "" >> $(ERROR_FILE) ; \
	fi
endif

# If a sanity file doesn't exist, just make sure it's dir exists
$(SANITY_FILES):
	-@$(prep-target)

######################################################
# dump out the variable settings...
######################################################
sane-settings::
	@$(ECHO)  >> $(MESSAGE_FILE)
	@$(ECHO) $(ALL_SETTINGS)  >> $(MESSAGE_FILE)
	@$(ECHO)  >> $(MESSAGE_FILE)

######################################################
# Check for existence of DEPLOY_MSSDK on windows
######################################################
sane-mssdk_path:
ifeq ($(PLATFORM), windows)
	@if [ -z "$(DEPLOY_MSSDK)" ]; then \
	  $(ECHO) "WARNING: Your DEPLOY_MSSDK setting is empty.\n" \
	    "        It is recommended to set ALT_DEPLOY_MSSDK.\n" \
	    "" >> $(WARNING_FILE) ; \
	fi
	@if [ ! -r "$(DEPLOY_MSSDK)" ]; then \
	  $(ECHO) "ERROR: You do not have a valid DEPLOY_MSSDK setting. \n" \
	    "      Please check your access to \n" \
	    "          $(DEPLOY_MSSDK) \n" \
	    "      and/or check your value of ALT_DEPLOY_MSSDK. \n" \
	    "" >> $(ERROR_FILE) ; \
	fi
endif

######################################################
# Check for existence of INSTALL_MSSDK on windows
######################################################
sane-install-mssdk_path:
ifeq ($(PLATFORM), windows)
	@if [ -z "$(INSTALL_MSSDK)" ]; then \
	  $(ECHO) "WARNING: Your INSTALL_MSSDK setting is empty.\n" \
	    "        It is recommended to set ALT_INSTALL_MSSDK.\n" \
	    "" >> $(WARNING_FILE) ; \
	fi
	@if [ ! -r "$(INSTALL_MSSDK)" ]; then \
	  $(ECHO) "ERROR: You do not have a valid INSTALL_MSSDK setting. \n" \
	    "      Please check your access to \n" \
	    "          $(INSTALL_MSSDK) \n" \
	    "      and/or check your value of ALT_INSTALL_MSSDK. \n" \
	    "" >> $(ERROR_FILE) ; \
	fi
endif

######################################################
# Check for existence of INSTALL_MSIVAL2 on windows
######################################################
sane-install-msival2_path:
ifeq ($(PLATFORM), windows)
	@if [ -z "$(INSTALL_MSIVAL2)" ]; then \
	  $(ECHO) "WARNING: Your INSTALL_MSIVAL2 setting is empty.\n" \
	    "        It is recommended to set ALT_INSTALL_MSIVAL2.\n" \
	    "" >> $(WARNING_FILE) ; \
	fi
	@if [ ! -r "$(INSTALL_MSIVAL2)" ]; then \
	  $(ECHO) "ERROR: You do not have a valid INSTALL_MSIVAL2 setting. \n" \
	    "      Please check your access to \n" \
	    "          $(INSTALL_MSIVAL2) \n" \
	    "      and/or check your value of ALT_INSTALL_MSIVAL2. \n" \
	    "" >> $(ERROR_FILE) ; \
	fi
endif

######################################################
# Check the Solaris GNU c++ compiler for solaris plugin
######################################################
sane-gcc-compiler:
ifeq ($(PLATFORM), solaris)
  ifndef OPENJDK
    @if [ -r $(GCC_COMPILER_PATH) ]; then \
	  if [ ! "$(GCC_VER)" = $(REQUIRED_GCC_VERSION) ]; then \
	    $(ECHO) "ERROR: The Solaris GCC compiler version must be $(REQUIRED_GCC_VERSION). \n" \
	      "      You are using the following compiler version: $(GCC_VER) \n" \
	      "      The compiler was obtained from the following location: \n" \
	      "          $(GCC_COMPILER_PATH) \n" \
	      "      Please change your compiler. \n" \
	      "" >> $(ERROR_FILE) ; \
    fi \
	else \
	  $(ECHO) "ERROR: You do not have a valid GCC_COMPILER_PATH setting. \n" \
	    "      Please check your access to \n" \
	    "          $(GCC_COMPILER_PATH) \n" \
	    "      and/or check your value of ALT_GCC_COMPILER_PATH. \n" \
	    "      This will affect you if you build the plugin target. \n" \
	    "" >> $(ERROR_FILE) ; \
	fi
  endif

  ifeq ($(PLATFORM), linux)
    ifdef ALT_GCC29_COMPILER_PATH
	@if [ ! -x $(ALT_GCC29_COMPILER_PATH)/bin/gcc ]; then \
 	    $(ECHO) "ERROR: You do not have a valid ALT_GCC29_COMPILER_PATH setting. \n" \
	         "      Please check your access to \n" \
	         "      $(ALT_GCC29_COMPILER_PATH)/bin/gcc \n" \
	         "      This will affect you if you build the plugin target. \n" \
	         "" >> $(ERROR_FILE) ; \
    fi
    endif
    ifdef ALT_GCC29_PLUGIN_LIB_PATH
	@if [ ! -r $(ALT_GCC29_PLUGIN_LIB_PATH)/libjavaplugin_oji.so ]; then \
	    $(ECHO) "Error: You do not have a valid ALT_GCC29_PLUGIN_LIB_PATH setting. \n" \
		        " Please check your access to \n" \
		        " $(ALT_GCC29_PLUGIN_LIB_PATH)/libjavaplugin_oji.so \n" \
		        " This will affect you if you build the plugin target, specifically for gcc 2.9 version of OJI plugin library. \n" \
		        "" >> $(ERROR_FILE) ; \
	fi
    else
	@if [ ! -r $(GCC29_COMPILER_PATH) ]; then \
	    $(ECHO) "ERROR: You do not have a valid GCC29_COMPILER_PATH setting. \n" \
	    	    " Please check your access to \n" \
	    	    " $(GCC29_COMPILER_PATH) \n" \
	    	    " and/or check your value of ALT_GCC29_COMPILER_PATH. \n" \
	    	    " This will affect you if you build the plugin target. \n" \
	    	    "" >> $(ERROR_FILE) ; \
	fi
    endif
  endif
endif


######################################################
# MOZILLA_HEADERS_PATH must be valid
######################################################
sane-mozilla:
ifeq ($(ARCH_DATA_MODEL), 32)
  ifdef ALT_MOZILLA_HEADERS_PATH
	@if [ `$(ECHO) $(subst \,/,$(ALT_MOZILLA_HEADERS_PATH)) | $(EGREP) -c '^([A-Za-z]:)?/'` -ne 1 ]; then \
	  $(ECHO) "ERROR: ALT_MOZILLA_HEADERS_PATH must be an Absolute Path Name, \n" \
	    "      not a Relative Path Name. \n" \
	    "      The current value of ALT_MOZILLA_HEADERS_PATH is \n" \
	    "          $(ALT_MOZILLA_HEADERS_PATH) \n" \
	    "      Please fix this and continue your build. \n" \
	    "" >> $(ERROR_FILE) ; \
	fi
  endif
	@#
	@# MOZILLA_HEADERS_PATH must be valid....
	@#
  ifeq ($(PLATFORM), windows)
	@if [ ! -r $(subst \,/,$(MOZILLA_HEADERS_PATH))/mozilla_headers_18.win32/java/bool.h ]; then \
	  $(ECHO) "ERROR: You do not have access to valid Mozilla header files. \n" \
	    "      Please check your access to \n" \
	    "          $(subst \,/,$(MOZILLA_HEADERS_PATH))/mozilla_headers_18.win32/java/bool.h \n" \
	    "      and/or check your value of ALT_JDK_DEVTOOLS_DIR, ALT_MOZILLA_HEADERS_PATH, \n" \
	    "	   and on Windows, ALT_JDK_JAVA_DRIVE. \n" \
	    "" >> $(ERROR_FILE) ; \
	fi
  else
	@if [ ! -r $(subst \,/,$(MOZILLA_HEADERS_PATH))/mozilla_headers_18/java/bool.h ]; then \
	  $(ECHO) "ERROR: You do not have access to valid Mozilla header files. \n" \
	    "      Please check your access to \n" \
	    "          $(subst \,/,$(MOZILLA_HEADERS_PATH))/mozilla_headers_18/java/bool.h \n" \
	    "      and/or check your value of ALT_JDK_DEVTOOLS_DIR, ALT_MOZILLA_HEADERS_PATH, \n" \
	    "" >> $(ERROR_FILE) ; \
	fi
  endif
	@#
	@# Check for presence of headers required for new Java Plug-In ("plugin2")
	@#
	@if [ ! -r $(subst \,/,$(MOZILLA_HEADERS_PATH))/plugin2_mozilla_headers/npapi.h ]; then \
	  $(ECHO) "ERROR: You do not have access to valid Mozilla header files for the new Java Plug-In. \n" \
	    "      Please check your access to \n" \
	    "          $(subst \,/,$(MOZILLA_HEADERS_PATH))/plugin2_mozilla_headers/npapi.h \n" \
	    "      and/or check your value of ALT_JDK_DEVTOOLS_DIR, ALT_MOZILLA_HEADERS_PATH, \n" \
	    "" >> $(ERROR_FILE) ; \
	fi
endif


######################################################
# Make sure Java Kernel VM is accessible
######################################################
sane-kernel-vm:
ifeq ($(PLATFORM), windows)
  ifeq ($(ARCH_DATA_MODEL), 32)
	@if [ ! -r $(HOTSPOT_KERNEL_PATH)/jvm.dll ]; then \
	    $(ECHO) "WARNING: Your HOTSPOT_IMPORT_PATH does not include a Kernel VM... \n" \
		    "     The kernel installer may not be built (unless hotspot is also). \n" \
		    "     $(HOTSPOT_KERNEL_PATH)/jvm.dll \n" \
		    "     Please check the value of ALT_HOTSPOT_IMPORT_PATH. \n" \
		    >> $(WARNING_FILE) ; \
	fi
  endif
endif


######################################################
# SECURITY_BASELINE_131 test
######################################################
security_baseline_131:
ifeq ($(PLATFORM), windows)
	@if [ -z "$(SECURITY_BASELINE_131)" ]; then \
	    $(ECHO) "WARNING: Your SECURITY_BASELINE_131 setting is empty.\n" \
		"        Setting it to the default value of 1.3.1_20.\n" \
		"        It is recommended to set SECURITY_BASELINE_131.\n" \
		"" >> $(WARNING_FILE) ; \
	fi
endif

######################################################
# SECURITY_BASELINE_142 test
######################################################
security_baseline_142:
ifeq ($(PLATFORM), windows)
	@if [ -z "$(SECURITY_BASELINE_142)" ]; then \
	    $(ECHO) "WARNING: Your SECURITY_BASELINE_142 setting is empty.\n" \
		"        Setting it to the default value of 1.4.2_10.\n" \
		"        It is recommended to set SECURITY_BASELINE_142.\n" \
		"" >> $(WARNING_FILE) ; \
	fi
endif

######################################################
# SECURITY_BASELINE_150 test
######################################################
security_baseline_150:
ifeq ($(PLATFORM), windows)
	@if [ -z "$(SECURITY_BASELINE_150)" ]; then \
	    $(ECHO) "WARNING: Your SECURITY_BASELINE_150 setting is empty.\n" \
		"        Setting it to the default value of 1.5.0_07.\n" \
		"        It is recommended to set SECURITY_BASELINE_150.\n" \
		"" >> $(WARNING_FILE) ; \
	fi
endif

######################################################
# SECURITY_BASELINE_160 test
######################################################
security_baseline_160:
ifeq ($(PLATFORM), windows)
	@if [ -z "$(SECURITY_BASELINE_160)" ]; then \
	    $(ECHO) "WARNING: Your SECURITY_BASELINE_160 setting is empty.\n" \
		"        Setting it to the default value of 1.6.0_11.\n" \
		"        It is recommended to set SECURITY_BASELINE_160.\n" \
		"" >> $(WARNING_FILE) ; \
	fi
endif


######################################################
# this should be the last rule in any target's sanity rule.
######################################################
sane-lastrule:
ifndef EXTERNALSANITYCONTROL
	@if [ -r $(MESSAGE_FILE) ]; then \
	  $(CAT) $(MESSAGE_FILE) ; \
	fi
	@if [ -r $(WARNING_FILE) ]; then \
	  $(CAT) $(WARNING_FILE) ; \
	fi
	@if [ "x$(INSANE)" != x ]; then \
	  $(ECHO) "INSANE mode requested. \n" \
	    "Sanity will not force a build termination, even with errors.\n" \
	    "" >> $(ERROR_FILE); \
	fi
	@if [ -r $(ERROR_FILE) ]; then \
	  if [ "x$(INSANE)" = x ]; then \
	    $(ECHO) "Exiting because of the above error(s). \n" \
	      "">> $(ERROR_FILE); \
	  fi ; \
	  $(CAT) $(ERROR_FILE) ; \
	  if [ "x$(INSANE)" = x ]; then \
	    exit 1 ; \
	  fi ; \
	fi
ifdef PEDANTIC
	@if [ -r $(WARNING_FILE) ]; then \
	  $(ECHO) "PEDANTIC mode requested. \n" \
	    "Exiting because of the above warning(s). \n" \
	    "" >> $(ERROR_FILE); \
	  $(CAT) $(ERROR_FILE) ; \
	  exit 1 ; \
	fi
endif # PEDANTIC
	@if [ ! -r $(ERROR_FILE) ]; then \
	  $(ECHO) "Sanity check passed." ; \
	fi
endif #  EXTERNALSANITYCONTROL