1 #
   2 # Copyright (c) 2011, 2016, 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 # All valid JVM features, regardless of platform
  27 VALID_JVM_FEATURES="compiler1 compiler2 zero shark minimal dtrace jvmti jvmci \
  28     fprof vm-structs jni-check services management all-gcs nmt cds \
  29     static-build link-time-opt"
  30 
  31 # All valid JVM variants
  32 VALID_JVM_VARIANTS="server client minimal core zero zeroshark custom"
  33 
  34 ###############################################################################
  35 # Check if the specified JVM variant should be built. To be used in shell if
  36 # constructs, like this:
  37 # if HOTSPOT_CHECK_JVM_VARIANT(server); then
  38 #
  39 # Only valid to use after HOTSPOT_SETUP_JVM_VARIANTS has setup variants.
  40 
  41 # Definition kept in one line to allow inlining in if statements.
  42 # Additional [] needed to keep m4 from mangling shell constructs.
  43 AC_DEFUN([HOTSPOT_CHECK_JVM_VARIANT],
  44 [ [ [[ " $JVM_VARIANTS " =~ " $1 " ]] ] ])
  45 
  46 ###############################################################################
  47 # Check if the specified JVM features are explicitly enabled. To be used in
  48 # shell if constructs, like this:
  49 # if HOTSPOT_CHECK_JVM_FEATURE(jvmti); then
  50 #
  51 # Only valid to use after HOTSPOT_SETUP_JVM_FEATURES has setup features.
  52 
  53 # Definition kept in one line to allow inlining in if statements.
  54 # Additional [] needed to keep m4 from mangling shell constructs.
  55 AC_DEFUN([HOTSPOT_CHECK_JVM_FEATURE],
  56 [ [ [[ " $JVM_FEATURES " =~ " $1 " ]] ] ])
  57 
  58 ###############################################################################
  59 # Check which variants of the JVM that we want to build. Available variants are:
  60 #   server: normal interpreter, and a tiered C1/C2 compiler
  61 #   client: normal interpreter, and C1 (no C2 compiler)
  62 #   minimal: reduced form of client with optional features stripped out
  63 #   core: normal interpreter only, no compiler
  64 #   zero: C++ based interpreter only, no compiler
  65 #   zeroshark: C++ based interpreter, and a llvm-based compiler
  66 #   custom: baseline JVM with no default features
  67 #
  68 AC_DEFUN_ONCE([HOTSPOT_SETUP_JVM_VARIANTS],
  69 [
  70   AC_ARG_WITH([jvm-variants], [AS_HELP_STRING([--with-jvm-variants],
  71       [JVM variants (separated by commas) to build (server,client,minimal,core,zero,zeroshark,custom) @<:@server@:>@])])
  72 
  73   if test "x$with_jvm_variants" = x; then
  74     with_jvm_variants="server"
  75   fi
  76   JVM_VARIANTS_OPT="$with_jvm_variants"
  77 
  78   # Has the user listed more than one variant?
  79   # Additional [] needed to keep m4 from mangling shell constructs.
  80   if [ [[ "$JVM_VARIANTS_OPT" =~ "," ]] ]; then
  81     BUILDING_MULTIPLE_JVM_VARIANTS=true
  82   else
  83     BUILDING_MULTIPLE_JVM_VARIANTS=false
  84   fi
  85   # Replace the commas with AND for use in the build directory name.
  86   JVM_VARIANTS_WITH_AND=`$ECHO "$JVM_VARIANTS_OPT" | $SED -e 's/,/AND/g'`
  87 
  88   AC_MSG_CHECKING([which variants of the JVM to build])
  89   # JVM_VARIANTS is a space-separated list.
  90   # Also use minimal, not minimal1 (which is kept for backwards compatibility).
  91   JVM_VARIANTS=`$ECHO $JVM_VARIANTS_OPT | $SED -e 's/,/ /g' -e 's/minimal1/minimal/'`
  92   AC_MSG_RESULT([$JVM_VARIANTS])
  93 
  94   # Check that the selected variants are valid
  95 
  96   # grep filter function inspired by a comment to http://stackoverflow.com/a/1617326
  97   # Notice that the original variant failes on SLES 10 and 11
  98   NEEDLE=${VALID_JVM_VARIANTS// /$'\n'}
  99   STACK=${JVM_VARIANTS// /$'\n'}
 100   INVALID_VARIANTS=`$GREP -Fvx "${NEEDLE}" <<< "${STACK}"`
 101   if test "x$INVALID_VARIANTS" != x; then
 102     AC_MSG_NOTICE([Unknown variant(s) specified: $INVALID_VARIANTS])
 103     AC_MSG_ERROR([The available JVM variants are: $VALID_JVM_VARIANTS])
 104   fi
 105 
 106   # All "special" variants share the same output directory ("server")
 107   VALID_MULTIPLE_JVM_VARIANTS="server client minimal"
 108   NEEDLE=${VALID_MULTIPLE_JVM_VARIANTS// /$'\n'}
 109   STACK=${JVM_VARIANTS// /$'\n'}
 110   INVALID_MULTIPLE_VARIANTS=`$GREP -Fvx "${NEEDLE}" <<< "${STACK}"`
 111   if  test "x$INVALID_MULTIPLE_VARIANTS" != x && test "x$BUILDING_MULTIPLE_JVM_VARIANTS" = xtrue; then
 112     AC_MSG_ERROR([You cannot build multiple variants with anything else than $VALID_MULTIPLE_JVM_VARIANTS.])
 113   fi
 114 
 115   AC_SUBST(JVM_VARIANTS)
 116   AC_SUBST(VALID_JVM_VARIANTS)
 117 
 118   # Override hotspot cpu definitions
 119   if test "x$OPENJDK_TARGET_CPU" = xarm; then
 120     HOTSPOT_TARGET_CPU=arm_32
 121     HOTSPOT_TARGET_CPU_DEFINE="ARM32"
 122     JVM_LDFLAGS="$JVM_LDFLAGS -fsigned-char"
 123     JVM_CFLAGS="$JVM_CFLAGS -DARM -fsigned-char"
 124   elif test "x$OPENJDK_TARGET_ABI_PROFILE" = xarm64; then
 125     AC_MSG_CHECKING([OPENJDK_TARGET_ABI_PROFILE == arm64])
 126     HOTSPOT_TARGET_CPU=arm_64
 127     HOTSPOT_TARGET_CPU_ARCH=arm
 128     JVM_LDFLAGS="$JVM_LDFLAGS -fsigned-char"
 129     JVM_CFLAGS="$JVM_CFLAGS -DARM -fsigned-char"
 130   fi
 131 
 132   if HOTSPOT_CHECK_JVM_VARIANT(zero) || HOTSPOT_CHECK_JVM_VARIANT(zeroshark); then
 133     # zero behaves as a platform and rewrites these values. This is really weird. :(
 134     # We are guaranteed that we do not build any other variants when building zero.
 135     HOTSPOT_TARGET_CPU=zero
 136     HOTSPOT_TARGET_CPU_ARCH=zero
 137   fi
 138 
 139 
 140 
 141 ])
 142 
 143 ###############################################################################
 144 # Check if dtrace should be enabled and has all prerequisites present.
 145 #
 146 AC_DEFUN_ONCE([HOTSPOT_SETUP_DTRACE],
 147 [
 148   # Test for dtrace dependencies
 149   AC_ARG_ENABLE([dtrace], [AS_HELP_STRING([--enable-dtrace@<:@=yes/no/auto@:>@],
 150       [enable dtrace. Default is auto, where dtrace is enabled if all dependencies
 151       are present.])])
 152 
 153   DTRACE_DEP_MISSING=false
 154 
 155   AC_MSG_CHECKING([for dtrace tool])
 156   if test "x$DTRACE" != "x" && test -x "$DTRACE"; then
 157     AC_MSG_RESULT([$DTRACE])
 158   else
 159     AC_MSG_RESULT([not found, cannot build dtrace])
 160     DTRACE_DEP_MISSING=true
 161   fi
 162 
 163   AC_CHECK_HEADERS([sys/sdt.h], [DTRACE_HEADERS_OK=yes],[DTRACE_HEADERS_OK=no])
 164   if test "x$DTRACE_HEADERS_OK" != "xyes"; then
 165     DTRACE_DEP_MISSING=true
 166   fi
 167 
 168   AC_MSG_CHECKING([if dtrace should be built])
 169   if test "x$enable_dtrace" = "xyes"; then
 170     if test "x$DTRACE_DEP_MISSING" = "xtrue"; then
 171       AC_MSG_RESULT([no, missing dependencies])
 172       HELP_MSG_MISSING_DEPENDENCY([dtrace])
 173       AC_MSG_ERROR([Cannot enable dtrace with missing dependencies. See above. $HELP_MSG])
 174     else
 175       INCLUDE_DTRACE=true
 176       AC_MSG_RESULT([yes, forced])
 177     fi
 178   elif test "x$enable_dtrace" = "xno"; then
 179     INCLUDE_DTRACE=false
 180     AC_MSG_RESULT([no, forced])
 181   elif test "x$enable_dtrace" = "xauto" || test "x$enable_dtrace" = "x"; then
 182     if test "x$DTRACE_DEP_MISSING" = "xtrue"; then
 183       INCLUDE_DTRACE=false
 184       AC_MSG_RESULT([no, missing dependencies])
 185     else
 186       INCLUDE_DTRACE=true
 187       AC_MSG_RESULT([yes, dependencies present])
 188     fi
 189   else
 190     AC_MSG_ERROR([Invalid value for --enable-dtrace: $enable_dtrace])
 191   fi
 192   AC_SUBST(INCLUDE_DTRACE)
 193 ])
 194 
 195 ###############################################################################
 196 # Set up all JVM features for each JVM variant.
 197 #
 198 AC_DEFUN_ONCE([HOTSPOT_SETUP_JVM_FEATURES],
 199 [
 200   # The user can in some cases supply additional jvm features. For the custom
 201   # variant, this defines the entire variant.
 202   AC_ARG_WITH([jvm-features], [AS_HELP_STRING([--with-jvm-features],
 203       [additional JVM features to enable (separated by comma),  use '--help' to show possible values @<:@none@:>@])])
 204   if test "x$with_jvm_features" != x; then
 205     AC_MSG_CHECKING([additional JVM features])
 206     JVM_FEATURES=`$ECHO $with_jvm_features | $SED -e 's/,/ /g'`
 207     AC_MSG_RESULT([$JVM_FEATURES])
 208   fi
 209 
 210   # Verify that dependencies are met for explicitly set features.
 211   if HOTSPOT_CHECK_JVM_FEATURE(jvmti) && ! HOTSPOT_CHECK_JVM_FEATURE(services); then
 212     AC_MSG_ERROR([Specified JVM feature 'jvmti' requires feature 'services'])
 213   fi
 214 
 215   if HOTSPOT_CHECK_JVM_FEATURE(management) && ! HOTSPOT_CHECK_JVM_FEATURE(nmt); then
 216     AC_MSG_ERROR([Specified JVM feature 'management' requires feature 'nmt'])
 217   fi
 218 
 219   if HOTSPOT_CHECK_JVM_FEATURE(jvmci) && ! (HOTSPOT_CHECK_JVM_FEATURE(compiler1) || HOTSPOT_CHECK_JVM_FEATURE(compiler2)); then
 220     AC_MSG_ERROR([Specified JVM feature 'jvmci' requires feature 'compiler2' or 'compiler1'])
 221   fi
 222 
 223   if HOTSPOT_CHECK_JVM_FEATURE(compiler2) && ! HOTSPOT_CHECK_JVM_FEATURE(all-gcs); then
 224     AC_MSG_ERROR([Specified JVM feature 'compiler2' requires feature 'all-gcs'])
 225   fi
 226 
 227   if HOTSPOT_CHECK_JVM_FEATURE(vm-structs) && ! HOTSPOT_CHECK_JVM_FEATURE(all-gcs); then
 228     AC_MSG_ERROR([Specified JVM feature 'vm-structs' requires feature 'all-gcs'])
 229   fi
 230 
 231   # Turn on additional features based on other parts of configure
 232   if test "x$INCLUDE_DTRACE" = "xtrue"; then
 233     JVM_FEATURES="$JVM_FEATURES dtrace"
 234   else
 235     if HOTSPOT_CHECK_JVM_FEATURE(dtrace); then
 236       AC_MSG_ERROR([To enable dtrace, you must use --enable-dtrace])
 237     fi
 238   fi
 239 
 240   if test "x$STATIC_BUILD" = "xtrue"; then
 241     JVM_FEATURES="$JVM_FEATURES static-build"
 242   else
 243     if HOTSPOT_CHECK_JVM_FEATURE(static-build); then
 244       AC_MSG_ERROR([To enable static-build, you must use --enable-static-build])
 245     fi
 246   fi
 247 
 248   if ! HOTSPOT_CHECK_JVM_VARIANT(zero) && ! HOTSPOT_CHECK_JVM_VARIANT(zeroshark); then
 249     if HOTSPOT_CHECK_JVM_FEATURE(zero); then
 250       AC_MSG_ERROR([To enable zero/zeroshark, you must use --with-jvm-variants=zero/zeroshark])
 251     fi
 252   fi
 253 
 254   if ! HOTSPOT_CHECK_JVM_VARIANT(zeroshark); then
 255     if HOTSPOT_CHECK_JVM_FEATURE(shark); then
 256       AC_MSG_ERROR([To enable shark, you must use --with-jvm-variants=zeroshark])
 257     fi
 258   fi
 259 
 260   # Only enable jvmci on x86_64, sparcv9 and aarch64.
 261   if test "x$OPENJDK_TARGET_CPU" = "xx86_64" || \
 262       test "x$OPENJDK_TARGET_CPU" = "xsparcv9" || \
 263       test "x$OPENJDK_TARGET_CPU" = "xaarch64" ; then
 264     JVM_FEATURES_jvmci="jvmci"
 265   else
 266     JVM_FEATURES_jvmci=""
 267   fi
 268 
 269   if test "x$OPENJDK_TARGET_CPU" = xarm \
 270       && ! HOTSPOT_CHECK_JVM_FEATURE(pregen-interpreter); then
 271     # Default to use link time optimizations on minimal on arm, unless
 272     # pregen-interpreter is active.
 273     JVM_FEATURES_link_time_opt="link-time-opt"
 274   else
 275     JVM_FEATURES_link_time_opt=""
 276   fi
 277 
 278   # All variants but minimal (and custom) get these features
 279   NON_MINIMAL_FEATURES="$NON_MINIMAL_FEATURES jvmti fprof vm-structs jni-check services management all-gcs nmt cds"
 280 
 281   # Enable features depending on variant.
 282   JVM_FEATURES_server="compiler1 compiler2 $NON_MINIMAL_FEATURES $JVM_FEATURES $JVM_FEATURES_jvmci"
 283   JVM_FEATURES_client="compiler1 $NON_MINIMAL_FEATURES $JVM_FEATURES $JVM_FEATURES_jvmci"
 284   JVM_FEATURES_core="$NON_MINIMAL_FEATURES $JVM_FEATURES"
 285   JVM_FEATURES_minimal="compiler1 minimal $JVM_FEATURES $JVM_FEATURES_link_time_opt"
 286   JVM_FEATURES_zero="zero $NON_MINIMAL_FEATURES $JVM_FEATURES"
 287   JVM_FEATURES_zeroshark="zero shark $NON_MINIMAL_FEATURES $JVM_FEATURES"
 288   JVM_FEATURES_custom="$JVM_FEATURES"
 289 
 290   AC_SUBST(JVM_FEATURES_server)
 291   AC_SUBST(JVM_FEATURES_client)
 292   AC_SUBST(JVM_FEATURES_core)
 293   AC_SUBST(JVM_FEATURES_minimal)
 294   AC_SUBST(JVM_FEATURES_zero)
 295   AC_SUBST(JVM_FEATURES_zeroshark)
 296   AC_SUBST(JVM_FEATURES_custom)
 297 
 298   # Used for verification of Makefiles by check-jvm-feature
 299   AC_SUBST(VALID_JVM_FEATURES)
 300 
 301   # We don't support --with-jvm-interpreter anymore, use zero instead.
 302   BASIC_DEPRECATED_ARG_WITH(jvm-interpreter)
 303 ])
 304 
 305 ###############################################################################
 306 # Validate JVM features once all setup is complete, including custom setup.
 307 #
 308 AC_DEFUN_ONCE([HOTSPOT_VALIDATE_JVM_FEATURES],
 309 [
 310   # Keep feature lists sorted and free of duplicates
 311   JVM_FEATURES_server="$($ECHO $($PRINTF '%s\n' $JVM_FEATURES_server | $SORT -u))"
 312   JVM_FEATURES_client="$($ECHO $($PRINTF '%s\n' $JVM_FEATURES_client | $SORT -u))"
 313   JVM_FEATURES_core="$($ECHO $($PRINTF '%s\n' $JVM_FEATURES_core | $SORT -u))"
 314   JVM_FEATURES_minimal="$($ECHO $($PRINTF '%s\n' $JVM_FEATURES_minimal | $SORT -u))"
 315   JVM_FEATURES_zero="$($ECHO $($PRINTF '%s\n' $JVM_FEATURES_zero | $SORT -u))"
 316   JVM_FEATURES_zeroshark="$($ECHO $($PRINTF '%s\n' $JVM_FEATURES_zeroshark | $SORT -u))"
 317   JVM_FEATURES_custom="$($ECHO $($PRINTF '%s\n' $JVM_FEATURES_custom | $SORT -u))"
 318 
 319   # Validate features
 320   for variant in $JVM_VARIANTS; do
 321     AC_MSG_CHECKING([JVM features for JVM variant '$variant'])
 322     features_var_name=JVM_FEATURES_$variant
 323     JVM_FEATURES_TO_TEST=${!features_var_name}
 324     AC_MSG_RESULT([$JVM_FEATURES_TO_TEST])
 325     NEEDLE=${VALID_JVM_FEATURES// /$'\n'}
 326     STACK=${JVM_FEATURES_TO_TEST// /$'\n'}
 327     INVALID_FEATURES=`$GREP -Fvx "${NEEDLE}" <<< "${STACK}"`
 328     if test "x$INVALID_FEATURES" != x; then
 329       AC_MSG_ERROR([Invalid JVM feature(s): $INVALID_FEATURES])
 330     fi
 331   done
 332 ])
 333 
 334 ################################################################################
 335 # Check if gtest should be built
 336 #
 337 AC_DEFUN_ONCE([HOTSPOT_ENABLE_DISABLE_GTEST],
 338 [
 339   AC_ARG_ENABLE([hotspot-gtest], [AS_HELP_STRING([--disable-hotspot-gtest],
 340       [Disables building of the Hotspot unit tests])])
 341 
 342   if test -e "$HOTSPOT_TOPDIR/test/native"; then
 343     GTEST_DIR_EXISTS="true"
 344   else
 345     GTEST_DIR_EXISTS="false"
 346   fi
 347 
 348   AC_MSG_CHECKING([if Hotspot gtest unit tests should be built])
 349   if test "x$enable_hotspot_gtest" = "xyes"; then
 350     if test "x$GTEST_DIR_EXISTS" = "xtrue"; then
 351       AC_MSG_RESULT([yes, forced])
 352       BUILD_GTEST="true"
 353     else
 354       AC_MSG_ERROR([Cannot build gtest without the test source])
 355     fi
 356   elif test "x$enable_hotspot_gtest" = "xno"; then
 357     AC_MSG_RESULT([no, forced])
 358     BUILD_GTEST="false"
 359   elif test "x$enable_hotspot_gtest" = "x"; then
 360     if test "x$GTEST_DIR_EXISTS" = "xtrue" && test "x$OPENJDK_TARGET_OS" != "xaix"; then
 361       AC_MSG_RESULT([yes])
 362       BUILD_GTEST="true"
 363     else
 364       AC_MSG_RESULT([no])
 365       BUILD_GTEST="false"
 366     fi
 367   else
 368     AC_MSG_ERROR([--enable-gtest must be either yes or no])
 369   fi
 370 
 371   AC_SUBST(BUILD_GTEST)
 372 ])