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