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