1 #
   2 # Copyright (c) 2011, 2018, 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 m4_include([flags-cflags.m4])
  27 m4_include([flags-ldflags.m4])
  28 m4_include([flags-other.m4])
  29 
  30 ################################################################################
  31 #
  32 # Setup ABI profile (for arm)
  33 #
  34 AC_DEFUN([FLAGS_SETUP_ABI_PROFILE],
  35 [
  36   AC_ARG_WITH(abi-profile, [AS_HELP_STRING([--with-abi-profile],
  37       [specify ABI profile for ARM builds (arm-vfp-sflt,arm-vfp-hflt,arm-sflt, armv5-vfp-sflt,armv6-vfp-hflt,aarch64) @<:@toolchain dependent@:>@ ])])
  38 
  39   if test "x$with_abi_profile" != x; then
  40     if test "x$OPENJDK_TARGET_CPU" != xarm && \
  41         test "x$OPENJDK_TARGET_CPU" != xaarch64; then
  42       AC_MSG_ERROR([--with-abi-profile only available on arm/aarch64])
  43     fi
  44 
  45     OPENJDK_TARGET_ABI_PROFILE=$with_abi_profile
  46     AC_MSG_CHECKING([for ABI profle])
  47     AC_MSG_RESULT([$OPENJDK_TARGET_ABI_PROFILE])
  48 
  49     # --- Arm-sflt CFLAGS and ASFLAGS ---
  50     # Armv5te is required for assembler, because pld insn used in arm32 hotspot is only in v5E and above.
  51     # However, there is also a GCC bug which generates unaligned strd/ldrd instructions on armv5te:
  52     # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82445, and it was fixed only quite recently.
  53     # The resulting compromise is to enable v5TE for assembler and let GCC generate code for v5T.
  54     if test "x$OPENJDK_TARGET_ABI_PROFILE" = xarm-vfp-sflt; then
  55       ARM_FLOAT_TYPE=vfp-sflt
  56       ARM_ARCH_TYPE_FLAGS='-march=armv7-a -mthumb'
  57       ARM_ARCH_TYPE_ASFLAGS='-march=armv7-a -mthumb'
  58     elif test "x$OPENJDK_TARGET_ABI_PROFILE" = xarm-vfp-hflt; then
  59       ARM_FLOAT_TYPE=vfp-hflt
  60       ARM_ARCH_TYPE_FLAGS='-march=armv7-a -mthumb'
  61       ARM_ARCH_TYPE_ASFLAGS='-march=armv7-a -mthumb'
  62     elif test "x$OPENJDK_TARGET_ABI_PROFILE" = xarm-sflt; then
  63       ARM_FLOAT_TYPE=sflt
  64       ARM_ARCH_TYPE_FLAGS='-march=armv5t -marm'
  65       ARM_ARCH_TYPE_ASFLAGS='-march=armv5te'
  66     elif test "x$OPENJDK_TARGET_ABI_PROFILE" = xarmv5-vfp-sflt; then
  67       ARM_FLOAT_TYPE=vfp-sflt
  68       ARM_ARCH_TYPE_FLAGS='-march=armv5t -marm'
  69       ARM_ARCH_TYPE_ASFLAGS='-march=armv5te'
  70     elif test "x$OPENJDK_TARGET_ABI_PROFILE" = xarmv6-vfp-hflt; then
  71       ARM_FLOAT_TYPE=vfp-hflt
  72       ARM_ARCH_TYPE_FLAGS='-march=armv6 -marm'
  73       ARM_ARCH_TYPE_ASFLAGS='-march=armv6'
  74     elif test "x$OPENJDK_TARGET_ABI_PROFILE" = xaarch64; then
  75       # No special flags, just need to trigger setting JDK_ARCH_ABI_PROP_NAME
  76       ARM_FLOAT_TYPE=
  77       ARM_ARCH_TYPE_FLAGS=
  78       ARM_ARCH_TYPE_ASFLAGS=
  79     else
  80       AC_MSG_ERROR([Invalid ABI profile: "$OPENJDK_TARGET_ABI_PROFILE"])
  81     fi
  82 
  83     if test "x$ARM_FLOAT_TYPE" = xvfp-sflt; then
  84       ARM_FLOAT_TYPE_FLAGS='-mfloat-abi=softfp -mfpu=vfp -DFLOAT_ARCH=-vfp-sflt'
  85       ARM_FLOAT_TYPE_ASFLAGS="-mfloat-abi=softfp -mfpu=vfp"
  86     elif test "x$ARM_FLOAT_TYPE" = xvfp-hflt; then
  87       ARM_FLOAT_TYPE_FLAGS='-mfloat-abi=hard -mfpu=vfp -DFLOAT_ARCH=-vfp-hflt'
  88       ARM_FLOAT_TYPE_ASFLAGS="-mfloat-abi=hard -mfpu=vfp"
  89     elif test "x$ARM_FLOAT_TYPE" = xsflt; then
  90       ARM_FLOAT_TYPE_FLAGS='-msoft-float -mfpu=vfp'
  91       ARM_FLOAT_TYPE_ASFLAGS="-mfloat-abi=soft -mfpu=vfp"
  92     fi
  93     AC_MSG_CHECKING([for $ARM_FLOAT_TYPE floating point flags])
  94     AC_MSG_RESULT([$ARM_FLOAT_TYPE_FLAGS])
  95     AC_MSG_CHECKING([for $ARM_FLOAT_TYPE floating point flags for assembler])
  96     AC_MSG_RESULT([$ARM_FLOAT_TYPE_ASFLAGS])
  97 
  98     AC_MSG_CHECKING([for arch type flags])
  99     AC_MSG_RESULT([$ARM_ARCH_TYPE_FLAGS])
 100     AC_MSG_CHECKING([for arch type flags for assembler])
 101     AC_MSG_RESULT([$ARM_ARCH_TYPE_ASFLAGS])
 102 
 103     # Now set JDK_ARCH_ABI_PROP_NAME. This is equivalent to the last part of the
 104     # autoconf target triplet.
 105     [ JDK_ARCH_ABI_PROP_NAME=`$ECHO $OPENJDK_TARGET_AUTOCONF_NAME | $SED -e 's/.*-\([^-]*\)$/\1/'` ]
 106     # Sanity check that it is a known ABI.
 107     if test "x$JDK_ARCH_ABI_PROP_NAME" != xgnu && \
 108         test "x$JDK_ARCH_ABI_PROP_NAME" != xgnueabi  && \
 109         test "x$JDK_ARCH_ABI_PROP_NAME" != xgnueabihf; then
 110           AC_MSG_WARN([Unknown autoconf target triplet ABI: "$JDK_ARCH_ABI_PROP_NAME"])
 111     fi
 112     AC_MSG_CHECKING([for ABI property name])
 113     AC_MSG_RESULT([$JDK_ARCH_ABI_PROP_NAME])
 114     AC_SUBST(JDK_ARCH_ABI_PROP_NAME)
 115   fi
 116 
 117   # When building with an abi profile, the name of that profile is appended on the
 118   # bundle platform, which is used in bundle names.
 119   if test "x$OPENJDK_TARGET_ABI_PROFILE" != x; then
 120     OPENJDK_TARGET_BUNDLE_PLATFORM="$OPENJDK_TARGET_OS_BUNDLE-$OPENJDK_TARGET_ABI_PROFILE"
 121   fi
 122 ])
 123 
 124 AC_DEFUN([FLAGS_SETUP_MACOSX_VERSION],
 125 [
 126   # Additional macosx handling
 127   if test "x$OPENJDK_TARGET_OS" = xmacosx; then
 128     # MACOSX_VERSION_MIN specifies the lowest version of Macosx that the built
 129     # binaries should be compatible with, even if compiled on a newer version
 130     # of the OS. It currently has a hard coded value. Setting this also limits
 131     # exposure to API changes in header files. Bumping this is likely to
 132     # require code changes to build.
 133     MACOSX_VERSION_MIN=10.9.0
 134     MACOSX_VERSION_MIN_NODOTS=${MACOSX_VERSION_MIN//\./}
 135 
 136     AC_SUBST(MACOSX_VERSION_MIN)
 137 
 138     # Setting --with-macosx-version-max=<version> makes it an error to build or
 139     # link to macosx APIs that are newer than the given OS version. The expected
 140     # format for <version> is either nn.n.n or nn.nn.nn. See /usr/include/AvailabilityMacros.h.
 141     AC_ARG_WITH([macosx-version-max], [AS_HELP_STRING([--with-macosx-version-max],
 142         [error on use of newer functionality. @<:@macosx@:>@])],
 143         [
 144           if echo "$with_macosx_version_max" | $GREP -q "^[[0-9]][[0-9]]\.[[0-9]]\.[[0-9]]\$"; then
 145               MACOSX_VERSION_MAX=$with_macosx_version_max
 146           elif echo "$with_macosx_version_max" | $GREP -q "^[[0-9]][[0-9]]\.[[0-9]][[0-9]]\.[[0-9]][[0-9]]\$"; then
 147               MACOSX_VERSION_MAX=$with_macosx_version_max
 148           elif test "x$with_macosx_version_max" = "xno"; then
 149               # Use build system default
 150               MACOSX_VERSION_MAX=
 151           else
 152               AC_MSG_ERROR([osx version format must be nn.n.n or nn.nn.nn])
 153           fi
 154         ],
 155         [MACOSX_VERSION_MAX=]
 156     )
 157     MACOSX_VERSION_MAX_NODOTS=${MACOSX_VERSION_MAX//\./}
 158 
 159     AC_SUBST(MACOSX_VERSION_MAX)
 160   fi
 161 ])
 162 
 163 # Reset the global CFLAGS/LDFLAGS variables and initialize them with the
 164 # corresponding configure arguments instead
 165 AC_DEFUN_ONCE([FLAGS_SETUP_USER_SUPPLIED_FLAGS],
 166 [
 167   if test "x$CFLAGS" != "x"; then
 168     AC_MSG_WARN([Ignoring CFLAGS($CFLAGS) found in environment. Use --with-extra-cflags])
 169   fi
 170 
 171   if test "x$CXXFLAGS" != "x"; then
 172     AC_MSG_WARN([Ignoring CXXFLAGS($CXXFLAGS) found in environment. Use --with-extra-cxxflags])
 173   fi
 174 
 175   if test "x$LDFLAGS" != "x"; then
 176     AC_MSG_WARN([Ignoring LDFLAGS($LDFLAGS) found in environment. Use --with-extra-ldflags])
 177   fi
 178 
 179   if test "x$ASFLAGS" != "x"; then
 180     AC_MSG_WARN([Ignoring ASFLAGS($ASFLAGS) found in environment. Use --with-extra-asflags])
 181   fi
 182 
 183   AC_ARG_WITH(extra-cflags, [AS_HELP_STRING([--with-extra-cflags],
 184       [extra flags to be used when compiling jdk c-files])])
 185 
 186   AC_ARG_WITH(extra-cxxflags, [AS_HELP_STRING([--with-extra-cxxflags],
 187       [extra flags to be used when compiling jdk c++-files])])
 188 
 189   AC_ARG_WITH(extra-ldflags, [AS_HELP_STRING([--with-extra-ldflags],
 190       [extra flags to be used when linking jdk])])
 191 
 192   AC_ARG_WITH(extra-asflags, [AS_HELP_STRING([--with-extra-asflags],
 193       [extra flags to be passed to the assembler])])
 194 
 195   USER_CFLAGS="$with_extra_cflags"
 196   USER_CXXFLAGS="$with_extra_cxxflags"
 197   USER_LDFLAGS="$with_extra_ldflags"
 198   USER_ASFLAGS="$with_extra_asflags"
 199 ])
 200 
 201 # Setup the sysroot flags and add them to global CFLAGS and LDFLAGS so
 202 # that configure can use them while detecting compilers.
 203 # TOOLCHAIN_TYPE is available here.
 204 # Param 1 - Optional prefix to all variables. (e.g BUILD_)
 205 AC_DEFUN([FLAGS_SETUP_SYSROOT_FLAGS],
 206 [
 207   if test "x[$]$1SYSROOT" != "x"; then
 208     if test "x$TOOLCHAIN_TYPE" = xsolstudio; then
 209       if test "x$OPENJDK_TARGET_OS" = xsolaris; then
 210         # Solaris Studio does not have a concept of sysroot. Instead we must
 211         # make sure the default include and lib dirs are appended to each
 212         # compile and link command line. Must also add -I-xbuiltin to enable
 213         # inlining of system functions and intrinsics.
 214         $1SYSROOT_CFLAGS="-I-xbuiltin -I[$]$1SYSROOT/usr/include"
 215         $1SYSROOT_LDFLAGS="-L[$]$1SYSROOT/usr/lib$OPENJDK_TARGET_CPU_ISADIR \
 216             -L[$]$1SYSROOT/lib$OPENJDK_TARGET_CPU_ISADIR"
 217         # If the devkit contains the ld linker, make sure we use it.
 218         AC_PATH_PROG(SOLARIS_LD, ld, , $DEVKIT_TOOLCHAIN_PATH:$DEVKIT_EXTRA_PATH)
 219         # Make sure this ld is runnable.
 220         if test -f "$SOLARIS_LD"; then
 221           if "$SOLARIS_LD" -V > /dev/null 2> /dev/null; then
 222             $1SYSROOT_LDFLAGS="[$]$1SYSROOT_LDFLAGS -Yl,$(dirname $SOLARIS_LD)"
 223           else
 224             AC_MSG_WARN([Could not run $SOLARIS_LD found in devkit, reverting to system ld])
 225           fi
 226         fi
 227       fi
 228     elif test "x$TOOLCHAIN_TYPE" = xgcc; then
 229       $1SYSROOT_CFLAGS="--sysroot=[$]$1SYSROOT"
 230       $1SYSROOT_LDFLAGS="--sysroot=[$]$1SYSROOT"
 231     elif test "x$TOOLCHAIN_TYPE" = xclang; then
 232       $1SYSROOT_CFLAGS="-isysroot [$]$1SYSROOT"
 233       $1SYSROOT_LDFLAGS="-isysroot [$]$1SYSROOT"
 234     fi
 235   fi
 236 
 237   if test "x$OPENJDK_TARGET_OS" = xmacosx; then
 238     # We also need -iframework<path>/System/Library/Frameworks
 239     $1SYSROOT_CFLAGS="[$]$1SYSROOT_CFLAGS -iframework [$]$1SYSROOT/System/Library/Frameworks"
 240     $1SYSROOT_LDFLAGS="[$]$1SYSROOT_LDFLAGS -iframework [$]$1SYSROOT/System/Library/Frameworks"
 241     # These always need to be set, or we can't find the frameworks embedded in JavaVM.framework
 242     # set this here so it doesn't have to be peppered throughout the forest
 243     $1SYSROOT_CFLAGS="[$]$1SYSROOT_CFLAGS -F [$]$1SYSROOT/System/Library/Frameworks/JavaVM.framework/Frameworks"
 244     $1SYSROOT_LDFLAGS="[$]$1SYSROOT_LDFLAGS -F [$]$1SYSROOT/System/Library/Frameworks/JavaVM.framework/Frameworks"
 245   fi
 246 
 247   AC_SUBST($1SYSROOT_CFLAGS)
 248   AC_SUBST($1SYSROOT_LDFLAGS)
 249 ])
 250 
 251 AC_DEFUN_ONCE([FLAGS_PRE_TOOLCHAIN],
 252 [
 253   # We should always include user supplied flags
 254   FLAGS_SETUP_USER_SUPPLIED_FLAGS
 255   # The sysroot flags are needed for configure to be able to run the compilers
 256   FLAGS_SETUP_SYSROOT_FLAGS
 257 
 258   # For solstudio and xlc, the word size flag is required for correct behavior.
 259   # For clang/gcc, the flag is only strictly required for reduced builds, but
 260   # set it always where possible (x86, sparc and ppc).
 261   if test "x$TOOLCHAIN_TYPE" = xxlc; then
 262     MACHINE_FLAG="-q${OPENJDK_TARGET_CPU_BITS}"
 263   elif test "x$TOOLCHAIN_TYPE" = xsolstudio; then
 264     MACHINE_FLAG="-m${OPENJDK_TARGET_CPU_BITS}"
 265   elif test "x$TOOLCHAIN_TYPE" = xgcc || test "x$TOOLCHAIN_TYPE" = xclang; then
 266     if test "x$OPENJDK_TARGET_CPU_ARCH" = xx86 &&
 267         test "x$OPENJDK_TARGET_CPU" != xx32 ||
 268         test "x$OPENJDK_TARGET_CPU_ARCH" = xsparc ||
 269         test "x$OPENJDK_TARGET_CPU_ARCH" = xppc; then
 270       MACHINE_FLAG="-m${OPENJDK_TARGET_CPU_BITS}"
 271     fi
 272   fi
 273 
 274   # FIXME: global flags are not used yet...
 275   # The "global" flags will *always* be set. Without them, it is not possible to
 276   # get a working compilation.
 277   GLOBAL_CFLAGS="$MACHINE_FLAG $SYSROOT_CFLAGS $USER_CFLAGS"
 278   GLOBAL_CXXFLAGS="$MACHINE_FLAG $SYSROOT_CFLAGS $USER_CXXFLAGS"
 279   GLOBAL_LDFLAGS="$MACHINE_FLAG $SYSROOT_LDFLAGS $USER_LDFLAGS"
 280   # FIXME: Don't really know how to do with this, but this was the old behavior
 281   GLOBAL_CPPFLAGS="$SYSROOT_CFLAGS"
 282   AC_SUBST(GLOBAL_CFLAGS)
 283   AC_SUBST(GLOBAL_CXXFLAGS)
 284   AC_SUBST(GLOBAL_LDFLAGS)
 285   AC_SUBST(GLOBAL_CPPFLAGS)
 286 
 287   # FIXME: For compatilibity, export this as EXTRA_CFLAGS for now.
 288   EXTRA_CFLAGS="$MACHINE_FLAG $USER_CFLAGS"
 289   EXTRA_CXXFLAGS="$MACHINE_FLAG $USER_CXXFLAGS"
 290   EXTRA_LDFLAGS="$MACHINE_FLAG $USER_LDFLAGS"
 291   EXTRA_ASFLAGS="$USER_ASFLAGS"
 292 
 293   AC_SUBST(EXTRA_CFLAGS)
 294   AC_SUBST(EXTRA_CXXFLAGS)
 295   AC_SUBST(EXTRA_LDFLAGS)
 296   AC_SUBST(EXTRA_ASFLAGS)
 297 
 298   # For autoconf testing to work, the global flags must also be stored in the
 299   # "unnamed" CFLAGS etc.
 300   CFLAGS="$GLOBAL_CFLAGS"
 301   CXXFLAGS="$GLOBAL_CXXFLAGS"
 302   LDFLAGS="$GLOBAL_LDFLAGS"
 303   CPPFLAGS="$GLOBAL_CPPFLAGS"
 304 ])
 305 
 306 AC_DEFUN([FLAGS_SETUP_TOOLCHAIN_CONTROL],
 307 [
 308   # COMPILER_TARGET_BITS_FLAG  : option for selecting 32- or 64-bit output
 309   # COMPILER_COMMAND_FILE_FLAG : option for passing a command file to the compiler
 310   # COMPILER_BINDCMD_FILE_FLAG : option for specifying a file which saves the binder
 311   #                              commands produced by the link step (currently AIX only)
 312   if test "x$TOOLCHAIN_TYPE" = xxlc; then
 313     COMPILER_TARGET_BITS_FLAG="-q"
 314     COMPILER_COMMAND_FILE_FLAG="-f"
 315     COMPILER_BINDCMD_FILE_FLAG="-bloadmap:"
 316   else
 317     COMPILER_TARGET_BITS_FLAG="-m"
 318     COMPILER_COMMAND_FILE_FLAG="@"
 319     COMPILER_BINDCMD_FILE_FLAG=""
 320 
 321     # The solstudio linker does not support @-files.
 322     if test "x$TOOLCHAIN_TYPE" = xsolstudio; then
 323       COMPILER_COMMAND_FILE_FLAG=
 324     fi
 325 
 326     # Check if @file is supported by gcc
 327     if test "x$TOOLCHAIN_TYPE" = xgcc; then
 328       AC_MSG_CHECKING([if @file is supported by gcc])
 329       # Extra emtpy "" to prevent ECHO from interpreting '--version' as argument
 330       $ECHO "" "--version" > command.file
 331       if $CXX @command.file 2>&AS_MESSAGE_LOG_FD >&AS_MESSAGE_LOG_FD; then
 332         AC_MSG_RESULT(yes)
 333         COMPILER_COMMAND_FILE_FLAG="@"
 334       else
 335         AC_MSG_RESULT(no)
 336         COMPILER_COMMAND_FILE_FLAG=
 337       fi
 338       $RM command.file
 339     fi
 340   fi
 341 
 342   AC_SUBST(COMPILER_TARGET_BITS_FLAG)
 343   AC_SUBST(COMPILER_COMMAND_FILE_FLAG)
 344   AC_SUBST(COMPILER_BINDCMD_FILE_FLAG)
 345 
 346   # Check that the compiler supports -mX (or -qX on AIX) flags
 347   # Set COMPILER_SUPPORTS_TARGET_BITS_FLAG to 'true' if it does
 348   FLAGS_COMPILER_CHECK_ARGUMENTS(ARGUMENT: [${COMPILER_TARGET_BITS_FLAG}${OPENJDK_TARGET_CPU_BITS}],
 349       IF_TRUE: [COMPILER_SUPPORTS_TARGET_BITS_FLAG=true],
 350       IF_FALSE: [COMPILER_SUPPORTS_TARGET_BITS_FLAG=false])
 351   AC_SUBST(COMPILER_SUPPORTS_TARGET_BITS_FLAG)
 352 
 353   if test "x$TOOLCHAIN_TYPE" = xmicrosoft; then
 354     CC_OUT_OPTION=-Fo
 355     LD_OUT_OPTION=-out:
 356     AR_OUT_OPTION=-out:
 357   else
 358     # The option used to specify the target .o,.a or .so file.
 359     # When compiling, how to specify the to be created object file.
 360     CC_OUT_OPTION='-o$(SPACE)'
 361     # When linking, how to specify the output
 362     LD_OUT_OPTION='-o$(SPACE)'
 363     # When archiving, how to specify the destination static archive.
 364     if test "x$OPENJDK_TARGET_OS" = xmacosx; then
 365       AR_OUT_OPTION='-r -cs$(SPACE)'
 366     else
 367       AR_OUT_OPTION='-rcs$(SPACE)'
 368     fi
 369   fi
 370   AC_SUBST(CC_OUT_OPTION)
 371   AC_SUBST(LD_OUT_OPTION)
 372   AC_SUBST(AR_OUT_OPTION)
 373 
 374   # Generate make dependency files
 375   if test "x$TOOLCHAIN_TYPE" = xgcc; then
 376     C_FLAG_DEPS="-MMD -MF"
 377   elif test "x$TOOLCHAIN_TYPE" = xclang; then
 378     C_FLAG_DEPS="-MMD -MF"
 379   elif test "x$TOOLCHAIN_TYPE" = xsolstudio; then
 380     C_FLAG_DEPS="-xMMD -xMF"
 381   elif test "x$TOOLCHAIN_TYPE" = xxlc; then
 382     C_FLAG_DEPS="-qmakedep=gcc -MF"
 383   fi
 384   CXX_FLAG_DEPS="$C_FLAG_DEPS"
 385   AC_SUBST(C_FLAG_DEPS)
 386   AC_SUBST(CXX_FLAG_DEPS)
 387 ])
 388 
 389 AC_DEFUN_ONCE([FLAGS_POST_TOOLCHAIN],
 390 [
 391   FLAGS_SETUP_TOOLCHAIN_CONTROL
 392 
 393   if test "x$BUILD_SYSROOT" != x; then
 394     FLAGS_SETUP_SYSROOT_FLAGS([BUILD_])
 395   else
 396     if test "x$COMPILE_TYPE" != "xcross"; then
 397       BUILD_SYSROOT_CFLAGS="$SYSROOT_CFLAGS"
 398       BUILD_SYSROOT_LDFLAGS="$SYSROOT_LDFLAGS"
 399     fi
 400   fi
 401   AC_SUBST(BUILD_SYSROOT_CFLAGS)
 402   AC_SUBST(BUILD_SYSROOT_LDFLAGS)
 403 
 404 ])
 405 
 406 AC_DEFUN([FLAGS_SETUP_FLAGS],
 407 [
 408   FLAGS_SETUP_MACOSX_VERSION
 409   FLAGS_SETUP_ABI_PROFILE
 410 
 411   FLAGS_SETUP_SHARED_LIBS
 412   FLAGS_SETUP_DEBUG_SYMBOLS
 413   FLAGS_SETUP_WARNINGS
 414   FLAGS_SETUP_QUALITY_CHECKS
 415   FLAGS_SETUP_OPTIMIZATION
 416 
 417   FLAGS_SETUP_CFLAGS
 418   FLAGS_SETUP_LDFLAGS
 419 
 420   FLAGS_SETUP_ARFLAGS
 421   FLAGS_SETUP_STRIPFLAGS
 422   FLAGS_SETUP_RCFLAGS
 423 
 424   FLAGS_SETUP_ASFLAGS
 425   FLAGS_SETUP_ASFLAGS_CPU_DEP([TARGET])
 426   FLAGS_SETUP_ASFLAGS_CPU_DEP([BUILD], [OPENJDK_BUILD_])
 427 ])
 428 
 429 # FLAGS_C_COMPILER_CHECK_ARGUMENTS(ARGUMENT: [ARGUMENT], IF_TRUE: [RUN-IF-TRUE],
 430 #                                  IF_FALSE: [RUN-IF-FALSE])
 431 # ------------------------------------------------------------
 432 # Check that the C compiler supports an argument
 433 BASIC_DEFUN_NAMED([FLAGS_C_COMPILER_CHECK_ARGUMENTS],
 434     [*ARGUMENT IF_TRUE IF_FALSE PREFIX], [$@],
 435 [
 436   AC_MSG_CHECKING([if ARG_PREFIX[CC] supports "ARG_ARGUMENT"])
 437   supports=yes
 438 
 439   saved_cflags="$CFLAGS"
 440   saved_cc="$CC"
 441   CFLAGS="$CFLAGS ARG_ARGUMENT"
 442   CC="$ARG_PREFIX[CC]"
 443   AC_LANG_PUSH([C])
 444   AC_COMPILE_IFELSE([AC_LANG_SOURCE([[int i;]])], [],
 445       [supports=no])
 446   AC_LANG_POP([C])
 447   CC="$saved_cc"
 448   CFLAGS="$saved_cflags"
 449 
 450   AC_MSG_RESULT([$supports])
 451   if test "x$supports" = "xyes" ; then
 452     :
 453     ARG_IF_TRUE
 454   else
 455     :
 456     ARG_IF_FALSE
 457   fi
 458 ])
 459 
 460 # FLAGS_CXX_COMPILER_CHECK_ARGUMENTS(ARGUMENT: [ARGUMENT], IF_TRUE: [RUN-IF-TRUE],
 461 #                                    IF_FALSE: [RUN-IF-FALSE])
 462 # ------------------------------------------------------------
 463 # Check that the C++ compiler supports an argument
 464 BASIC_DEFUN_NAMED([FLAGS_CXX_COMPILER_CHECK_ARGUMENTS],
 465     [*ARGUMENT IF_TRUE IF_FALSE PREFIX], [$@],
 466 [
 467   AC_MSG_CHECKING([if ARG_PREFIX[CXX] supports "ARG_ARGUMENT"])
 468   supports=yes
 469 
 470   saved_cxxflags="$CXXFLAGS"
 471   saved_cxx="$CXX"
 472   CXXFLAGS="$CXXFLAG ARG_ARGUMENT"
 473   CXX="$ARG_PREFIX[CXX]"
 474   AC_LANG_PUSH([C++])
 475   AC_COMPILE_IFELSE([AC_LANG_SOURCE([[int i;]])], [],
 476       [supports=no])
 477   AC_LANG_POP([C++])
 478   CXX="$saved_cxx"
 479   CXXFLAGS="$saved_cxxflags"
 480 
 481   AC_MSG_RESULT([$supports])
 482   if test "x$supports" = "xyes" ; then
 483     :
 484     ARG_IF_TRUE
 485   else
 486     :
 487     ARG_IF_FALSE
 488   fi
 489 ])
 490 
 491 # FLAGS_COMPILER_CHECK_ARGUMENTS(ARGUMENT: [ARGUMENT], IF_TRUE: [RUN-IF-TRUE],
 492 #                                IF_FALSE: [RUN-IF-FALSE])
 493 # ------------------------------------------------------------
 494 # Check that the C and C++ compilers support an argument
 495 BASIC_DEFUN_NAMED([FLAGS_COMPILER_CHECK_ARGUMENTS],
 496     [*ARGUMENT IF_TRUE IF_FALSE PREFIX], [$@],
 497 [
 498   FLAGS_C_COMPILER_CHECK_ARGUMENTS(ARGUMENT: [ARG_ARGUMENT],
 499       IF_TRUE: [C_COMP_SUPPORTS="yes"],
 500       IF_FALSE: [C_COMP_SUPPORTS="no"],
 501       PREFIX: [ARG_PREFIX])
 502   FLAGS_CXX_COMPILER_CHECK_ARGUMENTS(ARGUMENT: [ARG_ARGUMENT],
 503       IF_TRUE: [CXX_COMP_SUPPORTS="yes"],
 504       IF_FALSE: [CXX_COMP_SUPPORTS="no"],
 505       PREFIX: [ARG_PREFIX])
 506 
 507   AC_MSG_CHECKING([if both ARG_PREFIX[CC] and ARG_PREFIX[CXX] support "ARG_ARGUMENT"])
 508   supports=no
 509   if test "x$C_COMP_SUPPORTS" = "xyes" -a "x$CXX_COMP_SUPPORTS" = "xyes"; then
 510     supports=yes;
 511   fi
 512 
 513   AC_MSG_RESULT([$supports])
 514   if test "x$supports" = "xyes" ; then
 515     :
 516     ARG_IF_TRUE
 517   else
 518     :
 519     ARG_IF_FALSE
 520   fi
 521 ])
 522 
 523 # FLAGS_LINKER_CHECK_ARGUMENTS(ARGUMENT: [ARGUMENT], IF_TRUE: [RUN-IF-TRUE],
 524 #                                   IF_FALSE: [RUN-IF-FALSE])
 525 # ------------------------------------------------------------
 526 # Check that the linker support an argument
 527 BASIC_DEFUN_NAMED([FLAGS_LINKER_CHECK_ARGUMENTS],
 528     [*ARGUMENT IF_TRUE IF_FALSE], [$@],
 529 [
 530   AC_MSG_CHECKING([if linker supports "ARG_ARGUMENT"])
 531   supports=yes
 532 
 533   saved_ldflags="$LDFLAGS"
 534   LDFLAGS="$LDFLAGS ARG_ARGUMENT"
 535   AC_LANG_PUSH([C])
 536   AC_LINK_IFELSE([AC_LANG_PROGRAM([[]],[[]])],
 537       [], [supports=no])
 538   AC_LANG_POP([C])
 539   LDFLAGS="$saved_ldflags"
 540 
 541   AC_MSG_RESULT([$supports])
 542   if test "x$supports" = "xyes" ; then
 543     :
 544     ARG_IF_TRUE
 545   else
 546     :
 547     ARG_IF_FALSE
 548   fi
 549 ])