make/common/shared/Sanity.gmk

Print this page

        

@@ -35,39 +35,129 @@
 
 # All files created during sanity checking
 
 SANITY_FILES =  $(ERROR_FILE) $(WARNING_FILE) $(MESSAGE_FILE)
 
+# Build readme
+BUILD_README=http://hg.openjdk.java.net/jdk7/build/raw-file/tip/README-builds.html
+define BuildReadme # section
+"See $(BUILD_README)#$1 (or file:/$(call FullPath,$(JDK_TOPDIR)/../README-builds.html)#$1)."
+endef
+
 # How to say "The Release Engineering people use this"
-THE_OFFICIAL_USES=The official builds on $(PLATFORM) use
+THE_OFFICIAL_USES=The official $(PLATFORM) builds use
 
+# Warning about using different versions
+MAY_PRODUCE=This may produce binaries incorrectly or cause the build to fail.
+
+# If a comma is needed in the sentence, use ${comma}
+comma=,
+
 # How to say "You are using:"
 YOU_ARE_USING=You appear to be using
 
 # Error message
-define SanityError
-$(ECHO) "ERROR: $1\n" >> $(ERROR_FILE)
+define SanityError # primary secondary
+$(PRINTF) "\nERROR: %s\n" $1   >> $(ERROR_FILE); \
+$(PRINTF)   "       %s\n" $2   >> $(ERROR_FILE)
 endef
 
 # Warning message
-define SanityWarning
-$(ECHO) "WARNING: $1\n" >> $(WARNING_FILE)
+define SanityWarning # primary secondary
+$(PRINTF) "\nWARNING: %s\n" $1   >> $(WARNING_FILE); \
+$(PRINTF)   "         %s\n" $2   >> $(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.)
+# Issue unset variable warning
+define UnsetSanityWarning # name envname extraLines
+$(call SanityWarning, "You do not have a $(strip $1) setting.", \
+"We recommend that you set $(strip $2)." $3)
 endef
 
-# Official version warning message: name version required_version
-define OfficialWarningMessage
-$(call SanityWarning,\
-$(THE_OFFICIAL_USES) $1 $3. $(YOU_ARE_USING) $1 $2.)
+# Issue unset variable error
+define UnsetSanityError # name envname extraLines
+$(call SanityError, "You must have a $(strip $1) setting.", \
+"We recommend that you set $(strip $2)." $3)
 endef
 
+# Issue bad variable setting error
+define BadPathSanityError # name envname extraLines
+$(call SanityError, "You do not have a valid $(strip $1) setting.", \
+"Please check your access to $(strip $1)=$($(strip $1)) and/or check your value of $(strip $2)." $3)
+endef
 
+# Must be set and must exist and be a file
+define VarFileSanityCheck # name extraLines
+if [ ! -f "$($(strip $1))" -o ! -r "$($(strip $1))" ]; then \
+$(call SanityError, "Missing file $(strip $1)=$($(strip $1)).",$2); \
+fi
+endef
+
+# Must be set and must exist and be readable
+define VarPathSanityCheck # name envname extraLines
+if [ "$($(strip $1))" = "" ]; then \
+$(call UnsetSanityError,$(strip $1),$(strip $2),$3); \
+elif [ ! -d "$($(strip $1))" -o ! -r "$($(strip $1))" ]; then \
+$(call BadPathSanityError,$(strip $1),$(strip $2),$3); \
+fi
+endef
+
+# Unset is just a warning, if set must exist and be readable
+define OptionalVarPathSanityCheck # name envname extraLines
+if [ "$($(strip $1))" = "" ]; then \
+$(call UnsetSanityWarning,$(strip $1),$(strip $2),$3); \
+elif [ ! -d "$($(strip $1))" -o ! -r "$($(strip $1))" ]; then \
+$(call BadPathSanityError,$(strip $1),$(strip $2),$3); \
+fi
+endef
+
+# Common error, never set this environment variable
+define NeverSetSanityCheck # variableName
+$(if $($(strip $1)),$(call SanityError, \
+"Your $(strip $1) environment variable is set.", \
+"$(MAY_PRODUCE)" \
+"Please unset $(strip $1) and start your build again."),)
+endef
+
+define VarPathFileSanityCheck # name envname filepath extraLines
+if [ ! -f "$(strip $3)" -o ! -r  "$(strip $3)" ]; then \
+$(call SanityError, "File $(strip $3) does not exist.",\
+"You do not have a valid $(strip $1) setting." \
+"Please check your access to $(strip $1)=$($(strip $1)) and/or check your value of $(strip $2)." $4); \
+fi
+endef
+
+define OptionalVarPathFileSanityCheck # name envname filepath extraLines
+if [ ! -f "$(strip $3)" -o ! -r  "$(strip $3)" ]; then \
+$(call SanityWarning, "File $(strip $3) does not exist.",\
+"You do not have a valid $(strip $1) setting." \
+"Please check your access to $(strip $1)=$($(strip $1)) and/or check your value of $(strip $2)." $4); \
+fi
+endef
+
+# Common error, version too old, silent to be same or newer
+define VersionSanityCheck # toolName foundVer reqVer extraLines
+$(if $(subst newer,,$(subst same,,$(call CheckVersions,$(strip $2),$(strip $3)))),\
+$(call SanityError, \
+"$(YOU_ARE_USING) $(strip $1) $(strip $2) which is a $(call CheckVersions,$(strip $2),$(strip $3)) version.", \
+"$(THE_OFFICIAL_USES) $(strip $1) $(strip $3)." \
+"$(MAY_PRODUCE)" \
+ $4)\
+,)
+endef
+
+# Common error, version too old, and warn if not an exact match
+define SameVersionSanityCheck # toolName foundVer reqVer extraLines
+$(if $(subst newer,,$(call CheckVersions,$(strip $2),$(strip $3))),\
+$(call VersionSanityCheck,$(strip $1),$(strip $2),$(strip $3),$4),\
+$(call SanityWarning, \
+"$(YOU_ARE_USING) $(strip $1) $(strip $2) which is a $(call CheckVersions,$(strip $2),$(strip $3)) version.", \
+"$(THE_OFFICIAL_USES) $(strip $1) $(strip $3)." \
+"$(MAY_PRODUCE)" \
+ $4))
+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;}')

@@ -91,21 +181,21 @@
   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 \
+    if [ -f /etc/fedora-release ]; then \
       echo "Fedora"; \
-    elif [ -f /etc/redhat-release ] ; then \
+    elif [ -f /etc/redhat-release ]; then \
       echo "RedHat"; \
-    elif [ -f /etc/SuSE-release ] ; then \
+    elif [ -f /etc/SuSE-release ]; then \
       echo "SuSE"; \
     else \
       echo "Unknown"; \
     fi)
   OS_VARIANT_VERSION := $(shell \
-    if [ "$(OS_VARIANT_NAME)" = "Fedora" ] ; then \
+    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) | \

@@ -224,92 +314,82 @@
 ######################################################
 # 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)
+        @$(call SanityWarning, \
+"ALT_COPYRIGHT_YEAR but not the current year will be used for copyright year.",)
 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)
+        @$(call SanityWarning, \
+"You are building in 'INSANE' mode${comma} this is not a supported option.", \
+"Builds can be unpredictable and should not be trusted.")
 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
+        @$(call VersionSanityCheck,make,\
+                $(MAKE_VER),$(REQUIRED_MAKE_VER),)
 
 ######################################################
 # 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) ; \
+        @if [ "`$(ECHO) $(BUILD_NUMBER) | $(SED) 's@.*b[0-9][0-9]*.*@bNN@'`" != "bNN" ]; then \
+            $(call SanityWarning, \
+"The BUILD_NUMBER needs to contain b[0-9][0-9]*.", \
+"Currently BUILD_NUMBER=$(BUILD_NUMBER). \
+This has been known to cause build failures.") ; \
         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
+ifneq ($(ARCH_DATA_MODEL),32)
+  ifneq ($(ARCH_DATA_MODEL),64)
+        @$(call SanityError, \
+"The setting of ARCH_DATA_MODEL must be 32 or 64.", \
+"$(YOU_ARE_USING) ARCH_DATA_MODEL=$(ARCH_DATA_MODEL).")
+  endif
+endif
 
 ######################################################
-# Check the OS version (windows and linus have release name checks)
+# Check the OS version
 #   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.
 ######################################################
+sane-os_version:: sane-arch_data_model sane-memory_check sane-locale sane-os_patch_level
 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))
+        @$(call SameVersionSanityCheck,$(OS_VARIANT_NAME) version, \
+                $(OS_VARIANT_VERSION),$(REQUIRED_OS_VARIANT_VERSION),)
+  else
+        @$(call SanityWarning,\
+"$(OS_VARIANT_NAME) is not the required or expected $(REQUIRED_OS_VARIANT_NAME) variation.", )
+        @$(call SameVersionSanityCheck,$(PLATFORM) version,\
+                $(OS_VERSION),$(REQUIRED_OS_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
+  ifeq ($(OS_VARIANT_NAME),$(REQUIRED_OS_VARIANT_NAME))
+        @$(call VersionSanityCheck,$(OS_VARIANT_NAME) version,\
+                $(OS_VARIANT_VERSION),$(REQUIRED_OS_VARIANT_VERSION),)
   else
-    ifneq ($(OS_VARIANT_VERSION_CHECK),same)
-        @$(call OfficialWarningMessage,$(OS_VARIANT_NAME) version,$(OS_VARIANT_VERSION),$(REQUIRED_OS_VARIANT_VERSION))
+        @$(call SanityWarning,\
+"$(OS_VARIANT_NAME) is not the required $(REQUIRED_OS_VARIANT_NAME)", )
+        @$(call VersionSanityCheck,$(PLATFORM) version,\
+                $(OS_VERSION),$(REQUIRED_OS_VERSION),)
     endif
-  endif
 endif # OPENJDK
 
 ifeq ($(PLATFORM), windows)
   sane-os_version:: sane-cygwin sane-mks sane-cygwin-shell
 endif

@@ -317,79 +397,69 @@
 ######################################################
 # 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) ; \
+          $(call SanityWarning, \
+"This machine appears to only have $(MB_OF_MEMORY)Mb of physical memory.", \
+"Builds on this machine could be slow.") ; \
         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) ; \
+          $(call SanityWarning, \
+"LC_ALL has been set to $(LC_ALL)${comma} this can cause build failures.", \
+"Try setting LC_ALL to \"C\"."); \
         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) ; \
+          $(call SanityWarning, \
+"LANG has been set to $(LANG)${comma} this can cause build failures.", \
+"Try setting LANG to \"C\".") ; \
         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))
+        @$(call VersionSanityCheck,CYGWIN,\
+                $(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) ; \
+          $(call SanityError, \
+"You are using an unsupported shell.", \
+"Use either sh${comma} bash${comma} ksh${comma} zsh${comma} or tcsh." \
+"Using the cmd.exe utility is not supported." \
+"If you still want to try your current shell${comma} \
+ please export SHLVL=1 when running $(MAKE)."); \
         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))
+        @$(call VersionSanityCheck,MKS,\
+                $(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)
 ######################################################

@@ -460,27 +530,17 @@
 
 ######################################################
 # 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
+        @$(call NeverSetSanityCheck, CLASSPATH)
 
 ######################################################
 # 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
+        @$(call NeverSetSanityCheck, JAVA_HOME)
 
 ######################################################
 # Make sure the fonts are there
 # Exceptions are when explicitly building OPENJDK, or
 # when the entire CLOSED_SRC dir is excluded, so we are

@@ -487,16 +547,13 @@
 # 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 \
+        @if [ -d $(CLOSED_SRC) ]; then \
+          $(call VarFileSanityCheck,FONT_FILE, \
+"Verify you have downloaded and overlayed on the source area all the binary files.") ; \
         fi
 endif
 
 ######################################################
 # If building OPENJDK check pre-built binaries are

@@ -503,323 +560,230 @@
 # 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
+        @$(call OptionalVarPathSanityCheck,\
+                BINARY_PLUGS_PATH,ALT_BINARY_PLUGS_PATH, )
   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
+ifneq ($(VARIANT),DBG)
+  ifneq ($(VARIANT),OPT)
+        @$(call SanityError, \
+"Your VARIANT environment variable is set to VARIANT=$(VARIANT) \
+ and needs to be set to DBG or OPT.",)
+  endif
+endif
 
 ######################################################
 # 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
+        @$(call NeverSetSanityCheck, LD_LIBRARY_PATH)
 
 ######################################################
 # 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
+        @$(call NeverSetSanityCheck, LD_LIBRARY_PATH_64)
 
 ######################################################
 # 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
+        @$(call NeverSetSanityCheck, LD_OPTIONS)
 
 ######################################################
 # 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
+        @$(call NeverSetSanityCheck, LD_RUN_PATH)
 
 ######################################################
 # MAKEFLAGS cannot be set, unless you are insane.
+#   it is unacceptable  to have these in MAKEFLAGS
+#     -e or --environment-overrides
+#     -i or --ignore-errors
+#     -I or --include-dir
+#     -k or --keep-going
+#     -r or --nobuiltin-rules
+#     -o or --assume-old or --old-filevalue
+#     -t or --touch value in MAKEFLAGS
+#       Note - some may be processed out in GNU Make startup
 ######################################################
-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) ; \
+          $(call SanityError, \
+"Either the build was started with the flag -e or \
+ --environment-overrides or the MAKEFLAGS variable has this value set.", \
+"This will cause any environment variables you have defined to override \
+ the values defined by the makefiles." \
+"This practice is not recommemded by the authors of GNU Make \
+ and will lead to an improper build." \
+"Please fix and restart the build.") ; \
         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) ; \
+          $(call SanityError, \
+"Either the build was started with the flag -i or \
+ --ignore-errors or the MAKEFLAGS environment variable has this value set.", \
+"You will be unable to determine if the build is broken or not." \
+"Please fix and restart the build.") ; \
         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) ; \
+          $(call SanityError, \
+"Either the build was started with the flag -I or --include-dir \
+ or the MAKEFLAGS environment variable has this value set.", \
+"This will render your build questionable as not all the rules and \
+ dependencies are captured by the build." \
+"Please fix and restart the build.") ; \
         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) ; \
+          $(call SanityError, \
+"Either the build was started with the flag -k or --keep-going \
+ or the MAKEFLAGS environment variable has this value set.", \
+"You will be unable to determine if the build is broken or not." \
+"Please fix and restart the build.") ; \
         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) ; \
+          $(call SanityError, \
+"Either the build was started with the flag -o or --assume-old or --old-file \
+ or the MAKEFLAGS environment variable has this value set.", \
+"This could prevent the build from executing rules it should \
+ thus rendering a questionable result." \
+"Please fix and restart the build.") ; \
         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) ; \
+          $(call SanityError, \
+"Either the build was started with the flag -r or --no-builtin-rules \
+ or the MAKEFLAGS environment variable has this value set.", \
+"This may break the build by not allowing builtin rules that may be required." \
+"Please fix and restart the build.") ; \
         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) ; \
+          $(call SanityError, \
+"Either the build was started with the flag -t or --touch \
+ or the MAKEFLAGS environment variable has this value set.", \
+"This will leave the build in a unclear state and could lead to not \
+ executing rules which should be executed." \
+"Please fix and restart the build.") ; \
         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)
+        @$(call NeverSetSanityCheck, MAKEFLAGS)
 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) ; \
+          $(call SanityError, \
+"ALT_OUTPUTDIR must be an Absolute Path Name not a Relative Path Name.",) ; \
         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) ; \
+          $(call SanityError, \
+"On windows ALT_OUTPUTDIR must contain the drive letter.",) ; \
         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...
-        @#
+        @$(call VarPathSanityCheck,OUTPUTDIR,ALT_OUTPUTDIR, )
         @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) ; \
+          $(call SanityError, \
+"You must have write permissions to OUTPUTDIR.", \
+"The current value of OUTPUTDIR is $(OUTPUTDIR)." \
+"Either obtain these permissions or set ALT_OUTPUTDIR.") ; \
         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) ; \
+          $(call SanityWarning, \
+"You may not have enough free space in your OUTPUTDIR.", \
+"The current value of OUTPUTDIR is $(OUTPUTDIR)." \
+"You need '$(REQUIRED_FREE_SPACE)' Kbytes free on this device to build \
+and it appears that only '$(FREE_SPACE)' Kbytes are free." \
+"Either obtain more space or set ALT_OUTPUTDIR to a larger disk.") ; \
         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) ; \
+          $(call SanityError, \
+"ALT_BOOTDIR must be an Absolute Path Name${comma} not a Relative Path Name.", \
+"The current value of ALT_BOOTDIR is $(ALT_BOOTDIR)." \
+"Please fix this and continue your build.") ; \
         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
+        @$(call VersionSanityCheck,boot JDK,\
+                $(BOOT_VER),$(REQUIRED_BOOT_VER), \
+"Your ALT_BOOTDIR environment variable does not point to a valid JDK \
+ for bootstrapping this build." \
+"A JDK $(JDK_MINOR_VERSION) $(MARKET_NAME) build must be bootstrapped using \
+ JDK $(PREVIOUS_JDK_VERSION) fcs (or later).")
 
 ######################################################
 # 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) ; \
+          $(call SanityWarning, \
+"Your BOOTDIR is located on the J: drive.", \
+"Often the J: drive is mapped over a network." \
+"Using a mapped drive for the BOOTDIR may significantly slow down the build process." \
+"You may want to consider using the ALT_BOOTDIR variable to point the build \
+ to another location for the BOOTDIR instead." \
+"Your current BOOTDIR is: $(BOOTDIR)") ; \
         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) ; \
+          $(call SanityError, \
+"ALT_CACERTS_FILE must be an Absolute Path Name not a Relative Path Name.", \
+"The current value of ALT_CACERTS_FILE is $(ALT_CACERTS_FILE)." \
+"Please fix this and continue your build.") ; \
         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) ; \
+          $(call SanityError, \
+"You do not have access to a valid cacerts file.", \
+"Please check your access to $(subst \,/,$(CACERTS_FILE)) \
+ and/or check your value of ALT_CACERTS_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) ; \
+          $(call SanityError, \
+"You do not have access to a valid cacerts file.", \
+"The value of CACERTS_FILE must point to a normal file." \
+"Please check your access to $(subst \,/,$(CACERTS_FILE)) \
+ and/or check your value of ALT_CACERTS_FILE.") ; \
         fi
 
 
 ######################################################
 # Check for availability of FreeType (OpenJDK specific)

@@ -833,13 +797,13 @@
         @(($(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) ; \
+          $(call SanityError, \
+"FreeType version $(REQUIRED_FREETYPE_VERSION) or higher is required.", \
+"`$(CAT) $<`") ; \
         fi
 
 else
 #do nothing  (not OpenJDK)
 sane-freetype: 

@@ -851,139 +815,91 @@
 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); \
+            if [ "x$$valid" = "x" ]; then \
+                $(call SanityError, \
+"$$m set in the BUILD_MODULES variable is invalid.", ) ; \
             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
+        @$(call VarPathFileSanityCheck,\
+                CUPS_HEADERS_PATH,ALT_CUPS_HEADERS_PATH,\
+                $(CUPS_HEADERS_PATH)/cups/cups.h,$(call BuildReadme,cups))
 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
+        @$(call VarPathSanityCheck,DEVTOOLS_PATH,ALT_DEVTOOLS_PATH, )
 
 ######################################################
 # 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
+        @$(call VarPathFileSanityCheck,\
+                MSVCRT_DLL_PATH,ALT_MSVCRT_DLL_PATH,\
+                $(MSVCRT_DLL_PATH)/msvcrt.dll, )
   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
+        @$(call VarPathFileSanityCheck,\
+                MSVCRNN_DLL_PATH,ALT_MSVCRNN_DLL_PATH,\
+                $(MSVCRNN_DLL_PATH)/$(MSVCRNN_DLL), )
   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
+        @$(call VarPathSanityCheck,COMPILER_PATH,ALT_COMPILER_PATH, )
 
 ######################################################
 # 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
+        @$(call VarPathSanityCheck,UNIXCOMMAND_PATH,ALT_UNIXCOMMAND_PATH, )
 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) ; \
+            $(call SanityWarning, \
+"You do not have the utility $${utility} in the directory $(UNIXCOMMAND_PATH).", \
+"The utilities cpio${comma} ar${comma} file${comma} and m4 are required."); \
           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
+        @$(call VarPathSanityCheck,USRBIN_PATH,ALT_USRBIN_PATH, )
 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
+        @$(call VarPathSanityCheck,UNIXCCS_PATH,ALT_UNIXCCS_PATH, )
 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
+        @$(call OptionalVarPathSanityCheck,\
+                HOTSPOT_DOCS_IMPORT_PATH,ALT_HOTSPOT_DOCS_IMPORT_PATH, )
 
 ######################################################
 # 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.

@@ -990,17 +906,16 @@
 ######################################################
 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) ; \
+            $(call SanityWarning, \
+"This version of hotspot relies on __fabsf which is not always available \
+ on Solaris 8 and 9 machines unless they have the latest libm patch \
+ and the file /usr/include/iso/math_iso.h which can trigger this dependency.", \
+"Hotspot should NOT be dependent on this extern${comma} check the \
+ version of the hotspot library you are using.") ; \
             fi; \
         fi
 endif
 
 ######################################################

@@ -1007,103 +922,64 @@
 # 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) ; \
+          $(call SanityWarning, \
+"The file /usr/lib/libCrun.so.1 is missing the extern __1c2n6FIpv_0_ \
+ which indicates that the system is missing a required Solaris patch \
+ or you are using a pre-FCS release of Solaris 10.", \
+"You need the latest /usr/lib/libCrun.so.1 which comes with the \
+ FCS release of Solaris 10 and available through the latest \
+ Solaris 8 or 9 C++ runtime patches.") ; \
         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
+        @$(call VarPathSanityCheck,MSDEVTOOLS_PATH,ALT_MSDEVTOOLS_PATH, )
 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
+        @$(call VarPathFileSanityCheck,\
+                HOTSPOT_CLIENT_PATH,ALT_HOTSPOT_CLIENT_PATH,\
+                $(HOTSPOT_CLIENT_PATH)/$(LIB_PREFIX)jvm.$(LIBRARY_SUFFIX),\
+"The ALT_HOTSPOT_IMPORT_PATH may also be used.")
 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
-        @#
+        @$(call VarPathFileSanityCheck,\
+                HOTSPOT_SERVER_PATH,ALT_HOTSPOT_SERVER_PATH,\
+                $(HOTSPOT_SERVER_PATH)/$(LIB_PREFIX)jvm.$(LIBRARY_SUFFIX),\
+"The ALT_HOTSPOT_IMPORT_PATH may also be used.")
 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..
-        @#
+        @$(call VarPathFileSanityCheck,\
+                HOTSPOT_LIB_PATH,ALT_HOTSPOT_LIB_PATH,\
+                $(HOTSPOT_LIB_PATH)/jvm.lib, )
   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
+        @$(call OptionalVarPathFileSanityCheck,\
+                HOTSPOT_CLIENT_PATH,ALT_HOTSPOT_CLIENT_PATH,\
+                $(HOTSPOT_CLIENT_PATH)/jvm.map, \
+"These map files are optional and aid in the debugging of the JVM.")
+        @$(call OptionalVarPathFileSanityCheck,\
+                HOTSPOT_CLIENT_PATH,ALT_HOTSPOT_CLIENT_PATH,\
+                $(HOTSPOT_CLIENT_PATH)/jvm.pdb, \
+"These pdb files are optional and aid in the debugging of the JVM.")
   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
+        @$(call OptionalVarPathFileSanityCheck,\
+                HOTSPOT_SERVER_PATH,ALT_HOTSPOT_SERVER_PATH,\
+                $(HOTSPOT_SERVER_PATH)/jvm.map, \
+"These map files are optional and aid in the debugging of the JVM.")
+        @$(call OptionalVarPathFileSanityCheck,\
+                HOTSPOT_SERVER_PATH,ALT_HOTSPOT_SERVER_PATH,\
+                $(HOTSPOT_SERVER_PATH)/jvm.pdb, \
+"These pdb files are optional and aid in the debugging of the JVM.")
 endif   
 
 
 ######################################################
 # Check for existence of misc Hotspot imported files

@@ -1136,14 +1012,14 @@
 $(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) ; \
+        elif [ "$(@F)" != "jvm.h" -a "$(@F)" != "jmm.h" ]; then \
+          $(call SanityWarning, \
+"HOTSPOT_IMPORT_PATH does not contain the interface file $(@F).", \
+"Check your value of ALT_HOTSPOT_IMPORT_PATH."); \
           $(CP) $< $@.IMPORT; \
         else \
           $(CP) $< $@.IMPORT; \
         fi
 

@@ -1150,14 +1026,14 @@
 $(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) ; \
+        elif [ "$(@F)" != "jvm_md.h" ]; then \
+          $(call SanityWarning, \
+"HOTSPOT_IMPORT_PATH does not contain the interface file $(@F).", \
+"Check your value of ALT_HOTSPOT_IMPORT_PATH."); \
           $(CP) $< $@.IMPORT; \
         else \
           $(CP) $< $@.IMPORT; \
         fi
 

@@ -1169,24 +1045,24 @@
 #   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) ; \
+              "`$(CAT) $<.IMPORT | $(TMP_SDK_INCLUDE_GET_VERSION)`" ]; then \
+          $(call SanityWarning, \
+"The file $(<F) is not the same interface as the VM version.", \
+"This source has $(<F) `$(CAT) $< | $(TMP_SDK_INCLUDE_GET_FULL_VERSION)` and \
+ HOTSPOT_IMPORT_PATH contains $(<F) `$(CAT) $<.IMPORT | $(TMP_SDK_INCLUDE_GET_FULL_VERSION)`"); \
              $(ECHO) "Version mis-match" > $@ ; \
         fi
         @if [ "`$(CAT) $<        | $(TMP_SDK_INCLUDE_GET_FULL_VERSION)`" != \
-               "`$(CAT) $<.IMPORT | $(TMP_SDK_INCLUDE_GET_FULL_VERSION)`" ] ; then \
+               "`$(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 \
+        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

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

@@ -1243,171 +1117,107 @@
 # 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
+        @$(call OptionalVarPathFileSanityCheck,\
+                HOTSPOT_IMPORT_PATH,ALT_HOTSPOT_IMPORT_PATH,\
+                $(HOTSPOT_IMPORT_PATH)/lib/sa-jdi.jar,\
+"The JDI binding for the Serviceability Agent will not be included in the build.")
 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
+        @$(call VersionSanityCheck,ant,\
+                $(ANT_VER),$(REQUIRED_ANT_VER),)
 
 ######################################################
 # 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
+        @$(call VersionSanityCheck,zip,\
+                $(ZIP_VER),$(REQUIRED_ZIP_VER),)
 
 ######################################################
 # 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
+        @$(call VersionSanityCheck,unzip,\
+                $(UNZIP_VER),$(REQUIRED_UNZIP_VER),)
 
 ######################################################
 # 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 \
+        @$(call VersionSanityCheck,dxsdk,\
+                $(DXSDK_VER),$(REQUIRED_DXSDK_VER),\
+$(call BuildReadme,dxsdk))
+        @$(call VarPathFileSanityCheck,\
+                DXSDK_INCLUDE_PATH,ALT_DXSDK_INCLUDE_PATH,\
+                $(DXSDK_INCLUDE_PATH)/d3d9.h,\
+$(call BuildReadme,dxsdk))
+        @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) ; \
+            $(call SanityWarning, \
+"The DirectX SDK Include directory contains a newer basetsd.h \
+ which may indicate that you're using an incorrect version of DirectX SDK.", \
+"This may result in a build failure." \
+"The DirectX SDK Include dir was obtained from the following location: \
+ $(DXSDK_INCLUDE_PATH)" \
+$(call BuildReadme,dxsdk))
               fi \
-            fi \
-          fi \
         fi
 endif
 
 ######################################################
 # Check the linker version(s)
 ######################################################
+sane-link:
 ifeq ($(PLATFORM), windows)
-  LINK_CHECK  :=$(call CheckVersions,$(LINK_VER),$(REQUIRED_LINK_VER))
+  ifdef LINK_VER
+        @$(call SameVersionSanityCheck,link.exe,\
+                $(LINK_VER),$(REQUIRED_LINK_VER),\
+"To build JDK $(JDK_VERSION) you need \
+ $(REQUIRED_COMPILER_VERSION) - link.exe version $(REQUIRED_LINK_VER)." \
+"Specifically the $(REQUIRED_COMPILER_NAME) link.exe.")
+  endif
 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
+        @$(call SameVersionSanityCheck,C/C++ compiler,\
+                $(CC_VER),$(REQUIRED_CC_VER), \
+"The $(PLATFORM) compiler is not the $(REQUIRED_COMPILER_NAME) compiler." \
+"The compiler was obtained from the following location: $(COMPILER_PATH)")
+else
+        @$(call VersionSanityCheck,C/C++ compiler,,\
+                $(CC_VER),$(REQUIRED_CC_VER), \
+"The $(PLATFORM) compiler is not the $(REQUIRED_COMPILER_NAME) compiler." \
+"The compiler was obtained from the following location: $(COMPILER_PATH)")
 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
+        @$(call VersionSanityCheck,alsa,\
+                $(ALSA_VERSION),$(REQUIRED_ALSA_VERSION), \
+"Please install or reinstall the ALSA packages (drivers and lib)." \
+$(call BuildReadme,alsa))
 endif
 
+######################################################
 # If a sanity file doesn't exist, just make sure it's dir exists
 $(SANITY_FILES):
         -@$(prep-target)
 
 ######################################################

@@ -1421,60 +1231,30 @@
 ######################################################
 # 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
+        @$(call OptionalVarPathSanityCheck,\
+                DEPLOY_MSSDK,ALT_DEPLOY_MSSDK, )
 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
+        @$(call OptionalVarPathSanityCheck,\
+                INSTALL_MSSDK,ALT_INSTALL_MSSDK, )
 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
+        @$(call OptionalVarPathSanityCheck,\
+                INSTALL_MSIVAL2,ALT_INSTALL_MSIVAL2, )
 endif
 
 ######################################################
 # Check the Solaris GNU c++ compiler for solaris plugin
 ######################################################

@@ -1481,54 +1261,47 @@
 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) ; \
+            $(call SanityError, \
+"The Solaris GCC compiler version must be $(REQUIRED_GCC_VERSION).", \
+"You are using the following compiler version: $(GCC_VER)" \
+"The compiler was obtained from the following location: \
+ $(GCC_COMPILER_PATH)" \
+"Please change your compiler.") ; \
     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) ; \
+          $(call SanityError, \
+"You do not have a valid GCC_COMPILER_PATH setting.", \
+"Please check your access to $(GCC_COMPILER_PATH) \
+ and/or check your value of ALT_GCC_COMPILER_PATH." \
+"This will affect you if you build the plugin target.") ; \
         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) ; \
+            $(call SanityError, \
+"You do not have a valid ALT_GCC29_COMPILER_PATH setting.", \
+"Please check your access to $(ALT_GCC29_COMPILER_PATH)/bin/gcc" \
+"This will affect you if you build the plugin target.") ; \
     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) ; \
+            $(call SanityError, \
+"You do not have a valid ALT_GCC29_PLUGIN_LIB_PATH setting.", \
+"Please check your access to \
+  $(ALT_GCC29_PLUGIN_LIB_PATH)/libjavaplugin_oji.so" \
+"This will affect you if you build the plugin target \
+ specifically for gcc 2.9 version of OJI plugin library.") ; \
         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
+        @$(call VarPathSanityCheck,GCC29_COMPILER_PATH,ALT_GCC29_COMPILER_PATH, \
+"This will affect you if you build the plugin target.")
     endif
   endif
 endif
 
 

@@ -1537,119 +1310,84 @@
 ######################################################
 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) ; \
+          $(call SanityError, \
+"ALT_MOZILLA_HEADERS_PATH must be an Absolute Path Name not a Relative Path Name.", \
+"The current value of ALT_MOZILLA_HEADERS_PATH is $(ALT_MOZILLA_HEADERS_PATH)" \
+"Please fix this and continue your build.") ; \
         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
+        @$(call VarPathFileSanityCheck,\
+                MOZILLA_HEADERS_PATH,ALT_MOZILLA_HEADERS_PATH,\
+                $(MOZILLA_HEADERS_PATH)/mozilla_headers_18.win32/java/bool.h, \
+"Or check your value of ALT_JDK_DEVTOOLS_DIR.")
   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
+        @$(call VarPathFileSanityCheck,\
+                MOZILLA_HEADERS_PATH,ALT_MOZILLA_HEADERS_PATH,\
+                $(MOZILLA_HEADERS_PATH)/mozilla_headers_18/java/bool.h, \
+"Or check your value of ALT_JDK_DEVTOOLS_DIR.")
   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
+        @$(call VarPathFileSanityCheck,\
+                MOZILLA_HEADERS_PATH,ALT_MOZILLA_HEADERS_PATH,\
+                $(MOZILLA_HEADERS_PATH)/plugin2_mozilla_headers/npapi.h, \
+"Or check your value of ALT_JDK_DEVTOOLS_DIR." \
+"This file is needed for plugin2.")
 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
+        @$(call OptionalVarPathFileSanityCheck,\
+                HOTSPOT_KERNEL_PATH,ALT_HOTSPOT_IMPORT_PATH,\
+                $(HOTSPOT_KERNEL_PATH)/jvm.dll,\
+"Your HOTSPOT_IMPORT_PATH does not include a Kernel VM." \
+"The kernel installer may not be built (unless hotspot is also).")
   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
+        @$(call OptionalVarPathSanityCheck,\
+                SECURITY_BASELINE_131,SECURITY_BASELINE_131, )
 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
+        @$(call OptionalVarPathSanityCheck,\
+                SECURITY_BASELINE_142,SECURITY_BASELINE_142, )
 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
+        @$(call OptionalVarPathSanityCheck,\
+                SECURITY_BASELINE_150,SECURITY_BASELINE_150, )
 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
+        @$(call OptionalVarPathSanityCheck,\
+                SECURITY_BASELINE_160,SECURITY_BASELINE_160, )
 endif
 
 
 ######################################################
 # this should be the last rule in any target's sanity rule.

@@ -1661,33 +1399,33 @@
         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); \
+          $(PRINTF) "\n%s\n%s\n\n" "INSANE mode requested." \
+            "Sanity will not force a build termination, even with errors." \
+            >> $(ERROR_FILE); \
         fi
         @if [ -r $(ERROR_FILE) ]; then \
           if [ "x$(INSANE)" = x ]; then \
-            $(ECHO) "Exiting because of the above error(s). \n" \
-              "">> $(ERROR_FILE); \
+            $(PRINTF) "\n%s\n\n" "Exiting because of the above error(s)." \
+              >> $(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); \
+          $(PRINTF) "\n%s\n%s\n\n" "PEDANTIC mode requested." \
+            "Exiting because of the above warning(s)." \
+            >> $(ERROR_FILE); \
           $(CAT) $(ERROR_FILE) ; \
           exit 1 ; \
         fi
 endif # PEDANTIC
         @if [ ! -r $(ERROR_FILE) ]; then \
-          $(ECHO) "Sanity check passed." ; \
+          $(PRINTF) "\n%s\n" "Sanity check passed." ; \
         fi
 endif #  EXTERNALSANITYCONTROL