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 # Default to sane output from make.
  27 # Override with empty string to get insane amount of output.
  28 # Override with -d to get even more insane amount of debugging output.
  29 # Override with "-d -p" to get it all.
  30 VERBOSE=-s
  31 
  32 # Find all environment or command line variables that begin with ALT.
  33 list_alt_overrides_with_origins = $(filter ALT_%=environment ALT_%=command,$(foreach var,$(.VARIABLES),$(var)=$(firstword $(origin $(var)))))
  34 list_alt_overrides=$(subst =command,,$(subst =environment,,$(list_alt_overrides_with_origins)))
  35 ifneq ($(list_alt_overrides),)
  36     $(info You have set the following ALT_ variables:)
  37     $(foreach var,$(list_alt_overrides), $(info $(var)=$($(var))))
  38     $(error Using ALT_ variables is deprecated! Please clean your environment!)
  39 endif
  40 
  41 # The spec.gmk file contains the variables extracted by the configure script.
  42 # It is usually set with SPEC=....spec.gmk on the make command line.
  43 # However if you simply type make from the openjdk source root, it will go looking
  44 # for a spec file, if only one is found, use it. If more than one is found,
  45 # complain. If none is found, request the user to run configure!
  46 SPEC ?= $(wildcard $(CURDIR)/../../build/*/spec.gmk)
  47 
  48 ifeq ($(words $(SPEC)),0)
  49     $(error You must run configure!)
  50 endif
  51 
  52 ifneq ($(words $(SPEC)),1)
  53     ifeq ($(MAKECMDGOALS),all-conf)
  54         SPECS:=$(shell echo $(SPEC) | sed -e 's|$(CURDIR)/build/||g' -e 's|/spec.gmk|\\n|g' -e 's| ||g')
  55         allconf:
  56                 @echo Building configurations:
  57                 @printf "$(SPECS)"
  58                 @$(foreach s,$(SPEC),($(MAKE) SPEC=$s $(VERBOSE) VERBOSE=$(VERBOSE) images) &&) true
  59                 @echo Done building configurations:
  60                 @printf "$(SPECS)"
  61         .PHONY: all-conf
  62     else
  63         $(error Since you have more than one output dir configured under build, \
  64             you have to either run make from the output dir of your choice \
  65             or specify run "make SPEC=build/.../spec.gmk" or run all the build configurations \
  66             using "make all-conf")
  67     endif
  68 else
  69 
  70 # Now load the spec
  71 -include $(SPEC)
  72 
  73 # Load the vital tools for all the makefiles. 
  74 -include $(SRC_ROOT)/common/makefiles/MakeBase.gmk
  75 
  76 # Remove any build.log from a previous run
  77 ifneq (,$(BUILD_LOG))
  78     $(shell $(RM) $(BUILD_LOG))
  79 endif
  80 
  81 # Remove any javac server logs and port files. This
  82 # prevents a new make run to reuse the previous servers.
  83 ifneq (,$(JAVAC_SERVERS))
  84     $(shell mkdir -p $(JAVAC_SERVERS) && rm -rf $(JAVAC_SERVERS)/*)
  85 endif
  86 # Reset the build timers.
  87 $(eval $(call ResetTimers))
  88 # Clean out any notifications from the previous build.
  89 $(shell find $(OUTPUT_ROOT) -name "_the.*.notify" $(FIND_DELETE))
  90 
  91 all: jdk
  92         @$(call StopTimer)
  93         @$(if $(JAVAC_SERVERS),rm -rf $(JAVAC_SERVERS)/*.port)
  94 
  95 langtools: start-timer
  96         @$(call MakeStart,langtools,all)
  97         @($(CD) $(LANGTOOLS_TOPDIR)/makefiles && $(BUILD_LOG_WRAPPER) $(MAKE) -j$(NUM_CORES) $(LANGTOOLS_MAKE_ARGS))
  98         @$(call MakeFinish,langtools,all)
  99 
 100 corba: langtools
 101         @$(call MakeStart,corba,all)
 102         @($(CD) $(CORBA_TOPDIR)/makefiles && $(BUILD_LOG_WRAPPER) $(MAKE) -j$(NUM_CORES) $(CORBA_MAKE_ARGS))
 103         @$(call MakeFinish,corba,all)
 104 
 105 jaxp: langtools
 106         @$(call MakeStart,jaxp,all)
 107         @($(CD) $(JAXP_TOPDIR)/makefiles && $(BUILD_LOG_WRAPPER) $(MAKE) -j$(NUM_CORES) $(CORBA_MAKE_ARGS))
 108         @$(call MakeFinish,jaxp,all)
 109 
 110 jaxws: langtools jaxp
 111         @$(call MakeStart,jaxws,all)
 112         @($(CD) $(JAXWS_TOPDIR)/makefiles && $(BUILD_LOG_WRAPPER) $(MAKE) -j$(NUM_CORES) $(CORBA_MAKE_ARGS))
 113         @$(call MakeFinish,jaxws,all)
 114 
 115 hotspot: langtools
 116         @$(call MakeStart,hotspot,all)
 117         @($(CD) $(HOTSPOT_TOPDIR)/make && $(BUILD_LOG_WRAPPER) $(MAKE) -j1 $(HOTSPOT_MAKE_ARGS))
 118         @$(call MakeFinish,hotspot,all)
 119 
 120 jdk: langtools corba jaxp jaxws hotspot
 121         @$(call MakeStart,jdk,all)
 122         @($(CD) $(JDK_TOPDIR)/makefiles && $(BUILD_LOG_WRAPPER) $(MAKE) -j$(NUM_CORES) $(JDK_MAKE_ARGS))
 123         @$(call MakeFinish,jdk,all)
 124 
 125 images install packages: start-timer jdk langtools corba jaxp jaxws hotspot
 126         @$(call MakeStart,jdk-images,$@)
 127         @($(CD) $(JDK_TOPDIR)/makefiles && $(BUILD_LOG_WRAPPER) $(MAKE) -j$(NUM_CORES) $(JDK_MAKE_ARGS) $@)
 128         @$(call MakeFinish,jdk-images,$@)
 129         @$(call StopTimer)
 130         @$(if $(JAVAC_SERVERS),rm -rf $(JAVAC_SERVERS)/*.port)
 131 
 132 start-timer:
 133         @$(call StartTimer)
 134 
 135 .PHONY: jdk hotspot jaxws jaxp corba langtools install images packages start-timer
 136 
 137 # Remove everything, except the output from configure.
 138 clean:
 139         @(cd $(OUTPUT_ROOT) && $(RM) -r `$(LS) $(OUTPUT_ROOT) | grep -v spec.gmk | grep -v Makefile | grep -v config.status | grep -v config.log | grep -v config.h | grep -v configure-arguments | grep -v "localdevenv.*" | grep -v uncygdrive.exe`)
 140         @$(ECHO) Cleaned everything except the build configuration.
 141 .PHONY: clean
 142 
 143 # Remove everything, you have to rerun configure.
 144 dist-clean:
 145         @$(RM) -r $(OUTPUT_ROOT)
 146         @$(ECHO) Cleaned everything, you will have to re-run configure.
 147 .PHONY: dist-clean
 148 
 149 clean-jdk:
 150         @(cd $(OUTPUT_ROOT) && $(RM) -r `$(LS) $(OUTPUT_ROOT) | grep -v spec.gmk | grep -v Makefile | grep -v config.status | grep -v config.log |  grep -v config.h | grep -v configure-arguments | \
 151                                grep -v langtools | grep -v corba | grep -v jaxp | grep -v jaxws | grep -v hotspot`)
 152         @$(ECHO) "Cleaned jdk build artifacts (but not langtools,corba,jaxp,jaxws,hotspot nor the build configuration)"
 153 .PHONY: clean
 154 
 155 help:
 156         $(info     )
 157         $(info Typical make commands:)
 158         $(info     make)
 159         $(info     make VERBOSE=        # print all commands)
 160         $(info     make VERBOSE="-d -p" # debug make as well)
 161         $(info     make all-conf        # build images for all configurations)
 162         $(info     make clean           # remove build artifacts)
 163         $(info     make dist-clean      # you have to rerun configure)
 164 #       $(info     make test            # run tests)
 165         $(info     make images          # create the jdk and jre images)
 166         $(info     make install         # install the jdk image)
 167 #       $(info     make modules         # EXPERIMENTAL: Migrate JDK into a modularized form!)
 168         $(info     make packages        # create zips and other packages)
 169 
 170 #       $(info     make eclipse_workspace  # Create an Eclipse workspace)
 171 #       $(info     make netbeans_workspace # Create a NetBeans workspace)
 172 #       $(info     make vs_workspace       # Create a Visual Studio workspace)
 173 
 174 .PHONY: help
 175 
 176 endif