1 #
   2 # Copyright (c) 2011, 2013, 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 MAKE_ARGS:=$(MAKE_ARGS) -j$(JOBS)
  62 
  63 ### Main targets
  64 
  65 default: jdk
  66         @$(call CheckIfMakeAtEnd)
  67 
  68 all: images docs
  69         @$(call CheckIfMakeAtEnd)
  70 
  71 # Setup a rule for SPEC file that fails if executed. This check makes sure the configuration
  72 # is up to date after changes to configure
  73 $(SPEC): $(wildcard $(SRC_ROOT)/common/autoconf/*)
  74         @$(ECHO) ERROR: $(SPEC) is not up to date
  75         @$(ECHO) Please rerun configure!
  76         @if test "x$(IGNORE_OLD_CONFIG)" != "xtrue"; then exit 1; fi
  77 
  78 start-make: $(SPEC)
  79         @$(call AtMakeStart)
  80 
  81 langtools: langtools-only
  82 langtools-only: start-make
  83         @$(call TargetEnter)
  84         @($(CD) $(LANGTOOLS_TOPDIR)/makefiles && $(BUILD_LOG_WRAPPER) $(MAKE) $(MAKE_ARGS) -f BuildLangtools.gmk)
  85         @$(call TargetExit)
  86 
  87 corba: langtools corba-only
  88 corba-only: start-make
  89         @$(call TargetEnter)
  90         @($(CD) $(CORBA_TOPDIR)/makefiles && $(BUILD_LOG_WRAPPER) $(MAKE) $(MAKE_ARGS) -f BuildCorba.gmk)
  91         @$(call TargetExit)
  92 
  93 jaxp: langtools jaxp-only
  94 jaxp-only: start-make
  95         @$(call TargetEnter)
  96         @($(CD) $(JAXP_TOPDIR)/makefiles && $(BUILD_LOG_WRAPPER) $(MAKE) $(MAKE_ARGS) -f BuildJaxp.gmk)
  97         @$(call TargetExit)
  98 
  99 jaxws: langtools jaxp jaxws-only
 100 jaxws-only: start-make
 101         @$(call TargetEnter)
 102         @($(CD) $(JAXWS_TOPDIR)/makefiles && $(BUILD_LOG_WRAPPER) $(MAKE) $(MAKE_ARGS) -f BuildJaxws.gmk)
 103         @$(call TargetExit)
 104 
 105 ifeq ($(BUILD_HOTSPOT),true)
 106   hotspot: hotspot-only
 107   hotspot-only: start-make
 108         @$(call TargetEnter)
 109         @($(CD) $(SRC_ROOT)/common/makefiles && $(BUILD_LOG_WRAPPER) $(MAKE) $(MAKE_ARGS) -f HotspotWrapper.gmk)
 110         @$(call TargetExit)
 111 endif
 112 
 113 jdk: langtools hotspot corba jaxp jaxws jdk-only
 114 jdk-only: start-make
 115         @$(call TargetEnter)
 116         @($(CD) $(JDK_TOPDIR)/makefiles && $(BUILD_LOG_WRAPPER) $(MAKE) $(MAKE_ARGS) -f BuildJdk.gmk $(JDK_TARGET))
 117         @$(call TargetExit)
 118 
 119 nashorn: jdk nashorn-only
 120 nashorn-only: start-make
 121         @$(call TargetEnter)
 122         @($(CD) $(NASHORN_TOPDIR)/makefiles && $(BUILD_LOG_WRAPPER) $(MAKE) $(MAKE_ARGS) -f BuildNashorn.gmk)
 123         @$(call TargetExit)
 124 
 125 demos: jdk demos-only
 126 demos-only: start-make
 127         @$(call TargetEnter)
 128         @($(CD) $(JDK_TOPDIR)/makefiles && $(BUILD_LOG_WRAPPER) $(MAKE) $(MAKE_ARGS) -f BuildJdk.gmk demos)
 129         @$(call TargetExit)
 130 
 131 # Note: This double-colon rule is intentional, to support
 132 # custom make file integration.
 133 images:: source-tips demos nashorn images-only
 134 images-only: start-make
 135         @$(call TargetEnter)
 136         @($(CD) $(JDK_TOPDIR)/makefiles && $(BUILD_LOG_WRAPPER) $(MAKE) $(MAKE_ARGS) -f BuildJdk.gmk images)
 137         @$(call TargetExit)
 138 
 139 overlay-images: source-tips demos overlay-images-only
 140 overlay-images-only: start-make
 141         @$(call TargetEnter)
 142         @($(CD) $(JDK_TOPDIR)/makefiles && $(BUILD_LOG_WRAPPER) $(MAKE) $(MAKE_ARGS) -f BuildJdk.gmk overlay-images)
 143         @$(call TargetExit)
 144 
 145 profiles: profiles-oscheck source-tips jdk hotspot profiles-only
 146 profiles-only: start-make
 147         @$(call TargetEnter)
 148         @($(CD) $(JDK_TOPDIR)/makefiles && $(BUILD_LOG_WRAPPER) $(MAKE) $(MAKE_ARGS) -f BuildJdk.gmk profiles)
 149         @$(call TargetExit)
 150 
 151 profiles-oscheck:
 152         ifneq ($(OPENJDK_TARGET_OS), linux)
 153           @echo "Error: The Java SE 8 Compact Profiles are only implemented for Linux at this time" && exit 1
 154         endif
 155 
 156 install: images install-only
 157 install-only: start-make
 158         @$(call TargetEnter)
 159         @($(CD) $(JDK_TOPDIR)/makefiles && $(BUILD_LOG_WRAPPER) $(MAKE) $(MAKE_ARGS) -f BuildJdk.gmk install)
 160         @$(call TargetExit)
 161 
 162 docs: jdk docs-only
 163 docs-only: start-make
 164         @$(call TargetEnter)
 165         @($(CD) $(SRC_ROOT)/common/makefiles/javadoc && $(BUILD_LOG_WRAPPER) $(MAKE) $(MAKE_ARGS) -f Javadoc.gmk docs)
 166         @$(call TargetExit)
 167 
 168 sign-jars: jdk sign-jars-only
 169 sign-jars-only: start-make
 170         @$(call TargetEnter)
 171         @($(CD) $(JDK_TOPDIR)/makefiles && $(BUILD_LOG_WRAPPER) $(MAKE) $(MAKE_ARGS) -f BuildJdk.gmk sign-jars)
 172         @$(call TargetExit)
 173 
 174 bootcycle-images: images bootcycle-images-only
 175 bootcycle-images-only: start-make
 176         @$(ECHO) Boot cycle build step 2: Building a new JDK image using previously built image
 177         @($(CD) $(SRC_ROOT)/common/makefiles && $(BUILD_LOG_WRAPPER) $(MAKE) SPEC=$(dir $(SPEC))bootcycle-spec.gmk images)
 178 
 179 test: images test-only
 180 test-only: start-make
 181         @$(call TargetEnter)
 182         @($(CD) $(SRC_ROOT)/test && $(BUILD_LOG_WRAPPER) $(MAKE) -j1 -k MAKEFLAGS= JTREG="$(JTREG)" JTDIFF="$(JTDIFF)" PRODUCT_HOME="$(JDK_IMAGE_DIR)" ALT_OUTPUTDIR="$(OUTPUT_ROOT)" CONCURRENCY=$(JOBS) $(TEST)) || true
 183         @$(call TargetExit)
 184 
 185 # Stores the tips for each repository. This file is be used when constructing the jdk image and can be
 186 # used to track the exact sources used to build that image.
 187 source-tips: $(OUTPUT_ROOT)/source_tips
 188 $(OUTPUT_ROOT)/source_tips: FRC
 189         @$(MKDIR) -p $(@D)
 190         @$(RM) $@
 191         @$(call GetSourceTips)
 192 
 193 
 194 # Remove everything, except the output from configure.
 195 clean: clean-langtools clean-corba clean-jaxp clean-jaxws clean-hotspot clean-jdk clean-nashorn clean-images clean-overlay-images clean-bootcycle-build clean-docs clean-test
 196         @($(CD) $(OUTPUT_ROOT) && $(RM) -r tmp source_tips build.log* build-trace*.log*)
 197         @$(ECHO) Cleaned all build artifacts.
 198 
 199 # Remove everything, including configure configuration.
 200 # If the output directory was created by configure and now becomes empty, remove it as well.
 201 # FIXME: tmp should not be here, fix ResetTimers instead. And remove spec.sh!
 202 dist-clean: clean
 203         @($(CD) $(OUTPUT_ROOT) && $(RM) -r *spec.gmk config.* configure-arguments Makefile compare.sh spec.sh tmp javacservers)
 204         @$(if $(filter $(CONF_NAME),$(notdir $(OUTPUT_ROOT))), \
 205           if test "x`$(LS) $(OUTPUT_ROOT)`" != x; then \
 206             $(ECHO) "Warning: Not removing non-empty configuration directory for '$(CONF_NAME)'" ; \
 207           else \
 208             ($(CD) $(SRC_ROOT) && $(ECHO) "Removing configuration directory for '$(CONF_NAME)'" && $(RM) -r $(OUTPUT_ROOT)) \
 209           fi \
 210         )
 211         @$(ECHO) Cleaned everything, you will have to re-run configure.
 212 
 213 clean-langtools:
 214         $(call CleanComponent,langtools)
 215 clean-corba:
 216         $(call CleanComponent,corba)
 217 clean-jaxp:
 218         $(call CleanComponent,jaxp)
 219 clean-jaxws:
 220         $(call CleanComponent,jaxws)
 221 clean-hotspot:
 222         $(call CleanComponent,hotspot)
 223 clean-jdk:
 224         $(call CleanComponent,jdk)
 225 clean-nashorn:
 226         $(call CleanComponent,nashorn)
 227 clean-images:
 228         $(call CleanComponent,images)
 229 clean-overlay-images:
 230         $(call CleanComponent,overlay-images)
 231 clean-bootcycle-build:
 232         $(call CleanComponent,bootcycle-build)
 233 clean-docs:
 234         $(call CleanComponent,docs)
 235         $(call CleanComponent,docstemp)
 236 clean-test:
 237         $(call CleanComponent,testoutput)
 238 
 239 .PHONY: langtools corba jaxp jaxws hotspot jdk nashorn images overlay-images install test docs
 240 .PHONY: langtools-only corba-only jaxp-only jaxws-only hotspot-only jdk-only nashorn-only images-only overlay-images-only install-only test-only docs-only
 241 .PHONY: default all clean dist-clean bootcycle-images start-make
 242 .PHONY: clean-langtools clean-corba clean-jaxp clean-jaxws clean-hotspot clean-jdk clean-nashorn clean-images clean-docs clean-test clean-overlay-images clean-bootcycle-build
 243 .PHONY: profiles profiles-only profiles-oscheck
 244 
 245 FRC: # Force target