Makefile

Mon, 28 Feb 2011 10:56:10 +0100

author
ohrstrom
date
Mon, 28 Feb 2011 10:56:10 +0100
changeset 313
a1c8b847b753
parent 291
24900a58ab9f
child 317
c6f380693342
permissions
-rw-r--r--

7021753: Add a build times report
Summary: Report the build times at end of a jdkroot build.
Reviewed-by: ohair

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

mercurial