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