Makefile revision 1143:1823df83c30e
1#
2# Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
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
7# published by the Free Software Foundation.  Oracle designates this
8# particular file as subject to the "Classpath" exception as provided
9# by Oracle in the LICENSE file that accompanied this code.
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#
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.
24#
25
26# This must be the first rule
27default:
28
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.
35# /usr/ccs/bin/make lacks basically every other flow control mechanism.
36TEST_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.
39ifeq ($(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.)
41endif
42
43# Locate this Makefile
44ifeq ($(filter /%,$(lastword $(MAKEFILE_LIST))),)
45  makefile_path:=$(CURDIR)/$(lastword $(MAKEFILE_LIST))
46else
47  makefile_path:=$(lastword $(MAKEFILE_LIST))
48endif
49root_dir:=$(dir $(makefile_path))
50
51# ... and then we can include our helper functions
52include $(root_dir)/make/MakeHelpers.gmk
53
54$(eval $(call ParseLogLevel))
55$(eval $(call ParseConfAndSpec))
56
57# Now determine if we have zero, one or several configurations to build.
58ifeq ($(SPEC),)
59  # Since we got past ParseConfAndSpec, we must be building a global target. Do nothing.
60else
61  # In Cygwin, the MAKE variable gets messed up if the make executable is called with
62  # a Windows mixed path (c:/cygwin/bin/make.exe). If that's the case, fix it by removing
63  # the prepended root_dir.
64  ifneq ($(findstring :, $(MAKE)), )
65    MAKE := $(patsubst $(root_dir)%, %, $(MAKE))
66  endif
67
68  # We are potentially building multiple configurations.
69  # First, find out the valid targets
70  # Run the makefile with an arbitrary SPEC using -p -q (quiet dry-run and dump rules) to find
71  # available PHONY targets. Use this list as valid targets to pass on to the repeated calls.
72  all_phony_targets := $(sort $(filter-out $(global_targets), $(strip $(shell \
73      cd $(root_dir)/make && $(MAKE) -f Main.gmk -p -q FRC SPEC=$(firstword $(SPEC)) | \
74      grep "^.PHONY:" | head -n 1 | cut -d " " -f 2-))))
75
76  # Loop through the configurations and call the main-wrapper for each one. The wrapper
77  # target will execute with a single configuration loaded.
78  $(all_phony_targets):
79	@$(if $(TARGET_RUN),,\
80          $(foreach spec,$(SPEC),\
81            (cd $(root_dir) && $(MAKE) SPEC=$(spec) MAIN_TARGETS="$(call GetRealTarget)" \
82	    $(VERBOSE) VERBOSE=$(VERBOSE) LOG_LEVEL=$(LOG_LEVEL) main-wrapper) &&) true)
83	@echo > /dev/null
84	$(eval TARGET_RUN=true)
85
86  .PHONY: $(all_phony_targets)
87
88  ifneq ($(MAIN_TARGETS), )
89    # The wrapper target was called so we now have a single configuration. Load the spec file
90    # and call the real Main.gmk.
91    include $(SPEC)
92
93    ### Clean up from previous run
94    # Remove any build.log from a previous run, if they exist
95    ifneq (,$(BUILD_LOG))
96      ifneq (,$(BUILD_LOG_PREVIOUS))
97        # Rotate old log
98        $(shell $(RM) $(BUILD_LOG_PREVIOUS) 2> /dev/null)
99        $(shell $(MV) $(BUILD_LOG) $(BUILD_LOG_PREVIOUS) 2> /dev/null)
100      else
101        $(shell $(RM) $(BUILD_LOG) 2> /dev/null)
102      endif
103      $(shell $(RM) $(OUTPUT_ROOT)/build-trace-time.log 2> /dev/null)
104    endif
105    # Remove any javac server logs and port files. This
106    # prevents a new make run to reuse the previous servers.
107    ifneq (,$(SJAVAC_SERVER_DIR))
108      $(shell $(MKDIR) -p $(SJAVAC_SERVER_DIR) && $(RM) -rf $(SJAVAC_SERVER_DIR)/*)
109    endif
110
111    main-wrapper:
112	@$(if $(findstring clean, $(MAIN_TARGETS)), , $(call AtMakeStart))
113	(cd $(root_dir)/make && $(BUILD_LOG_WRAPPER) $(MAKE) -f Main.gmk SPEC=$(SPEC) -j $(JOBS) \
114	    $(VERBOSE) VERBOSE=$(VERBOSE) LOG_LEVEL=$(LOG_LEVEL) $(MAIN_TARGETS) \
115	    $(if $(filter true, $(OUTPUT_SYNC_SUPPORTED)), -O$(OUTPUT_SYNC)))
116	@$(if $(findstring clean, $(MAIN_TARGETS)), , $(call AtMakeEnd))
117
118     .PHONY: main-wrapper
119
120   endif
121endif
122
123# Here are "global" targets, i.e. targets that can be executed without specifying a single configuration.
124# If you add more global targets, please update the variable global_targets in MakeHelpers.
125
126help:
127	$(info )
128	$(info OpenJDK Makefile help)
129	$(info =====================)
130	$(info )
131	$(info Common make targets)
132	$(info .  make [default]         # Compile all modules in langtools, hotspot, jaxp, jaxws,)
133	$(info .                         # corba and jdk and create a runnable "exploded" image)
134	$(info .  make all               # Compile everything, all repos, docs and images)
135	$(info .  make images            # Create complete j2sdk and j2re images)
136	$(info .  make docs              # Create all docs)
137	$(info .  make docs-javadoc      # Create just javadocs, depends on less than full docs)
138	$(info .  make profiles          # Create complete j2re compact profile images)
139	$(info .  make bootcycle-images  # Build images twice, second time with newly built JDK)
140	$(info .  make install           # Install the generated images locally)
141	$(info .  make clean             # Remove all files generated by make, but not those)
142	$(info .                         # generated by configure. Do not run clean and other)
143	$(info .                         # targets together as that might behave in an)
144	$(info .                         # unexpected way.)
145	$(info .  make dist-clean        # Remove all files, including configuration)
146	$(info .  make help              # Give some help on using make)
147	$(info .  make test              # Run tests, default is all tests (see TEST below))
148	$(info )
149	$(info Targets for specific modules)
150	$(info .  make <module>          # Build <module> and everything it depends on. )
151	$(info .  make <module>-only     # Build <module> only, without dependencies. This)
152	$(info .                         # is faster but can result in incorrect build results!)
153	$(info .  make <module>-java     # Compile java classes for <module> and everything it)
154	$(info .                         # depends on)
155	$(info .  make <module>-libs     # Build native libraries for <module> and everything it)
156	$(info .                         # depends on)
157	$(info .  make <module>-launchers# Build native executables for <module> and everything it)
158	$(info .                         # depends on)
159	$(info .  make <module>-gensrc   # Execute the gensrc step for <module> and everything it)
160	$(info .                         # depends on)
161	$(info )
162	$(info Useful make variables)
163	$(info .  make CONF=             # Build all configurations (note, assignment is empty))
164	$(info .  make CONF=<substring>  # Build the configuration(s) with a name matching)
165	$(info .                         # <substring>)
166	$(info )
167	$(info .  make LOG=<loglevel>    # Change the log level from warn to <loglevel>)
168	$(info .                         # Available log levels are:)
169	$(info .                         # 'warn' (default), 'info', 'debug' and 'trace')
170	$(info .                         # To see executed command lines, use LOG=debug)
171	$(info )
172	$(info .  make JOBS=<n>          # Run <n> parallel make jobs)
173	$(info .                         # Note that -jN does not work as expected!)
174	$(info )
175	$(info .  make test TEST=<test>  # Only run the given test or tests, e.g.)
176	$(info .                         # make test TEST="jdk_lang jdk_net")
177	$(info )
178
179.PHONY: help
180