common/makefiles/Main.gmk
changeset 14111 2a82ecb35fc7
child 14378 0ef5d942b98e
equal deleted inserted replaced
14104:8d9d430b4244 14111:2a82ecb35fc7
       
     1 #
       
     2 # Copyright (c) 2011, 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 ### This is the main part of the Makefile, for the normal case with SPEC specifying a single existing spec.gmk file.
       
    27 
       
    28 # Now load the spec
       
    29 include $(SPEC)
       
    30 
       
    31 # Load the vital tools for all the makefiles. 
       
    32 include $(SRC_ROOT)/common/makefiles/MakeBase.gmk
       
    33 
       
    34 # Include the corresponding custom file, if present.
       
    35 -include $(CUSTOM_MAKE_DIR)/Main.gmk
       
    36 
       
    37 ### Clean up from previous run
       
    38 
       
    39 # Remove any build.log from a previous run, if they exist
       
    40 ifneq (,$(BUILD_LOG))
       
    41     ifneq (,$(BUILD_LOG_PREVIOUS))
       
    42         # Rotate old log
       
    43         $(shell $(RM) $(BUILD_LOG_PREVIOUS) 2> /dev/null)
       
    44         $(shell $(MV) $(BUILD_LOG) $(BUILD_LOG_PREVIOUS) 2> /dev/null)
       
    45     else
       
    46         $(shell $(RM) $(BUILD_LOG) 2> /dev/null)
       
    47     endif
       
    48     $(shell $(RM) $(OUTPUT_ROOT)/build-trace-time.log 2> /dev/null)
       
    49 endif
       
    50 # Remove any javac server logs and port files. This
       
    51 # prevents a new make run to reuse the previous servers.
       
    52 ifneq (,$(SJAVAC_SERVER_DIR))
       
    53     $(shell $(MKDIR) -p $(SJAVAC_SERVER_DIR) && $(RM) -rf $(SJAVAC_SERVER_DIR)/*)
       
    54 endif
       
    55 
       
    56 # Reset the build timers.
       
    57 $(eval $(call ResetAllTimers))
       
    58 
       
    59 # Setup number of jobs to use. -jN is unfortunately not available for us to parse from the command line,
       
    60 # hence this workaround.
       
    61 ifeq ($(JOBS),)
       
    62     JOBS=$(NUM_CORES)
       
    63 endif
       
    64 MAKE_ARGS:=$(MAKE_ARGS) -j$(JOBS)
       
    65 
       
    66 ### Main targets
       
    67 
       
    68 all: jdk
       
    69 
       
    70 start-make:
       
    71 	@$(call AtMakeStart)
       
    72 
       
    73 langtools: langtools-only
       
    74 langtools-only: start-make
       
    75 	@$(call TargetEnter)
       
    76 	@($(CD) $(LANGTOOLS_TOPDIR)/makefiles && $(BUILD_LOG_WRAPPER) $(MAKE) $(MAKE_ARGS) -f BuildLangtools.gmk)
       
    77 	@$(call TargetExit)
       
    78 
       
    79 corba: langtools corba-only
       
    80 corba-only: start-make
       
    81 	@$(call TargetEnter)
       
    82 	@($(CD) $(CORBA_TOPDIR)/makefiles && $(BUILD_LOG_WRAPPER) $(MAKE) $(MAKE_ARGS) -f BuildCorba.gmk)
       
    83 	@$(call TargetExit)
       
    84 
       
    85 jaxp: langtools jaxp-only
       
    86 jaxp-only: start-make
       
    87 	@$(call TargetEnter)
       
    88 	@($(CD) $(JAXP_TOPDIR)/makefiles && $(BUILD_LOG_WRAPPER) $(MAKE) $(MAKE_ARGS) -f BuildJaxp.gmk)
       
    89 	@$(call TargetExit)
       
    90 
       
    91 jaxws: langtools jaxp jaxws-only
       
    92 jaxws-only: start-make
       
    93 	@$(call TargetEnter)
       
    94 	@($(CD) $(JAXWS_TOPDIR)/makefiles && $(BUILD_LOG_WRAPPER) $(MAKE) $(MAKE_ARGS) -f BuildJaxws.gmk)
       
    95 	@$(call TargetExit)
       
    96 
       
    97 hotspot: hotspot-only
       
    98 hotspot-only: start-make
       
    99 	@$(call TargetEnter)
       
   100 	@($(CD) $(SRC_ROOT)/common/makefiles && $(BUILD_LOG_WRAPPER) $(MAKE) $(MAKE_ARGS) -f HotspotWrapper.gmk)
       
   101 	@$(call TargetExit)
       
   102 
       
   103 jdk: langtools hotspot corba jaxp jaxws jdk-only
       
   104 jdk-only: start-make
       
   105 	@$(call TargetEnter)
       
   106 	@($(CD) $(JDK_TOPDIR)/makefiles && $(BUILD_LOG_WRAPPER) $(MAKE) $(MAKE_ARGS) -f BuildJdk.gmk $(JDK_TARGET))
       
   107 	@$(call TargetExit)
       
   108 
       
   109 demos: jdk demos-only
       
   110 demos-only: start-make
       
   111 	@$(call TargetEnter)
       
   112 	@($(CD) $(JDK_TOPDIR)/makefiles && $(BUILD_LOG_WRAPPER) $(MAKE) $(MAKE_ARGS) -f BuildJdk.gmk demos)
       
   113 	@$(call TargetExit)
       
   114 
       
   115 images: source-tips demos images-only
       
   116 images-only: start-make
       
   117 	@$(call TargetEnter)
       
   118 	@($(CD) $(JDK_TOPDIR)/makefiles && $(BUILD_LOG_WRAPPER) $(MAKE) $(MAKE_ARGS) -f BuildJdk.gmk images)
       
   119 	@$(call TargetExit)
       
   120 
       
   121 overlay-images: source-tips demos overlay-images-only
       
   122 overlay-images-only: start-make
       
   123 	@$(call TargetEnter)
       
   124 	@($(CD) $(JDK_TOPDIR)/makefiles && $(BUILD_LOG_WRAPPER) $(MAKE) $(MAKE_ARGS) -f BuildJdk.gmk overlay-images)
       
   125 	@$(call TargetExit)
       
   126 
       
   127 bundles: images bundles-only
       
   128 bundles-only: start-make
       
   129 	@$(call TargetEnter)
       
   130 	@($(CD) $(JDK_TOPDIR)/makefiles && $(BUILD_LOG_WRAPPER) $(MAKE) $(MAKE_ARGS) -f BuildJdk.gmk bundles)
       
   131 	@$(call TargetExit)
       
   132 
       
   133 install: images install-only
       
   134 install-only: start-make
       
   135 	@$(call TargetEnter)
       
   136 	@($(CD) $(JDK_TOPDIR)/makefiles && $(BUILD_LOG_WRAPPER) $(MAKE) $(MAKE_ARGS) -f BuildJdk.gmk install)
       
   137 	@$(call TargetExit)
       
   138 
       
   139 docs: jdk docs-only
       
   140 docs-only: start-make
       
   141 	@$(call TargetEnter)
       
   142 	@($(CD) $(SRC_ROOT)/common/makefiles/javadoc && $(BUILD_LOG_WRAPPER) $(MAKE) $(MAKE_ARGS) -f Javadoc.gmk docs)
       
   143 	@$(call TargetExit)
       
   144 
       
   145 bootcycle-images:
       
   146 	@$(ECHO) Boot cycle build step 1: Building the JDK image normally
       
   147 	@($(CD) $(SRC_ROOT)/common/makefiles && $(BUILD_LOG_WRAPPER) $(MAKE) SPEC=$(SPEC) images)
       
   148 	@$(ECHO) Boot cycle build step 2: Building a new JDK image using previously built image
       
   149 	@($(CD) $(SRC_ROOT)/common/makefiles && $(BUILD_LOG_WRAPPER) $(MAKE) SPEC=$(dir $(SPEC))bootcycle-spec.gmk images)
       
   150 
       
   151 test: start-make
       
   152 	@$(call TargetEnter)
       
   153 	@($(CD) $(SRC_ROOT)/test && $(BUILD_LOG_WRAPPER) $(MAKE) MAKEFLAGS= -j1 PRODUCT_HOME=$(OUTPUT_ROOT)/jdk JPRT_JAVA_HOME=$(OUTPUT_ROOT)/jdk ALT_OUTPUTDIR=$(OUTPUT_ROOT) $(TEST)) || true
       
   154 	@$(call TargetExit)
       
   155 
       
   156 # Stores the tips for each repository. This file is be used when constructing the jdk image and can be
       
   157 # used to track the exact sources used to build that image.
       
   158 source-tips: $(OUTPUT_ROOT)/source_tips
       
   159 $(OUTPUT_ROOT)/source_tips: FRC
       
   160 	@$(MKDIR) -p $(@D)
       
   161 	@$(RM) $@
       
   162 	@$(if $(HG),$(call GetSourceTips),$(ECHO) "hg not installed" > $@)
       
   163 
       
   164 
       
   165 # Remove everything, except the output from configure.
       
   166 clean: clean-langtools clean-corba clean-jaxp clean-jaxws clean-hotspot clean-jdk clean-images clean-overlay-images clean-bootcycle-build
       
   167 	@($(CD) $(OUTPUT_ROOT) && $(RM) -r tmp source_tips build.log* build-trace*.log*)
       
   168 	@$(ECHO) Cleaned all build artifacts.
       
   169 
       
   170 # Remove everything, including configure configuration.
       
   171 # If the output directory was created by configure and now becomes empty, remove it as well.
       
   172 # FIXME: tmp should not be here, fix ResetTimers instead. And remove spec.sh!
       
   173 dist-clean: clean
       
   174 	@($(CD) $(OUTPUT_ROOT) && $(RM) -r *spec.gmk config.* configure-arguments Makefile compare.sh spec.sh tmp)
       
   175 	@$(if $(filter $(CONF_NAME),$(notdir $(OUTPUT_ROOT))), \
       
   176     if test "x`$(LS) $(OUTPUT_ROOT)`" != x; then \
       
   177         $(ECHO) "Warning: Not removing non-empty configuration directory for '$(CONF_NAME)'" ;\
       
   178     else \
       
   179         ($(CD) $(SRC_ROOT) && $(ECHO) "Removing configuration directory for '$(CONF_NAME)'" && $(RM) -r $(OUTPUT_ROOT)) \
       
   180     fi \
       
   181   )
       
   182 	@$(ECHO) Cleaned everything, you will have to re-run configure.
       
   183 
       
   184 clean-langtools:
       
   185 	$(call CleanComponent,langtools)
       
   186 clean-corba:
       
   187 	$(call CleanComponent,corba)
       
   188 clean-jaxp:
       
   189 	$(call CleanComponent,jaxp)
       
   190 clean-jaxws:
       
   191 	$(call CleanComponent,jaxws)
       
   192 clean-hotspot:
       
   193 	$(call CleanComponent,hotspot)
       
   194 clean-jdk:
       
   195 	$(call CleanComponent,jdk)
       
   196 clean-images:
       
   197 	$(call CleanComponent,images)
       
   198 clean-overlay-images:
       
   199 	$(call CleanComponent,overlay-images)
       
   200 clean-bootcycle-build:
       
   201 	$(call CleanComponent,bootcycle-build)
       
   202 
       
   203 .PHONY: langtools corba jaxp jaxws hotspot jdk images overlay-images install
       
   204 .PHONY: langtools-only corba-only jaxp-only jaxws-only hotspot-only jdk-only images-only overlay-images-only install-only
       
   205 .PHONY: all test clean dist-clean bootcycle-images start-make
       
   206 .PHONY: clean-langtools clean-corba clean-jaxp clean-jaxws clean-hotspot clean-jdk clean-images clean-overlay-images clean-bootcycle-build
       
   207 
       
   208 FRC: # Force target