author | ctornqvi |
Wed, 22 Apr 2015 13:58:28 -0700 | |
changeset 30536 | 8eafd36e9a8d |
parent 29663 | 74ff65003536 |
child 29788 | b581a3d9db41 |
permissions | -rw-r--r-- |
0 | 1 |
# |
29662 | 2 |
# Copyright (c) 2012, 2015, Oracle and/or its affiliates. All rights reserved. |
0 | 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 |
|
5499 | 7 |
# published by the Free Software Foundation. Oracle designates this |
0 | 8 |
# particular file as subject to the "Classpath" exception as provided |
5499 | 9 |
# by Oracle in the LICENSE file that accompanied this code. |
0 | 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 |
# |
|
5499 | 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. |
|
0 | 24 |
# |
25 |
||
29662 | 26 |
################################################################################ |
27 |
# This is the bootstrapping part of the build. This file is included from the |
|
28 |
# top level Makefile, and is responsible for launching the Main.gmk file with |
|
29 |
# the proper make and the proper make arguments. |
|
30 |
################################################################################ |
|
31 |
||
21759 | 32 |
# This must be the first rule |
33 |
default: |
|
29662 | 34 |
.PHONY: default |
17
bb9f330cd95a
6649672: Adjustments to OUTPUTDIR default and mkdirs to avoid empty directory clutter
ohair
parents:
16
diff
changeset
|
35 |
|
21759 | 36 |
# Inclusion of this pseudo-target will cause make to execute this file |
29662 | 37 |
# serially, regardless of -j. |
21759 | 38 |
.NOTPARALLEL: |
9618 | 39 |
|
29662 | 40 |
# If included from the top-level Makefile then topdir is set, but not when |
41 |
# recursively calling ourself with a spec. |
|
42 |
ifeq ($(topdir),) |
|
43 |
topdir := $(strip $(patsubst %/make/, %, $(dir $(lastword $(MAKEFILE_LIST))))) |
|
874
638ddad10e12
6728161: Add SKIP_BOOT_CYCLE feature to create boot jdk and use it during build
ohair
parents:
668
diff
changeset
|
44 |
endif |
638ddad10e12
6728161: Add SKIP_BOOT_CYCLE feature to create boot jdk and use it during build
ohair
parents:
668
diff
changeset
|
45 |
|
29662 | 46 |
# Our helper functions. Will include $(SPEC) if $(HAS_SPEC) is true. |
47 |
include $(topdir)/make/InitSupport.gmk |
|
48 |
||
49 |
# Here are "global" targets, i.e. targets that can be executed without having a configuration. |
|
50 |
# This will define ALL_GLOBAL_TARGETS. |
|
51 |
include $(topdir)/make/Help.gmk |
|
27595
cff167b3bfa2
8065914: Various improvements and cleanup of build system
ihse
parents:
26548
diff
changeset
|
52 |
|
29662 | 53 |
# Extract main targets from Main.gmk. |
54 |
ifneq ($(any_spec_file), ) |
|
29663
74ff65003536
8076123: 9-dev build fail: make/Init.gmk:142: *** multiple target patterns. Stop.
erikj
parents:
29662
diff
changeset
|
55 |
ifeq ($(wildcard $(dir $(any_spec_file))/make-support/module-deps.gmk),) |
29662 | 56 |
# If make-support does not exist, we need to build the genmodules java tool first. |
57 |
$(info Creating data for first make execution in new configuration...) |
|
58 |
ignore_output := $(shell $(MAKE) -r -R -f $(topdir)/make/Main.gmk \ |
|
59 |
-I $(topdir)/make/common SPEC=$(any_spec_file) NO_RECIPES=true FRC) |
|
60 |
$(info Done) |
|
28902
0c09b47449c8
8069064: Various improvements and fixes in build system
ihse
parents:
28286
diff
changeset
|
61 |
endif |
29662 | 62 |
ALL_MAIN_TARGETS := $(shell $(MAKE) -r -R -f $(topdir)/make/Main.gmk \ |
63 |
-I $(topdir)/make/common SPEC=$(any_spec_file) NO_RECIPES=true print-targets) |
|
64 |
else |
|
65 |
# Without at least a single valid configuration, we cannot extract any real |
|
66 |
# targets. To provide a helpful error message about the missing configuration |
|
67 |
# later on, accept whatever targets the user has provided for now. |
|
68 |
ALL_MAIN_TARGETS := $(if $(MAKECMDGOALS), $(MAKECMDGOALS), default) |
|
28902
0c09b47449c8
8069064: Various improvements and fixes in build system
ihse
parents:
28286
diff
changeset
|
69 |
endif |
0c09b47449c8
8069064: Various improvements and fixes in build system
ihse
parents:
28286
diff
changeset
|
70 |
|
29662 | 71 |
# Targets provided by this file. |
72 |
ALL_INIT_TARGETS := reconfigure |
|
73 |
||
74 |
ALL_TARGETS := $(sort $(ALL_GLOBAL_TARGETS) $(ALL_MAIN_TARGETS) $(ALL_INIT_TARGETS)) |
|
75 |
||
76 |
ifneq ($(findstring qp, $(MAKEFLAGS)),) |
|
77 |
############################################################################## |
|
27595
cff167b3bfa2
8065914: Various improvements and cleanup of build system
ihse
parents:
26548
diff
changeset
|
78 |
# When called with -qp, assume an external part (e.g. bash completion) is trying |
29662 | 79 |
# to understand our targets. Just list our targets and do no more checking. |
80 |
############################################################################## |
|
81 |
||
82 |
$(ALL_TARGETS): |
|
83 |
||
84 |
.PHONY: $(ALL_TARGETS) |
|
85 |
||
86 |
else ifeq ($(HAS_SPEC),) |
|
874
638ddad10e12
6728161: Add SKIP_BOOT_CYCLE feature to create boot jdk and use it during build
ohair
parents:
668
diff
changeset
|
87 |
|
29662 | 88 |
############################################################################## |
89 |
# This is the normal case, we have been called from the command line by the |
|
90 |
# user and we need to call ourself back with a proper SPEC. |
|
91 |
############################################################################## |
|
8441 | 92 |
|
29662 | 93 |
$(eval $(call CheckControlVariables)) |
94 |
$(eval $(call CheckDeprecatedEnvironment)) |
|
95 |
$(eval $(call CheckInvalidMakeFlags)) |
|
96 |
||
97 |
$(eval $(call ParseConfCheckOption)) |
|
98 |
||
99 |
# Check that the LOG given is valid, and set LOG_LEVEL, LOG_NOFILE and MAKE_LOG_FLAGS. |
|
100 |
$(eval $(call ParseLogLevel)) |
|
101 |
||
102 |
ifneq ($(findstring $(LOG_LEVEL),info debug trace),) |
|
103 |
$(info Running make as '$(strip $(MAKE) $(MFLAGS) $(COMMAND_LINE_VARIABLES) $(MAKECMDGOALS))') |
|
25854 | 104 |
endif |
105 |
||
29662 | 106 |
# CALLED_TARGETS is the list of targets that the user provided, |
107 |
# or "default" if unspecified. |
|
108 |
CALLED_TARGETS := $(if $(MAKECMDGOALS), $(MAKECMDGOALS), default) |
|
109 |
CALLED_SPEC_TARGETS := $(filter $(ALL_MAIN_TARGETS) $(ALL_INIT_TARGETS), $(CALLED_TARGETS)) |
|
110 |
ifneq ($(CALLED_SPEC_TARGETS),) |
|
111 |
# We have at least one non-global target, which need a SPEC |
|
112 |
$(eval $(call ParseConfAndSpec)) |
|
113 |
# Now SPECS contain 1..N spec files (otherwise ParseConfAndSpec fails) |
|
25854 | 114 |
|
29662 | 115 |
INIT_TARGETS := $(filter $(ALL_INIT_TARGETS), $(CALLED_SPEC_TARGETS)) |
116 |
SEQUENTIAL_TARGETS := $(filter dist-clean clean%, $(CALLED_SPEC_TARGETS)) |
|
117 |
PARALLEL_TARGETS := $(filter-out $(INIT_TARGETS) $(SEQUENTIAL_TARGETS), $(CALLED_SPEC_TARGETS)) |
|
874
638ddad10e12
6728161: Add SKIP_BOOT_CYCLE feature to create boot jdk and use it during build
ohair
parents:
668
diff
changeset
|
118 |
|
29662 | 119 |
# The spec files depend on the autoconf source code. This check makes sure |
120 |
# the configuration is up to date after changes to configure. |
|
121 |
$(SPECS): $(wildcard $(topdir)/common/autoconf/*) |
|
122 |
ifeq ($(CONF_CHECK), fail) |
|
123 |
@echo "Error: The configuration is not up to date for '$(lastword $(subst /, , $(dir $@)))'." |
|
124 |
$(call PrintConfCheckFailed) |
|
125 |
@exit 2 |
|
126 |
else ifeq ($(CONF_CHECK), auto) |
|
127 |
@echo "Note: The configuration is not up to date for '$(lastword $(subst /, , $(dir $@)))'." |
|
128 |
@( cd $(topdir) && \ |
|
129 |
$(MAKE) $(MFLAGS) $(MAKE_LOG_FLAGS) -f $(topdir)/make/Init.gmk SPEC=$@ HAS_SPEC=true \ |
|
130 |
reconfigure ) |
|
131 |
else ifeq ($(CONF_CHECK), ignore) |
|
132 |
# Do nothing |
|
26398
ca1f84f97e20
8057537: Serialize reconfigure and fix make clean-foo foo
erikj
parents:
26128
diff
changeset
|
133 |
endif |
25854 | 134 |
|
29662 | 135 |
# Unless reconfigure is explicitely called, let all targets depend on the spec files to be up to date. |
136 |
ifeq ($(findstring reconfigure, $(CALLED_SPEC_TARGETS)), ) |
|
137 |
$(CALLED_SPEC_TARGETS): $(SPECS) |
|
138 |
endif |
|
874
638ddad10e12
6728161: Add SKIP_BOOT_CYCLE feature to create boot jdk and use it during build
ohair
parents:
668
diff
changeset
|
139 |
|
29662 | 140 |
# The recipe will be run once for every target specified, but we only want to execute the |
141 |
# recipe a single time, hence the TARGET_DONE with a dummy command if true. |
|
142 |
$(ALL_MAIN_TARGETS) $(ALL_INIT_TARGETS): |
|
143 |
@$(if $(TARGET_DONE), \ |
|
144 |
true \ |
|
145 |
, \ |
|
146 |
$(foreach spec, $(SPECS), \ |
|
147 |
( cd $(topdir) && \ |
|
148 |
$(MAKE) $(MFLAGS) $(MAKE_LOG_FLAGS) -j 1 -f $(topdir)/make/Init.gmk \ |
|
149 |
SPEC=$(spec) HAS_SPEC=true \ |
|
150 |
USER_MAKE_VARS="$(USER_MAKE_VARS)" MAKE_LOG_FLAGS=$(MAKE_LOG_FLAGS) \ |
|
151 |
LOG_LEVEL=$(LOG_LEVEL) LOG_NOFILE=$(LOG_NOFILE) \ |
|
152 |
INIT_TARGETS="$(INIT_TARGETS)" SEQUENTIAL_TARGETS="$(SEQUENTIAL_TARGETS)" \ |
|
153 |
PARALLEL_TARGETS="$(PARALLEL_TARGETS)" \ |
|
154 |
main ) && \ |
|
155 |
) true \ |
|
156 |
$(eval TARGET_DONE=true) \ |
|
157 |
) |
|
158 |
||
159 |
.PHONY: $(ALL_MAIN_TARGETS) $(ALL_INIT_TARGETS) |
|
0 | 160 |
|
29662 | 161 |
endif # has $(CALLED_SPEC_TARGETS) |
162 |
||
163 |
else # HAS_SPEC=true |
|
164 |
||
165 |
############################################################################## |
|
166 |
# Now we have a spec. This part provides the "main" target that acts as a |
|
167 |
# trampoline to call the Main.gmk with the value of $(MAKE) found in the spec |
|
168 |
# file. |
|
169 |
############################################################################## |
|
170 |
||
171 |
ifeq ($(LOG_NOFILE), true) |
|
172 |
# Disable log wrapper if LOG=[level,]nofile was given |
|
173 |
override BUILD_LOG_WRAPPER := |
|
174 |
endif |
|
175 |
||
176 |
ifeq ($(OUTPUT_SYNC_SUPPORTED), true) |
|
177 |
OUTPUT_SYNC_FLAG := -O$(OUTPUT_SYNC) |
|
178 |
endif |
|
179 |
||
180 |
$(eval $(call CheckSpecSanity)) |
|
28902
0c09b47449c8
8069064: Various improvements and fixes in build system
ihse
parents:
28286
diff
changeset
|
181 |
|
29662 | 182 |
reconfigure: |
183 |
ifneq ($(CONFIGURE_COMMAND_LINE), ) |
|
184 |
$(ECHO) "Re-running configure using arguments '$(CONFIGURE_COMMAND_LINE)'" |
|
185 |
else |
|
186 |
$(ECHO) "Re-running configure using default settings" |
|
187 |
endif |
|
188 |
( cd $(OUTPUT_ROOT) && PATH="$(ORIGINAL_PATH)" \ |
|
189 |
$(BASH) $(TOPDIR)/configure $(CONFIGURE_COMMAND_LINE) ) |
|
190 |
||
191 |
main-init: |
|
192 |
$(call RotateLogFiles) |
|
193 |
$(BUILD_LOG_WRAPPER) $(PRINTF) "Building target(s) '$(strip \ |
|
194 |
$(INIT_TARGETS) $(SEQUENTIAL_TARGETS) $(PARALLEL_TARGETS) \ |
|
195 |
)' in configuration '$(CONF_NAME)'\n" |
|
196 |
||
197 |
||
198 |
# MAKEOVERRIDES is automatically set and propagated by Make to sub-Make calls. |
|
199 |
# We need to clear it of the init-specific variables. The user-specified |
|
200 |
# variables are explicitely propagated using $(USER_MAKE_VARS). |
|
201 |
main: MAKEOVERRIDES := |
|
0 | 202 |
|
29662 | 203 |
main: $(INIT_TARGETS) main-init |
204 |
ifneq ($(SEQUENTIAL_TARGETS), ) |
|
205 |
# Don't touch build output dir since we might be cleaning. That means |
|
206 |
# no log wrapper. |
|
207 |
( cd $(TOPDIR) && \ |
|
208 |
$(MAKE) $(MAKE_ARGS) -j 1 -f make/Main.gmk $(USER_MAKE_VARS) \ |
|
209 |
$(SEQUENTIAL_TARGETS) \ |
|
210 |
) |
|
211 |
endif |
|
212 |
ifneq ($(PARALLEL_TARGETS), ) |
|
213 |
$(call StartGlobalTimer) |
|
214 |
$(call PrepareSmartJavac) |
|
215 |
( cd $(TOPDIR) && \ |
|
216 |
$(BUILD_LOG_WRAPPER) $(MAKE) $(MAKE_ARGS) $(OUTPUT_SYNC_FLAG) \ |
|
217 |
-j $(JOBS) -f make/Main.gmk $(USER_MAKE_VARS) \ |
|
218 |
$(PARALLEL_TARGETS) \ |
|
219 |
) |
|
220 |
$(call CleanupSmartJavac) |
|
221 |
$(call StopGlobalTimer) |
|
222 |
$(call ReportBuildTimes) |
|
223 |
endif |
|
224 |
$(BUILD_LOG_WRAPPER) $(PRINTF) "Finished building target(s) '$(strip \ |
|
225 |
$(INIT_TARGETS) $(SEQUENTIAL_TARGETS) $(PARALLEL_TARGETS) \ |
|
226 |
)' in configuration '$(CONF_NAME)'\n" |
|
227 |
||
228 |
.PHONY: reconfigure main-init main |
|
229 |
endif |