e2b4542f0d7a6fc1974a9aa89139e78695fdec55jeff.schenk#! /bin/sh
dfc4e0fc3052835b2a069aa9d869fa1161c33fe6Peter Major#
dfc4e0fc3052835b2a069aa9d869fa1161c33fe6Peter Major# Copyright (c) 1999, 2008, Oracle and/or its affiliates. All rights reserved.
dfc4e0fc3052835b2a069aa9d869fa1161c33fe6Peter Major# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
0e24a32eaa806a8967db562761fc03e73aa81dc7Neil Madden#
dfc4e0fc3052835b2a069aa9d869fa1161c33fe6Peter Major# This code is free software; you can redistribute it and/or modify it
dfc4e0fc3052835b2a069aa9d869fa1161c33fe6Peter Major# under the terms of the GNU General Public License version 2 only, as
dfc4e0fc3052835b2a069aa9d869fa1161c33fe6Peter Major# published by the Free Software Foundation.
dfc4e0fc3052835b2a069aa9d869fa1161c33fe6Peter Major#
dfc4e0fc3052835b2a069aa9d869fa1161c33fe6Peter Major# This code is distributed in the hope that it will be useful, but WITHOUT
dfc4e0fc3052835b2a069aa9d869fa1161c33fe6Peter Major# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
dfc4e0fc3052835b2a069aa9d869fa1161c33fe6Peter Major# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
dfc4e0fc3052835b2a069aa9d869fa1161c33fe6Peter Major# version 2 for more details (a copy is included in the LICENSE file that
dfc4e0fc3052835b2a069aa9d869fa1161c33fe6Peter Major# accompanied this code).
dfc4e0fc3052835b2a069aa9d869fa1161c33fe6Peter Major#
dfc4e0fc3052835b2a069aa9d869fa1161c33fe6Peter Major# You should have received a copy of the GNU General Public License version
dfc4e0fc3052835b2a069aa9d869fa1161c33fe6Peter Major# 2 along with this work; if not, write to the Free Software Foundation,
dfc4e0fc3052835b2a069aa9d869fa1161c33fe6Peter Major# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
dfc4e0fc3052835b2a069aa9d869fa1161c33fe6Peter Major#
dfc4e0fc3052835b2a069aa9d869fa1161c33fe6Peter Major# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
dfc4e0fc3052835b2a069aa9d869fa1161c33fe6Peter Major# or visit www.oracle.com if you need additional information or have any
dfc4e0fc3052835b2a069aa9d869fa1161c33fe6Peter Major# questions.
dfc4e0fc3052835b2a069aa9d869fa1161c33fe6Peter Major#
dfc4e0fc3052835b2a069aa9d869fa1161c33fe6Peter Major#
dfc4e0fc3052835b2a069aa9d869fa1161c33fe6Peter Major
1f48f8236de7de97be1c6b9d06bef50b379c8801jenkins# This script is used only from top.make.
e2b4542f0d7a6fc1974a9aa89139e78695fdec55jeff.schenk# The macro $(MFLAGS-adjusted) calls this script to
e2b4542f0d7a6fc1974a9aa89139e78695fdec55jeff.schenk# adjust the "-j" arguments to take into account
e2b4542f0d7a6fc1974a9aa89139e78695fdec55jeff.schenk# the HOTSPOT_BUILD_JOBS variable. The default
e2b4542f0d7a6fc1974a9aa89139e78695fdec55jeff.schenk# handling of the "-j" argument by gnumake does
a622f6b14edb724c3cdbc8b5836a109d4ac80086Peter Major# not meet our needs, so we must adjust it ourselves.
e2b4542f0d7a6fc1974a9aa89139e78695fdec55jeff.schenk
1c39f25b4e11ae0397f825f3d031bd01983b98f0Bruno Lavit# This argument adjustment applies to two recursive
e2b4542f0d7a6fc1974a9aa89139e78695fdec55jeff.schenk# calls to "$(MAKE) $(MFLAGS-adjusted)" in top.make.
e2b4542f0d7a6fc1974a9aa89139e78695fdec55jeff.schenk# One invokes adlc.make, and the other invokes vm.make.
e2b4542f0d7a6fc1974a9aa89139e78695fdec55jeff.schenk# The adjustment propagates the desired concurrency
e2b4542f0d7a6fc1974a9aa89139e78695fdec55jeff.schenk# level down to the sub-make (of the adlc or vm).
e2b4542f0d7a6fc1974a9aa89139e78695fdec55jeff.schenk# The default behavior of gnumake is to run all
e2b4542f0d7a6fc1974a9aa89139e78695fdec55jeff.schenk# sub-makes without concurrency ("-j1").
e2b4542f0d7a6fc1974a9aa89139e78695fdec55jeff.schenk
e2b4542f0d7a6fc1974a9aa89139e78695fdec55jeff.schenk# Also, we use a make variable rather than an explicit
ef957cfcdd1da08a4fb4b7394ee4a9337269f730James Phillpotts# "-j<N>" argument to control this setting, so that
11ff9d3ed91c2431cf64f0e777666b196ea58095Mark de Reeper# the concurrency setting (which must be tuned separately
9e34f70f789dbd049eed2b273ca9b7d2cd26fd51cweng# for each MP system) can be set via an environment variable.
0e24a32eaa806a8967db562761fc03e73aa81dc7Neil Madden# The recommended setting is 1.5x to 2x the number of available
11ff9d3ed91c2431cf64f0e777666b196ea58095Mark de Reeper# CPUs on the MP system, which is large enough to keep the CPUs
11ff9d3ed91c2431cf64f0e777666b196ea58095Mark de Reeper# busy (even though some jobs may be I/O bound) but not too large,
11ff9d3ed91c2431cf64f0e777666b196ea58095Mark de Reeper# we may presume, to overflow the system's swap space.
11ff9d3ed91c2431cf64f0e777666b196ea58095Mark de Reeper
ccf9d4a5c6453fa9f8b839baeee25147865fbb7dJames Phillpottsset -eu
11ff9d3ed91c2431cf64f0e777666b196ea58095Mark de Reeper
ef957cfcdd1da08a4fb4b7394ee4a9337269f730James Phillpottsdefault_build_jobs=4
ef957cfcdd1da08a4fb4b7394ee4a9337269f730James Phillpotts
e2b4542f0d7a6fc1974a9aa89139e78695fdec55jeff.schenkcase $# in
e2b4542f0d7a6fc1974a9aa89139e78695fdec55jeff.schenk[12]) true;;
e2b4542f0d7a6fc1974a9aa89139e78695fdec55jeff.schenk*) >&2 echo "Usage: $0 ${MFLAGS} ${HOTSPOT_BUILD_JOBS}"; exit 2;;
d7acdbdfb47e51f588dbf7bafc4706000a44aca5Jonathan Scudderesac
e2b4542f0d7a6fc1974a9aa89139e78695fdec55jeff.schenk
206513b755b9d0098f909c3ffc5f858c3caa0d65Bruno LavitMFLAGS=$1
206513b755b9d0098f909c3ffc5f858c3caa0d65Bruno LavitHOTSPOT_BUILD_JOBS=${2-}
206513b755b9d0098f909c3ffc5f858c3caa0d65Bruno Lavit
206513b755b9d0098f909c3ffc5f858c3caa0d65Bruno Lavit# Normalize any -jN argument to the form " -j${HBJ}"
ef957cfcdd1da08a4fb4b7394ee4a9337269f730James PhillpottsMFLAGS=`
206513b755b9d0098f909c3ffc5f858c3caa0d65Bruno Lavit echo "$MFLAGS" \
206513b755b9d0098f909c3ffc5f858c3caa0d65Bruno Lavit | sed '
206513b755b9d0098f909c3ffc5f858c3caa0d65Bruno Lavit s/^-/ -/
206513b755b9d0098f909c3ffc5f858c3caa0d65Bruno Lavit s/ -\([^ ][^ ]*\)j/ -\1 -j/
206513b755b9d0098f909c3ffc5f858c3caa0d65Bruno Lavit s/ -j[0-9][0-9]*/ -j/
206513b755b9d0098f909c3ffc5f858c3caa0d65Bruno Lavit s/ -j\([^ ]\)/ -j -\1/
206513b755b9d0098f909c3ffc5f858c3caa0d65Bruno Lavit s/ -j/ -j'${HOTSPOT_BUILD_JOBS:-${default_build_jobs}}'/
206513b755b9d0098f909c3ffc5f858c3caa0d65Bruno Lavit ' `
206513b755b9d0098f909c3ffc5f858c3caa0d65Bruno Lavit
206513b755b9d0098f909c3ffc5f858c3caa0d65Bruno Lavitcase ${HOTSPOT_BUILD_JOBS} in \
206513b755b9d0098f909c3ffc5f858c3caa0d65Bruno Lavit
206513b755b9d0098f909c3ffc5f858c3caa0d65Bruno Lavit'') case ${MFLAGS} in
206513b755b9d0098f909c3ffc5f858c3caa0d65Bruno Lavit *\ -j*)
206513b755b9d0098f909c3ffc5f858c3caa0d65Bruno Lavit >&2 echo "# Note: -jN is ineffective for setting parallelism in this makefile."
206513b755b9d0098f909c3ffc5f858c3caa0d65Bruno Lavit >&2 echo "# please set HOTSPOT_BUILD_JOBS=${default_build_jobs} in the command line or environment."
206513b755b9d0098f909c3ffc5f858c3caa0d65Bruno Lavit esac;;
206513b755b9d0098f909c3ffc5f858c3caa0d65Bruno Lavit
206513b755b9d0098f909c3ffc5f858c3caa0d65Bruno Lavit?*) case ${MFLAGS} in
206513b755b9d0098f909c3ffc5f858c3caa0d65Bruno Lavit *\ -j*) true;;
206513b755b9d0098f909c3ffc5f858c3caa0d65Bruno Lavit *) MFLAGS="-j${HOTSPOT_BUILD_JOBS} ${MFLAGS}";;
ef957cfcdd1da08a4fb4b7394ee4a9337269f730James Phillpotts esac;;
73db2ddb960cafd7ffb6daf89eb697910d36c56dJames Phillpottsesac
73db2ddb960cafd7ffb6daf89eb697910d36c56dJames Phillpotts
73db2ddb960cafd7ffb6daf89eb697910d36c56dJames Phillpottsecho "${MFLAGS}"
73db2ddb960cafd7ffb6daf89eb697910d36c56dJames Phillpotts