author | erikj |
Mon, 14 Jan 2013 15:30:22 +0100 | |
changeset 15072 | 71f6bf463347 |
parent 15053 | 64278cb83950 |
child 16583 | f29d60d73e42 |
permissions | -rw-r--r-- |
13133
701e61c32ece
7182051: Update of latest build-infra Makefiles (missing files)
erikj
parents:
diff
changeset
|
1 |
# |
701e61c32ece
7182051: Update of latest build-infra Makefiles (missing files)
erikj
parents:
diff
changeset
|
2 |
# Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. |
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 |
701e61c32ece
7182051: Update of latest build-infra Makefiles (missing files)
erikj
parents:
diff
changeset
|
29 |
# not depend on the spec.gmk file having been read. (The purpose of this |
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. |
701e61c32ece
7182051: Update of latest build-infra Makefiles (missing files)
erikj
parents:
diff
changeset
|
43 |
MAKE_ARGS=$(foreach var,$(subst =command,,$(filter %=command,$(foreach var,$(.VARIABLES),$(var)=$(firstword $(origin $(var)))))),$(var)=$($(var))) |
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. |
49 |
BUILDTIMESDIR=$(OUTPUT_ROOT)/tmp/buildtimes |
|
50 |
||
51 |
# Global targets are possible to run either with or without a SPEC. The prototypical |
|
52 |
# global target is "help". |
|
15053
64278cb83950
8005549: build-infra: Merge NewMakefile.gmk and common/makefiles/Makefile
erikj
parents:
14462
diff
changeset
|
53 |
global_targets=help jprt% bridgeBuild |
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 |
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 |
) |
|
66 |
endef |
|
67 |
||
68 |
### Functions for timers |
|
69 |
||
70 |
# Record starting time for build of a sub repository. |
|
71 |
define RecordStartTime |
|
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 |
|
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 |
|
79 |
# that a build will never take 24 hours or more. |
|
80 |
define RecordEndTime |
|
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 |
|
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 |
|
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`" |
|
97 |
endef |
|
98 |
||
99 |
define ResetAllTimers |
|
100 |
$$(shell $(MKDIR) -p $(BUILDTIMESDIR) && $(RM) $(BUILDTIMESDIR)/build_time_*) |
|
101 |
endef |
|
102 |
||
103 |
define StartGlobalTimer |
|
104 |
$(call RecordStartTime,TOTAL) |
|
105 |
endef |
|
106 |
||
107 |
define StopGlobalTimer |
|
108 |
$(call RecordEndTime,TOTAL) |
|
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 |
|
15053
64278cb83950
8005549: build-infra: Merge NewMakefile.gmk and common/makefiles/Makefile
erikj
parents:
14462
diff
changeset
|
115 |
$(strip $(if $(MAKECMDGOALS),$(MAKECMDGOALS),default)) |
14111 | 116 |
endef |
117 |
||
118 |
# Do not indent this function, this will add whitespace at the start which the caller won't handle |
|
119 |
define LastGoal |
|
120 |
$(strip $(lastword $(call GetRealTarget))) |
|
121 |
endef |
|
122 |
||
123 |
# Check if the current target is the final target, as specified by |
|
124 |
# the user on the command line. If so, call AtRootMakeEnd. |
|
125 |
define CheckIfMakeAtEnd |
|
126 |
# Check if the current target is the last goal |
|
127 |
$(if $(filter $@,$(call LastGoal)),$(call AtMakeEnd)) |
|
128 |
# If the target is 'foo-only', check if our goal was stated as 'foo' |
|
15053
64278cb83950
8005549: build-infra: Merge NewMakefile.gmk and common/makefiles/Makefile
erikj
parents:
14462
diff
changeset
|
129 |
$(if $(filter $@,$(call LastGoal)-only),$(call AtMakeEnd)) |
14111 | 130 |
endef |
131 |
||
132 |
# Hook to be called when starting to execute a top-level target |
|
133 |
define TargetEnter |
|
134 |
$(BUILD_LOG_WRAPPER) $(PRINTF) "## Starting $(patsubst %-only,%,$@)\n" |
|
135 |
$(call RecordStartTime,$(patsubst %-only,%,$@)) |
|
136 |
endef |
|
137 |
||
138 |
# Hook to be called when finish executing a top-level target |
|
139 |
define TargetExit |
|
140 |
$(call RecordEndTime,$(patsubst %-only,%,$@)) |
|
141 |
$(BUILD_LOG_WRAPPER) $(PRINTF) "## Finished $(patsubst %-only,%,$@) (build time %s)\n\n" \ |
|
14462
5731c2f9d507
8003327: build-infra: "/bin/sh: : cannot execute" on solaris
tbell
parents:
14379
diff
changeset
|
142 |
"`$(CAT) $(BUILDTIMESDIR)/build_time_diff_$(patsubst %-only,%,$@) | $(CUT) -f 1 -d ' '`" |
14111 | 143 |
$(call CheckIfMakeAtEnd) |
144 |
endef |
|
145 |
||
146 |
# Hook to be called as the very first thing when running a normal build |
|
147 |
define AtMakeStart |
|
148 |
$(if $(findstring --jobserver,$(MAKEFLAGS)),$(error make -j is not supported, use make JOBS=n)) |
|
149 |
$(call CheckEnvironment) |
|
150 |
@$(PRINTF) $(LOG_INFO) "Running make as '$(MAKE) $(MFLAGS) $(MAKE_ARGS)'\n" |
|
151 |
@$(PRINTF) "Building $(PRODUCT_NAME) for target '$(call GetRealTarget)' in configuration '$(CONF_NAME)'\n\n" |
|
152 |
$(call StartGlobalTimer) |
|
153 |
endef |
|
154 |
||
155 |
# Hook to be called as the very last thing for targets that are "top level" targets |
|
156 |
define AtMakeEnd |
|
14379
b449aa34783e
8003274: build-infra: Makefile changes needed for sjavac
tbell
parents:
14111
diff
changeset
|
157 |
[ -f $(SJAVAC_SERVER_DIR)/server.port ] && echo Stopping sjavac server && $(TOUCH) $(SJAVAC_SERVER_DIR)/server.port.stop; true |
14111 | 158 |
$(call StopGlobalTimer) |
159 |
$(call ReportBuildTimes) |
|
160 |
@$(PRINTF) "Finished building $(PRODUCT_NAME) for target '$(call GetRealTarget)'\n" |
|
161 |
$(call CheckEnvironment) |
|
162 |
endef |
|
163 |
||
164 |
### Functions for parsing and setting up make options from command-line |
|
165 |
||
166 |
define FatalError |
|
13133
701e61c32ece
7182051: Update of latest build-infra Makefiles (missing files)
erikj
parents:
diff
changeset
|
167 |
# If the user specificed a "global" target (e.g. 'help'), do not exit but continue running |
14111 | 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 |
701e61c32ece
7182051: Update of latest build-infra Makefiles (missing files)
erikj
parents:
diff
changeset
|
172 |
ifeq ($$(origin VERBOSE),undefined) |
701e61c32ece
7182051: Update of latest build-infra Makefiles (missing files)
erikj
parents:
diff
changeset
|
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 |
|
b449aa34783e
8003274: build-infra: Makefile changes needed for sjavac
tbell
parents:
14111
diff
changeset
|
175 |
# If the "nofile" argument is given, act on it and strip it away |
13697 | 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 |
override LOG:=$$(LOG_STRIPPED3) |
|
188 |
endif |
|
189 |
||
13133
701e61c32ece
7182051: Update of latest build-infra Makefiles (missing files)
erikj
parents:
diff
changeset
|
190 |
ifeq ($$(LOG),) |
701e61c32ece
7182051: Update of latest build-infra Makefiles (missing files)
erikj
parents:
diff
changeset
|
191 |
# Set LOG to "warn" as default if not set (and no VERBOSE given) |
13697 | 192 |
override LOG=warn |
13133
701e61c32ece
7182051: Update of latest build-infra Makefiles (missing files)
erikj
parents:
diff
changeset
|
193 |
endif |
701e61c32ece
7182051: Update of latest build-infra Makefiles (missing files)
erikj
parents:
diff
changeset
|
194 |
ifeq ($$(LOG),warn) |
701e61c32ece
7182051: Update of latest build-infra Makefiles (missing files)
erikj
parents:
diff
changeset
|
195 |
VERBOSE=-s |
701e61c32ece
7182051: Update of latest build-infra Makefiles (missing files)
erikj
parents:
diff
changeset
|
196 |
else ifeq ($$(LOG),info) |
14111 | 197 |
VERBOSE=-s |
13133
701e61c32ece
7182051: Update of latest build-infra Makefiles (missing files)
erikj
parents:
diff
changeset
|
198 |
else ifeq ($$(LOG),debug) |
701e61c32ece
7182051: Update of latest build-infra Makefiles (missing files)
erikj
parents:
diff
changeset
|
199 |
VERBOSE= |
701e61c32ece
7182051: Update of latest build-infra Makefiles (missing files)
erikj
parents:
diff
changeset
|
200 |
else ifeq ($$(LOG),trace) |
14111 | 201 |
VERBOSE= |
13133
701e61c32ece
7182051: Update of latest build-infra Makefiles (missing files)
erikj
parents:
diff
changeset
|
202 |
else |
701e61c32ece
7182051: Update of latest build-infra Makefiles (missing files)
erikj
parents:
diff
changeset
|
203 |
$$(info Error: LOG must be one of: warn, info, debug or trace.) |
14111 | 204 |
$$(eval $$(call FatalError)) |
13133
701e61c32ece
7182051: Update of latest build-infra Makefiles (missing files)
erikj
parents:
diff
changeset
|
205 |
endif |
701e61c32ece
7182051: Update of latest build-infra Makefiles (missing files)
erikj
parents:
diff
changeset
|
206 |
else |
701e61c32ece
7182051: Update of latest build-infra Makefiles (missing files)
erikj
parents:
diff
changeset
|
207 |
ifneq ($$(LOG),) |
701e61c32ece
7182051: Update of latest build-infra Makefiles (missing files)
erikj
parents:
diff
changeset
|
208 |
# We have both a VERBOSE and a LOG argument. This is OK only if this is a repeated call by ourselves, |
701e61c32ece
7182051: Update of latest build-infra Makefiles (missing files)
erikj
parents:
diff
changeset
|
209 |
# but complain if this is the top-level make call. |
701e61c32ece
7182051: Update of latest build-infra Makefiles (missing files)
erikj
parents:
diff
changeset
|
210 |
ifeq ($$(MAKELEVEL),0) |
701e61c32ece
7182051: Update of latest build-infra Makefiles (missing files)
erikj
parents:
diff
changeset
|
211 |
$$(info Cannot use LOG=$$(LOG) and VERBOSE=$$(VERBOSE) at the same time. Choose one.) |
14111 | 212 |
$$(eval $$(call FatalError)) |
13133
701e61c32ece
7182051: Update of latest build-infra Makefiles (missing files)
erikj
parents:
diff
changeset
|
213 |
endif |
701e61c32ece
7182051: Update of latest build-infra Makefiles (missing files)
erikj
parents:
diff
changeset
|
214 |
endif |
701e61c32ece
7182051: Update of latest build-infra Makefiles (missing files)
erikj
parents:
diff
changeset
|
215 |
endif |
701e61c32ece
7182051: Update of latest build-infra Makefiles (missing files)
erikj
parents:
diff
changeset
|
216 |
endef |
701e61c32ece
7182051: Update of latest build-infra Makefiles (missing files)
erikj
parents:
diff
changeset
|
217 |
|
701e61c32ece
7182051: Update of latest build-infra Makefiles (missing files)
erikj
parents:
diff
changeset
|
218 |
define ParseConfAndSpec |
14111 | 219 |
ifneq ($$(filter-out $(global_targets),$$(call GetRealTarget)),) |
220 |
# If we only have global targets, no need to bother with SPEC or CONF |
|
221 |
ifneq ($$(origin SPEC),undefined) |
|
222 |
# We have been given a SPEC, check that it works out properly |
|
223 |
ifeq ($$(wildcard $$(SPEC)),) |
|
224 |
$$(info Cannot locate spec.gmk, given by SPEC=$$(SPEC)) |
|
225 |
$$(eval $$(call FatalError)) |
|
13133
701e61c32ece
7182051: Update of latest build-infra Makefiles (missing files)
erikj
parents:
diff
changeset
|
226 |
endif |
14111 | 227 |
ifneq ($$(origin CONF),undefined) |
228 |
# We also have a CONF argument. This is OK only if this is a repeated call by ourselves, |
|
229 |
# but complain if this is the top-level make call. |
|
230 |
ifeq ($$(MAKELEVEL),0) |
|
231 |
$$(info Cannot use CONF=$$(CONF) and SPEC=$$(SPEC) at the same time. Choose one.) |
|
232 |
$$(eval $$(call FatalError)) |
|
13133
701e61c32ece
7182051: Update of latest build-infra Makefiles (missing files)
erikj
parents:
diff
changeset
|
233 |
endif |
701e61c32ece
7182051: Update of latest build-infra Makefiles (missing files)
erikj
parents:
diff
changeset
|
234 |
endif |
14111 | 235 |
# ... OK, we're satisfied, we'll use this SPEC later on |
13133
701e61c32ece
7182051: Update of latest build-infra Makefiles (missing files)
erikj
parents:
diff
changeset
|
236 |
else |
14111 | 237 |
# Find all spec.gmk files in the build output directory |
238 |
output_dir=$$(root_dir)/build |
|
239 |
all_spec_files=$$(wildcard $$(output_dir)/*/spec.gmk) |
|
240 |
ifeq ($$(all_spec_files),) |
|
241 |
$$(info No configurations found for $$(root_dir)! Please run configure to create a configuration.) |
|
242 |
$$(eval $$(call FatalError)) |
|
13133
701e61c32ece
7182051: Update of latest build-infra Makefiles (missing files)
erikj
parents:
diff
changeset
|
243 |
endif |
14111 | 244 |
# Extract the configuration names from the path |
245 |
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
|
246 |
|
14111 | 247 |
ifneq ($$(origin CONF),undefined) |
248 |
# User have given a CONF= argument. |
|
249 |
ifeq ($$(CONF),) |
|
250 |
# If given CONF=, match all configurations |
|
251 |
matching_confs=$$(strip $$(all_confs)) |
|
252 |
else |
|
253 |
# Otherwise select those that contain the given CONF string |
|
254 |
matching_confs=$$(strip $$(foreach var,$$(all_confs),$$(if $$(findstring $$(CONF),$$(var)),$$(var)))) |
|
255 |
endif |
|
256 |
ifeq ($$(matching_confs),) |
|
257 |
$$(info No configurations found matching CONF=$$(CONF)) |
|
258 |
$$(info Available configurations:) |
|
259 |
$$(foreach var,$$(all_confs),$$(info * $$(var))) |
|
260 |
$$(eval $$(call FatalError)) |
|
261 |
else |
|
262 |
ifeq ($$(words $$(matching_confs)),1) |
|
263 |
$$(info Building '$$(matching_confs)' (matching CONF=$$(CONF))) |
|
264 |
else |
|
265 |
$$(info Building target '$(call GetRealTarget)' in the following configurations (matching CONF=$$(CONF)):) |
|
266 |
$$(foreach var,$$(matching_confs),$$(info * $$(var))) |
|
267 |
endif |
|
268 |
endif |
|
269 |
||
270 |
# Create a SPEC definition. This will contain the path to one or more spec.gmk files. |
|
271 |
SPEC=$$(addsuffix /spec.gmk,$$(addprefix $$(output_dir)/,$$(matching_confs))) |
|
272 |
else |
|
273 |
# No CONF or SPEC given, check the available configurations |
|
274 |
ifneq ($$(words $$(all_spec_files)),1) |
|
275 |
$$(info No CONF given, but more than one configuration found in $$(output_dir).) |
|
276 |
$$(info Available configurations:) |
|
277 |
$$(foreach var,$$(all_confs),$$(info * $$(var))) |
|
278 |
$$(info Please retry building with CONF=<config pattern> (or SPEC=<specfile>)) |
|
279 |
$$(eval $$(call FatalError)) |
|
280 |
endif |
|
281 |
||
282 |
# We found exactly one configuration, use it |
|
283 |
SPEC=$$(strip $$(all_spec_files)) |
|
284 |
endif |
|
13133
701e61c32ece
7182051: Update of latest build-infra Makefiles (missing files)
erikj
parents:
diff
changeset
|
285 |
endif |
701e61c32ece
7182051: Update of latest build-infra Makefiles (missing files)
erikj
parents:
diff
changeset
|
286 |
endif |
701e61c32ece
7182051: Update of latest build-infra Makefiles (missing files)
erikj
parents:
diff
changeset
|
287 |
endef |
701e61c32ece
7182051: Update of latest build-infra Makefiles (missing files)
erikj
parents:
diff
changeset
|
288 |
|
14111 | 289 |
### Convenience functions from Main.gmk |
13133
701e61c32ece
7182051: Update of latest build-infra Makefiles (missing files)
erikj
parents:
diff
changeset
|
290 |
|
13697 | 291 |
# Cleans the component given as $1 |
292 |
define CleanComponent |
|
293 |
@$(PRINTF) "Cleaning $1 build artifacts ..." |
|
294 |
@($(CD) $(OUTPUT_ROOT) && $(RM) -r $1) |
|
295 |
@$(PRINTF) " done\n" |
|
296 |
endef |
|
297 |
||
13133
701e61c32ece
7182051: Update of latest build-infra Makefiles (missing files)
erikj
parents:
diff
changeset
|
298 |
endif # _MAKEHELPERS_GMK |