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 # Makefile for building and packaging all of the JDK and the JRE. See 28 # also included files. 29 # 30 31 BUILDDIR=. 32 33 include $(BUILDDIR)/common/Defs.gmk 34 35 # 36 # Make sure we are clear what the default target is 37 # 38 default_target: all 39 40 # 41 # Check target 42 # 43 44 check: variable_check 45 46 # 47 # Help target 48 # 49 help: intro_help target_help variable_help notes_help examples_help 50 51 # Intro help message 52 intro_help: 53 @$(ECHO) "\ 54 Makefile for the main JDK workspace. \n\ 55 Default behavior is to use the BOOTDIR javac to bootstrap the build and \n\ 56 import in pre-built components like the VM from the JDK_IMPORT_PATH. \n\ 57 " 58 59 # Target help 60 target_help: 61 @$(ECHO) "\ 62 --- Common Targets --- \n\ 63 all -- build the core JDK (default target) \n\ 64 help -- Print out help information \n\ 65 check -- Check make variable values for correctness \n\ 66 sanity -- Perform detailed sanity checks on system and settings \n\ 67 openjdk -- synonym for 'OPENJDK=true all' \n\ 68 fastdebug -- build the core JDK in 'fastdebug' mode (-g -O) \n\ 69 debug -- build the core JDK in 'debug' mode (-g) \n\ 70 clean -- remove all built and imported files \n\ 71 clobber -- same as clean \n\ 72 docs -- run javadoc to generate the JDK documentation \n\ 73 images -- build the jdk and jre image directories \n\ 74 import -- copy in the pre-built components (e.g. VM) \n\ 75 import_product -- copy in the product components \n\ 76 import_fastdebug -- copy in the fastdebug components \n\ 77 import_debug -- copy in the debug components \n\ 78 create_links -- create softlinks in Solaris 32bit build to 64bit dirs \n\ 79 " 80 81 # Variable help (only common ones used by this workspace) 82 variable_help: variable_help_intro variable_list variable_help_end 83 variable_help_intro: 84 @$(ECHO) "--- Common Variables ---" 85 variable_help_end: 86 @$(ECHO) " " 87 88 # One line descriptions for the variables 89 OUTPUTDIR.desc = Output directory 90 PARALLEL_COMPILE_JOBS.desc = Solaris/Linux parallel compile run count 91 SLASH_JAVA.desc = Root of all build tools, e.g. /java or J: 92 BOOTDIR.desc = JDK used to boot the build 93 LANGTOOLS_DIST.desc = langtools dist area used to build 94 CORBA_DIST.desc = corba dist area 95 JAXP_DIST.desc = jaxp dist area 96 JAXWS_DIST.desc = jaxws dist area 97 JDK_IMPORT_PATH.desc = JDK used to import components of the build 98 COMPILER_PATH.desc = Compiler install directory 99 CACERTS_FILE.desc = Location of certificates file 100 DEVTOOLS_PATH.desc = Directory containing zip and unzip 101 CUPS_HEADERS_PATH.desc = Include directory location for CUPS header files 102 DXSDK_PATH.desc = Root directory of DirectX SDK 103 104 # Make variables to print out (description and value) 105 VARIABLE_PRINTVAL_LIST += \ 106 OUTPUTDIR \ 107 PARALLEL_COMPILE_JOBS \ 108 SLASH_JAVA \ 109 BOOTDIR \ 110 LANGTOOLS_DIST \ 111 JAXWS_DIST \ 112 CORBA_DIST \ 113 JAXP_DIST \ 114 JDK_IMPORT_PATH \ 115 COMPILER_PATH \ 116 CACERTS_FILE \ 117 DEVTOOLS_PATH 118 119 # Make variables that should refer to directories that exist 120 VARIABLE_CHECKDIR_LIST += \ 121 SLASH_JAVA \ 122 BOOTDIR \ 123 JDK_IMPORT_PATH \ 124 COMPILER_PATH \ 125 DEVTOOLS_PATH 126 127 # Make variables that should refer to files that exist 128 VARIABLE_CHECKFIL_LIST += \ 129 CACERTS_FILE 130 131 # Some are windows specific 132 ifeq ($(PLATFORM), windows) 133 134 VARIABLE_PRINTVAL_LIST += \ 135 DXSDK_PATH 136 137 VARIABLE_CHECKDIR_LIST += \ 138 DXSDK_PATH 139 140 endif 141 142 # For pattern rules below, so all are treated the same 143 DO_PRINTVAL_LIST=$(VARIABLE_PRINTVAL_LIST:%=%.printval) 144 DO_CHECKDIR_LIST=$(VARIABLE_CHECKDIR_LIST:%=%.checkdir) 145 DO_CHECKFIL_LIST=$(VARIABLE_CHECKFIL_LIST:%=%.checkfil) 146 147 # Complete variable check 148 variable_check: $(DO_CHECKDIR_LIST) $(DO_CHECKFIL_LIST) 149 variable_list: $(DO_PRINTVAL_LIST) variable_check 150 151 # Pattern rule for printing out a variable 152 %.printval: 153 @$(ECHO) " ALT_$* - $($*.desc)" 154 @$(ECHO) " \t $*=$($*)" 155 156 # Pattern rule for checking to see if a variable with a directory exists 157 %.checkdir: 158 @if [ ! -d $($*) ] ; then \ 159 $(ECHO) "WARNING: $* does not exist, try $(MAKE) sanity"; \ 160 fi 161 162 # Pattern rule for checking to see if a variable with a file exists 163 %.checkfil: 164 @if [ ! -f $($*) ] ; then \ 165 $(ECHO) "WARNING: $* does not exist, try $(MAKE) sanity"; \ 166 fi 167 168 # Misc notes on help 169 notes_help: 170 @$(ECHO) "\ 171 --- Notes --- \n\ 172 - All builds use same output directory unless overridden with \n\ 173 \t ALT_OUTPUTDIR=<dir>, changing from product to fastdebug you may want \n\ 174 \t to use the clean target first. \n\ 175 - LANGTOOLS_DIST must refer to a langtools dist area, used to build. \n\ 176 - CORBA_DIST must refer to a corba dist area. \n\ 177 - JAXP_DIST must refer to a jaxp dist area. \n\ 178 - JAXWS_DIST must refer to a jaxws dist area. \n\ 179 - JDK_IMPORT_PATH must refer to a compatible build, not all past promoted \n\ 180 \t builds or previous release JDK builds will work. \n\ 181 - The 'debug' target and 'import_debug' only works when a debug promoted \n\ 182 \t build is available, and they currently are not. \n\ 183 - The fastest builds have been when the workspace and the BOOTDIR are on \n\ 184 \t local disk. \n\ 185 " 186 187 examples_help: 188 @$(ECHO) "\ 189 --- Examples --- \n\ 190 $(MAKE) fastdebug \n\ 191 $(MAKE) ALT_OUTPUTDIR=/tmp/foobar all \n\ 192 $(MAKE) ALT_OUTPUTDIR=/tmp/foobar fastdebug images \n\ 193 $(MAKE) ALT_OUTPUTDIR=/tmp/foobar all docs images \n\ 194 $(MAKE) ALT_BOOTDIR=/opt/java/jdk1.6.0 \n\ 195 $(MAKE) ALT_JDK_IMPORT_PATH=/opt/java/jdk1.7.0 \n\ 196 " 197 198 # 199 # 'all' target intro 200 # 201 all:: 202 @$(ECHO) $(PLATFORM) $(ARCH) $(RELEASE) build started: $(shell $(DATE) '+%y-%m-%d %H:%M') 203 204 # Just in case anyone uses this old name, same as 'build' 205 optimized: build 206 207 openjdk: 208 $(MAKE) OPENJDK=true all 209 210 # 211 # Special debug rules (You may also want to set ALT_OUTPUTDIR) 212 # 213 debug: 214 $(MAKE) VARIANT=DBG all 215 fastdebug: 216 $(MAKE) VARIANT=DBG FASTDEBUG=true all 217 218 # 219 # Rules to re-import VM and other JDK files 220 # 221 import: 222 $(CD) java/redist; $(MAKE) clean all 223 224 import_fastdebug: 225 $(MAKE) VARIANT=DBG FASTDEBUG=true import 226 227 import_product: 228 $(MAKE) VARIANT=OPT FASTDEBUG=false import 229 230 # 231 # Core. 232 # 233 234 all build:: sanity-all post-sanity-all 235 236 SUBDIRS = tools java javax sun com jdk 237 ifeq ($(PLATFORM), macosx) 238 SUBDIRS += apple 239 endif 240 ifeq ($(PLATFORM), windows) 241 SUBDIRS += bridge 242 endif 243 SUBDIRS_tools = launchers 244 SUBDIRS_misc = org jpda 245 246 # demos 247 ifndef NO_DEMOS 248 SUBDIRS_misc += mkdemo 249 endif 250 251 # samples 252 ifndef NO_SAMPLES 253 SUBDIRS_misc += mksample 254 endif 255 256 # Alternate classes implementation 257 ifndef OPENJDK 258 SUBDIRS_misc += altclasses 259 endif 260 261 include $(BUILDDIR)/common/Subdirs.gmk 262 263 all build:: 264 $(SUBDIRS-loop) 265 266 clean clobber:: 267 $(RM) -r $(OUTPUTDIR) 268 269 # 270 # Docs 271 # 272 OTHERSUBDIRS = docs 273 docs:: sanity-docs post-sanity-docs 274 $(OTHERSUBDIRS-loop) 275 276 # 277 # Release engineering targets. 278 # 279 include $(BUILDDIR)/common/Release.gmk 280 -include $(CUSTOM_MAKE_DIR)/Release.gmk 281 282 # 283 # Cscope targets. 284 # 285 include $(BUILDDIR)/common/Cscope.gmk 286 287 # 288 # Sanity checks. 289 # 290 include $(BUILDDIR)/common/Sanity.gmk 291 292 $(OUTPUTDIR) $(TEMPDIR): 293 $(MKDIR) -p $@ 294 295 # this should be the last rule in this file: 296 all:: 297 @if [ -r $(WARNING_FILE) ]; then \ 298 $(CAT) $(WARNING_FILE) ; \ 299 fi 300 @$(ECHO) $(PLATFORM) $(ARCH) $(RELEASE) build finished: $(shell $(DATE) '+%y-%m-%d %H:%M') 301 302 # 303 # Developer rule that links 32 and 64 bit builds on Solaris by creating 304 # softlinks in the 32bit outputdir to the 64bit outputdir. 305 # 306 ifeq ($(PLATFORM), solaris) 307 ifeq ($(ARCH_FAMILY), sparc) 308 ARCH32 = sparc 309 ARCH64 = sparcv9 310 else 311 ARCH32 = i586 312 ARCH64 = amd64 313 endif 314 OUTPUTDIR32 = $(ABS_OUTPUTDIR)/../$(PLATFORM)-$(ARCH32) 315 OUTPUTDIR64 = $(ABS_OUTPUTDIR)/../$(PLATFORM)-$(ARCH64) 316 endif 317 318 create_links: 319 ifeq ($(PLATFORM), solaris) 320 @if [ -d $(OUTPUTDIR32) -a -d $(OUTPUTDIR64) ] ; then \ 321 dirlist=`($(CD) $(OUTPUTDIR64); $(FIND) . -name $(ARCH64))`; \ 322 for sd in $$dirlist ; do \ 323 pdir=`$(DIRNAME) $$sd`; \ 324 if [ -d $(OUTPUTDIR32)/$$pdir ] ; then \ 325 echo "Creating link for $$sd"; \ 326 (cd $(OUTPUTDIR32)/$$pdir; $(RM) $(ARCH64); \ 327 $(LN) -s $(OUTPUTDIR64)/$$sd ); \ 328 fi; \ 329 done; \ 330 else \ 331 $(ECHO) "Build both 32 and 64 bit versions first"; \ 332 fi 333 else 334 $(ECHO) "Rule $@ does not apply on $(PLATFORM)-$(ARCH)" 335 endif 336 337 # 338 # Test rule 339 # 340 341 .NOTPARALLEL: test_run 342 343 test: 344 $(MAKE) test_run 345 346 test_run: test_clean test_start test_summary 347 348 test_start: 349 @$(ECHO) "Tests started at `$(DATE)`" 350 351 test_clean: 352 $(RM) $(OUTPUTDIR)/test_failures.txt $(OUTPUTDIR)/test_log.txt 353 354 test_summary: $(OUTPUTDIR)/test_failures.txt 355 @$(ECHO) "#################################################" 356 @$(ECHO) "Tests completed at `$(DATE)`" 357 @( $(EGREP) '^TEST STATS:' $(OUTPUTDIR)/test_log.txt \ 358 || $(ECHO) "No TEST STATS seen in log" ) 359 @$(ECHO) "For complete details see: $(OUTPUTDIR)/test_log.txt" 360 @$(ECHO) "#################################################" 361 @if [ -s $< ] ; then \ 362 $(ECHO) "ERROR: Test failure count: `$(CAT) $< | $(WC) -l`"; \ 363 $(CAT) $<; \ 364 exit 1; \ 365 else \ 366 $(ECHO) "Success! No failures detected"; \ 367 fi 368 369 # Get failure list from log 370 $(OUTPUTDIR)/test_failures.txt: $(OUTPUTDIR)/test_log.txt 371 @$(RM) $@ 372 @( $(EGREP) '^FAILED:' $< || $(ECHO) "" ) | $(NAWK) 'length>0' > $@ 373 374 # Get log file of all tests run 375 JDK_TO_TEST := $(shell \ 376 if [ -d "$(ABS_OUTPUTDIR)/j2sdk-image" ] ; then \ 377 $(ECHO) "$(ABS_OUTPUTDIR)/j2sdk-image"; \ 378 elif [ -d "$(ABS_OUTPUTDIR)/bin" ] ; then \ 379 $(ECHO) "$(ABS_OUTPUTDIR)"; \ 380 elif [ "$(PRODUCT_HOME)" != "" -a -d "$(PRODUCT_HOME)/bin" ] ; then \ 381 $(ECHO) "$(PRODUCT_HOME)"; \ 382 fi \ 383 ) 384 385 TEST_TARGETS=jdk_all 386 $(OUTPUTDIR)/test_log.txt: 387 $(RM) $@ 388 ( $(CD) ../test && \ 389 $(MAKE) NO_STOPPING=- PRODUCT_HOME=$(JDK_TO_TEST) $(TEST_TARGETS) \ 390 ) | tee $@ 391 392 # 393 # JPRT rules 394 # 395 396 include jprt.gmk 397 398 # 399 # Phonies to avoid accidents. 400 # 401 .PHONY: all build clean clobber optimized debug fastdebug create_links \ 402 import import_product import_fastdebug import_debug \ 403 test test_run test_start test_clean test_summary