Makefile 8.5 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
#
# Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License version 2 only, as
# published by the Free Software Foundation.  Oracle designates this
# particular file as subject to the "Classpath" exception as provided
# by Oracle in the LICENSE file that accompanied this code.
#
# This code is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
# version 2 for more details (a copy is included in the LICENSE file that
# accompanied this code).
#
# You should have received a copy of the GNU General Public License version
# 2 along with this work; if not, write to the Free Software Foundation,
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
#
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
# or visit www.oracle.com if you need additional information or have any
# questions.
#

26 27 28
# This must be the first rule
default: all

29 30 31
# Locate this Makefile
ifeq ($(filter /%,$(lastword $(MAKEFILE_LIST))),)
    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 38
# ... and then we can include our helper functions
include $(dir $(makefile_path))/MakeHelpers.gmk
39

40
$(eval $(call ParseLogLevel))
41
$(eval $(call SetupLogging))
42
$(eval $(call ParseConfAndSpec))
43

44 45 46 47
# Setup number of jobs to use. -jN is unfortunately not available for us to parse from the command line,
# hence this workaround.
ifeq ($(JOBS),)
    JOBS=$(NUM_CORES)
48 49 50
endif

ifneq ($(words $(SPEC)),1)
51 52
### We have multiple configurations to build, call make repeatedly
all jdk hotspot jaxws jaxp corba langtools install images clean dist-clean:
53 54
	@$(foreach spec,$(SPEC),($(MAKE) -f $(makefile_path) SPEC=$(spec) $(VERBOSE) VERBOSE=$(VERBOSE) $@ $(MAKE_ARGS)) &&) true

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 67 68
### Clean up from previous run

# Remove any build.log from a previous run, if they exist
69
ifneq (,$(BUILD_LOG))
70 71 72 73 74 75 76
    ifneq (,$(BUILD_LOG_PREVIOUS))
        # Rotate old log
        $(shell $(RM) $(BUILD_LOG_PREVIOUS) 2> /dev/null)
        $(shell $(MV) $(BUILD_LOG) $(BUILD_LOG_PREVIOUS) 2> /dev/null)
    else
        $(shell $(RM) $(BUILD_LOG) 2> /dev/null)
    endif
77 78 79 80 81 82 83 84 85
endif
# Remove any javac server logs and port files. This
# prevents a new make run to reuse the previous servers.
ifneq (,$(JAVAC_SERVERS))
    $(shell mkdir -p $(JAVAC_SERVERS) && rm -rf $(JAVAC_SERVERS)/*)
endif
# Clean out any notifications from the previous build.
$(shell find $(OUTPUT_ROOT) -name "_the.*.notify" $(FIND_DELETE))

86 87 88 89
# Reset the build timers.
$(eval $(call ResetTimers))

### Main targets
90

91 92
all: jdk
	@$(if $(JAVAC_SERVERS),rm -rf $(JAVAC_SERVERS)/*.port)
93
	@$(call AtRootMakeEnd)
94

95 96
langtools: start-make langtools-only
langtools-only:
97
	@$(call MakeStart,langtools,all)
98
	@($(CD) $(LANGTOOLS_TOPDIR)/makefiles && $(BUILD_LOG_WRAPPER) $(MAKE) -j$(JOBS) $(MAKE_ARGS))
99 100
	@$(call MakeFinish,langtools,all)

101 102
corba: langtools corba-only
corba-only:
103
	@$(call MakeStart,corba,all)
104
	@($(CD) $(CORBA_TOPDIR)/makefiles && $(BUILD_LOG_WRAPPER) $(MAKE) -j$(JOBS) $(MAKE_ARGS))
105 106
	@$(call MakeFinish,corba,all)

107 108
jaxp: langtools jaxp-only
jaxp-only:
109
	@$(call MakeStart,jaxp,all)
110
	@($(CD) $(JAXP_TOPDIR)/makefiles && $(BUILD_LOG_WRAPPER) $(MAKE) -j$(JOBS) $(MAKE_ARGS))
111 112
	@$(call MakeFinish,jaxp,all)

113 114
jaxws: langtools jaxp jaxws-only
jaxws-only:
115
	@$(call MakeStart,jaxws,all)
116
	@($(CD) $(JAXWS_TOPDIR)/makefiles && $(BUILD_LOG_WRAPPER) $(MAKE) -j$(JOBS) $(MAKE_ARGS))
117 118
	@$(call MakeFinish,jaxws,all)

119 120
hotspot: langtools hotspot-only
hotspot-only:
121
	@$(call MakeStart,hotspot,all)
122
	@($(CD) $(HOTSPOT_TOPDIR)/make && $(BUILD_LOG_WRAPPER) $(MAKE) -j1 $(HOTSPOT_MAKE_ARGS) $(MAKE_ARGS))
123 124
	@$(call MakeFinish,hotspot,all)

125 126
jdk: langtools corba jaxp jaxws hotspot jdk-only
jdk-only:
127
	@$(call MakeStart,jdk,all)
128
	@($(CD) $(JDK_TOPDIR)/makefiles && $(BUILD_LOG_WRAPPER) $(MAKE) -j$(JOBS) $(MAKE_ARGS))
129 130
	@$(call MakeFinish,jdk,all)

131 132
images: source-tips start-make jdk langtools corba jaxp jaxws hotspot images-only
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 136
	@$(call MakeFinish,jdk-images,$@)
	@$(if $(JAVAC_SERVERS),rm -rf $(JAVAC_SERVERS)/*.port)
137 138
	@$(call AtRootMakeEnd)

139 140 141 142 143
install: source-tips start-make jdk langtools corba jaxp jaxws hotspot install-only
install-only:
	@$(call MakeStart,jdk-images,$@)
	@($(CD) $(JDK_TOPDIR)/makefiles && $(BUILD_LOG_WRAPPER) $(MAKE) -j$(JOBS) $(JDK_MAKE_ARGS) $(MAKE_ARGS) install)
	@$(call MakeFinish,jdk-images,$@)
144 145
	@$(if $(JAVAC_SERVERS),rm -rf $(JAVAC_SERVERS)/*.port)
	@$(call AtRootMakeEnd)
146

147 148 149
start-make:
	@$(call AtRootMakeStart)

150
.PHONY: jdk hotspot jaxws jaxp corba langtools install images start-make
151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166

test: start-make
	@$(call MakeStart,test,$(if $(TEST),$(TEST),all))
	@($(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
	@$(call MakeFinish,test,$(if $(TEST),$(TEST),all))
	@$(call AtRootMakeEnd)
.PHONY: test


# Stores the tips for each repository. This file is be used when constructing the jdk image and can be
# used to track the exact sources used to build that image.
source-tips: $(OUTPUT_ROOT)/source_tips
$(OUTPUT_ROOT)/source_tips: FRC
	@$(MKDIR) -p $(@D)
	@$(RM) $@
	@$(call GetSourceTips)
167 168 169 170


# Remove everything, except the output from configure.
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 173 174 175 176 177 178 179 180 181
	@$(ECHO) Cleaned everything except the build configuration.
.PHONY: clean

# Remove everything, you have to rerun configure.
dist-clean:
	@$(RM) -r $(OUTPUT_ROOT)
	@$(ECHO) Cleaned everything, you will have to re-run configure.
.PHONY: dist-clean

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 184 185 186
                               grep -v langtools | grep -v corba | grep -v jaxp | grep -v jaxws | grep -v hotspot`)
	@$(ECHO) "Cleaned jdk build artifacts (but not langtools,corba,jaxp,jaxws,hotspot nor the build configuration)"
.PHONY: clean

187
endif
188

189 190
# Here are "global" targets, i.e. targets that can be executed without specifying a single configuration.
# If you addd more global targets, please update the fatal-error macro.
191

192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218
help:
	$(info )
	$(info OpenJDK Makefile help)
	$(info =====================)
	$(info )
	$(info Common make targets)
	$(info .  make [all]            # Compile all code but do not create images)
	$(info .  make images           # Create complete j2sdk and j2re images)
	$(info .  make install          # Install the generated images locally)
	$(info .  make clean            # Remove all files generated by make, but not those generated by configure)
	$(info .  make dist-clean       # Remove all files generated by both make and configure)
	$(info .  make help             # Give some help on using make)
	$(info .  make test             # Run tests, default is all tests (see TEST below))
	$(info )
	$(info Useful make variables)
	$(info .  make CONF=            # Build all configurations (note, assignment is empty))
	$(info .  make CONF=<substring> # Build the configuration(s) with a name matching the given substring)
	$(info )
	$(info .  make LOG=<loglevel>   # Change loglevel from warn (default) to the given loglevel)
	$(info .                        # Available loglevels are: warn, info, debug and trace)
	$(info .                        # To see executed command lines, use LOG=info)
	$(info )
	$(info .  make test TEST=<test> # Only run the given test or tests, e.g.)
	$(info .                        # make test TEST="jdk_lang jdk_net")
	$(info )
.PHONY: help
FRC: # Force target