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 237 SUBDIRS_tools = launchers 238 SUBDIRS_misc = org sunw jpda mkdemo mksample 239 240 # Alternate classes implementation 241 ifndef OPENJDK 242 SUBDIRS_misc += altclasses 243 endif 244 245 include $(BUILDDIR)/common/Subdirs.gmk 246 247 all build:: 248 $(SUBDIRS-loop) 249 250 clean clobber:: 251 $(RM) -r $(OUTPUTDIR) 252 253 # 254 # Docs 255 # 256 OTHERSUBDIRS = docs 257 docs:: sanity-docs post-sanity-docs 258 $(OTHERSUBDIRS-loop) 259 260 # 261 # Release engineering targets. 262 # 263 include $(BUILDDIR)/common/Release.gmk 264 ifeq ($(HAS_CUSTOM_MAKE),1) 265 include $(CUSTOM_MAKE_DIR)/Release.gmk 266 endif 267 268 # 269 # Cscope targets. 270 # 271 include $(BUILDDIR)/common/Cscope.gmk 272 273 # 274 # Sanity checks. 275 # 276 include $(BUILDDIR)/common/Sanity.gmk 277 278 $(OUTPUTDIR) $(TEMPDIR): 279 $(MKDIR) -p $@ 280 281 # this should be the last rule in this file: 282 all:: 283 @if [ -r $(WARNING_FILE) ]; then \ 284 $(CAT) $(WARNING_FILE) ; \ 285 fi 286 @$(ECHO) $(PLATFORM) $(ARCH) $(RELEASE) build finished: $(shell $(DATE) '+%y-%m-%d %H:%M') 287 288 # 289 # Developer rule that links 32 and 64 bit builds on Solaris by creating 290 # softlinks in the 32bit outputdir to the 64bit outputdir. 291 # 292 ifeq ($(PLATFORM), solaris) 293 ifeq ($(ARCH_FAMILY), sparc) 294 ARCH32 = sparc 295 ARCH64 = sparcv9 296 else 297 ARCH32 = i586 298 ARCH64 = amd64 299 endif 300 OUTPUTDIR32 = $(ABS_OUTPUTDIR)/../$(PLATFORM)-$(ARCH32) 301 OUTPUTDIR64 = $(ABS_OUTPUTDIR)/../$(PLATFORM)-$(ARCH64) 302 endif 303 304 create_links: 305 ifeq ($(PLATFORM), solaris) 306 @if [ -d $(OUTPUTDIR32) -a -d $(OUTPUTDIR64) ] ; then \ 307 dirlist=`($(CD) $(OUTPUTDIR64); $(FIND) . -name $(ARCH64))`; \ 308 for sd in $$dirlist ; do \ 309 pdir=`$(DIRNAME) $$sd`; \ 310 if [ -d $(OUTPUTDIR32)/$$pdir ] ; then \ 311 echo "Creating link for $$sd"; \ 312 (cd $(OUTPUTDIR32)/$$pdir; $(RM) $(ARCH64); \ 313 $(LN) -s $(OUTPUTDIR64)/$$sd ); \ 314 fi; \ 315 done; \ 316 else \ 317 $(ECHO) "Build both 32 and 64 bit versions first"; \ 318 fi 319 else 320 $(ECHO) "Rule $@ does not apply on $(PLATFORM)-$(ARCH)" 321 endif 322 323 # 324 # Test rule 325 # 326 327 .NOTPARALLEL: test_run 328 329 test: 330 $(MAKE) test_run 331 332 test_run: test_clean test_start test_summary 333 334 test_start: 335 @$(ECHO) "Tests started at `$(DATE)`" 336 337 test_clean: 338 $(RM) $(OUTPUTDIR)/test_failures.txt $(OUTPUTDIR)/test_log.txt 339 340 test_summary: $(OUTPUTDIR)/test_failures.txt 341 @$(ECHO) "#################################################" 342 @$(ECHO) "Tests completed at `$(DATE)`" 343 @( $(EGREP) '^TEST STATS:' $(OUTPUTDIR)/test_log.txt \ 344 || $(ECHO) "No TEST STATS seen in log" ) 345 @$(ECHO) "For complete details see: $(OUTPUTDIR)/test_log.txt" 346 @$(ECHO) "#################################################" 347 @if [ -s $< ] ; then \ 348 $(ECHO) "ERROR: Test failure count: `$(CAT) $< | $(WC) -l`"; \ 349 $(CAT) $<; \ 350 exit 1; \ 351 else \ 352 $(ECHO) "Success! No failures detected"; \ 353 fi 354 355 # Get failure list from log 356 $(OUTPUTDIR)/test_failures.txt: $(OUTPUTDIR)/test_log.txt 357 @$(RM) $@ 358 @( $(EGREP) '^FAILED:' $< || $(ECHO) "" ) | $(NAWK) 'length>0' > $@ 359 360 # Get log file of all tests run 361 JDK_TO_TEST := $(shell \ 362 if [ -d "$(ABS_OUTPUTDIR)/j2sdk-image" ] ; then \ 363 $(ECHO) "$(ABS_OUTPUTDIR)/j2sdk-image"; \ 364 elif [ -d "$(ABS_OUTPUTDIR)/bin" ] ; then \ 365 $(ECHO) "$(ABS_OUTPUTDIR)"; \ 366 elif [ "$(PRODUCT_HOME)" != "" -a -d "$(PRODUCT_HOME)/bin" ] ; then \ 367 $(ECHO) "$(PRODUCT_HOME)"; \ 368 fi \ 369 ) 370 371 TEST_TARGETS=jdk_all 372 $(OUTPUTDIR)/test_log.txt: 373 $(RM) $@ 374 ( $(CD) ../test && \ 375 $(MAKE) NO_STOPPING=- PRODUCT_HOME=$(JDK_TO_TEST) $(TEST_TARGETS) \ 376 ) | tee $@ 377 378 # 379 # JPRT rules 380 # 381 382 include jprt.gmk 383 384 # 385 # Phonies to avoid accidents. 386 # 387 .PHONY: all build clean clobber optimized debug fastdebug create_links \ 388 import import_product import_fastdebug import_debug \ 389 test test_run test_start test_clean test_summary 390