Fri, 12 Oct 2012 10:49:39 -0700
Merge
aoqi@0 | 1 | #! /bin/sh |
aoqi@0 | 2 | # |
aoqi@0 | 3 | # Copyright (c) 1999, 2008, Oracle and/or its affiliates. All rights reserved. |
aoqi@0 | 4 | # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
aoqi@0 | 5 | # |
aoqi@0 | 6 | # This code is free software; you can redistribute it and/or modify it |
aoqi@0 | 7 | # under the terms of the GNU General Public License version 2 only, as |
aoqi@0 | 8 | # published by the Free Software Foundation. |
aoqi@0 | 9 | # |
aoqi@0 | 10 | # This code is distributed in the hope that it will be useful, but WITHOUT |
aoqi@0 | 11 | # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
aoqi@0 | 12 | # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
aoqi@0 | 13 | # version 2 for more details (a copy is included in the LICENSE file that |
aoqi@0 | 14 | # accompanied this code). |
aoqi@0 | 15 | # |
aoqi@0 | 16 | # You should have received a copy of the GNU General Public License version |
aoqi@0 | 17 | # 2 along with this work; if not, write to the Free Software Foundation, |
aoqi@0 | 18 | # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
aoqi@0 | 19 | # |
aoqi@0 | 20 | # Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
aoqi@0 | 21 | # or visit www.oracle.com if you need additional information or have any |
aoqi@0 | 22 | # questions. |
aoqi@0 | 23 | # |
aoqi@0 | 24 | # |
aoqi@0 | 25 | |
aoqi@0 | 26 | # This script is used only from top.make. |
aoqi@0 | 27 | # The macro $(MFLAGS-adjusted) calls this script to |
aoqi@0 | 28 | # adjust the "-j" arguments to take into account |
aoqi@0 | 29 | # the HOTSPOT_BUILD_JOBS variable. The default |
aoqi@0 | 30 | # handling of the "-j" argument by gnumake does |
aoqi@0 | 31 | # not meet our needs, so we must adjust it ourselves. |
aoqi@0 | 32 | |
aoqi@0 | 33 | # This argument adjustment applies to two recursive |
aoqi@0 | 34 | # calls to "$(MAKE) $(MFLAGS-adjusted)" in top.make. |
aoqi@0 | 35 | # One invokes adlc.make, and the other invokes vm.make. |
aoqi@0 | 36 | # The adjustment propagates the desired concurrency |
aoqi@0 | 37 | # level down to the sub-make (of the adlc or vm). |
aoqi@0 | 38 | # The default behavior of gnumake is to run all |
aoqi@0 | 39 | # sub-makes without concurrency ("-j1"). |
aoqi@0 | 40 | |
aoqi@0 | 41 | # Also, we use a make variable rather than an explicit |
aoqi@0 | 42 | # "-j<N>" argument to control this setting, so that |
aoqi@0 | 43 | # the concurrency setting (which must be tuned separately |
aoqi@0 | 44 | # for each MP system) can be set via an environment variable. |
aoqi@0 | 45 | # The recommended setting is 1.5x to 2x the number of available |
aoqi@0 | 46 | # CPUs on the MP system, which is large enough to keep the CPUs |
aoqi@0 | 47 | # busy (even though some jobs may be I/O bound) but not too large, |
aoqi@0 | 48 | # we may presume, to overflow the system's swap space. |
aoqi@0 | 49 | |
aoqi@0 | 50 | set -eu |
aoqi@0 | 51 | |
aoqi@0 | 52 | default_build_jobs=4 |
aoqi@0 | 53 | |
aoqi@0 | 54 | case $# in |
aoqi@0 | 55 | [12]) true;; |
aoqi@0 | 56 | *) >&2 echo "Usage: $0 ${MFLAGS} ${HOTSPOT_BUILD_JOBS}"; exit 2;; |
aoqi@0 | 57 | esac |
aoqi@0 | 58 | |
aoqi@0 | 59 | MFLAGS=$1 |
aoqi@0 | 60 | HOTSPOT_BUILD_JOBS=${2-} |
aoqi@0 | 61 | |
aoqi@0 | 62 | # Normalize any -jN argument to the form " -j${HBJ}" |
aoqi@0 | 63 | MFLAGS=` |
aoqi@0 | 64 | echo "$MFLAGS" \ |
aoqi@0 | 65 | | sed ' |
aoqi@0 | 66 | s/^-/ -/ |
aoqi@0 | 67 | s/ -\([^ ][^ ]*\)j/ -\1 -j/ |
aoqi@0 | 68 | s/ -j[0-9][0-9]*/ -j/ |
aoqi@0 | 69 | s/ -j\([^ ]\)/ -j -\1/ |
aoqi@0 | 70 | s/ -j/ -j'${HOTSPOT_BUILD_JOBS:-${default_build_jobs}}'/ |
aoqi@0 | 71 | ' ` |
aoqi@0 | 72 | |
aoqi@0 | 73 | case ${HOTSPOT_BUILD_JOBS} in \ |
aoqi@0 | 74 | |
aoqi@0 | 75 | '') case ${MFLAGS} in |
aoqi@0 | 76 | *\ -j*) |
aoqi@0 | 77 | >&2 echo "# Note: -jN is ineffective for setting parallelism in this makefile." |
aoqi@0 | 78 | >&2 echo "# please set HOTSPOT_BUILD_JOBS=${default_build_jobs} in the command line or environment." |
aoqi@0 | 79 | esac;; |
aoqi@0 | 80 | |
aoqi@0 | 81 | ?*) case ${MFLAGS} in |
aoqi@0 | 82 | *\ -j*) true;; |
aoqi@0 | 83 | *) MFLAGS="-j${HOTSPOT_BUILD_JOBS} ${MFLAGS}";; |
aoqi@0 | 84 | esac;; |
aoqi@0 | 85 | esac |
aoqi@0 | 86 | |
aoqi@0 | 87 | echo "${MFLAGS}" |