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 must be the first rule 27 default: all 28 29 # Locate this Makefile 30 ifeq ($(filter /%,$(lastword $(MAKEFILE_LIST))),) 31 makefile_path:=$(CURDIR)/$(lastword $(MAKEFILE_LIST)) 32 else 33 makefile_path:=$(lastword $(MAKEFILE_LIST)) 34 endif 35 root_dir:=$(patsubst %/common/makefiles/Makefile,%,$(makefile_path)) 36 37 # ... and then we can include our helper functions 38 include $(dir $(makefile_path))/MakeHelpers.gmk 39 40 $(eval $(call ParseLogLevel)) 41 $(eval $(call SetupLogging)) 42 $(eval $(call ParseConfAndSpec)) 43 44 # Setup number of jobs to use. -jN is unfortunately not available for us to parse from the command line, 45 # hence this workaround. 46 ifeq ($(JOBS),) 47 JOBS=$(NUM_CORES) 48 endif 49 50 ifneq ($(words $(SPEC)),1) 51 ### We have multiple configurations to build, call make repeatedly 52 all jdk hotspot jaxws jaxp corba langtools install images clean dist-clean: 53 @$(foreach spec,$(SPEC),($(MAKE) -f $(makefile_path) SPEC=$(spec) $(VERBOSE) VERBOSE=$(VERBOSE) $@ $(MAKE_ARGS)) &&) true 54 55 .PHONY: all jdk hotspot jaxws jaxp corba langtools install images clean dist-clean 56 57 else 58 ### This is the main part of the Makefile, for the normal case with SPEC specifying a single existing spec.gmk file. 59 60 # Now load the spec 61 include $(SPEC) 62 63 # Load the vital tools for all the makefiles. 64 include $(SRC_ROOT)/common/makefiles/MakeBase.gmk 65 66 ### Clean up from previous run 67 68 # Remove any build.log from a previous run, if they exist 69 ifneq (,$(BUILD_LOG)) 70 ifneq (,$(BUILD_LOG_PREVIOUS)) 71 # Rotate old log 72 $(shell $(RM) $(BUILD_LOG_PREVIOUS) 2> /dev/null) 73 $(shell $(MV) $(BUILD_LOG) $(BUILD_LOG_PREVIOUS) 2> /dev/null) 74 else 75 $(shell $(RM) $(BUILD_LOG) 2> /dev/null) 76 endif 77 endif 78 # Remove any javac server logs and port files. This 79 # prevents a new make run to reuse the previous servers. 80 ifneq (,$(JAVAC_SERVERS)) 81 $(shell mkdir -p $(JAVAC_SERVERS) && rm -rf $(JAVAC_SERVERS)/*) 82 endif 83 # Clean out any notifications from the previous build. 84 $(shell find $(OUTPUT_ROOT) -name "_the.*.notify" $(FIND_DELETE)) 85 86 # Reset the build timers. 87 $(eval $(call ResetTimers)) 88 89 ### Main targets 90 91 all: jdk 92 @$(if $(JAVAC_SERVERS),rm -rf $(JAVAC_SERVERS)/*.port) 93 @$(call AtRootMakeEnd) 94 95 langtools: start-make langtools-only 96 langtools-only: 97 @$(call MakeStart,langtools,all) 98 @($(CD) $(LANGTOOLS_TOPDIR)/makefiles && $(BUILD_LOG_WRAPPER) $(MAKE) -j$(JOBS) $(MAKE_ARGS)) 99 @$(call MakeFinish,langtools,all) 100 101 corba: langtools corba-only 102 corba-only: 103 @$(call MakeStart,corba,all) 104 @($(CD) $(CORBA_TOPDIR)/makefiles && $(BUILD_LOG_WRAPPER) $(MAKE) -j$(JOBS) $(MAKE_ARGS)) 105 @$(call MakeFinish,corba,all) 106 107 jaxp: langtools jaxp-only 108 jaxp-only: 109 @$(call MakeStart,jaxp,all) 110 @($(CD) $(JAXP_TOPDIR)/makefiles && $(BUILD_LOG_WRAPPER) $(MAKE) -j$(JOBS) $(MAKE_ARGS)) 111 @$(call MakeFinish,jaxp,all) 112 113 jaxws: langtools jaxp jaxws-only 114 jaxws-only: 115 @$(call MakeStart,jaxws,all) 116 @($(CD) $(JAXWS_TOPDIR)/makefiles && $(BUILD_LOG_WRAPPER) $(MAKE) -j$(JOBS) $(MAKE_ARGS)) 117 @$(call MakeFinish,jaxws,all) 118 119 hotspot: langtools hotspot-only 120 hotspot-only: 121 @$(call MakeStart,hotspot,all) 122 @($(CD) $(HOTSPOT_TOPDIR)/make && $(BUILD_LOG_WRAPPER) $(MAKE) -j1 $(HOTSPOT_MAKE_ARGS) $(MAKE_ARGS)) 123 @$(call MakeFinish,hotspot,all) 124 125 jdk: langtools corba jaxp jaxws hotspot jdk-only 126 jdk-only: 127 @$(call MakeStart,jdk,all) 128 @($(CD) $(JDK_TOPDIR)/makefiles && $(BUILD_LOG_WRAPPER) $(MAKE) -j$(JOBS) $(MAKE_ARGS)) 129 @$(call MakeFinish,jdk,all) 130 131 images: source-tips start-make jdk langtools corba jaxp jaxws hotspot images-only 132 images-only: 133 @$(call MakeStart,jdk-images,$@) 134 @($(CD) $(JDK_TOPDIR)/makefiles && $(BUILD_LOG_WRAPPER) $(MAKE) -j$(JOBS) $(JDK_MAKE_ARGS) $(MAKE_ARGS) images) 135 @$(call MakeFinish,jdk-images,$@) 136 @$(if $(JAVAC_SERVERS),rm -rf $(JAVAC_SERVERS)/*.port) 137 @$(call AtRootMakeEnd) 138 139 install: source-tips start-make jdk langtools corba jaxp jaxws hotspot install-only 140 install-only: 141 @$(call MakeStart,jdk-images,$@) 142 @($(CD) $(JDK_TOPDIR)/makefiles && $(BUILD_LOG_WRAPPER) $(MAKE) -j$(JOBS) $(JDK_MAKE_ARGS) $(MAKE_ARGS) install) 143 @$(call MakeFinish,jdk-images,$@) 144 @$(if $(JAVAC_SERVERS),rm -rf $(JAVAC_SERVERS)/*.port) 145 @$(call AtRootMakeEnd) 146 147 start-make: 148 @$(call AtRootMakeStart) 149 150 .PHONY: jdk hotspot jaxws jaxp corba langtools install images start-make 151 152 test: start-make 153 @$(call MakeStart,test,$(if $(TEST),$(TEST),all)) 154 @($(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 155 @$(call MakeFinish,test,$(if $(TEST),$(TEST),all)) 156 @$(call AtRootMakeEnd) 157 .PHONY: test 158 159 160 # Stores the tips for each repository. This file is be used when constructing the jdk image and can be 161 # used to track the exact sources used to build that image. 162 source-tips: $(OUTPUT_ROOT)/source_tips 163 $(OUTPUT_ROOT)/source_tips: FRC 164 @$(MKDIR) -p $(@D) 165 @$(RM) $@ 166 @$(call GetSourceTips) 167 168 169 # Remove everything, except the output from configure. 170 clean: 171 @(cd $(OUTPUT_ROOT) && $(RM) -r `$(LS) $(OUTPUT_ROOT) | grep -v spec.gmk | grep -v spec.sh | 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`) 172 @$(ECHO) Cleaned everything except the build configuration. 173 .PHONY: clean 174 175 # Remove everything, you have to rerun configure. 176 dist-clean: 177 @$(RM) -r $(OUTPUT_ROOT) 178 @$(ECHO) Cleaned everything, you will have to re-run configure. 179 .PHONY: dist-clean 180 181 clean-jdk: 182 @(cd $(OUTPUT_ROOT) && $(RM) -r `$(LS) $(OUTPUT_ROOT) | grep -v spec.gmk | grep -v spec.sh | grep -v Makefile | grep -v config.status | grep -v config.log | grep -v config.h | grep -v configure-arguments | \ 183 grep -v langtools | grep -v corba | grep -v jaxp | grep -v jaxws | grep -v hotspot`) 184 @$(ECHO) "Cleaned jdk build artifacts (but not langtools,corba,jaxp,jaxws,hotspot nor the build configuration)" 185 .PHONY: clean 186 187 endif 188 189 # Here are "global" targets, i.e. targets that can be executed without specifying a single configuration. 190 # If you addd more global targets, please update the fatal-error macro. 191 192 help: 193 $(info ) 194 $(info OpenJDK Makefile help) 195 $(info =====================) 196 $(info ) 197 $(info Common make targets) 198 $(info . make [all] # Compile all code but do not create images) 199 $(info . make images # Create complete j2sdk and j2re images) 200 $(info . make install # Install the generated images locally) 201 $(info . make clean # Remove all files generated by make, but not those generated by configure) 202 $(info . make dist-clean # Remove all files generated by both make and configure) 203 $(info . make help # Give some help on using make) 204 $(info . make test # Run tests, default is all tests (see TEST below)) 205 $(info ) 206 $(info Useful make variables) 207 $(info . make CONF= # Build all configurations (note, assignment is empty)) 208 $(info . make CONF=<substring> # Build the configuration(s) with a name matching the given substring) 209 $(info ) 210 $(info . make LOG=<loglevel> # Change loglevel from warn (default) to the given loglevel) 211 $(info . # Available loglevels are: warn, info, debug and trace) 212 $(info . # To see executed command lines, use LOG=info) 213 $(info ) 214 $(info . make test TEST=<test> # Only run the given test or tests, e.g.) 215 $(info . # make test TEST="jdk_lang jdk_net") 216 $(info ) 217 .PHONY: help 218 FRC: # Force target