common/makefiles/Makefile

Fri, 26 Oct 2012 14:29:57 -0700

author
ohair
date
Fri, 26 Oct 2012 14:29:57 -0700
changeset 494
e64f2cb57d05
parent 478
2ba6f4da4bf3
child 559
ef6adbf511cc
permissions
-rw-r--r--

8000992: Update new build-infra makefiles
Summary: Build-infra project integration. Multiple authors on this work: erikj and ihse primarily, also changes from ohair, tbell, and dholmes. Special credit to ohstrom for his smartjavac work.
Reviewed-by: erikj, ihse, dholmes, tbell

ohair@425 1 #
ohair@425 2 # Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
ohair@425 3 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
ohair@425 4 #
ohair@425 5 # This code is free software; you can redistribute it and/or modify it
ohair@425 6 # under the terms of the GNU General Public License version 2 only, as
ohair@425 7 # published by the Free Software Foundation. Oracle designates this
ohair@425 8 # particular file as subject to the "Classpath" exception as provided
ohair@425 9 # by Oracle in the LICENSE file that accompanied this code.
ohair@425 10 #
ohair@425 11 # This code is distributed in the hope that it will be useful, but WITHOUT
ohair@425 12 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
ohair@425 13 # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
ohair@425 14 # version 2 for more details (a copy is included in the LICENSE file that
ohair@425 15 # accompanied this code).
ohair@425 16 #
ohair@425 17 # You should have received a copy of the GNU General Public License version
ohair@425 18 # 2 along with this work; if not, write to the Free Software Foundation,
ohair@425 19 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
ohair@425 20 #
ohair@425 21 # Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
ohair@425 22 # or visit www.oracle.com if you need additional information or have any
ohair@425 23 # questions.
ohair@425 24 #
ohair@425 25
erikj@445 26 # This must be the first rule
ohair@494 27 all:
erikj@445 28
ohair@478 29 # Inclusion of this pseudo-target will cause make to execute this file
ohair@478 30 # serially, regardless of -j. Recursively called makefiles will not be
ohair@478 31 # affected, however. This is required for correct dependency management.
ohair@478 32 .NOTPARALLEL:
ohair@478 33
ohair@494 34 # The shell code below will be executed on /usr/ccs/bin/make on Solaris, but not in GNU make.
ohair@494 35 # /usr/ccs/bin/make lacks basically every other flow control mechanism.
ohair@494 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
ohair@494 37
ohair@494 38 # Assume we have GNU make, but check version.
ohair@494 39 ifeq (,$(findstring 3.81,$(MAKE_VERSION)))
ohair@494 40 ifeq (,$(findstring 3.82,$(MAKE_VERSION)))
ohair@494 41 $(error This version of GNU Make is too low ($(MAKE_VERSION)). Check your path, or upgrade to 3.81 or newer.)
ohair@494 42 endif
ohair@494 43 endif
ohair@494 44
erikj@458 45 # Locate this Makefile
erikj@458 46 ifeq ($(filter /%,$(lastword $(MAKEFILE_LIST))),)
erikj@458 47 makefile_path:=$(CURDIR)/$(lastword $(MAKEFILE_LIST))
erikj@458 48 else
erikj@458 49 makefile_path:=$(lastword $(MAKEFILE_LIST))
erikj@458 50 endif
erikj@458 51 root_dir:=$(patsubst %/common/makefiles/Makefile,%,$(makefile_path))
erikj@445 52
erikj@458 53 # ... and then we can include our helper functions
erikj@458 54 include $(dir $(makefile_path))/MakeHelpers.gmk
erikj@445 55
erikj@458 56 $(eval $(call ParseLogLevel))
erikj@458 57 $(eval $(call ParseConfAndSpec))
erikj@445 58
ohair@494 59 # Now determine if we have zero, one or several configurations to build.
ohair@494 60 ifeq ($(SPEC),)
ohair@494 61 # Since we got past ParseConfAndSpec, we must be building a global target. Do nothing.
ohair@494 62 else
ohair@494 63 ifeq ($(words $(SPEC)),1)
ohair@494 64 # We are building a single configuration. This is the normal case. Execute the Main.gmk file.
ohair@494 65 include $(dir $(makefile_path))/Main.gmk
ohair@494 66 else
ohair@494 67 # We are building multiple configurations.
ohair@494 68 # First, find out the valid targets
ohair@494 69 # Run the makefile with an arbitraty SPEC using -p -q (quiet dry-run and dump rules) to find
ohair@494 70 # available PHONY targets. Use this list as valid targets to pass on to the repeated calls.
ohair@494 71 all_phony_targets=$(filter-out $(global_targets), $(strip $(shell \
ohair@494 72 $(MAKE) -p -q -f $(makefile_path) SPEC=$(firstword $(SPEC)) | \
ohair@494 73 grep ^.PHONY: | head -n 1 | cut -d " " -f 2-)))
ohair@494 74
ohair@494 75 $(all_phony_targets):
ohair@478 76 @$(foreach spec,$(SPEC),($(MAKE) -f $(makefile_path) SPEC=$(spec) $(VERBOSE) VERBOSE=$(VERBOSE) $@) &&) true
erikj@445 77
erikj@458 78 endif
ohair@425 79 endif
erikj@445 80
erikj@445 81 # Here are "global" targets, i.e. targets that can be executed without specifying a single configuration.
ohair@494 82 # If you addd more global targets, please update the variable global_targets in MakeHelpers.
erikj@445 83
ohair@425 84 help:
erikj@445 85 $(info )
erikj@445 86 $(info OpenJDK Makefile help)
erikj@445 87 $(info =====================)
erikj@445 88 $(info )
erikj@445 89 $(info Common make targets)
ohair@478 90 $(info . make [all] # Compile all code but do not create images)
ohair@478 91 $(info . make images # Create complete j2sdk and j2re images)
ohair@478 92 $(info . make overlay-images # Create limited images for sparc 64 bit platforms)
ohair@478 93 $(info . make bootcycle-images # Build images twice, second time with newly build JDK)
ohair@478 94 $(info . make install # Install the generated images locally)
ohair@478 95 $(info . make clean # Remove all files generated by make, but not those)
ohair@478 96 $(info . # generated by configure)
ohair@478 97 $(info . make dist-clean # Remove all files, including configuration)
ohair@478 98 $(info . make help # Give some help on using make)
ohair@478 99 $(info . make test # Run tests, default is all tests (see TEST below))
ohair@478 100 $(info )
ohair@478 101 $(info Targets for specific components)
ohair@494 102 $(info (Component is any of langtools, corba, jaxp, jaxws, hotspot, jdk, images or overlay-images))
ohair@478 103 $(info . make <component> # Build <component> and everything it depends on. )
ohair@478 104 $(info . make <component>-only # Build <component> only, without dependencies. This)
ohair@478 105 $(info . # is faster but can result in incorrect build results!)
ohair@478 106 $(info . make clean-<component> # Remove files generated by make for <component>)
erikj@445 107 $(info )
erikj@445 108 $(info Useful make variables)
ohair@478 109 $(info . make CONF= # Build all configurations (note, assignment is empty))
ohair@478 110 $(info . make CONF=<substring> # Build the configuration(s) with a name matching)
ohair@478 111 $(info . # <substring>)
erikj@445 112 $(info )
ohair@478 113 $(info . make LOG=<loglevel> # Change the log level from warn to <loglevel>)
ohair@478 114 $(info . # Available log levels are:)
ohair@478 115 $(info . # 'warn' (default), 'info', 'debug' and 'trace')
ohair@494 116 $(info . # To see executed command lines, use LOG=debug)
erikj@445 117 $(info )
ohair@478 118 $(info . make JOBS=<n> # Run <n> parallel make jobs)
ohair@478 119 $(info . # Note that -jN does not work as expected!)
ohair@478 120 $(info )
ohair@478 121 $(info . make test TEST=<test> # Only run the given test or tests, e.g.)
ohair@478 122 $(info . # make test TEST="jdk_lang jdk_net")
erikj@445 123 $(info )
ohair@494 124
ohair@494 125 configure:
ohair@494 126 @$(SHELL) $(root_dir)/configure $(CONFIGURE_ARGS)
ohair@494 127 @echo ====================================================
ohair@494 128 @echo "Note: This is a non-recommended way of running configure."
ohair@494 129 @echo "Instead, run 'sh configure' in the top-level directory"
ohair@494 130
ohair@494 131 .PHONY: help configure

mercurial