1 # 2 # Copyright (c) 1995, 2012, 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 # 27 # Common variables used by all the Java makefiles. This file should 28 # not contain rules. 29 # 30 31 # The build times report is turned off by setting REPORT_BUILD_TIMES to nothing. 32 # This is necessary for the target clobber/clean which will erase the 33 # directories where the buildtimes are stored. 34 REPORT_BUILD_TIMES=1 35 # Store the build times in this directory. 36 BUILDTIMESDIR=$(ABS_OUTPUTDIR)/tmp/buildtimes 37 38 # Record starting time for build of a sub repository. 39 define RecordStartTime 40 $(MKDIR) -p $(BUILDTIMESDIR) 41 $(DATE) '+%Y %m %d %H %M %S' | $(NAWK) '{ print $$1,$$2,$$3,$$4,$$5,$$6,($$4*3600+$$5*60+$$6) }' > $(BUILDTIMESDIR)/build_time_start_$1 42 $(DATE) '+%Y-%m-%d %H:%M:%S' > $(BUILDTIMESDIR)/build_time_start_$1_human_readable 43 endef 44 45 # Indicate that we started to build a sub repository and record starting time. 46 define MakeStart 47 $(call RecordStartTime,$1) 48 $(PRINTF) "\n\n%s\n%s\n##### %-60.60s #####\n%s\n\n" \ 49 "########################################################################" \ 50 "########################################################################" \ 51 "Entering $1 for target(s) $2" \ 52 "########################################################################" 53 endef 54 55 # Record ending time and calculate the difference and store it in a 56 # easy to read format. Handles builds that cross midnight. Expects 57 # that a build will never take 24 hours or more. 58 define RecordEndTime 59 $(DATE) '+%Y %m %d %H %M %S' | $(NAWK) '{ print $$1,$$2,$$3,$$4,$$5,$$6,($$4*3600+$$5*60+$$6) }' > $(BUILDTIMESDIR)/build_time_end_$1 60 $(DATE) '+%Y-%m-%d %H:%M:%S' > $(BUILDTIMESDIR)/build_time_end_$1_human_readable 61 $(ECHO) `$(CAT) $(BUILDTIMESDIR)/build_time_start_$1` `$(CAT) $(BUILDTIMESDIR)/build_time_end_$1` $1 | \ 62 $(NAWK) '{ F=$$7; T=$$14; if (F > T) { T+=3600*24 }; D=T-F; H=int(D/3600); \ 63 M=int((D-H*3600)/60); S=D-H*3600-M*60; printf("%02d:%02d:%02d %s\n",H,M,S,$$15); }' \ 64 > $(BUILDTIMESDIR)/build_time_diff_$1 65 endef 66 67 # Indicate that we are done. 68 # Record ending time and print out the total time it took to build. 69 define MakeFinish 70 $(if $(REPORT_BUILD_TIMES),$(call RecordEndTime,$1),) 71 $(PRINTF) "%s\n##### %-60.60s #####\n%s\n##### %-60.60s #####\n%s\n\n" \ 72 "########################################################################" \ 73 "Leaving $1 for target(s) $2" \ 74 "########################################################################" \ 75 $(if $(REPORT_BUILD_TIMES),"Build time `$(CAT) $(BUILDTIMESDIR)/build_time_diff_$1` for target(s) $2","") \ 76 "########################################################################" 77 endef 78 79 # Find all build_time_* files and print their contents in a list sorted 80 # on the name of the sub repository. 81 define ReportBuildTimes 82 $(PRINTF) -- "-- Build times ----------\nTarget %s\nStart %s\nEnd %s\n%s\n%s\n-------------------------\n" \ 83 $1 \ 84 "`$(CAT) $(BUILDTIMESDIR)/build_time_start_TOTAL_human_readable`" \ 85 "`$(CAT) $(BUILDTIMESDIR)/build_time_end_TOTAL_human_readable`" \ 86 "`$(LS) $(BUILDTIMESDIR)/build_time_diff_* | $(GREP) -v _TOTAL | $(XARGS) $(CAT) | $(SORT) -k 2`" \ 87 "`$(CAT) $(BUILDTIMESDIR)/build_time_diff_TOTAL`" 88 endef 89 90 ifdef OPENJDK 91 ifneq ($(OPENJDK),true) 92 x:=$(error "OPENJDK (if defined) can only be set to true") 93 endif 94 endif 95 96 # Define absolute paths to TOPDIRs 97 ABS_LANGTOOLS_TOPDIR:=$(call OptFullPath,"$(LANGTOOLS_TOPDIR)") 98 ABS_CORBA_TOPDIR:=$(call OptFullPath,"$(CORBA_TOPDIR)") 99 ABS_JAXP_TOPDIR:=$(call OptFullPath,"$(JAXP_TOPDIR)") 100 ABS_JAXWS_TOPDIR:=$(call OptFullPath,"$(JAXWS_TOPDIR)") 101 ABS_BDB_TOPDIR:=$(call OptFullPath,"$(BDB_TOPDIR)") 102 ABS_JDK_TOPDIR:=$(call OptFullPath,"$(JDK_TOPDIR)") 103 ABS_HOTSPOT_TOPDIR:=$(call OptFullPath,"$(HOTSPOT_TOPDIR)") 104 ABS_INSTALL_TOPDIR:=$(call OptFullPath,"$(INSTALL_TOPDIR)") 105 ABS_SPONSORS_TOPDIR:=$(call OptFullPath,"$(SPONSORS_TOPDIR)") 106 ABS_DEPLOY_TOPDIR:=$(call OptFullPath,"$(DEPLOY_TOPDIR)") 107 108 # Macro to return true or false if a file exists and is readable 109 define MkExists 110 $(shell if [ -r $1 ]; then $(ECHO) true; else $(ECHO) false; fi) 111 endef 112 113 HOTSPOT_SRC_AVAILABLE := $(call MkExists,$(HOTSPOT_TOPDIR)/make/Makefile) 114 ifndef BUILD_HOTSPOT 115 ifdef ALT_HOTSPOT_IMPORT_PATH 116 BUILD_HOTSPOT := false 117 else 118 BUILD_HOTSPOT := $(HOTSPOT_SRC_AVAILABLE) 119 endif 120 endif 121 122 LANGTOOLS_SRC_AVAILABLE := $(call MkExists,$(LANGTOOLS_TOPDIR)/make/Makefile) 123 ifndef BUILD_LANGTOOLS 124 ifdef ALT_LANGTOOLS_DIST 125 BUILD_LANGTOOLS := false 126 else 127 BUILD_LANGTOOLS := $(LANGTOOLS_SRC_AVAILABLE) 128 endif 129 endif 130 131 CORBA_SRC_AVAILABLE := $(call MkExists,$(CORBA_TOPDIR)/make/Makefile) 132 ifndef BUILD_CORBA 133 ifdef ALT_CORBA_DIST 134 BUILD_CORBA := false 135 else 136 BUILD_CORBA := $(CORBA_SRC_AVAILABLE) 137 endif 138 endif 139 140 JAXP_SRC_AVAILABLE := $(call MkExists,$(JAXP_TOPDIR)/make/Makefile) 141 ifndef BUILD_JAXP 142 ifdef ALT_JAXP_DIST 143 BUILD_JAXP := false 144 else 145 BUILD_JAXP := $(JAXP_SRC_AVAILABLE) 146 endif 147 endif 148 149 JAXWS_SRC_AVAILABLE := $(call MkExists,$(JAXWS_TOPDIR)/make/Makefile) 150 ifndef BUILD_JAXWS 151 ifdef ALT_JAXWS_DIST 152 BUILD_JAXWS := false 153 else 154 BUILD_JAXWS := $(JAXWS_SRC_AVAILABLE) 155 endif 156 endif 157 158 # If USE_SYSTEM_BDB is defined then simply ignore the bdb repo. 159 # If the bdb repo does not exist then set USE_SYSTEM_BDB 160 BDB_SRC_AVAILABLE := $(call MkExists,$(BDB_TOPDIR)/make/Makefile) 161 ifdef USE_SYSTEM_BDB 162 BUILD_BDB := false 163 USE_SYSTEM_BDB := true 164 else 165 ifndef BUILD_BDB 166 ifdef ALT_BDB_IMPORT_PATH 167 BUILD_BDB := false 168 else 169 BUILD_BDB := $(BDB_SRC_AVAILABLE) 170 ifeq ($(BUILD_BDB),false) 171 USE_SYSTEM_BDB := true 172 endif 173 endif 174 endif 175 endif 176 177 JDK_SRC_AVAILABLE := $(call MkExists,$(JDK_TOPDIR)/make/Makefile) 178 ifndef BUILD_JDK 179 BUILD_JDK := $(JDK_SRC_AVAILABLE) 180 endif 181 ifeq ($(JDK_SRC_AVAILABLE),true) 182 JDK_CLOSED_SRC_AVAILABLE := $(call MkExists,$(JDK_TOPDIR)/src/closed) 183 ifeq ($(JDK_CLOSED_SRC_AVAILABLE),false) 184 OPENJDK = true 185 endif 186 endif 187 188 DEPLOY_SRC_AVAILABLE := $(call MkExists,$(DEPLOY_TOPDIR)/make/Makefile) 189 ifndef BUILD_DEPLOY 190 BUILD_DEPLOY := $(DEPLOY_SRC_AVAILABLE) 191 endif 192 193 INSTALL_SRC_AVAILABLE := $(call MkExists,$(INSTALL_TOPDIR)/make/Makefile) 194 ifndef BUILD_INSTALL 195 ifdef DEV_ONLY 196 BUILD_INSTALL := false 197 else 198 BUILD_INSTALL := $(INSTALL_SRC_AVAILABLE) 199 endif 200 endif 201 202 SPONSORS_SRC_AVAILABLE := $(call MkExists,$(SPONSORS_TOPDIR)/make/Makefile) 203 ifndef BUILD_SPONSORS 204 ifdef DEV_ONLY 205 BUILD_SPONSORS := false 206 else 207 BUILD_SPONSORS := $(SPONSORS_SRC_AVAILABLE) 208 endif 209 endif 210 211 212 # Do we build the source bundles? 213 BUNDLE_RULES = $(JDK_TOPDIR)/make/closed/bundles.gmk 214 ifeq ($(SKIP_BUNDLES_BUILD), true) 215 BUNDLE_RULES_AVAILABLE := false 216 else 217 BUNDLE_RULES_AVAILABLE := $(call MkExists,$(BUNDLE_RULES)) 218 endif 219 220 # Current things we do NOT build for OPENJDK 221 ifdef OPENJDK 222 BUILD_DEPLOY = false 223 BUILD_INSTALL = false 224 BUILD_SPONSORS = false 225 BUNDLE_RULES_AVAILABLE := false 226 # These could be over-ridden on the command line or in environment 227 ifndef SKIP_FASTDEBUG_BUILD 228 SKIP_FASTDEBUG_BUILD = true 229 endif 230 ifndef SKIP_DEBUG_BUILD 231 SKIP_DEBUG_BUILD = true 232 endif 233 ifndef SKIP_COMPARE_IMAGES 234 SKIP_COMPARE_IMAGES = true 235 endif 236 else 237 238 # Various non-OPENJDK reasons to NOT build the deploy repository 239 ifeq ($(ARCH), ia64) 240 BUILD_DEPLOY=false 241 endif 242 ifeq ($(ARCH), sparcv9) 243 BUILD_DEPLOY=false 244 endif 245 ifeq ($(ARCH), amd64) 246 ifeq ($(PLATFORM), solaris) 247 BUILD_DEPLOY=false 248 endif 249 endif 250 251 endif 252 ifndef SKIP_PRODUCT_BUILD 253 SKIP_PRODUCT_BUILD = false 254 endif 255 256 # Many reasons why we would want to skip the comparison to previous jdk 257 ifndef SKIP_COMPARE_IMAGES 258 ifeq ($(BUILD_JDK), false) 259 SKIP_COMPARE_IMAGES = true 260 endif 261 ifeq ($(BUILD_DEPLOY), false) 262 SKIP_COMPARE_IMAGES = true 263 endif 264 ifeq ($(BUILD_INSTALL), false) 265 SKIP_COMPARE_IMAGES = true 266 endif 267 ifdef DEV_ONLY 268 SKIP_COMPARE_IMAGES = true 269 endif 270 endif 271 272 # Select defaults if these are not set to true or false 273 ifndef SKIP_DEBUG_BUILD 274 SKIP_DEBUG_BUILD=true 275 endif 276 ifndef SKIP_FASTDEBUG_BUILD 277 SKIP_FASTDEBUG_BUILD=true 278 endif 279 280 # Select javadoc setting GENERATE_DOCS 281 ifndef NO_DOCS 282 # Default value (we want javadoc run) 283 GENERATE_DOCS=true 284 # No DOCS build when JDK_UPDATE_VERSION set on non-OPENJDK builds 285 ifndef OPENJDK 286 ifdef JDK_UPDATE_VERSION 287 GENERATE_DOCS=false 288 endif 289 endif 290 # If langtools, corba, jaxp, and jaxws are not being built, 291 # a full jdk javadoc is not possible 292 ifneq ($(BUILD_LANGTOOLS), true) 293 GENERATE_DOCS=false 294 endif 295 ifneq ($(BUILD_CORBA), true) 296 GENERATE_DOCS=false 297 endif 298 ifneq ($(BUILD_JAXP), true) 299 GENERATE_DOCS=false 300 endif 301 ifneq ($(BUILD_JAXWS), true) 302 GENERATE_DOCS=false 303 endif 304 ifeq ($(GENERATE_DOCS),false) 305 NO_DOCS=true 306 endif 307 else 308 GENERATE_DOCS=false 309 endif 310 311 # Output directory for hotspot build 312 HOTSPOT_DIR = $(ABS_OUTPUTDIR)/hotspot 313 314 # Output directory for bdb build 315 BDB_DIR = $(ABS_OUTPUTDIR)/bdb 316 317 # If we are building components 318 ifndef ALT_LANGTOOLS_DIST 319 LANGTOOLS_OUTPUTDIR = $(ABS_OUTPUTDIR)/langtools 320 ABS_LANGTOOLS_DIST = $(LANGTOOLS_OUTPUTDIR)/dist 321 endif 322 ifndef ALT_CORBA_DIST 323 CORBA_OUTPUTDIR = $(ABS_OUTPUTDIR)/corba 324 ABS_CORBA_DIST = $(CORBA_OUTPUTDIR)/dist 325 endif 326 ifndef ALT_JAXP_DIST 327 JAXP_OUTPUTDIR = $(ABS_OUTPUTDIR)/jaxp 328 ABS_JAXP_DIST = $(JAXP_OUTPUTDIR)/dist 329 endif 330 ifndef ALT_JAXWS_DIST 331 JAXWS_OUTPUTDIR = $(ABS_OUTPUTDIR)/jaxws 332 ABS_JAXWS_DIST = $(JAXWS_OUTPUTDIR)/dist 333 endif 334 335 # Common make arguments (supplied to all component builds) 336 COMMON_BUILD_ARGUMENTS = \ 337 JDK_TOPDIR=$(ABS_JDK_TOPDIR) \ 338 JDK_MAKE_SHARED_DIR=$(ABS_JDK_TOPDIR)/make/common/shared \ 339 EXTERNALSANITYCONTROL=true \ 340 SOURCE_LANGUAGE_VERSION=$(SOURCE_LANGUAGE_VERSION) \ 341 TARGET_CLASS_VERSION=$(TARGET_CLASS_VERSION) \ 342 MILESTONE=$(MILESTONE) \ 343 BUILD_NUMBER=$(BUILD_NUMBER) \ 344 JDK_BUILD_NUMBER=$(JDK_BUILD_NUMBER) \ 345 FULL_VERSION=$(FULL_VERSION) \ 346 PREVIOUS_JDK_VERSION=$(PREVIOUS_JDK_VERSION) \ 347 JDK_VERSION=$(JDK_VERSION) \ 348 JDK_MKTG_VERSION=$(JDK_MKTG_VERSION) \ 349 JDK_MAJOR_VERSION=$(JDK_MAJOR_VERSION) \ 350 JDK_MINOR_VERSION=$(JDK_MINOR_VERSION) \ 351 JDK_MICRO_VERSION=$(JDK_MICRO_VERSION) \ 352 PREVIOUS_MAJOR_VERSION=$(PREVIOUS_MAJOR_VERSION) \ 353 PREVIOUS_MINOR_VERSION=$(PREVIOUS_MINOR_VERSION) \ 354 PREVIOUS_MICRO_VERSION=$(PREVIOUS_MICRO_VERSION) 355 356 ifdef ARCH_DATA_MODEL 357 COMMON_BUILD_ARGUMENTS += ARCH_DATA_MODEL=$(ARCH_DATA_MODEL) 358 endif 359 360 ifeq ($(DEBUG_NAME), debug) 361 COMMON_BUILD_ARGUMENTS += VARIANT=DBG DEBUG_CLASSFILES=true 362 endif 363 364 ifeq ($(DEBUG_NAME), fastdebug) 365 COMMON_BUILD_ARGUMENTS += VARIANT=DBG FASTDEBUG=true DEBUG_CLASSFILES=true 366 endif 367 368 ifdef COOKED_JDK_UPDATE_VERSION 369 COMMON_BUILD_ARGUMENTS += COOKED_JDK_UPDATE_VERSION=$(COOKED_JDK_UPDATE_VERSION) 370 endif 371 372 ifdef COOKED_BUILD_NUMBER 373 COMMON_BUILD_ARGUMENTS += COOKED_BUILD_NUMBER=$(COOKED_BUILD_NUMBER) 374 endif 375 376 ifdef ANT_HOME 377 COMMON_BUILD_ARGUMENTS += ANT_HOME="$(ANT_HOME)" 378 endif 379 380 # When all repos support FULL_DEBUG_SYMBOLS and ZIP_DEBUGINFO_FILES, 381 # then these can be set here: 382 #ifdef FULL_DEBUG_SYMBOLS 383 # COMMON_BUILD_ARGUMENTS += FULL_DEBUG_SYMBOLS=$(FULL_DEBUG_SYMBOLS) 384 #endif 385 # 386 #ifdef ZIP_DEBUGINFO_FILES 387 # COMMON_BUILD_ARGUMENTS += ZIP_DEBUGINFO_FILES="$(ZIP_DEBUGINFO_FILES)" 388 #endif