author | coleenp |
Thu, 19 Mar 2015 23:33:38 +0000 | |
changeset 30106 | ab720069962d |
parent 29156 | bd932374081c |
permissions | -rw-r--r-- |
13133
701e61c32ece
7182051: Update of latest build-infra Makefiles (missing files)
erikj
parents:
diff
changeset
|
1 |
# |
29156
bd932374081c
8072842: Add support for building native JTReg tests
ihse
parents:
29060
diff
changeset
|
2 |
# Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved. |
13133
701e61c32ece
7182051: Update of latest build-infra Makefiles (missing files)
erikj
parents:
diff
changeset
|
3 |
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
701e61c32ece
7182051: Update of latest build-infra Makefiles (missing files)
erikj
parents:
diff
changeset
|
4 |
# |
701e61c32ece
7182051: Update of latest build-infra Makefiles (missing files)
erikj
parents:
diff
changeset
|
5 |
# This code is free software; you can redistribute it and/or modify it |
701e61c32ece
7182051: Update of latest build-infra Makefiles (missing files)
erikj
parents:
diff
changeset
|
6 |
# under the terms of the GNU General Public License version 2 only, as |
701e61c32ece
7182051: Update of latest build-infra Makefiles (missing files)
erikj
parents:
diff
changeset
|
7 |
# published by the Free Software Foundation. Oracle designates this |
701e61c32ece
7182051: Update of latest build-infra Makefiles (missing files)
erikj
parents:
diff
changeset
|
8 |
# particular file as subject to the "Classpath" exception as provided |
701e61c32ece
7182051: Update of latest build-infra Makefiles (missing files)
erikj
parents:
diff
changeset
|
9 |
# by Oracle in the LICENSE file that accompanied this code. |
701e61c32ece
7182051: Update of latest build-infra Makefiles (missing files)
erikj
parents:
diff
changeset
|
10 |
# |
701e61c32ece
7182051: Update of latest build-infra Makefiles (missing files)
erikj
parents:
diff
changeset
|
11 |
# This code is distributed in the hope that it will be useful, but WITHOUT |
701e61c32ece
7182051: Update of latest build-infra Makefiles (missing files)
erikj
parents:
diff
changeset
|
12 |
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
701e61c32ece
7182051: Update of latest build-infra Makefiles (missing files)
erikj
parents:
diff
changeset
|
13 |
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
701e61c32ece
7182051: Update of latest build-infra Makefiles (missing files)
erikj
parents:
diff
changeset
|
14 |
# version 2 for more details (a copy is included in the LICENSE file that |
701e61c32ece
7182051: Update of latest build-infra Makefiles (missing files)
erikj
parents:
diff
changeset
|
15 |
# accompanied this code). |
701e61c32ece
7182051: Update of latest build-infra Makefiles (missing files)
erikj
parents:
diff
changeset
|
16 |
# |
701e61c32ece
7182051: Update of latest build-infra Makefiles (missing files)
erikj
parents:
diff
changeset
|
17 |
# You should have received a copy of the GNU General Public License version |
701e61c32ece
7182051: Update of latest build-infra Makefiles (missing files)
erikj
parents:
diff
changeset
|
18 |
# 2 along with this work; if not, write to the Free Software Foundation, |
701e61c32ece
7182051: Update of latest build-infra Makefiles (missing files)
erikj
parents:
diff
changeset
|
19 |
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
701e61c32ece
7182051: Update of latest build-infra Makefiles (missing files)
erikj
parents:
diff
changeset
|
20 |
# |
701e61c32ece
7182051: Update of latest build-infra Makefiles (missing files)
erikj
parents:
diff
changeset
|
21 |
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
701e61c32ece
7182051: Update of latest build-infra Makefiles (missing files)
erikj
parents:
diff
changeset
|
22 |
# or visit www.oracle.com if you need additional information or have any |
701e61c32ece
7182051: Update of latest build-infra Makefiles (missing files)
erikj
parents:
diff
changeset
|
23 |
# questions. |
701e61c32ece
7182051: Update of latest build-infra Makefiles (missing files)
erikj
parents:
diff
changeset
|
24 |
# |
701e61c32ece
7182051: Update of latest build-infra Makefiles (missing files)
erikj
parents:
diff
changeset
|
25 |
|
701e61c32ece
7182051: Update of latest build-infra Makefiles (missing files)
erikj
parents:
diff
changeset
|
26 |
################################################################ |
701e61c32ece
7182051: Update of latest build-infra Makefiles (missing files)
erikj
parents:
diff
changeset
|
27 |
# |
701e61c32ece
7182051: Update of latest build-infra Makefiles (missing files)
erikj
parents:
diff
changeset
|
28 |
# This file contains helper functions for the top-level Makefile that does |
20363 | 29 |
# not depend on the spec.gmk file having been read. (The purpose of this |
13133
701e61c32ece
7182051: Update of latest build-infra Makefiles (missing files)
erikj
parents:
diff
changeset
|
30 |
# file is ju to avoid cluttering the top-level Makefile.) |
701e61c32ece
7182051: Update of latest build-infra Makefiles (missing files)
erikj
parents:
diff
changeset
|
31 |
# |
701e61c32ece
7182051: Update of latest build-infra Makefiles (missing files)
erikj
parents:
diff
changeset
|
32 |
################################################################ |
701e61c32ece
7182051: Update of latest build-infra Makefiles (missing files)
erikj
parents:
diff
changeset
|
33 |
|
701e61c32ece
7182051: Update of latest build-infra Makefiles (missing files)
erikj
parents:
diff
changeset
|
34 |
ifndef _MAKEHELPERS_GMK |
701e61c32ece
7182051: Update of latest build-infra Makefiles (missing files)
erikj
parents:
diff
changeset
|
35 |
_MAKEHELPERS_GMK := 1 |
701e61c32ece
7182051: Update of latest build-infra Makefiles (missing files)
erikj
parents:
diff
changeset
|
36 |
|
701e61c32ece
7182051: Update of latest build-infra Makefiles (missing files)
erikj
parents:
diff
changeset
|
37 |
############################## |
701e61c32ece
7182051: Update of latest build-infra Makefiles (missing files)
erikj
parents:
diff
changeset
|
38 |
# Stuff to run at include time |
701e61c32ece
7182051: Update of latest build-infra Makefiles (missing files)
erikj
parents:
diff
changeset
|
39 |
############################## |
701e61c32ece
7182051: Update of latest build-infra Makefiles (missing files)
erikj
parents:
diff
changeset
|
40 |
|
701e61c32ece
7182051: Update of latest build-infra Makefiles (missing files)
erikj
parents:
diff
changeset
|
41 |
# Find out which variables were passed explicitely on the make command line. These |
701e61c32ece
7182051: Update of latest build-infra Makefiles (missing files)
erikj
parents:
diff
changeset
|
42 |
# will be passed on to sub-makes, overriding spec.gmk settings. |
25854 | 43 |
MAKE_ARGS=$(foreach var,$(subst =command,,$(filter %=command,$(foreach var,$(.VARIABLES),$(var)=$(firstword $(origin $(var)))))),$(var)="$($(var))") |
13133
701e61c32ece
7182051: Update of latest build-infra Makefiles (missing files)
erikj
parents:
diff
changeset
|
44 |
|
701e61c32ece
7182051: Update of latest build-infra Makefiles (missing files)
erikj
parents:
diff
changeset
|
45 |
list_alt_overrides_with_origins=$(filter ALT_%=environment ALT_%=command,$(foreach var,$(.VARIABLES),$(var)=$(firstword $(origin $(var))))) |
701e61c32ece
7182051: Update of latest build-infra Makefiles (missing files)
erikj
parents:
diff
changeset
|
46 |
list_alt_overrides=$(subst =command,,$(subst =environment,,$(list_alt_overrides_with_origins))) |
701e61c32ece
7182051: Update of latest build-infra Makefiles (missing files)
erikj
parents:
diff
changeset
|
47 |
|
14111 | 48 |
# Store the build times in this directory. |
27560 | 49 |
BUILDTIMESDIR=$(OUTPUT_ROOT)/make-support/build-times |
14111 | 50 |
|
51 |
# Global targets are possible to run either with or without a SPEC. The prototypical |
|
20363 | 52 |
# global target is "help". |
22031 | 53 |
global_targets=help |
14111 | 54 |
|
13133
701e61c32ece
7182051: Update of latest build-infra Makefiles (missing files)
erikj
parents:
diff
changeset
|
55 |
############################## |
701e61c32ece
7182051: Update of latest build-infra Makefiles (missing files)
erikj
parents:
diff
changeset
|
56 |
# Functions |
701e61c32ece
7182051: Update of latest build-infra Makefiles (missing files)
erikj
parents:
diff
changeset
|
57 |
############################## |
701e61c32ece
7182051: Update of latest build-infra Makefiles (missing files)
erikj
parents:
diff
changeset
|
58 |
|
14111 | 59 |
define CheckEnvironment |
20363 | 60 |
# Find all environment or command line variables that begin with ALT. |
61 |
$(if $(list_alt_overrides), |
|
62 |
@$(PRINTF) "\nWARNING: You have the following ALT_ variables set:\n" |
|
63 |
@$(PRINTF) "$(foreach var,$(list_alt_overrides),$(var)=$$$(var))\n" |
|
64 |
@$(PRINTF) "ALT_ variables are deprecated and will be ignored. Please clean your environment.\n\n" |
|
65 |
) |
|
14111 | 66 |
endef |
67 |
||
68 |
### Functions for timers |
|
69 |
||
70 |
# Record starting time for build of a sub repository. |
|
71 |
define RecordStartTime |
|
20363 | 72 |
$(MKDIR) -p $(BUILDTIMESDIR) |
73 |
$(DATE) '+%Y %m %d %H %M %S' | $(NAWK) '{ print $$1,$$2,$$3,$$4,$$5,$$6,($$4*3600+$$5*60+$$6) }' > $(BUILDTIMESDIR)/build_time_start_$1 |
|
74 |
$(DATE) '+%Y-%m-%d %H:%M:%S' > $(BUILDTIMESDIR)/build_time_start_$1_human_readable |
|
14111 | 75 |
endef |
76 |
||
77 |
# Record ending time and calculate the difference and store it in a |
|
78 |
# easy to read format. Handles builds that cross midnight. Expects |
|
20363 | 79 |
# that a build will never take 24 hours or more. |
14111 | 80 |
define RecordEndTime |
20363 | 81 |
$(DATE) '+%Y %m %d %H %M %S' | $(NAWK) '{ print $$1,$$2,$$3,$$4,$$5,$$6,($$4*3600+$$5*60+$$6) }' > $(BUILDTIMESDIR)/build_time_end_$1 |
82 |
$(DATE) '+%Y-%m-%d %H:%M:%S' > $(BUILDTIMESDIR)/build_time_end_$1_human_readable |
|
83 |
$(ECHO) `$(CAT) $(BUILDTIMESDIR)/build_time_start_$1` `$(CAT) $(BUILDTIMESDIR)/build_time_end_$1` $1 | \ |
|
84 |
$(NAWK) '{ F=$$7; T=$$14; if (F > T) { T+=3600*24 }; D=T-F; H=int(D/3600); \ |
|
85 |
M=int((D-H*3600)/60); S=D-H*3600-M*60; printf("%02d:%02d:%02d %s\n",H,M,S,$$15); }' \ |
|
86 |
> $(BUILDTIMESDIR)/build_time_diff_$1 |
|
14111 | 87 |
endef |
88 |
||
89 |
# Find all build_time_* files and print their contents in a list sorted |
|
90 |
# on the name of the sub repository. |
|
91 |
define ReportBuildTimes |
|
20363 | 92 |
$(BUILD_LOG_WRAPPER) $(PRINTF) -- "----- Build times -------\nStart %s\nEnd %s\n%s\n%s\n-------------------------\n" \ |
93 |
"`$(CAT) $(BUILDTIMESDIR)/build_time_start_TOTAL_human_readable`" \ |
|
94 |
"`$(CAT) $(BUILDTIMESDIR)/build_time_end_TOTAL_human_readable`" \ |
|
95 |
"`$(LS) $(BUILDTIMESDIR)/build_time_diff_* | $(GREP) -v _TOTAL | $(XARGS) $(CAT) | $(SORT) -k 2`" \ |
|
96 |
"`$(CAT) $(BUILDTIMESDIR)/build_time_diff_TOTAL`" |
|
14111 | 97 |
endef |
98 |
||
99 |
define ResetAllTimers |
|
20363 | 100 |
$$(shell $(MKDIR) -p $(BUILDTIMESDIR) && $(RM) $(BUILDTIMESDIR)/build_time_*) |
14111 | 101 |
endef |
102 |
||
103 |
define StartGlobalTimer |
|
20363 | 104 |
$(call RecordStartTime,TOTAL) |
14111 | 105 |
endef |
106 |
||
107 |
define StopGlobalTimer |
|
20363 | 108 |
$(call RecordEndTime,TOTAL) |
14111 | 109 |
endef |
110 |
||
111 |
### Functions for managing makefile structure (start/end of makefile and individual targets) |
|
112 |
||
113 |
# Do not indent this function, this will add whitespace at the start which the caller won't handle |
|
114 |
define GetRealTarget |
|
25854 | 115 |
$(strip $(if $(findstring main-wrapper, $(MAKECMDGOALS)), $(MAIN_TARGETS), \ |
116 |
$(if $(MAKECMDGOALS),$(MAKECMDGOALS),default))) |
|
14111 | 117 |
endef |
118 |
||
119 |
# Do not indent this function, this will add whitespace at the start which the caller won't handle |
|
120 |
define LastGoal |
|
121 |
$(strip $(lastword $(call GetRealTarget))) |
|
122 |
endef |
|
123 |
||
124 |
# Check if the current target is the final target, as specified by |
|
125 |
# the user on the command line. If so, call AtRootMakeEnd. |
|
126 |
define CheckIfMakeAtEnd |
|
20363 | 127 |
# Check if the current target is the last goal |
128 |
$(if $(filter $@,$(call LastGoal)),$(call AtMakeEnd)) |
|
129 |
# If the target is 'foo-only', check if our goal was stated as 'foo' |
|
130 |
$(if $(filter $@,$(call LastGoal)-only),$(call AtMakeEnd)) |
|
14111 | 131 |
endef |
132 |
||
133 |
# Hook to be called when starting to execute a top-level target |
|
134 |
define TargetEnter |
|
25854 | 135 |
$(PRINTF) "## Starting $(patsubst %-only,%,$@)\n" |
20363 | 136 |
$(call RecordStartTime,$(patsubst %-only,%,$@)) |
14111 | 137 |
endef |
138 |
||
139 |
# Hook to be called when finish executing a top-level target |
|
140 |
define TargetExit |
|
20363 | 141 |
$(call RecordEndTime,$(patsubst %-only,%,$@)) |
25854 | 142 |
$(PRINTF) "## Finished $(patsubst %-only,%,$@) (build time %s)\n\n" \ |
20363 | 143 |
"`$(CAT) $(BUILDTIMESDIR)/build_time_diff_$(patsubst %-only,%,$@) | $(CUT) -f 1 -d ' '`" |
14111 | 144 |
endef |
145 |
||
146 |
# Hook to be called as the very first thing when running a normal build |
|
147 |
define AtMakeStart |
|
20363 | 148 |
$(if $(findstring --jobserver,$(MAKEFLAGS)),$(error make -j is not supported, use make JOBS=n)) |
149 |
$(call CheckEnvironment) |
|
25854 | 150 |
$(BUILD_LOG_WRAPPER) $(PRINTF) $(LOG_INFO) "Running make as '$(MAKE) $(MFLAGS) $(MAKE_ARGS)'\n" |
151 |
$(BUILD_LOG_WRAPPER) $(PRINTF) "Building $(PRODUCT_NAME) for target '$(call GetRealTarget)' in configuration '$(CONF_NAME)'\n\n" |
|
20363 | 152 |
$(call StartGlobalTimer) |
14111 | 153 |
endef |
154 |
||
155 |
# Hook to be called as the very last thing for targets that are "top level" targets |
|
156 |
define AtMakeEnd |
|
20363 | 157 |
[ -f $(SJAVAC_SERVER_DIR)/server.port ] && echo Stopping sjavac server && $(TOUCH) $(SJAVAC_SERVER_DIR)/server.port.stop; true |
158 |
$(call StopGlobalTimer) |
|
159 |
$(call ReportBuildTimes) |
|
25854 | 160 |
@$(PRINTF) "\nFinished building $(PRODUCT_NAME) for target '$(call GetRealTarget)'\n" |
20363 | 161 |
$(call CheckEnvironment) |
14111 | 162 |
endef |
163 |
||
164 |
### Functions for parsing and setting up make options from command-line |
|
165 |
||
166 |
define FatalError |
|
20363 | 167 |
# If the user specificed a "global" target (e.g. 'help'), do not exit but continue running |
168 |
$$(if $$(filter-out $(global_targets),$$(call GetRealTarget)),$$(error Cannot continue)) |
|
13133
701e61c32ece
7182051: Update of latest build-infra Makefiles (missing files)
erikj
parents:
diff
changeset
|
169 |
endef |
701e61c32ece
7182051: Update of latest build-infra Makefiles (missing files)
erikj
parents:
diff
changeset
|
170 |
|
701e61c32ece
7182051: Update of latest build-infra Makefiles (missing files)
erikj
parents:
diff
changeset
|
171 |
define ParseLogLevel |
20363 | 172 |
ifeq ($$(origin VERBOSE),undefined) |
173 |
# Setup logging according to LOG (but only if VERBOSE is not given) |
|
14379
b449aa34783e
8003274: build-infra: Makefile changes needed for sjavac
tbell
parents:
14111
diff
changeset
|
174 |
|
20363 | 175 |
# If the "nofile" argument is given, act on it and strip it away |
176 |
ifneq ($$(findstring nofile,$$(LOG)),) |
|
177 |
# Reset the build log wrapper, regardless of other values |
|
178 |
override BUILD_LOG_WRAPPER= |
|
179 |
# COMMA is defined in spec.gmk, but that is not included yet |
|
180 |
COMMA=, |
|
181 |
# First try to remove ",nofile" if it exists |
|
182 |
LOG_STRIPPED1=$$(subst $$(COMMA)nofile,,$$(LOG)) |
|
183 |
# Otherwise just remove "nofile" |
|
184 |
LOG_STRIPPED2=$$(subst nofile,,$$(LOG_STRIPPED1)) |
|
185 |
# We might have ended up with a leading comma. Remove it |
|
186 |
LOG_STRIPPED3=$$(strip $$(patsubst $$(COMMA)%,%,$$(LOG_STRIPPED2))) |
|
187 |
LOG_LEVEL:=$$(LOG_STRIPPED3) |
|
188 |
else |
|
189 |
LOG_LEVEL:=$$(LOG) |
|
190 |
endif |
|
13697 | 191 |
|
20363 | 192 |
ifeq ($$(LOG_LEVEL),) |
193 |
# Set LOG to "warn" as default if not set (and no VERBOSE given) |
|
194 |
override LOG_LEVEL=warn |
|
195 |
endif |
|
196 |
ifeq ($$(LOG_LEVEL),warn) |
|
197 |
VERBOSE=-s |
|
198 |
else ifeq ($$(LOG_LEVEL),info) |
|
199 |
VERBOSE=-s |
|
200 |
else ifeq ($$(LOG_LEVEL),debug) |
|
201 |
VERBOSE= |
|
202 |
else ifeq ($$(LOG_LEVEL),trace) |
|
203 |
VERBOSE= |
|
13133
701e61c32ece
7182051: Update of latest build-infra Makefiles (missing files)
erikj
parents:
diff
changeset
|
204 |
else |
20363 | 205 |
$$(info Error: LOG must be one of: warn, info, debug or trace.) |
206 |
$$(eval $$(call FatalError)) |
|
207 |
endif |
|
208 |
else |
|
209 |
# Provide resonable interpretations of LOG_LEVEL if VERBOSE is given. |
|
210 |
ifeq ($(VERBOSE),) |
|
211 |
LOG_LEVEL:=debug |
|
212 |
else |
|
213 |
LOG_LEVEL:=warn |
|
13133
701e61c32ece
7182051: Update of latest build-infra Makefiles (missing files)
erikj
parents:
diff
changeset
|
214 |
endif |
20363 | 215 |
ifneq ($$(LOG),) |
216 |
# We have both a VERBOSE and a LOG argument. This is OK only if this is a repeated call by ourselves, |
|
217 |
# but complain if this is the top-level make call. |
|
218 |
ifeq ($$(MAKELEVEL),0) |
|
219 |
$$(info Cannot use LOG=$$(LOG) and VERBOSE=$$(VERBOSE) at the same time. Choose one.) |
|
220 |
$$(eval $$(call FatalError)) |
|
221 |
endif |
|
222 |
endif |
|
223 |
endif |
|
13133
701e61c32ece
7182051: Update of latest build-infra Makefiles (missing files)
erikj
parents:
diff
changeset
|
224 |
endef |
701e61c32ece
7182051: Update of latest build-infra Makefiles (missing files)
erikj
parents:
diff
changeset
|
225 |
|
701e61c32ece
7182051: Update of latest build-infra Makefiles (missing files)
erikj
parents:
diff
changeset
|
226 |
define ParseConfAndSpec |
20363 | 227 |
ifneq ($$(filter-out $(global_targets),$$(call GetRealTarget)),) |
228 |
# If we only have global targets, no need to bother with SPEC or CONF |
|
229 |
ifneq ($$(origin SPEC),undefined) |
|
230 |
# We have been given a SPEC, check that it works out properly |
|
231 |
ifneq ($$(origin CONF),undefined) |
|
232 |
# We also have a CONF argument. This is OK only if this is a repeated call by ourselves, |
|
233 |
# but complain if this is the top-level make call. |
|
234 |
ifeq ($$(MAKELEVEL),0) |
|
27595
cff167b3bfa2
8065914: Various improvements and cleanup of build system
ihse
parents:
27000
diff
changeset
|
235 |
$$(info Error: Cannot use CONF=$$(CONF) and SPEC=$$(SPEC) at the same time. Choose one.) |
20363 | 236 |
$$(eval $$(call FatalError)) |
237 |
endif |
|
238 |
endif |
|
27595
cff167b3bfa2
8065914: Various improvements and cleanup of build system
ihse
parents:
27000
diff
changeset
|
239 |
ifeq ($$(wildcard $$(SPEC)),) |
cff167b3bfa2
8065914: Various improvements and cleanup of build system
ihse
parents:
27000
diff
changeset
|
240 |
$$(info Error: Cannot locate spec.gmk, given by SPEC=$$(SPEC).) |
cff167b3bfa2
8065914: Various improvements and cleanup of build system
ihse
parents:
27000
diff
changeset
|
241 |
$$(eval $$(call FatalError)) |
cff167b3bfa2
8065914: Various improvements and cleanup of build system
ihse
parents:
27000
diff
changeset
|
242 |
endif |
20363 | 243 |
# ... OK, we're satisfied, we'll use this SPEC later on |
244 |
else |
|
245 |
# Find all spec.gmk files in the build output directory |
|
246 |
output_dir=$$(root_dir)/build |
|
247 |
all_spec_files=$$(wildcard $$(output_dir)/*/spec.gmk) |
|
248 |
ifeq ($$(all_spec_files),) |
|
27595
cff167b3bfa2
8065914: Various improvements and cleanup of build system
ihse
parents:
27000
diff
changeset
|
249 |
$$(info Error: No configurations found for $$(root_dir).) |
cff167b3bfa2
8065914: Various improvements and cleanup of build system
ihse
parents:
27000
diff
changeset
|
250 |
$$(info Please run 'bash configure' to create a configuration.) |
20363 | 251 |
$$(eval $$(call FatalError)) |
252 |
endif |
|
253 |
# Extract the configuration names from the path |
|
254 |
all_confs=$$(patsubst %/spec.gmk,%,$$(patsubst $$(output_dir)/%,%,$$(all_spec_files))) |
|
13133
701e61c32ece
7182051: Update of latest build-infra Makefiles (missing files)
erikj
parents:
diff
changeset
|
255 |
|
20363 | 256 |
ifneq ($$(origin CONF),undefined) |
257 |
# User have given a CONF= argument. |
|
258 |
ifeq ($$(CONF),) |
|
259 |
# If given CONF=, match all configurations |
|
260 |
matching_confs=$$(strip $$(all_confs)) |
|
261 |
else |
|
262 |
# Otherwise select those that contain the given CONF string |
|
263 |
matching_confs=$$(strip $$(foreach var,$$(all_confs),$$(if $$(findstring $$(CONF),$$(var)),$$(var)))) |
|
264 |
endif |
|
265 |
ifeq ($$(matching_confs),) |
|
27595
cff167b3bfa2
8065914: Various improvements and cleanup of build system
ihse
parents:
27000
diff
changeset
|
266 |
$$(info Error: No configurations found matching CONF=$$(CONF).) |
cff167b3bfa2
8065914: Various improvements and cleanup of build system
ihse
parents:
27000
diff
changeset
|
267 |
$$(info Available configurations in $$(output_dir):) |
20363 | 268 |
$$(foreach var,$$(all_confs),$$(info * $$(var))) |
269 |
$$(eval $$(call FatalError)) |
|
270 |
else |
|
271 |
ifeq ($$(words $$(matching_confs)),1) |
|
272 |
$$(info Building '$$(matching_confs)' (matching CONF=$$(CONF))) |
|
273 |
else |
|
27595
cff167b3bfa2
8065914: Various improvements and cleanup of build system
ihse
parents:
27000
diff
changeset
|
274 |
$$(info Building target '$(call GetRealTarget)' in these configurations (matching CONF=$$(CONF)):) |
20363 | 275 |
$$(foreach var,$$(matching_confs),$$(info * $$(var))) |
276 |
endif |
|
277 |
endif |
|
14111 | 278 |
|
20363 | 279 |
# Create a SPEC definition. This will contain the path to one or more spec.gmk files. |
280 |
SPEC=$$(addsuffix /spec.gmk,$$(addprefix $$(output_dir)/,$$(matching_confs))) |
|
281 |
else |
|
282 |
# No CONF or SPEC given, check the available configurations |
|
283 |
ifneq ($$(words $$(all_spec_files)),1) |
|
27595
cff167b3bfa2
8065914: Various improvements and cleanup of build system
ihse
parents:
27000
diff
changeset
|
284 |
$$(info Error: No CONF given, but more than one configuration found.) |
cff167b3bfa2
8065914: Various improvements and cleanup of build system
ihse
parents:
27000
diff
changeset
|
285 |
$$(info Available configurations in $$(output_dir):) |
20363 | 286 |
$$(foreach var,$$(all_confs),$$(info * $$(var))) |
27595
cff167b3bfa2
8065914: Various improvements and cleanup of build system
ihse
parents:
27000
diff
changeset
|
287 |
$$(info Please retry building with CONF=<config pattern> (or SPEC=<specfile>).) |
20363 | 288 |
$$(eval $$(call FatalError)) |
289 |
endif |
|
14111 | 290 |
|
20363 | 291 |
# We found exactly one configuration, use it |
292 |
SPEC=$$(strip $$(all_spec_files)) |
|
293 |
endif |
|
13133
701e61c32ece
7182051: Update of latest build-infra Makefiles (missing files)
erikj
parents:
diff
changeset
|
294 |
endif |
20363 | 295 |
endif |
13133
701e61c32ece
7182051: Update of latest build-infra Makefiles (missing files)
erikj
parents:
diff
changeset
|
296 |
endef |
701e61c32ece
7182051: Update of latest build-infra Makefiles (missing files)
erikj
parents:
diff
changeset
|
297 |
|
14111 | 298 |
### Convenience functions from Main.gmk |
13133
701e61c32ece
7182051: Update of latest build-infra Makefiles (missing files)
erikj
parents:
diff
changeset
|
299 |
|
29156
bd932374081c
8072842: Add support for building native JTReg tests
ihse
parents:
29060
diff
changeset
|
300 |
# Run the tests specified by $1. |
bd932374081c
8072842: Add support for building native JTReg tests
ihse
parents:
29060
diff
changeset
|
301 |
define RunTests |
bd932374081c
8072842: Add support for building native JTReg tests
ihse
parents:
29060
diff
changeset
|
302 |
($(CD) $(SRC_ROOT)/test && $(MAKE) $(MAKE_ARGS) -j1 -k MAKEFLAGS= \ |
bd932374081c
8072842: Add support for building native JTReg tests
ihse
parents:
29060
diff
changeset
|
303 |
JT_HOME=$(JT_HOME) PRODUCT_HOME=$(JDK_IMAGE_DIR) \ |
bd932374081c
8072842: Add support for building native JTReg tests
ihse
parents:
29060
diff
changeset
|
304 |
TEST_IMAGE_DIR=$(TEST_IMAGE_DIR) \ |
bd932374081c
8072842: Add support for building native JTReg tests
ihse
parents:
29060
diff
changeset
|
305 |
ALT_OUTPUTDIR=$(OUTPUT_ROOT) CONCURRENCY=$(JOBS) $1) || true |
bd932374081c
8072842: Add support for building native JTReg tests
ihse
parents:
29060
diff
changeset
|
306 |
endef |
bd932374081c
8072842: Add support for building native JTReg tests
ihse
parents:
29060
diff
changeset
|
307 |
|
27560 | 308 |
# Cleans the dir given as $1 |
309 |
define CleanDir |
|
25854 | 310 |
@$(PRINTF) "Cleaning $(strip $1) build artifacts ..." |
20363 | 311 |
@($(CD) $(OUTPUT_ROOT) && $(RM) -r $1) |
312 |
@$(PRINTF) " done\n" |
|
13697 | 313 |
endef |
314 |
||
29156
bd932374081c
8072842: Add support for building native JTReg tests
ihse
parents:
29060
diff
changeset
|
315 |
define CleanTest |
bd932374081c
8072842: Add support for building native JTReg tests
ihse
parents:
29060
diff
changeset
|
316 |
@$(PRINTF) "Cleaning test $(strip $1) ..." |
bd932374081c
8072842: Add support for building native JTReg tests
ihse
parents:
29060
diff
changeset
|
317 |
@$(RM) -r $(SUPPORT_OUTPUTDIR)/test/$(strip $(subst -,/,$1)) |
bd932374081c
8072842: Add support for building native JTReg tests
ihse
parents:
29060
diff
changeset
|
318 |
@$(PRINTF) " done\n" |
bd932374081c
8072842: Add support for building native JTReg tests
ihse
parents:
29060
diff
changeset
|
319 |
endef |
bd932374081c
8072842: Add support for building native JTReg tests
ihse
parents:
29060
diff
changeset
|
320 |
|
27560 | 321 |
define Clean-gensrc |
322 |
@$(PRINTF) "Cleaning gensrc $(if $1,for $(strip $1) )..." |
|
323 |
@$(RM) -r $(SUPPORT_OUTPUTDIR)/gensrc/$(strip $1) |
|
324 |
@$(RM) -r $(SUPPORT_OUTPUTDIR)/gensrc_no_docs/$(strip $1) |
|
325 |
@$(PRINTF) " done\n" |
|
326 |
endef |
|
327 |
||
328 |
define Clean-java |
|
329 |
@$(PRINTF) "Cleaning java $(if $1,for $(strip $1) )..." |
|
330 |
@$(RM) -r $(JDK_OUTPUTDIR)/modules/$(strip $1) |
|
331 |
@$(RM) -r $(SUPPORT_OUTPUTDIR)/misc/$(strip $1) |
|
332 |
@$(PRINTF) " done\n" |
|
333 |
@$(PRINTF) "Cleaning headers $(if $1,for $(strip $1)) ..." |
|
334 |
@$(RM) -r $(SUPPORT_OUTPUTDIR)/headers/$(strip $1) |
|
335 |
@$(PRINTF) " done\n" |
|
336 |
endef |
|
337 |
||
338 |
define Clean-native |
|
339 |
@$(PRINTF) "Cleaning native $(if $1,for $(strip $1) )..." |
|
340 |
@$(RM) -r $(SUPPORT_OUTPUTDIR)/native/$(strip $1) |
|
341 |
@$(RM) -r $(SUPPORT_OUTPUTDIR)/modules_libs/$(strip $1) |
|
342 |
@$(RM) -r $(SUPPORT_OUTPUTDIR)/modules_libs-stripped/$(strip $1) |
|
343 |
@$(RM) -r $(SUPPORT_OUTPUTDIR)/modules_cmds/$(strip $1) |
|
344 |
@$(RM) -r $(SUPPORT_OUTPUTDIR)/modules_cmds-stripped/$(strip $1) |
|
345 |
@$(PRINTF) " done\n" |
|
346 |
endef |
|
347 |
||
348 |
define Clean-include |
|
349 |
@$(PRINTF) "Cleaning include $(if $1,for $(strip $1) )..." |
|
350 |
@$(RM) -r $(SUPPORT_OUTPUTDIR)/modules_include/$(strip $1) |
|
351 |
@$(PRINTF) " done\n" |
|
352 |
endef |
|
353 |
||
354 |
define CleanModule |
|
355 |
$(call Clean-gensrc, $1) |
|
356 |
$(call Clean-java, $1) |
|
357 |
$(call Clean-native, $1) |
|
358 |
$(call Clean-include, $1) |
|
359 |
endef |
|
360 |
||
361 |
||
26116
f051bd253364
8055095: Improve "do nothing" incremental build performance after modularized source code integration
erikj
parents:
25854
diff
changeset
|
362 |
################################################################################ |
f051bd253364
8055095: Improve "do nothing" incremental build performance after modularized source code integration
erikj
parents:
25854
diff
changeset
|
363 |
|
27560 | 364 |
MAKE_TOPDIR_LIST := $(JDK_TOPDIR) $(CORBA_TOPDIR) $(LANGTOOLS_TOPDIR) |
365 |
MAKE_MAKEDIR_LIST := make |
|
366 |
||
367 |
# Helper macro for DeclareRecipesForPhase |
|
368 |
# Declare a recipe for calling the module and phase specific makefile. |
|
369 |
# If there are multiple makefiles to call, create a rule for each topdir |
|
28356 | 370 |
# that contains a makefile with the target $module-$suffix-$repodir, |
27560 | 371 |
# (i.e: java.base-gensrc-jdk) |
372 |
# Normally there is only one makefile, and the target will just be |
|
373 |
# $module-$suffix |
|
374 |
# Param 1: Name of list to add targets to |
|
375 |
# Param 2: Module name |
|
376 |
# Param 3: Topdir |
|
377 |
define DeclareRecipeForModuleMakefile |
|
378 |
ifeq ($$($1_MULTIPLE_MAKEFILES), true) |
|
379 |
$2-$$($1_TARGET_SUFFIX): $2-$$($1_TARGET_SUFFIX)-$$(notdir $3) |
|
380 |
$1 += $2-$$($1_TARGET_SUFFIX)-$$(notdir $3) |
|
26116
f051bd253364
8055095: Improve "do nothing" incremental build performance after modularized source code integration
erikj
parents:
25854
diff
changeset
|
381 |
|
27560 | 382 |
$2-$$($1_TARGET_SUFFIX)-$$(notdir $3): |
383 |
else |
|
384 |
$2-$$($1_TARGET_SUFFIX): |
|
385 |
endif |
|
386 |
$(ECHO) $(LOG_INFO) "Building $$@" |
|
387 |
ifeq ($$($1_USE_WRAPPER), true) |
|
388 |
+($(CD) $(SRC_ROOT)/make && $(MAKE) $(MAKE_ARGS) \ |
|
389 |
-f ModuleWrapper.gmk \ |
|
390 |
$$(addprefix -I, $$(wildcard $$(addprefix $3/, $(MAKE_MAKEDIR_LIST)) \ |
|
391 |
$$(addsuffix /$$($1_MAKE_SUBDIR), $$(addprefix $3/, $(MAKE_MAKEDIR_LIST))))) \ |
|
392 |
MODULE=$2 MAKEFILE_PREFIX=$$($1_FILE_PREFIX)) |
|
393 |
else |
|
394 |
+($(CD) $$(dir $$(firstword $$(wildcard $$(patsubst %, \ |
|
395 |
$3/%/$$($1_MAKE_SUBDIR)/$$($1_FILE_PREFIX)-$2.gmk, $(MAKE_MAKEDIR_LIST))))) \ |
|
396 |
&& $(MAKE) $(MAKE_ARGS) \ |
|
397 |
-f $$($1_FILE_PREFIX)-$2.gmk \ |
|
398 |
$$(addprefix -I, $$(wildcard $$(addprefix $3/, $(MAKE_MAKEDIR_LIST)) \ |
|
29060
baa66d2b7e95
8073498: Enhance GensrcProperties.gmk to allow an alternative source root
erikj
parents:
28356
diff
changeset
|
399 |
$$(addsuffix /$$($1_MAKE_SUBDIR), $$(addprefix $3/, $(MAKE_MAKEDIR_LIST))))) \ |
27560 | 400 |
MODULE=$2) |
401 |
endif |
|
402 |
||
403 |
endef |
|
26116
f051bd253364
8055095: Improve "do nothing" incremental build performance after modularized source code integration
erikj
parents:
25854
diff
changeset
|
404 |
|
27560 | 405 |
# Helper macro for DeclareRecipesForPhase |
406 |
# Param 1: Name of list to add targets to |
|
407 |
# Param 2: Module name |
|
408 |
define DeclareRecipesForPhaseAndModule |
|
409 |
$1_$2_TOPDIRS := $$(strip $$(sort $$(foreach d, $(MAKE_TOPDIR_LIST), \ |
|
410 |
$$(patsubst $$d/%, $$d, $$(filter $$d/%, \ |
|
411 |
$$(wildcard $$(patsubst %, %/$$($1_MAKE_SUBDIR)/$$($1_FILE_PREFIX)-$2.gmk, \ |
|
412 |
$$(foreach s, $(MAKE_MAKEDIR_LIST), \ |
|
413 |
$$(addsuffix /$$s, $(MAKE_TOPDIR_LIST)))))))))) |
|
414 |
||
415 |
# Only declare recipes if there are makefiles to call |
|
416 |
ifneq ($$($1_$2_TOPDIRS), ) |
|
417 |
$$(foreach d, $$($1_$2_TOPDIRS), \ |
|
418 |
$$(eval $$(call DeclareRecipeForModuleMakefile,$1,$2,$$d))) |
|
419 |
$1 += $2-$$($1_TARGET_SUFFIX) |
|
420 |
$1_MODULES += $2 |
|
421 |
endif |
|
422 |
endef |
|
423 |
||
424 |
# Declare recipes for a specific module and build phase if there are makefiles |
|
425 |
# present for the specific combination. |
|
426 |
# Param 1: Name of list to add targets to |
|
427 |
# Named params: |
|
428 |
# TARGET_SUFFIX : Suffix of target to create for recipe |
|
429 |
# MAKE_SUBDIR : Subdir for this build phase |
|
430 |
# FILE_PREFIX : File prefix for this build phase |
|
431 |
# USE_WRAPPER : Set to true to use ModuleWrapper.gmk |
|
432 |
# CHECK_MODULES : List of modules to try |
|
433 |
# MULTIPLE_MAKEFILES : Set to true to handle makefils for the same module in |
|
434 |
# phase in multiple repos |
|
435 |
# Exported variables: |
|
436 |
# $1_MODULES : All modules that had rules generated |
|
437 |
# $1_TARGETS : All targets generated |
|
438 |
define DeclareRecipesForPhase |
|
439 |
$(foreach i,2 3 4 5 6 7, $(if $($i),$(strip $1)_$(strip $($i)))$(NEWLINE)) |
|
440 |
$(if $(8),$(error Internal makefile error: Too many arguments to \ |
|
441 |
DeclareRecipesForPhase, please update MakeHelper.gmk)) |
|
442 |
||
443 |
$$(foreach m, $$($(strip $1)_CHECK_MODULES), \ |
|
444 |
$$(eval $$(call DeclareRecipesForPhaseAndModule,$(strip $1),$$m))) |
|
445 |
||
446 |
$(strip $1)_TARGETS := $$($(strip $1)) |
|
26116
f051bd253364
8055095: Improve "do nothing" incremental build performance after modularized source code integration
erikj
parents:
25854
diff
changeset
|
447 |
endef |
f051bd253364
8055095: Improve "do nothing" incremental build performance after modularized source code integration
erikj
parents:
25854
diff
changeset
|
448 |
|
f051bd253364
8055095: Improve "do nothing" incremental build performance after modularized source code integration
erikj
parents:
25854
diff
changeset
|
449 |
################################################################################ |
f051bd253364
8055095: Improve "do nothing" incremental build performance after modularized source code integration
erikj
parents:
25854
diff
changeset
|
450 |
|
13133
701e61c32ece
7182051: Update of latest build-infra Makefiles (missing files)
erikj
parents:
diff
changeset
|
451 |
endif # _MAKEHELPERS_GMK |