sanity-rules.gmk 12.5 KB
Newer Older
D
duke 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356
#
# Copyright 2001-2007 Sun Microsystems, Inc.  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.  Sun designates this
# particular file as subject to the "Classpath" exception as provided
# by Sun 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
# CA 95054 USA or visit www.sun.com if you need additional information or
# have any questions.
#

################################################################
# SANITY
################################################################

sanity:: pre-sanity settings insane environment

ifeq ($(BUILD_HOTSPOT), true)
  sanity:: hotspot-sanity
endif

ifeq ($(BUILD_DEPLOY), true)
  sanity:: deploy-sanity
endif

ifeq ($(BUILD_JDK), true)
  sanity:: jdk-sanity 
endif

# Only need these sanity rules when not doing a debug build
ifeq ($(DEBUG_NAME),)

  ifeq ($(BUILD_INSTALL), true)
    sanity:: install-sanity
  endif

  ifeq ($(BUILD_SPONSORS), true)
    sanity:: sponsors-sanity
  endif

endif

sanity:: post-sanity

source-sanity : pre-sanity alt_bootdir bootdir post-sanity

$(ERROR_FILE) $(WARNING_FILE) $(MESSAGE_FILE):
	@$(prep-target)

purge-sanity: $(ERROR_FILE) $(WARNING_FILE) $(MESSAGE_FILE)
	-@$(RM) $(ERROR_FILE) $(WARNING_FILE) $(MESSAGE_FILE)

pre-sanity: purge-sanity 

# this should be the last rule in any target's sanity rule.
post-sanity post-sanity-hotspot post-sanity-jdk post-sanity-install post-sanity-deploy:
	@if [ -r $(MESSAGE_FILE) ]; then \
	  $(ECHO) "" ; \
	  $(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
	@if [ ! -r $(ERROR_FILE) ]; then \
	  $(ECHO) "Sanity check passed." ; \
	fi

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

# Get list of environment variables set that we do not want set
ifdef ALT_HOTSPOT_SERVER_PATH
  DO_NOT_SET_LIST += ALT_HOTSPOT_SERVER_PATH
endif
ifdef ALT_HOTSPOT_CLIENT_PATH
  DO_NOT_SET_LIST += ALT_HOTSPOT_CLIENT_PATH
endif
ifdef ALT_HOTSPOT_LIB_PATH
  DO_NOT_SET_LIST += ALT_HOTSPOT_LIB_PATH
endif

# Error message for environment variable set that should not be
%.do_not_set:
	@$(ECHO) "ERROR: Your build environment has the variable\n" \
	   "        $* defined. Please unset it and restart your build. \n" \
	   "" >> $(ERROR_FILE)

# Check the environment variables	
environment: $(DO_NOT_SET_LIST:%=%.do_not_set)
ifeq ($(LANGTOOLS_SRC_AVAILABLE), true)
  ifneq ($(BUILD_LANGTOOLS), true)
	@$(ECHO) "WARNING: You are not building the LANGTOOLS sources.\n" \
           "        Lang tools (javac) will be obtained from \n" \
           "        the location set in ALT_JDK_IMPORT_PATH. \n" \
           "" >> $(WARNING_FILE)
  endif
endif
ifeq ($(JAXP_SRC_AVAILABLE), true)
  ifneq ($(BUILD_JAXP), true)
	@$(ECHO) "WARNING: You are not building the JAXP sources.\n" \
           "        The jaxp files will be obtained from \n" \
           "        the location set in ALT_JDK_IMPORT_PATH. \n" \
           "" >> $(WARNING_FILE)
  endif
endif
ifeq ($(JAXWS_SRC_AVAILABLE), true)
  ifneq ($(BUILD_JAXWS), true)
	@$(ECHO) "WARNING: You are not building the JAXWS sources.\n" \
           "        The jaxws files will be obtained from \n" \
           "        the location set in ALT_JDK_IMPORT_PATH. \n" \
           "" >> $(WARNING_FILE)
  endif
endif
ifeq ($(CORBA_SRC_AVAILABLE), true)
  ifneq ($(BUILD_CORBA), true)
	@$(ECHO) "WARNING: You are not building the CORBA sources.\n" \
           "        The corba files will be obtained from \n" \
           "        the location set in ALT_JDK_IMPORT_PATH. \n" \
           "" >> $(WARNING_FILE)
  endif
endif
ifeq ($(HOTSPOT_SRC_AVAILABLE), true)
  ifneq ($(BUILD_HOTSPOT), true)
	@$(ECHO) "WARNING: You are not building the HOTSPOT sources.\n" \
           "        Hotspot libs will be obtained from \n" \
           "        the location set in ALT_HOTSPOT_IMPORT_PATH. \n" \
           "" >> $(WARNING_FILE)
  endif
endif
ifeq ($(JDK_SRC_AVAILABLE), true)
  ifneq ($(BUILD_JDK), true)
	@$(ECHO) "WARNING: You are not building the JDK sources.\n" \
	   "        This will result in a development-only\n" \
	   "        build of the JDK , lacking the jdk binaries.\n" \
	   "" >> $(WARNING_FILE)
  endif
endif
ifeq ($(DEPLOY_SRC_AVAILABLE), true)
  ifneq ($(BUILD_DEPLOY), true)
	@$(ECHO) "WARNING: You are not building the DEPLOY sources.\n" \
	   "        This will result in a development-only\n" \
	   "        build of the JDK, lacking the plugin and javaws binaries.\n" \
	   "" >> $(WARNING_FILE)
  endif
endif
ifeq ($(INSTALL_SRC_AVAILABLE), true)
  ifneq ($(BUILD_INSTALL), true)
	@$(ECHO) "WARNING: You are not building the INSTALL sources.\n" \
	   "        This will result in a development-only\n" \
	   "        build of the JDK, lacking the installation bundles\n" \
	   "" >> $(WARNING_FILE)
  endif
endif
ifeq ($(SPONSORS_SRC_AVAILABLE), true)
  ifneq ($(BUILD_SPONSORS), true)
	@$(ECHO) "WARNING: You are not building the SPONSORS sources.\n" \
	   "" >> $(WARNING_FILE)
  endif
endif
ifndef OPENJDK
  ifdef NO_DOCS
	@$(ECHO) "WARNING: Your build environment has the variable NO_DOCS\n" \
	   "        defined. This will result in a development-only\n" \
	   "        build of the JDK, lacking the documentation.\n" \
	   "" >> $(WARNING_FILE)
  endif
endif
ifdef NO_IMAGES
	@$(ECHO) "WARNING: Your build environment has the variable NO_IMAGES\n" \
	   "        defined. This will result in a development-only\n" \
	   "        build of the JDK, lacking the install images\n" \
	   "        and bundles.\n" \
	   "" >> $(WARNING_FILE)
endif
ifdef DEV_ONLY
	@$(ECHO) "WARNING: Your build environment has the variable DEV_ONLY\n" \
	   "        defined. This will result in a development-only\n" \
	   "        build of the JDK, lacking the documentation\n" \
	   "        build and installation bundles.\n" \
	   "" >> $(WARNING_FILE)
endif

######################################################
# if specified, ALT_BOOTDIR must point to non-relative path if set
######################################################
alt_bootdir:
ifdef ALT_BOOTDIR
	@if [ `$(ECHO) $(subst \,/,$(ALT_BOOTDIR)) | $(EGREP) -ci '^([a-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.
######################################################
JAVA_VERSION := $(shell $(BOOTDIR)/bin/java$(EXE_SUFFIX) -version 2>&1  | $(NAWK) -F'"' '{ print $$2 }')
JAVA_VERSION_OK := $(shell $(ECHO) $(JAVA_VERSION) | $(EGREP) -c '^1.[5-6].[0-9]')
bootdir:
	@if [ -x $(BOOTDIR)/bin/java$(EXE_SUFFIX) ]; then \
	  if [ $(JAVA_VERSION_OK) -ne 1 ]; then \
	    $(ECHO) "ERROR: Your BOOTDIR environment variable does not point \n" \
	      "      to a valid JDK for bootstrapping this build. \n" \
	      "      A JDK $(JDK_MKTG_VERSION) source generation process must be \n" \
	      "      bootstrapped using JDK $(PREVIOUS_JDK_VERSION) fcs (or later). \n" \
	      "      Apparently, your bootstrap JDK is version $(JAVA_VERSION) \n" \
	      "      Please update your ALT_BOOTDIR setting and start your build again. \n" \
	      "" >> $(ERROR_FILE) ; \
	  fi \
	else \
	  $(ECHO) "ERROR: BOOTDIR does not point to a valid Java 2 SDK \n" \
	    "      Check that you have access to \n" \
	    "          $(BOOTDIR)/bin/java$(EXE_SUFFIX) \n" \
	    "      and/or check your value of ALT_BOOTDIR. \n" \
	    "" >> $(ERROR_FILE) ; \
	fi

######################################################
# dump out the variable settings...
######################################################
ifneq ($(PLATFORM), windows)
  ifndef HOSTNAME
    HOSTNAME := $(shell hostname)
  endif
endif
settings:: 
	@$(ECHO) "Build Machine Information:" >> $(MESSAGE_FILE)
ifeq ($(PLATFORM), windows)
	@$(ECHO) "   build machine = $(COMPUTERNAME)"  >> $(MESSAGE_FILE)
else
	@$(ECHO) "   build machine = $(HOSTNAME)"  >> $(MESSAGE_FILE)
endif
	@$(ECHO) "" >> $(MESSAGE_FILE)
	@$(ECHO) "Build Directory Structure:" >> $(MESSAGE_FILE)
	@$(ECHO) "   CWD = `$(PWD)`" >> $(MESSAGE_FILE)
	@$(ECHO) "   TOPDIR = $(TOPDIR)"  >> $(MESSAGE_FILE)
	@$(ECHO) "   CONTROL_TOPDIR = $(CONTROL_TOPDIR)"  >> $(MESSAGE_FILE)
ifeq ($(LANGTOOLS_SRC_AVAILABLE), true)
	@$(ECHO) "   LANGTOOLS_TOPDIR = $(LANGTOOLS_TOPDIR)"  >> $(MESSAGE_FILE)
endif
ifeq ($(JAXP_SRC_AVAILABLE), true)
	@$(ECHO) "   JAXP_TOPDIR = $(JAXP_TOPDIR)"  >> $(MESSAGE_FILE)
endif
ifeq ($(JAXWS_SRC_AVAILABLE), true)
	@$(ECHO) "   JAXWS_TOPDIR = $(JAXWS_TOPDIR)"  >> $(MESSAGE_FILE)
endif
ifeq ($(CORBA_SRC_AVAILABLE), true)
	@$(ECHO) "   CORBA_TOPDIR = $(CORBA_TOPDIR)"  >> $(MESSAGE_FILE)
endif
ifeq ($(HOTSPOT_SRC_AVAILABLE), true)
	@$(ECHO) "   HOTSPOT_TOPDIR = $(HOTSPOT_TOPDIR)"  >> $(MESSAGE_FILE)
endif
ifeq ($(JDK_SRC_AVAILABLE), true)
	@$(ECHO) "   JDK_TOPDIR = $(JDK_TOPDIR)"  >> $(MESSAGE_FILE)
endif
ifeq ($(DEPLOY_SRC_AVAILABLE), true)
	@$(ECHO) "   DEPLOY_TOPDIR = $(DEPLOY_TOPDIR)"  >> $(MESSAGE_FILE)
endif
ifeq ($(INSTALL_SRC_AVAILABLE), true)
	@$(ECHO) "   INSTALL_TOPDIR = $(INSTALL_TOPDIR)"  >> $(MESSAGE_FILE)
endif
ifeq ($(SPONSORS_SRC_AVAILABLE), true)
	@$(ECHO) "   SPONSORS_TOPDIR = $(SPONSORS_TOPDIR)"  >> $(MESSAGE_FILE)
endif
	@$(ECHO) "" >> $(MESSAGE_FILE)
ifneq ($(SKIP_COMPARE_IMAGES), true)
	@$(ECHO) "External File/Binary Locations:" >> $(MESSAGE_FILE)
	@$(ECHO) "   PREVIOUS_JRE_BUNDLE = $(PREVIOUS_JRE_BUNDLE) " >> $(MESSAGE_FILE)
	@$(ECHO) "   PREVIOUS_JDK_BUNDLE = $(PREVIOUS_JDK_BUNDLE) " >> $(MESSAGE_FILE)
	@$(ECHO) "" >> $(MESSAGE_FILE)
endif
	@$(ECHO) "Build Directives:" >> $(MESSAGE_FILE)
ifeq ($(LANGTOOLS_SRC_AVAILABLE), true)
	@$(ECHO) "   BUILD_LANGTOOLS = $(BUILD_LANGTOOLS) " >> $(MESSAGE_FILE)
endif
ifeq ($(JAXP_SRC_AVAILABLE), true)
	@$(ECHO) "   BUILD_JAXP = $(BUILD_JAXP) " >> $(MESSAGE_FILE)
endif
ifeq ($(JAXWS_SRC_AVAILABLE), true)
	@$(ECHO) "   BUILD_JAXWS = $(BUILD_JAXWS) " >> $(MESSAGE_FILE)
endif
ifeq ($(CORBA_SRC_AVAILABLE), true)
	@$(ECHO) "   BUILD_CORBA = $(BUILD_CORBA) " >> $(MESSAGE_FILE)
endif
ifeq ($(HOTSPOT_SRC_AVAILABLE), true)
	@$(ECHO) "   BUILD_HOTSPOT = $(BUILD_HOTSPOT) " >> $(MESSAGE_FILE)
endif
ifeq ($(JDK_SRC_AVAILABLE), true)
	@$(ECHO) "   BUILD_JDK    = $(BUILD_JDK) " >> $(MESSAGE_FILE)
endif
ifeq ($(DEPLOY_SRC_AVAILABLE), true)
	@$(ECHO) "   BUILD_DEPLOY  = $(BUILD_DEPLOY) " >> $(MESSAGE_FILE)
endif
ifeq ($(INSTALL_SRC_AVAILABLE), true)
	@$(ECHO) "   BUILD_INSTALL = $(BUILD_INSTALL) " >> $(MESSAGE_FILE)
endif
ifeq ($(SPONSORS_SRC_AVAILABLE), true)
	@$(ECHO) "   BUILD_SPONSORS = $(BUILD_SPONSORS) " >> $(MESSAGE_FILE)
endif
	@$(ECHO) "" >> $(MESSAGE_FILE)

.PHONY: sanity settings pre-sanity insane \
	post-sanity post-sanity-hotspot post-sanity-jdk \
	post-sanity-install post-sanity-deploy \
	alt_bootdir bootdir