Skip to content
This repository was archived by the owner on Oct 22, 2020. It is now read-only.

Commit 02e0c6f

Browse files
author
ihse
committed
8076060: Improve make bootstrap process
Reviewed-by: erikj
1 parent 8a43cf0 commit 02e0c6f

15 files changed

+970
-746
lines changed

Makefile

+28-186
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#
2-
# Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
2+
# Copyright (c) 2012, 2015, Oracle and/or its affiliates. All rights reserved.
33
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
#
55
# This code is free software; you can redistribute it and/or modify it
@@ -23,200 +23,42 @@
2323
# questions.
2424
#
2525

26-
# This must be the first rule
27-
default:
26+
###
27+
### This file is just a very small wrapper needed to run the real make/Init.gmk.
28+
### It also performs some sanity checks on make.
29+
###
2830

29-
# Inclusion of this pseudo-target will cause make to execute this file
30-
# serially, regardless of -j. Recursively called makefiles will not be
31-
# affected, however. This is required for correct dependency management.
32-
.NOTPARALLEL:
33-
34-
# The shell code below will be executed on /usr/ccs/bin/make on Solaris, but not in GNU make.
31+
# The shell code below will be executed on /usr/ccs/bin/make on Solaris, but not in GNU Make.
3532
# /usr/ccs/bin/make lacks basically every other flow control mechanism.
36-
.TEST_FOR_NON_GNUMAKE:sh=echo You are not using GNU make/gmake, this is a requirement. Check your path. 1>&2 && exit 1
37-
38-
# Assume we have GNU make, but check version.
39-
ifeq ($(strip $(foreach v, 3.81% 3.82% 4.%, $(filter $v, $(MAKE_VERSION)))), )
40-
$(error This version of GNU Make is too low ($(MAKE_VERSION)). Check your path, or upgrade to 3.81 or newer.)
41-
endif
33+
.TEST_FOR_NON_GNUMAKE:sh=echo You are not using GNU Make/gmake, this is a requirement. Check your path. 1>&2 && exit 1
4234

43-
# Locate this Makefile
44-
ifeq ($(filter /%,$(lastword $(MAKEFILE_LIST))),)
45-
makefile_path:=$(CURDIR)/$(lastword $(MAKEFILE_LIST))
46-
else
47-
makefile_path:=$(lastword $(MAKEFILE_LIST))
35+
# The .FEATURES variable is likely to be unique for GNU Make.
36+
ifeq ($(.FEATURES), )
37+
$(info Error: '$(MAKE)' does not seem to be GNU Make, which is a requirement.)
38+
$(info Check your path, or upgrade to GNU Make 3.81 or newer.)
39+
$(error Cannot continue)
4840
endif
49-
root_dir:=$(patsubst %/,%,$(dir $(makefile_path)))
5041

51-
ifeq ($(MAIN_TARGETS), )
52-
COMMAND_LINE_VARIABLES:=$(subst =command,,$(filter %=command,$(foreach var,$(.VARIABLES),$(var)=$(firstword $(origin $(var))))))
53-
MAKE_CONTROL_VARIABLES:=LOG CONF SPEC JOBS TEST IGNORE_OLD_CONFIG
54-
UNKNOWN_COMMAND_LINE_VARIABLES:=$(strip $(filter-out $(MAKE_CONTROL_VARIABLES), $(COMMAND_LINE_VARIABLES)))
55-
ifneq ($(UNKNOWN_COMMAND_LINE_VARIABLES), )
56-
$(info Note: Command line contains non-control variables: $(UNKNOWN_COMMAND_LINE_VARIABLES).)
57-
$(info Make sure it is not mistyped, and that you intend to override this variable.)
58-
$(info 'make help' will list known control variables)
59-
endif
42+
# Assume we have GNU Make, but check version.
43+
ifeq ($(strip $(foreach v, 3.81% 3.82% 4.%, $(filter $v, $(MAKE_VERSION)))), )
44+
$(info Error: This version of GNU Make is too low ($(MAKE_VERSION)).)
45+
$(info Check your path, or upgrade to GNU Make 3.81 or newer.)
46+
$(error Cannot continue)
6047
endif
6148

62-
ifneq ($(findstring qp,$(MAKEFLAGS)),)
63-
# When called with -qp, assume an external part (e.g. bash completion) is trying
64-
# to understand our targets.
65-
# Duplication of global targets, needed before ParseConfAndSpec in case we have
66-
# no configurations.
67-
help:
68-
# If both CONF and SPEC are unset, look for all available configurations by
69-
# setting CONF to the empty string.
70-
ifeq ($(SPEC), )
71-
CONF?=
72-
endif
49+
# In Cygwin, the MAKE variable gets prepended with the current directory if the
50+
# make executable is called using a Windows mixed path (c:/cygwin/bin/make.exe).
51+
ifneq ($(findstring :, $(MAKE)), )
52+
MAKE := $(patsubst $(CURDIR)%, %, $(patsubst $(CURDIR)/%, %, $(MAKE)))
7353
endif
7454

75-
# ... and then we can include our helper functions
76-
include $(root_dir)/make/MakeHelpers.gmk
77-
78-
$(eval $(call ParseLogLevel))
79-
$(eval $(call ParseConfAndSpec))
80-
81-
# Now determine if we have zero, one or several configurations to build.
82-
ifeq ($(SPEC),)
83-
# Since we got past ParseConfAndSpec, we must be building a global target. Do nothing.
55+
# Locate this Makefile
56+
ifeq ($(filter /%, $(lastword $(MAKEFILE_LIST))),)
57+
makefile_path := $(CURDIR)/$(strip $(lastword $(MAKEFILE_LIST)))
8458
else
85-
# In Cygwin, the MAKE variable gets messed up if the make executable is called with
86-
# a Windows mixed path (c:/cygwin/bin/make.exe). If that's the case, fix it by removing
87-
# the prepended root_dir.
88-
ifneq ($(findstring :, $(MAKE)), )
89-
MAKE := $(patsubst $(root_dir)%, %, $(MAKE))
90-
endif
91-
92-
# We are potentially building multiple configurations.
93-
# First, find out the valid targets
94-
# Run the makefile with an arbitrary SPEC using -p -q (quiet dry-run and dump rules) to find
95-
# available PHONY targets. Use this list as valid targets to pass on to the repeated calls.
96-
all_phony_targets := $(sort $(filter-out $(global_targets), $(strip $(shell \
97-
cd $(root_dir)/make && $(MAKE) -f Main.gmk -p -q FRC SPEC=$(firstword $(SPEC)) \
98-
-I $(root_dir)/make/common | grep "^.PHONY:" | head -n 1 | cut -d " " -f 2-))))
99-
100-
# Loop through the configurations and call the main-wrapper for each one. The wrapper
101-
# target will execute with a single configuration loaded.
102-
$(all_phony_targets):
103-
@$(if $(TARGET_RUN),,\
104-
$(foreach spec,$(SPEC),\
105-
(cd $(root_dir) && $(MAKE) SPEC=$(spec) MAIN_TARGETS="$(call GetRealTarget)" \
106-
$(VERBOSE) VERBOSE=$(VERBOSE) LOG_LEVEL=$(LOG_LEVEL) main-wrapper) &&) true)
107-
@echo > /dev/null
108-
$(eval TARGET_RUN=true)
109-
110-
.PHONY: $(all_phony_targets)
111-
112-
ifneq ($(MAIN_TARGETS), )
113-
# The wrapper target was called so we now have a single configuration. Load the spec file
114-
# and call the real Main.gmk.
115-
include $(SPEC)
116-
include $(SRC_ROOT)/make/common/MakeBase.gmk
117-
118-
### Clean up from previous run
119-
# Remove any build.log from a previous run, if they exist
120-
ifneq (,$(BUILD_LOG))
121-
ifneq (,$(BUILD_LOG_PREVIOUS))
122-
# Rotate old log
123-
$(shell $(RM) $(BUILD_LOG_PREVIOUS) 2> /dev/null)
124-
$(shell $(MV) $(BUILD_LOG) $(BUILD_LOG_PREVIOUS) 2> /dev/null)
125-
else
126-
$(shell $(RM) $(BUILD_LOG) 2> /dev/null)
127-
endif
128-
$(shell $(RM) $(OUTPUT_ROOT)/build-trace-time.log 2> /dev/null)
129-
endif
130-
# Remove any javac server logs and port files. This
131-
# prevents a new make run to reuse the previous servers.
132-
ifneq (,$(SJAVAC_SERVER_DIR))
133-
$(shell $(MKDIR) -p $(SJAVAC_SERVER_DIR) && $(RM) -rf $(SJAVAC_SERVER_DIR)/*)
134-
endif
135-
136-
# Split out the targets requiring sequential execution. Run these targets separately
137-
# from the rest so that the rest may still enjoy full parallel execution.
138-
SEQUENTIAL_TARGETS := $(filter dist-clean clean% reconfigure, $(MAIN_TARGETS))
139-
PARALLEL_TARGETS := $(filter-out $(SEQUENTIAL_TARGETS), $(MAIN_TARGETS))
140-
141-
main-wrapper:
142-
ifneq ($(SEQUENTIAL_TARGETS), )
143-
(cd $(SRC_ROOT)/make && $(MAKE) -f Main.gmk SPEC=$(SPEC) -j 1 \
144-
$(VERBOSE) VERBOSE=$(VERBOSE) LOG_LEVEL=$(LOG_LEVEL) $(SEQUENTIAL_TARGETS))
145-
endif
146-
ifneq ($(PARALLEL_TARGETS), )
147-
@$(call AtMakeStart)
148-
(cd $(SRC_ROOT)/make && $(BUILD_LOG_WRAPPER) $(MAKE) -f Main.gmk SPEC=$(SPEC) -j $(JOBS) \
149-
$(VERBOSE) VERBOSE=$(VERBOSE) LOG_LEVEL=$(LOG_LEVEL) $(PARALLEL_TARGETS) \
150-
$(if $(filter true, $(OUTPUT_SYNC_SUPPORTED)), -O$(OUTPUT_SYNC)))
151-
@$(call AtMakeEnd)
152-
endif
153-
154-
.PHONY: main-wrapper
155-
156-
endif
59+
makefile_path := $(lastword $(MAKEFILE_LIST))
15760
endif
61+
topdir := $(strip $(patsubst %/, %, $(dir $(makefile_path))))
15862

159-
# Here are "global" targets, i.e. targets that can be executed without specifying a single configuration.
160-
# If you add more global targets, please update the variable global_targets in MakeHelpers.
161-
162-
# Helper macro to allow $(info) to properly print strings beginning with spaces.
163-
_:=
164-
165-
help:
166-
$(info )
167-
$(info OpenJDK Makefile help)
168-
$(info =====================)
169-
$(info )
170-
$(info Common make targets)
171-
$(info $(_) make [default] # Compile all modules in langtools, hotspot, jdk, jaxws,)
172-
$(info $(_) # jaxp and corba, and create a runnable "exploded" image)
173-
$(info $(_) make all # Compile everything, all repos, docs and images)
174-
$(info $(_) make images # Create complete j2sdk and j2re images)
175-
$(info $(_) make <phase> # Build the specified phase and everything it depends on)
176-
$(info $(_) # (gensrc, java, copy, libs, launchers, gendata, rmic))
177-
$(info $(_) make *-only # Applies to most targets and disables compling the)
178-
$(info $(_) # dependencies for the target. This is faster but may)
179-
$(info $(_) # result in incorrect build results!)
180-
$(info $(_) make docs # Create all docs)
181-
$(info $(_) make docs-javadoc # Create just javadocs, depends on less than full docs)
182-
$(info $(_) make profiles # Create complete j2re compact profile images)
183-
$(info $(_) make bootcycle-images # Build images twice, second time with newly built JDK)
184-
$(info $(_) make install # Install the generated images locally)
185-
$(info $(_) make reconfigure # Rerun configure with the same arguments as last time)
186-
$(info $(_) make help # Give some help on using make)
187-
$(info $(_) make test # Run tests, default is all tests (see TEST below))
188-
$(info )
189-
$(info Targets for cleaning)
190-
$(info $(_) make clean # Remove all files generated by make, but not those)
191-
$(info $(_) # generated by configure)
192-
$(info $(_) make dist-clean # Remove all files, including configuration)
193-
$(info $(_) make clean-<outputdir> # Remove the subdir in the output dir with the name)
194-
$(info $(_) make clean-<phase> # Remove all build results related to a certain build)
195-
$(info $(_) # phase (gensrc, java, libs, launchers))
196-
$(info $(_) make clean-<module> # Remove all build results related to a certain module)
197-
$(info $(_) make clean-<module>-<phase> # Remove all build results related to a certain)
198-
$(info $(_) # module and phase)
199-
$(info )
200-
$(info Targets for specific modules)
201-
$(info $(_) make <module> # Build <module> and everything it depends on.)
202-
$(info $(_) make <module>-<phase> # Compile the specified phase for the specified module)
203-
$(info $(_) # and everything it depends on)
204-
$(info $(_) # (gensrc, java, copy, libs, launchers, gendata, rmic))
205-
$(info )
206-
$(info Make control variables)
207-
$(info $(_) CONF= # Build all configurations (note, assignment is empty))
208-
$(info $(_) CONF=<substring> # Build the configuration(s) with a name matching)
209-
$(info $(_) # <substring>)
210-
$(info $(_) SPEC=<spec file> # Build the configuration given by the spec file)
211-
$(info $(_) LOG=<loglevel> # Change the log level from warn to <loglevel>)
212-
$(info $(_) # Available log levels are:)
213-
$(info $(_) # 'warn' (default), 'info', 'debug' and 'trace')
214-
$(info $(_) # To see executed command lines, use LOG=debug)
215-
$(info $(_) JOBS=<n> # Run <n> parallel make jobs)
216-
$(info $(_) # Note that -jN does not work as expected!)
217-
$(info $(_) IGNORE_OLD_CONFIG=true # Skip tests if spec file is up to date)
218-
$(info $(_) make test TEST=<test> # Only run the given test or tests, e.g.)
219-
$(info $(_) # make test TEST="jdk_lang jdk_net")
220-
$(info )
221-
222-
.PHONY: help
63+
# ... and then we can include the real makefile
64+
include $(topdir)/make/Init.gmk

common/autoconf/basics.m4

+2-14
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ AC_DEFUN([BASIC_PREPEND_TO_PATH],
7878
AC_DEFUN([BASIC_FIXUP_PATH],
7979
[
8080
# Only process if variable expands to non-empty
81-
81+
8282
if test "x[$]$1" != x; then
8383
if test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.cygwin"; then
8484
BASIC_FIXUP_PATH_CYGWIN($1)
@@ -118,7 +118,7 @@ AC_DEFUN([BASIC_FIXUP_PATH],
118118
AC_DEFUN([BASIC_FIXUP_EXECUTABLE],
119119
[
120120
# Only process if variable expands to non-empty
121-
121+
122122
if test "x[$]$1" != x; then
123123
if test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.cygwin"; then
124124
BASIC_FIXUP_EXECUTABLE_CYGWIN($1)
@@ -709,18 +709,6 @@ AC_DEFUN_ONCE([BASIC_SETUP_OUTPUT_DIR],
709709
AC_CONFIG_FILES([$OUTPUT_ROOT/Makefile:$AUTOCONF_DIR/Makefile.in])
710710
])
711711

712-
AC_DEFUN_ONCE([BASIC_SETUP_LOGGING],
713-
[
714-
# Setup default logging of stdout and stderr to build.log in the output root.
715-
BUILD_LOG='$(OUTPUT_ROOT)/build.log'
716-
BUILD_LOG_PREVIOUS='$(OUTPUT_ROOT)/build.log.old'
717-
BUILD_LOG_WRAPPER='$(BASH) $(SRC_ROOT)/common/bin/logger.sh $(BUILD_LOG)'
718-
AC_SUBST(BUILD_LOG)
719-
AC_SUBST(BUILD_LOG_PREVIOUS)
720-
AC_SUBST(BUILD_LOG_WRAPPER)
721-
])
722-
723-
724712
#%%% Simple tools %%%
725713

726714
# Check if we have found a usable version of make

common/autoconf/configure.ac

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#
2-
# Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved.
2+
# Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved.
33
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
#
55
# This code is free software; you can redistribute it and/or modify it
@@ -88,7 +88,6 @@ PLATFORM_SETUP_OPENJDK_BUILD_AND_TARGET
8888

8989
# Continue setting up basic stuff. Most remaining code require fundamental tools.
9090
BASIC_SETUP_PATHS
91-
BASIC_SETUP_LOGGING
9291

9392
# Check if it's a pure open build or if custom sources are to be used.
9493
JDKOPT_SETUP_OPEN_OR_CUSTOM

common/autoconf/generated-configure.sh

+1-16
Original file line numberDiff line numberDiff line change
@@ -907,9 +907,6 @@ JVM_VARIANTS
907907
JVM_INTERPRETER
908908
JDK_VARIANT
909909
SET_OPENJDK
910-
BUILD_LOG_WRAPPER
911-
BUILD_LOG_PREVIOUS
912-
BUILD_LOG
913910
TOPDIR
914911
PATH_SEP
915912
ZERO_ARCHDEF
@@ -3471,9 +3468,6 @@ ac_configure="$SHELL $ac_aux_dir/configure" # Please don't use this var.
34713468

34723469

34733470

3474-
3475-
3476-
34773471
#%%% Simple tools %%%
34783472

34793473
# Check if we have found a usable version of make
@@ -4369,7 +4363,7 @@ VS_SDK_PLATFORM_NAME_2013=
43694363
#CUSTOM_AUTOCONF_INCLUDE
43704364

43714365
# Do not change or remove the following line, it is needed for consistency checks:
4372-
DATE_WHEN_GENERATED=1426774983
4366+
DATE_WHEN_GENERATED=1427382753
43734367

43744368
###############################################################################
43754369
#
@@ -14401,15 +14395,6 @@ $as_echo "$as_me: The path of TOPDIR, which resolves as \"$path\", is invalid."
1440114395
AUTOCONF_DIR=$TOPDIR/common/autoconf
1440214396

1440314397

14404-
# Setup default logging of stdout and stderr to build.log in the output root.
14405-
BUILD_LOG='$(OUTPUT_ROOT)/build.log'
14406-
BUILD_LOG_PREVIOUS='$(OUTPUT_ROOT)/build.log.old'
14407-
BUILD_LOG_WRAPPER='$(BASH) $(SRC_ROOT)/common/bin/logger.sh $(BUILD_LOG)'
14408-
14409-
14410-
14411-
14412-
1441314398
# Check if it's a pure open build or if custom sources are to be used.
1441414399

1441514400
# Check whether --enable-openjdk-only was given.

common/autoconf/spec.gmk.in

+5-30
Original file line numberDiff line numberDiff line change
@@ -55,25 +55,12 @@ CONFIGURE_COMMAND_LINE:=@CONFIGURE_COMMAND_LINE@
5555
# A self-referential reference to this file.
5656
SPEC:=@SPEC@
5757

58-
# Specify where the spec file is.
59-
MAKE_ARGS="SPEC=$(SPEC)"
58+
# What make to use for main processing, after bootstrapping top-level Makefile.
59+
MAKE := @MAKE@
6060

61-
MAKE:=@MAKE@
62-
63-
# Pass along the verbosity and log level settings.
64-
ifeq (,$(findstring VERBOSE=,$(MAKE)))
65-
MAKE:=$(MAKE) $(VERBOSE) VERBOSE="$(VERBOSE)" LOG_LEVEL="$(LOG_LEVEL)"
66-
endif
67-
68-
# No implicit variables or rules!
69-
ifeq (,$(findstring -R,$(MAKE)))
70-
MAKE:=$(MAKE) -R
71-
endif
72-
73-
# Specify where the common include directory for makefiles is.
74-
ifeq (,$(findstring -I @TOPDIR@/make/common,$(MAKE)))
75-
MAKE:=$(MAKE) -I @TOPDIR@/make/common
76-
endif
61+
# The default make arguments
62+
MAKE_ARGS = $(MAKE_LOG_FLAGS) -R -I $(TOPDIR)/make/common SPEC=$(SPEC) \
63+
MAKE_LOG_FLAGS="$(MAKE_LOG_FLAGS)" LOG_LEVEL=$(LOG_LEVEL)
7764

7865
OUTPUT_SYNC_SUPPORTED:=@OUTPUT_SYNC_SUPPORTED@
7966
OUTPUT_SYNC:=@OUTPUT_SYNC@
@@ -573,18 +560,6 @@ JTREGEXE:=@JTREGEXE@
573560
XCODEBUILD=@XCODEBUILD@
574561
FIXPATH:=@FIXPATH@
575562

576-
# Where the build output is stored for your convenience.
577-
BUILD_LOG:=@BUILD_LOG@
578-
BUILD_LOG_PREVIOUS:=@BUILD_LOG_PREVIOUS@
579-
# Disable the build log wrapper on sjavac+windows until
580-
# we have solved how to prevent the log wrapper to wait
581-
# for the background sjavac server process.
582-
ifeq (@ENABLE_SJAVAC@X@OPENJDK_BUILD_OS@,yesXwindows)
583-
BUILD_LOG_WRAPPER:=
584-
else
585-
BUILD_LOG_WRAPPER:=@BUILD_LOG_WRAPPER@
586-
endif
587-
588563
# Build setup
589564
ENABLE_JFR=@ENABLE_JFR@
590565
ENABLE_INTREE_EC=@ENABLE_INTREE_EC@

configure

+2-1
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,5 @@ this_script_dir=`cd $this_script_dir > /dev/null && pwd`
3131

3232
# Delegate to wrapper, forcing wrapper to believe $0 is this script by using -c.
3333
# This trick is needed to get autoconf to co-operate properly.
34-
bash -c ". $this_script_dir/common/autoconf/configure" $this_script_dir/configure CHECKME $this_script_dir "$@"
34+
# The ${-:+-$-} construction passes on bash options.
35+
bash ${-:+-$-} -c ". $this_script_dir/common/autoconf/configure" $this_script_dir/configure CHECKME $this_script_dir "$@"

0 commit comments

Comments
 (0)