1 # 2 # Copyright (c) 1995, 2011, Oracle and/or its affiliates. All rights reserved. 3 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 # 5 # This code is free software; you can redistribute it and/or modify it 6 # under the terms of the GNU General Public License version 2 only, as 7 # published by the Free Software Foundation. Oracle designates this 8 # particular file as subject to the "Classpath" exception as provided 9 # by Oracle in the LICENSE file that accompanied this code. 10 # 11 # This code is distributed in the hope that it will be useful, but WITHOUT 12 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 14 # version 2 for more details (a copy is included in the LICENSE file that 15 # accompanied this code). 16 # 17 # You should have received a copy of the GNU General Public License version 18 # 2 along with this work; if not, write to the Free Software Foundation, 19 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 20 # 21 # Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 # or visit www.oracle.com if you need additional information or have any 23 # questions. 24 # 25 26 BUILD_PARENT_DIRECTORY=. 27 28 # Basename of any originally supplied ALT_OUTPUTDIR directory 29 ifndef ORIG_OUTPUTDIR_BASENAME 30 ifdef ALT_OUTPUTDIR 31 ORIG_OUTPUTDIR_BASENAME := $(shell basename $(ALT_OUTPUTDIR)) 32 else 33 ORIG_OUTPUTDIR_BASENAME = $(PLATFORM)-$(ARCH) 34 endif 35 endif 36 export ORIG_OUTPUTDIR_BASENAME 37 38 # The three possible directories created for output (3 build flavors) 39 OUTPUTDIR_BASENAME- = $(ORIG_OUTPUTDIR_BASENAME) 40 OUTPUTDIR_BASENAME-debug = $(ORIG_OUTPUTDIR_BASENAME)-debug 41 OUTPUTDIR_BASENAME-fastdebug = $(ORIG_OUTPUTDIR_BASENAME)-fastdebug 42 43 # Relative path to a debug output area 44 REL_JDK_OUTPUTDIR = ../$(OUTPUTDIR_BASENAME-$(DEBUG_NAME)) 45 46 # The created jdk image directory (legacy or module image) 47 JDK_IMAGE_DIRNAME=jdk-module-image 48 ifdef BUILD_LEGACY 49 JDK_IMAGE_DIRNAME = j2sdk-image 50 endif 51 52 JDK_IMAGE_DIR = $(OUTPUTDIR)/$(JDK_IMAGE_DIRNAME) 53 ABS_JDK_IMAGE_DIR = $(ABS_OUTPUTDIR)/$(JDK_IMAGE_DIRNAME) 54 55 # Relative path from an output directory to the image directory 56 REL_JDK_IMAGE_DIR = ../$(OUTPUTDIR_BASENAME-$(DEBUG_NAME))/$(JDK_IMAGE_DIRNAME) 57 REL_JDK_DEBUG_IMAGE_DIR = ../$(OUTPUTDIR_BASENAME-debug)/$(JDK_IMAGE_DIRNAME) 58 REL_JDK_FASTDEBUG_IMAGE_DIR = ../$(OUTPUTDIR_BASENAME-fastdebug)/$(JDK_IMAGE_DIRNAME) 59 60 ifndef TOPDIR 61 TOPDIR:=. 62 endif 63 64 ifndef JDK_TOPDIR 65 JDK_TOPDIR=$(TOPDIR)/jdk 66 endif 67 ifndef JDK_MAKE_SHARED_DIR 68 JDK_MAKE_SHARED_DIR=$(JDK_TOPDIR)/make/common/shared 69 endif 70 71 default: all 72 73 include $(JDK_MAKE_SHARED_DIR)/Defs-control.gmk 74 include ./make/Defs-internal.gmk 75 include ./make/sanity-rules.gmk 76 include ./make/hotspot-rules.gmk 77 include ./make/langtools-rules.gmk 78 include ./make/corba-rules.gmk 79 include ./make/jaxp-rules.gmk 80 include ./make/jaxws-rules.gmk 81 include ./make/jdk-rules.gmk 82 include ./make/install-rules.gmk 83 include ./make/sponsors-rules.gmk 84 include ./make/deploy-rules.gmk 85 86 all:: sanity 87 88 ifeq ($(SKIP_FASTDEBUG_BUILD), false) 89 all:: fastdebug_build 90 endif 91 92 ifeq ($(SKIP_DEBUG_BUILD), false) 93 all:: debug_build 94 endif 95 96 all:: all_product_build 97 98 all_product_build:: 99 100 # Everything for a full product build 101 ifeq ($(SKIP_PRODUCT_BUILD), false) 102 103 all_product_build:: product_build 104 105 ifeq ($(BUILD_INSTALL), true) 106 all_product_build:: $(INSTALL) 107 clobber:: install-clobber 108 endif 109 110 ifeq ($(BUILD_SPONSORS), true) 111 all_product_build:: $(SPONSORS) 112 clobber:: sponsors-clobber 113 endif 114 115 ifneq ($(SKIP_COMPARE_IMAGES), true) 116 all_product_build:: compare-image 117 endif 118 119 endif 120 121 define StartTimer 122 $(MKDIR) -p $(BUILDTIMESDIR) 123 $(RM) $(BUILDTIMESDIR)/build_time_* 124 $(call RecordStartTime,TOTAL) 125 endef 126 127 define StopTimer 128 $(if $(REPORT_BUILD_TIMES),$(call RecordEndTime,TOTAL) && $(call ReportBuildTimes,$1),) 129 endef 130 131 # Generic build of basic repo series 132 generic_build_repo_series:: $(SOURCE_TIPS) 133 $(MKDIR) -p $(JDK_IMAGE_DIR) 134 @$(call StartTimer) 135 136 ifeq ($(BUILD_LANGTOOLS), true) 137 generic_build_repo_series:: langtools 138 clobber:: langtools-clobber 139 endif 140 141 ifeq ($(BUILD_CORBA), true) 142 generic_build_repo_series:: corba 143 clobber:: corba-clobber 144 endif 145 146 ifeq ($(BUILD_JAXP), true) 147 generic_build_repo_series:: jaxp 148 clobber:: jaxp-clobber 149 endif 150 151 ifeq ($(BUILD_JAXWS), true) 152 generic_build_repo_series:: jaxws 153 clobber:: jaxws-clobber 154 endif 155 156 ifeq ($(BUILD_HOTSPOT), true) 157 generic_build_repo_series:: $(HOTSPOT) 158 clobber:: hotspot-clobber 159 endif 160 161 ifeq ($(BUILD_JDK), true) 162 generic_build_repo_series:: $(JDK_JAVA_EXE) 163 clobber:: jdk-clobber 164 endif 165 166 ifeq ($(BUILD_DEPLOY), true) 167 generic_build_repo_series:: $(DEPLOY) 168 clobber:: deploy-clobber 169 endif 170 171 generic_build_repo_series:: 172 @$(call StopTimer,$(if $(DEBUG_NAME),$(DEBUG_NAME)_build,all_product_build)) 173 174 # The debug build, fastdebug or debug. Needs special handling. 175 # Note that debug builds do NOT do INSTALL steps, but must be done 176 # after the product build and before the INSTALL step of the product build. 177 # 178 # DEBUG_NAME is fastdebug or debug 179 # ALT_OUTPUTDIR is changed to have -debug or -fastdebug suffix 180 # The resulting image directory (j2sdk-image) is used by the install makefiles 181 # to create a debug install bundle jdk-*-debug-** bundle (tar or zip) 182 # which will install in the debug or fastdebug subdirectory of the 183 # normal product install area. 184 # The install process needs to know what the DEBUG_NAME is, so 185 # look for INSTALL_DEBUG_NAME in the install rules. 186 # 187 # NOTE: On windows, do not use $(ABS_BOOTDIR_OUTPUTDIR)-$(DEBUG_NAME). 188 # Due to the use of short paths in $(ABS_OUTPUTDIR), this may 189 # not be the same location. 190 # 191 192 # Location of fresh bootdir output 193 ABS_BOOTDIR_OUTPUTDIR=$(ABS_OUTPUTDIR)/bootjdk 194 FRESH_BOOTDIR=$(ABS_BOOTDIR_OUTPUTDIR)/$(JDK_IMAGE_DIRNAME) 195 FRESH_DEBUG_BOOTDIR=$(ABS_BOOTDIR_OUTPUTDIR)/$(REL_JDK_IMAGE_DIR) 196 197 create_fresh_product_bootdir: FRC 198 $(MAKE) ALT_OUTPUTDIR=$(ABS_BOOTDIR_OUTPUTDIR) \ 199 GENERATE_DOCS=false \ 200 BOOT_CYCLE_SETTINGS= \ 201 build_product_image 202 203 create_fresh_debug_bootdir: FRC 204 $(MAKE) ALT_OUTPUTDIR=$(ABS_BOOTDIR_OUTPUTDIR) \ 205 GENERATE_DOCS=false \ 206 BOOT_CYCLE_DEBUG_SETTINGS= \ 207 build_debug_image 208 209 create_fresh_fastdebug_bootdir: FRC 210 $(MAKE) ALT_OUTPUTDIR=$(ABS_BOOTDIR_OUTPUTDIR) \ 211 GENERATE_DOCS=false \ 212 BOOT_CYCLE_DEBUG_SETTINGS= \ 213 build_fastdebug_image 214 215 # Create boot image? 216 ifeq ($(SKIP_BOOT_CYCLE),false) 217 ifneq ($(PLATFORM)$(ARCH_DATA_MODEL),solaris64) 218 DO_BOOT_CYCLE=true 219 endif 220 endif 221 222 223 224 ifeq ($(DO_BOOT_CYCLE),true) 225 226 # Create the bootdir to use in the build 227 product_build:: create_fresh_product_bootdir 228 debug_build:: create_fresh_debug_bootdir 229 fastdebug_build:: create_fresh_fastdebug_bootdir 230 231 # Define variables to be used now for the boot jdk 232 BOOT_CYCLE_SETTINGS= \ 233 ALT_BOOTDIR=$(FRESH_BOOTDIR) \ 234 ALT_JDK_IMPORT_PATH=$(FRESH_BOOTDIR) 235 BOOT_CYCLE_DEBUG_SETTINGS= \ 236 ALT_BOOTDIR=$(FRESH_DEBUG_BOOTDIR) \ 237 ALT_JDK_IMPORT_PATH=$(FRESH_DEBUG_BOOTDIR) 238 239 else 240 241 # Use the supplied ALT_BOOTDIR as the boot 242 BOOT_CYCLE_SETTINGS= 243 BOOT_CYCLE_DEBUG_SETTINGS= 244 245 endif 246 247 build_product_image: 248 $(MAKE) \ 249 SKIP_FASTDEBUG_BUILD=true \ 250 SKIP_DEBUG_BUILD=true \ 251 $(BOOT_CYCLE_SETTINGS) \ 252 generic_build_repo_series 253 254 # NOTE: On windows, do not use $(ABS_OUTPUTDIR)-$(DEBUG_NAME). 255 # Due to the use of short paths in $(ABS_OUTPUTDIR), this may 256 # not be the same location. 257 258 generic_debug_build: 259 $(MAKE) \ 260 ALT_OUTPUTDIR=$(ABS_OUTPUTDIR)/$(REL_JDK_OUTPUTDIR) \ 261 DEBUG_NAME=$(DEBUG_NAME) \ 262 GENERATE_DOCS=false \ 263 $(BOOT_CYCLE_DEBUG_SETTINGS) \ 264 generic_build_repo_series 265 266 build_debug_image: 267 $(MAKE) DEBUG_NAME=debug generic_debug_build 268 269 build_fastdebug_image: 270 $(MAKE) DEBUG_NAME=fastdebug generic_debug_build 271 272 # Build final image 273 product_build:: build_product_image 274 debug_build:: build_debug_image 275 fastdebug_build:: build_fastdebug_image 276 277 # The source tips are stored with the relative path to the repo. 278 # This file will be used when constructing the jdk image. 279 source_tips: $(SOURCE_TIPS) 280 $(CAT) $< 281 $(SOURCE_TIPS): FRC 282 @$(prep-target) 283 @$(call GetSourceTips) 284 285 clobber:: REPORT_BUILD_TIMES= 286 clobber:: 287 $(RM) -r $(OUTPUTDIR)/* 288 -($(RMDIR) -p $(OUTPUTDIR) > $(DEV_NULL) 2>&1; $(TRUE)) 289 290 clean: clobber 291 292 # 293 # Dev builds 294 # 295 296 dev : dev-build 297 298 dev-build: 299 $(MAKE) DEV_ONLY=true all 300 dev-sanity: 301 $(MAKE) DEV_ONLY=true sanity 302 dev-clobber: 303 $(MAKE) DEV_ONLY=true clobber 304 305 # 306 # Quick jdk verification build 307 # 308 jdk_only: 309 $(MAKE) SKIP_FASTDEBUG_BUILD=true BUILD_HOTSPOT=false all 310 311 312 # 313 # Quick jdk verification fastdebug build 314 # 315 jdk_fastdebug_only: 316 $(MAKE) DEBUG_NAME=fastdebug BUILD_HOTSPOT=false BUILD_DEPLOY=false \ 317 BUILD_INSTALL=false BUILD_SPONSORS=false generic_debug_build 318 319 # 320 # Quick deploy verification fastdebug build 321 # 322 deploy_fastdebug_only: 323 $(MAKE) \ 324 DEBUG_NAME=fastdebug \ 325 BUILD_HOTSPOT=false \ 326 BUILD_JDK=false \ 327 BUILD_LANGTOOLS=false \ 328 BUILD_CORBA=false \ 329 BUILD_JAXP=false \ 330 BUILD_JAXWS=false \ 331 BUILD_INSTALL=false \ 332 BUILD_SPONSORS=false \ 333 generic_debug_build 334 335 # 336 # Product build (skip debug builds) 337 # 338 product_only: 339 $(MAKE) SKIP_FASTDEBUG_BUILD=true all 340 341 # 342 # Check target 343 # 344 345 check: variable_check 346 347 # 348 # Help target 349 # 350 help: intro_help target_help variable_help notes_help examples_help 351 352 # Intro help message 353 intro_help: 354 @$(ECHO) "\ 355 Makefile for the modular JDK builds (all the JDK). \n\ 356 " 357 358 # Target help 359 target_help: 360 @$(ECHO) "\ 361 --- Common Targets --- \n\ 362 all -- build the core JDK (default target) \n\ 363 help -- Print out help information \n\ 364 check -- Check make variable values for correctness \n\ 365 sanity -- Perform detailed sanity checks on system and settings \n\ 366 fastdebug_build -- build the core JDK in 'fastdebug' mode (-g -O) \n\ 367 debug_build -- build the core JDK in 'debug' mode (-g) \n\ 368 clean -- remove all built and imported files \n\ 369 clobber -- same as clean \n\ 370 " 371 372 # Variable help (only common ones used by this Makefile) 373 variable_help: variable_help_intro variable_list variable_help_end 374 variable_help_intro: 375 @$(ECHO) "--- Common Variables ---" 376 variable_help_end: 377 @$(ECHO) " " 378 379 # One line descriptions for the variables 380 OUTPUTDIR.desc = Output directory 381 PARALLEL_COMPILE_JOBS.desc = Solaris/Linux parallel compile run count 382 SLASH_JAVA.desc = Root of all build tools, e.g. /java or J: 383 BOOTDIR.desc = JDK used to boot the build 384 JDK_IMPORT_PATH.desc = JDK used to import components of the build 385 COMPILER_PATH.desc = Compiler install directory 386 CACERTS_FILE.desc = Location of certificates file 387 DEVTOOLS_PATH.desc = Directory containing zip and gnumake 388 CUPS_HEADERS_PATH.desc = Include directory location for CUPS header files 389 DXSDK_PATH.desc = Root directory of DirectX SDK 390 391 # Make variables to print out (description and value) 392 VARIABLE_PRINTVAL_LIST += \ 393 OUTPUTDIR \ 394 PARALLEL_COMPILE_JOBS \ 395 SLASH_JAVA \ 396 BOOTDIR \ 397 JDK_IMPORT_PATH \ 398 COMPILER_PATH \ 399 CACERTS_FILE \ 400 DEVTOOLS_PATH 401 402 # Make variables that should refer to directories that exist 403 VARIABLE_CHECKDIR_LIST += \ 404 SLASH_JAVA \ 405 BOOTDIR \ 406 JDK_IMPORT_PATH \ 407 COMPILER_PATH \ 408 DEVTOOLS_PATH 409 410 # Make variables that should refer to files that exist 411 VARIABLE_CHECKFIL_LIST += \ 412 CACERTS_FILE 413 414 # Some are windows specific 415 ifeq ($(PLATFORM), windows) 416 417 VARIABLE_PRINTVAL_LIST += \ 418 DXSDK_PATH 419 420 VARIABLE_CHECKDIR_LIST += \ 421 DXSDK_PATH 422 423 endif 424 425 # For pattern rules below, so all are treated the same 426 DO_PRINTVAL_LIST=$(VARIABLE_PRINTVAL_LIST:%=%.printval) 427 DO_CHECKDIR_LIST=$(VARIABLE_CHECKDIR_LIST:%=%.checkdir) 428 DO_CHECKFIL_LIST=$(VARIABLE_CHECKFIL_LIST:%=%.checkfil) 429 430 # Complete variable check 431 variable_check: $(DO_CHECKDIR_LIST) $(DO_CHECKFIL_LIST) 432 variable_list: $(DO_PRINTVAL_LIST) variable_check 433 434 # Pattern rule for printing out a variable 435 %.printval: 436 @$(ECHO) " ALT_$* - $($*.desc)" 437 @$(ECHO) " \t $*=$($*)" 438 439 # Pattern rule for checking to see if a variable with a directory exists 440 %.checkdir: 441 @if [ ! -d $($*) ] ; then \ 442 $(ECHO) "WARNING: $* does not exist, try $(MAKE) sanity"; \ 443 fi 444 445 # Pattern rule for checking to see if a variable with a file exists 446 %.checkfil: 447 @if [ ! -f $($*) ] ; then \ 448 $(ECHO) "WARNING: $* does not exist, try $(MAKE) sanity"; \ 449 fi 450 451 # Misc notes on help 452 notes_help: 453 @$(ECHO) "\ 454 --- Notes --- \n\ 455 - All builds use same output directory unless overridden with \n\ 456 \t ALT_OUTPUTDIR=<dir>, changing from product to fastdebug you may want \n\ 457 \t to use the clean target first. \n\ 458 - JDK_IMPORT_PATH must refer to a compatible build, not all past promoted \n\ 459 \t builds or previous release JDK builds will work. \n\ 460 - The fastest builds have been when the sources and the BOOTDIR are on \n\ 461 \t local disk. \n\ 462 " 463 464 examples_help: 465 @$(ECHO) "\ 466 --- Examples --- \n\ 467 $(MAKE) fastdebug_build \n\ 468 $(MAKE) ALT_OUTPUTDIR=/tmp/foobar all \n\ 469 $(MAKE) ALT_OUTPUTDIR=/tmp/foobar fastdebug_build \n\ 470 $(MAKE) ALT_OUTPUTDIR=/tmp/foobar all \n\ 471 $(MAKE) ALT_BOOTDIR=/opt/java/jdk1.5.0 \n\ 472 $(MAKE) ALT_JDK_IMPORT_PATH=/opt/java/jdk1.6.0 \n\ 473 " 474 475 ################################################################ 476 # Source bundling 477 ################################################################ 478 ifeq ($(BUNDLE_RULES_AVAILABLE), true) 479 include $(BUNDLE_RULES) 480 endif 481 482 ################################################################ 483 # rule to test 484 ################################################################ 485 486 .NOTPARALLEL: test_run 487 488 test: 489 $(MAKE) test_run 490 491 test_run: test_clean test_start test_summary 492 493 test_start: 494 @$(ECHO) "Tests started at `$(DATE)`" 495 496 test_clean: 497 $(RM) $(OUTPUTDIR)/test_failures.txt $(OUTPUTDIR)/test_log.txt 498 499 test_summary: $(OUTPUTDIR)/test_failures.txt 500 @$(ECHO) "#################################################" 501 @$(ECHO) "Tests completed at `$(DATE)`" 502 @( $(EGREP) '^TEST STATS:' $(OUTPUTDIR)/test_log.txt \ 503 || $(ECHO) "No TEST STATS seen in log" ) 504 @$(ECHO) "For complete details see: $(OUTPUTDIR)/test_log.txt" 505 @$(ECHO) "#################################################" 506 @if [ -s $< ] ; then \ 507 $(ECHO) "ERROR: Test failure count: `$(CAT) $< | $(WC) -l`"; \ 508 $(CAT) $<; \ 509 exit 1; \ 510 else \ 511 $(ECHO) "Success! No failures detected"; \ 512 fi 513 514 # Get failure list from log 515 $(OUTPUTDIR)/test_failures.txt: $(OUTPUTDIR)/test_log.txt 516 @$(RM) $@ 517 @( $(EGREP) '^FAILED:' $< || $(ECHO) "" ) | $(NAWK) 'length>0' > $@ 518 519 # Get log file of all tests run 520 JDK_TO_TEST := $(shell \ 521 if [ -d "$(ABS_JDK_IMAGE_DIR)" ] ; then \ 522 $(ECHO) "$(ABS_JDK_IMAGE_DIR)"; \ 523 elif [ -d "$(ABS_OUTPUTDIR)/bin" ] ; then \ 524 $(ECHO) "$(ABS_OUTPUTDIR)"; \ 525 elif [ "$(PRODUCT_HOME)" != "" -a -d "$(PRODUCT_HOME)/bin" ] ; then \ 526 $(ECHO) "$(PRODUCT_HOME)"; \ 527 fi \ 528 ) 529 TEST_TARGETS=all 530 $(OUTPUTDIR)/test_log.txt: 531 $(RM) $@ 532 ( $(CD) test && \ 533 $(MAKE) NO_STOPPING=- PRODUCT_HOME=$(JDK_TO_TEST) $(TEST_TARGETS) \ 534 ) | tee $@ 535 536 ################################################################ 537 # JPRT rule to build 538 ################################################################ 539 540 include ./make/jprt.gmk 541 542 ################################################################ 543 # PHONY 544 ################################################################ 545 546 .PHONY: all test test_run test_start test_summary test_clean \ 547 generic_build_repo_series \ 548 what clobber insane \ 549 dev dev-build dev-sanity dev-clobber \ 550 product_build \ 551 fastdebug_build \ 552 debug_build \ 553 build_product_image \ 554 build_debug_image \ 555 build_fastdebug_image \ 556 create_fresh_product_bootdir \ 557 create_fresh_debug_bootdir \ 558 create_fresh_fastdebug_bootdir \ 559 generic_debug_build 560 561 # Force target 562 FRC: 563