1 #
   2 # Copyright (c) 2011, 2014, 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 AC_DEFUN_ONCE([FLAGS_SETUP_INIT_FLAGS],
  27 [
  28   # Option used to tell the compiler whether to create 32- or 64-bit executables
  29   if test "x$TOOLCHAIN_TYPE" = xxlc; then
  30     COMPILER_TARGET_BITS_FLAG="-q"
  31   else
  32     COMPILER_TARGET_BITS_FLAG="-m"
  33   fi
  34   AC_SUBST(COMPILER_TARGET_BITS_FLAG)
  35 
  36   # FIXME: figure out if we should select AR flags depending on OS or toolchain.
  37   if test "x$OPENJDK_TARGET_OS" = xmacosx; then
  38     ARFLAGS="-r"
  39   elif test "x$OPENJDK_TARGET_OS" = xaix; then
  40     ARFLAGS="-X64"
  41   elif test "x$OPENJDK_TARGET_OS" = xwindows; then
  42     # lib.exe is used as AR to create static libraries.
  43     ARFLAGS="-nologo -NODEFAULTLIB:MSVCRT"
  44   else
  45     ARFLAGS=""
  46   fi
  47   AC_SUBST(ARFLAGS)
  48 
  49   ## Setup strip.
  50   # FIXME: should this really be per platform, or should it be per toolchain type?
  51   # strip is not provided by clang or solstudio; so guessing platform makes most sense.
  52   # FIXME: we should really only export STRIPFLAGS from here, not POST_STRIP_CMD.
  53   if test "x$OPENJDK_TARGET_OS" = xlinux; then
  54     STRIPFLAGS="-g"
  55   elif test "x$OPENJDK_TARGET_OS" = xsolaris; then
  56     STRIPFLAGS="-x"
  57   elif test "x$OPENJDK_TARGET_OS" = xmacosx; then
  58     STRIPFLAGS="-S"
  59   elif test "x$OPENJDK_TARGET_OS" = xaix; then
  60     STRIPFLAGS="-X32_64"
  61   fi
  62 
  63   if test "x$OPENJDK_TARGET_OS" != xwindows; then
  64     POST_STRIP_CMD="$STRIP $STRIPFLAGS"
  65   fi
  66   AC_SUBST(POST_STRIP_CMD)
  67 
  68   if test "x$OPENJDK_TARGET_OS" = xsolaris; then
  69     # FIXME: break out into MCSFLAGS
  70     POST_MCS_CMD="$MCS -d -a \"JDK $FULL_VERSION\""
  71   fi
  72   AC_SUBST(POST_MCS_CMD)
  73 
  74   if test "x$TOOLCHAIN_TYPE" = xmicrosoft; then
  75     CC_OUT_OPTION=-Fo
  76     EXE_OUT_OPTION=-out:
  77     LD_OUT_OPTION=-out:
  78     AR_OUT_OPTION=-out:
  79   else
  80     # The option used to specify the target .o,.a or .so file.
  81     # When compiling, how to specify the to be created object file.
  82     CC_OUT_OPTION='-o$(SPACE)'
  83     # When linking, how to specify the to be created executable.
  84     EXE_OUT_OPTION='-o$(SPACE)'
  85     # When linking, how to specify the to be created dynamically linkable library.
  86     LD_OUT_OPTION='-o$(SPACE)'
  87     # When archiving, how to specify the to be create static archive for object files.
  88     AR_OUT_OPTION='rcs$(SPACE)'
  89   fi
  90   AC_SUBST(CC_OUT_OPTION)
  91   AC_SUBST(EXE_OUT_OPTION)
  92   AC_SUBST(LD_OUT_OPTION)
  93   AC_SUBST(AR_OUT_OPTION)
  94 
  95   # On Windows, we need to set RC flags.
  96   if test "x$TOOLCHAIN_TYPE" = xmicrosoft; then
  97     RC_FLAGS="-nologo -l 0x409 -r"
  98     if test "x$VARIANT" = xOPT; then
  99       RC_FLAGS="$RC_FLAGS -d NDEBUG"
 100     fi
 101 
 102     # The version variables used to create RC_FLAGS may be overridden
 103     # in a custom configure script, or possibly the command line.
 104     # Let those variables be expanded at make time in spec.gmk.
 105     # The \$ are escaped to the shell, and the $(...) variables
 106     # are evaluated by make.
 107     RC_FLAGS="$RC_FLAGS \
 108         -d \"JDK_BUILD_ID=\$(FULL_VERSION)\" \
 109         -d \"JDK_COMPANY=\$(COMPANY_NAME)\" \
 110         -d \"JDK_COMPONENT=\$(PRODUCT_NAME) \$(JDK_RC_PLATFORM_NAME) binary\" \
 111         -d \"JDK_VER=\$(JDK_MINOR_VERSION).\$(JDK_MICRO_VERSION).\$(if \$(JDK_UPDATE_VERSION),\$(JDK_UPDATE_VERSION),0).\$(COOKED_BUILD_NUMBER)\" \
 112         -d \"JDK_COPYRIGHT=Copyright \xA9 $COPYRIGHT_YEAR\" \
 113         -d \"JDK_NAME=\$(PRODUCT_NAME) \$(JDK_RC_PLATFORM_NAME) \$(JDK_MINOR_VERSION) \$(JDK_UPDATE_META_TAG)\" \
 114         -d \"JDK_FVER=\$(JDK_MINOR_VERSION),\$(JDK_MICRO_VERSION),\$(if \$(JDK_UPDATE_VERSION),\$(JDK_UPDATE_VERSION),0),\$(COOKED_BUILD_NUMBER)\""
 115   fi
 116   AC_SUBST(RC_FLAGS)
 117 
 118   if test "x$TOOLCHAIN_TYPE" = xmicrosoft; then
 119     # FIXME: likely bug, should be CCXXFLAGS_JDK? or one for C or CXX.
 120     CCXXFLAGS="$CCXXFLAGS -nologo"
 121   fi
 122 ])
 123 
 124 AC_DEFUN_ONCE([FLAGS_SETUP_COMPILER_FLAGS_FOR_LIBS],
 125 [
 126   ###############################################################################
 127   #
 128   # How to compile shared libraries.
 129   #
 130 
 131   if test "x$TOOLCHAIN_TYPE" = xgcc; then
 132     PICFLAG="-fPIC"
 133     C_FLAG_REORDER=''
 134     CXX_FLAG_REORDER=''
 135 
 136     if test "x$OPENJDK_TARGET_OS" = xmacosx; then
 137       # Linking is different on MacOSX
 138       SHARED_LIBRARY_FLAGS="-dynamiclib -compatibility_version 1.0.0 -current_version 1.0.0 $PICFLAG"
 139       SET_EXECUTABLE_ORIGIN='-Xlinker -rpath -Xlinker @loader_path/.'
 140       SET_SHARED_LIBRARY_ORIGIN="$SET_EXECUTABLE_ORIGIN"
 141       SET_SHARED_LIBRARY_NAME='-Xlinker -install_name -Xlinker @rpath/[$]1'
 142       SET_SHARED_LIBRARY_MAPFILE=''
 143     else
 144       # Default works for linux, might work on other platforms as well.
 145       SHARED_LIBRARY_FLAGS='-shared'
 146       SET_EXECUTABLE_ORIGIN='-Xlinker -rpath -Xlinker \$$$$ORIGIN[$]1'
 147       SET_SHARED_LIBRARY_ORIGIN="-Xlinker -z -Xlinker origin $SET_EXECUTABLE_ORIGIN"
 148       SET_SHARED_LIBRARY_NAME='-Xlinker -soname=[$]1'
 149       SET_SHARED_LIBRARY_MAPFILE='-Xlinker -version-script=[$]1'
 150     fi
 151   elif test "x$TOOLCHAIN_TYPE" = xsolstudio; then
 152     PICFLAG="-KPIC"
 153     C_FLAG_REORDER='-xF'
 154     CXX_FLAG_REORDER='-xF'
 155     SHARED_LIBRARY_FLAGS="-G"
 156     SET_EXECUTABLE_ORIGIN='-R\$$$$ORIGIN[$]1'
 157     SET_SHARED_LIBRARY_ORIGIN="$SET_EXECUTABLE_ORIGIN"
 158     SET_SHARED_LIBRARY_NAME=''
 159     SET_SHARED_LIBRARY_MAPFILE='-M[$]1'
 160   elif test "x$TOOLCHAIN_TYPE" = xxlc; then
 161     PICFLAG="-qpic=large"
 162     C_FLAG_REORDER=''
 163     CXX_FLAG_REORDER=''
 164     SHARED_LIBRARY_FLAGS="-qmkshrobj"
 165     SET_EXECUTABLE_ORIGIN=""
 166     SET_SHARED_LIBRARY_ORIGIN=''
 167     SET_SHARED_LIBRARY_NAME=''
 168     SET_SHARED_LIBRARY_MAPFILE=''
 169   elif test "x$TOOLCHAIN_TYPE" = xmicrosoft; then
 170     PICFLAG=""
 171     C_FLAG_REORDER=''
 172     CXX_FLAG_REORDER=''
 173     SHARED_LIBRARY_FLAGS="-LD"
 174     SET_EXECUTABLE_ORIGIN=''
 175     SET_SHARED_LIBRARY_ORIGIN=''
 176     SET_SHARED_LIBRARY_NAME=''
 177     SET_SHARED_LIBRARY_MAPFILE=''
 178   fi
 179 
 180   AC_SUBST(C_FLAG_REORDER)
 181   AC_SUBST(CXX_FLAG_REORDER)
 182   AC_SUBST(SHARED_LIBRARY_FLAGS)
 183   AC_SUBST(SET_EXECUTABLE_ORIGIN)
 184   AC_SUBST(SET_SHARED_LIBRARY_ORIGIN)
 185   AC_SUBST(SET_SHARED_LIBRARY_NAME)
 186   AC_SUBST(SET_SHARED_LIBRARY_MAPFILE)
 187 
 188   if test "x$OPENJDK_TARGET_OS" = xsolaris; then
 189     CFLAGS_JDK="${CFLAGS_JDK} -D__solaris__"
 190     CXXFLAGS_JDK="${CXXFLAGS_JDK} -D__solaris__"
 191     CFLAGS_JDKLIB_EXTRA='-xstrconst'
 192   fi
 193   # The (cross) compiler is now configured, we can now test capabilities
 194   # of the target platform.
 195 ])
 196 
 197 # Documentation on common flags used for solstudio in HIGHEST.
 198 #
 199 # WARNING: Use of OPTIMIZATION_LEVEL=HIGHEST in your Makefile needs to be
 200 #          done with care, there are some assumptions below that need to
 201 #          be understood about the use of pointers, and IEEE behavior.
 202 #
 203 # -fns: Use non-standard floating point mode (not IEEE 754)
 204 # -fsimple: Do some simplification of floating point arithmetic (not IEEE 754)
 205 # -fsingle: Use single precision floating point with 'float'
 206 # -xalias_level=basic: Assume memory references via basic pointer types do not alias
 207 #   (Source with excessing pointer casting and data access with mixed
 208 #    pointer types are not recommended)
 209 # -xbuiltin=%all: Use intrinsic or inline versions for math/std functions
 210 #   (If you expect perfect errno behavior, do not use this)
 211 # -xdepend: Loop data dependency optimizations (need -xO3 or higher)
 212 # -xrestrict: Pointer parameters to functions do not overlap
 213 #   (Similar to -xalias_level=basic usage, but less obvious sometimes.
 214 #    If you pass in multiple pointers to the same data, do not use this)
 215 # -xlibmil: Inline some library routines
 216 #   (If you expect perfect errno behavior, do not use this)
 217 # -xlibmopt: Use optimized math routines (CURRENTLY DISABLED)
 218 #   (If you expect perfect errno behavior, do not use this)
 219 #  Can cause undefined external on Solaris 8 X86 on __sincos, removing for now
 220 
 221     # FIXME: this will never happen since sparc != sparcv9, ie 32 bit, which we don't build anymore.
 222     # Bug?
 223     #if test "x$OPENJDK_TARGET_CPU" = xsparc; then
 224     #  CFLAGS_JDK="${CFLAGS_JDK} -xmemalign=4s"
 225     #  CXXFLAGS_JDK="${CXXFLAGS_JDK} -xmemalign=4s"
 226     #fi
 227 
 228 AC_DEFUN_ONCE([FLAGS_SETUP_COMPILER_FLAGS_FOR_OPTIMIZATION],
 229 [
 230 
 231   ###############################################################################
 232   #
 233   # Setup the opt flags for different compilers
 234   # and different operating systems.
 235   #
 236 
 237   # FIXME: this was indirectly the old default, but just inherited.
 238   # if test "x$TOOLCHAIN_TYPE" = xmicrosoft; then
 239   #   C_FLAG_DEPS="-MMD -MF"
 240   # fi
 241 
 242   # Generate make dependency files
 243   if test "x$TOOLCHAIN_TYPE" = xgcc; then
 244     C_FLAG_DEPS="-MMD -MF"
 245   elif test "x$TOOLCHAIN_TYPE" = xsolstudio; then
 246     C_FLAG_DEPS="-xMMD -xMF"
 247   elif test "x$TOOLCHAIN_TYPE" = xxlc; then
 248     C_FLAG_DEPS="-qmakedep=gcc -MF"
 249   fi
 250   CXX_FLAG_DEPS="$C_FLAG_DEPS"
 251   AC_SUBST(C_FLAG_DEPS)
 252   AC_SUBST(CXX_FLAG_DEPS)
 253 
 254   # Debug symbols
 255   if test "x$TOOLCHAIN_TYPE" = xgcc; then
 256     if test "x$OPENJDK_TARGET_CPU_BITS" = "x64" && test "x$DEBUG_LEVEL" = "xfastdebug"; then
 257       CFLAGS_DEBUG_SYMBOLS="-g1"
 258       CXXFLAGS_DEBUG_SYMBOLS="-g1"
 259     else
 260       CFLAGS_DEBUG_SYMBOLS="-g"
 261       CXXFLAGS_DEBUG_SYMBOLS="-g"
 262     fi
 263   elif test "x$TOOLCHAIN_TYPE" = xsolstudio; then
 264     CFLAGS_DEBUG_SYMBOLS="-g -xs"
 265     CXXFLAGS_DEBUG_SYMBOLS="-g0 -xs"
 266   elif test "x$TOOLCHAIN_TYPE" = xxlc; then
 267     CFLAGS_DEBUG_SYMBOLS="-g"
 268     CXXFLAGS_DEBUG_SYMBOLS="-g"
 269   fi
 270   AC_SUBST(CFLAGS_DEBUG_SYMBOLS)
 271   AC_SUBST(CXXFLAGS_DEBUG_SYMBOLS)
 272 
 273   # Optimization levels
 274   if test "x$TOOLCHAIN_TYPE" = xsolstudio; then
 275     CC_HIGHEST="$CC_HIGHEST -fns -fsimple -fsingle -xalias_level=basic -xbuiltin=%all -xdepend -xrestrict -xlibmil"
 276 
 277     if test "x$OPENJDK_TARGET_CPU_ARCH" = "xx86"; then
 278       # FIXME: seems we always set -xregs=no%frameptr; put it elsewhere more global?
 279       C_O_FLAG_HIGHEST="-xO4 -Wu,-O4~yz $CC_HIGHEST -xregs=no%frameptr"
 280       C_O_FLAG_HI="-xO4 -Wu,-O4~yz -xregs=no%frameptr"
 281       C_O_FLAG_NORM="-xO2 -Wu,-O2~yz -xregs=no%frameptr"
 282       C_O_FLAG_NONE="-xregs=no%frameptr"
 283       CXX_O_FLAG_HIGHEST="-xO4 -Qoption ube -O4~yz $CC_HIGHEST -xregs=no%frameptr"
 284       CXX_O_FLAG_HI="-xO4 -Qoption ube -O4~yz -xregs=no%frameptr"
 285       CXX_O_FLAG_NORM="-xO2 -Qoption ube -O2~yz -xregs=no%frameptr"
 286       CXX_O_FLAG_NONE="-xregs=no%frameptr"
 287       if test "x$OPENJDK_TARGET_CPU_BITS" = "x32"; then
 288         C_O_FLAG_HIGHEST="$C_O_FLAG_HIGHEST -xchip=pentium"
 289         CXX_O_FLAG_HIGHEST="$CXX_O_FLAG_HIGHEST -xchip=pentium"
 290       fi
 291     elif test "x$OPENJDK_TARGET_CPU_ARCH" = "xsparc"; then
 292       C_O_FLAG_HIGHEST="-xO4 -Wc,-Qrm-s -Wc,-Qiselect-T0 $CC_HIGHEST -xprefetch=auto,explicit -xchip=ultra"
 293       C_O_FLAG_HI="-xO4 -Wc,-Qrm-s -Wc,-Qiselect-T0"
 294       C_O_FLAG_NORM="-xO2 -Wc,-Qrm-s -Wc,-Qiselect-T0"
 295       C_O_FLAG_NONE=""
 296       CXX_O_FLAG_HIGHEST="-xO4 -Qoption cg -Qrm-s -Qoption cg -Qiselect-T0 $CC_HIGHEST -xprefetch=auto,explicit -xchip=ultra"
 297       CXX_O_FLAG_HI="-xO4 -Qoption cg -Qrm-s -Qoption cg -Qiselect-T0"
 298       CXX_O_FLAG_NORM="-xO2 -Qoption cg -Qrm-s -Qoption cg -Qiselect-T0"
 299       CXX_O_FLAG_NONE=""
 300     fi
 301   else
 302     # The remaining toolchains share opt flags between CC and CXX;
 303     # setup for C and duplicate afterwards.
 304     if test "x$TOOLCHAIN_TYPE" = xgcc; then
 305       if test "x$OPENJDK_TARGET_OS" = xmacosx; then
 306         # On MacOSX we optimize for size, something
 307         # we should do for all platforms?
 308         C_O_FLAG_HIGHEST="-Os"
 309         C_O_FLAG_HI="-Os"
 310         C_O_FLAG_NORM="-Os"
 311         C_O_FLAG_NONE=""
 312       else
 313         C_O_FLAG_HIGHEST="-O3"
 314         C_O_FLAG_HI="-O3"
 315         C_O_FLAG_NORM="-O2"
 316         C_O_FLAG_NONE="-O0"
 317       fi
 318     elif test "x$TOOLCHAIN_TYPE" = xxlc; then
 319       C_O_FLAG_HIGHEST="-O3"
 320       C_O_FLAG_HI="-O3 -qstrict"
 321       C_O_FLAG_NORM="-O2"
 322       C_O_FLAG_NONE=""
 323     elif test "x$TOOLCHAIN_TYPE" = xmicrosoft; then
 324       C_O_FLAG_HIGHEST="-O2"
 325       C_O_FLAG_HI="-O1"
 326       C_O_FLAG_NORM="-O1"
 327       C_O_FLAG_NONE="-Od"
 328     fi
 329     CXX_O_FLAG_HIGHEST="$C_O_FLAG_HIGHEST"
 330     CXX_O_FLAG_HI="$C_O_FLAG_HI"
 331     CXX_O_FLAG_NORM="$C_O_FLAG_NORM"
 332     CXX_O_FLAG_NONE="$C_O_FLAG_NONE"
 333   fi
 334 
 335   AC_SUBST(C_O_FLAG_HIGHEST)
 336   AC_SUBST(C_O_FLAG_HI)
 337   AC_SUBST(C_O_FLAG_NORM)
 338   AC_SUBST(C_O_FLAG_NONE)
 339   AC_SUBST(CXX_O_FLAG_HIGHEST)
 340   AC_SUBST(CXX_O_FLAG_HI)
 341   AC_SUBST(CXX_O_FLAG_NORM)
 342   AC_SUBST(CXX_O_FLAG_NONE)
 343 ])
 344 
 345 AC_DEFUN_ONCE([FLAGS_SETUP_COMPILER_FLAGS_FOR_JDK],
 346 [
 347   # Special extras...
 348   if test "x$TOOLCHAIN_TYPE" = xsolstudio; then
 349     if test "x$OPENJDK_TARGET_CPU_ARCH" = "xsparc"; then
 350       CFLAGS_JDKLIB_EXTRA="${CFLAGS_JDKLIB_EXTRA} -xregs=no%appl"
 351       CXXFLAGS_JDKLIB_EXTRA="${CXXFLAGS_JDKLIB_EXTRA} -xregs=no%appl"
 352     fi
 353   elif test "x$TOOLCHAIN_TYPE" = xxlc; then
 354     LDFLAGS_JDK="${LDFLAGS_JDK} -q64 -brtl -bnolibpath -liconv -bexpall"
 355     CFLAGS_JDK="${CFLAGS_JDK} -qchars=signed -q64 -qfullpath -qsaveopt"
 356     CXXFLAGS_JDK="${CXXFLAGS_JDK} -qchars=signed -q64 -qfullpath -qsaveopt"
 357   fi
 358 
 359   if test "x$CFLAGS" != "x${ADDED_CFLAGS}"; then
 360     AC_MSG_WARN([Ignoring CFLAGS($CFLAGS) found in environment. Use --with-extra-cflags])
 361   fi
 362 
 363   if test "x$CXXFLAGS" != "x${ADDED_CXXFLAGS}"; then
 364     AC_MSG_WARN([Ignoring CXXFLAGS($CXXFLAGS) found in environment. Use --with-extra-cxxflags])
 365   fi
 366 
 367   if test "x$LDFLAGS" != "x${ADDED_LDFLAGS}"; then
 368     AC_MSG_WARN([Ignoring LDFLAGS($LDFLAGS) found in environment. Use --with-extra-ldflags])
 369   fi
 370 
 371   AC_ARG_WITH(extra-cflags, [AS_HELP_STRING([--with-extra-cflags],
 372       [extra flags to be used when compiling jdk c-files])])
 373 
 374   AC_ARG_WITH(extra-cxxflags, [AS_HELP_STRING([--with-extra-cxxflags],
 375       [extra flags to be used when compiling jdk c++-files])])
 376 
 377   AC_ARG_WITH(extra-ldflags, [AS_HELP_STRING([--with-extra-ldflags],
 378       [extra flags to be used when linking jdk])])
 379 
 380   CFLAGS_JDK="${CFLAGS_JDK} $with_extra_cflags"
 381   CXXFLAGS_JDK="${CXXFLAGS_JDK} $with_extra_cxxflags"
 382   LDFLAGS_JDK="${LDFLAGS_JDK} $with_extra_ldflags"
 383 
 384   # Hotspot needs these set in their legacy form
 385   LEGACY_EXTRA_CFLAGS=$with_extra_cflags
 386   LEGACY_EXTRA_CXXFLAGS=$with_extra_cxxflags
 387   LEGACY_EXTRA_LDFLAGS=$with_extra_ldflags
 388 
 389   AC_SUBST(LEGACY_EXTRA_CFLAGS)
 390   AC_SUBST(LEGACY_EXTRA_CXXFLAGS)
 391   AC_SUBST(LEGACY_EXTRA_LDFLAGS)
 392 
 393   ###############################################################################
 394   #
 395   # Now setup the CFLAGS and LDFLAGS for the JDK build.
 396   # Later we will also have CFLAGS and LDFLAGS for the hotspot subrepo build.
 397   #
 398 
 399   # Setup compiler/platform specific flags to CFLAGS_JDK,
 400   # CXXFLAGS_JDK and CCXXFLAGS_JDK (common to C and CXX?)
 401   if test "x$TOOLCHAIN_TYPE" = xgcc; then
 402     # these options are used for both C and C++ compiles
 403     CCXXFLAGS_JDK="$CCXXFLAGS $CCXXFLAGS_JDK -Wall -Wno-parentheses -Wextra -Wno-unused -Wno-unused-parameter -Wformat=2 \
 404         -pipe -D_GNU_SOURCE -D_REENTRANT -D_LARGEFILE64_SOURCE"
 405     case $OPENJDK_TARGET_CPU_ARCH in
 406       arm )
 407         # on arm we don't prevent gcc to omit frame pointer but do prevent strict aliasing
 408         CFLAGS_JDK="${CFLAGS_JDK} -fno-strict-aliasing"
 409         ;;
 410       ppc )
 411         # on ppc we don't prevent gcc to omit frame pointer nor strict-aliasing
 412         ;;
 413       * )
 414         CCXXFLAGS_JDK="$CCXXFLAGS_JDK -fno-omit-frame-pointer"
 415         CFLAGS_JDK="${CFLAGS_JDK} -fno-strict-aliasing"
 416         ;;
 417     esac
 418   elif test "x$TOOLCHAIN_TYPE" = xsolstudio; then
 419     CCXXFLAGS_JDK="$CCXXFLAGS $CCXXFLAGS_JDK -DTRACING -DMACRO_MEMSYS_OPS -DBREAKPTS"
 420     if test "x$OPENJDK_TARGET_CPU_ARCH" = xx86; then
 421       CCXXFLAGS_JDK="$CCXXFLAGS_JDK -DcpuIntel -Di586 -D$OPENJDK_TARGET_CPU_LEGACY_LIB"
 422       CFLAGS_JDK="$CFLAGS_JDK -erroff=E_BAD_PRAGMA_PACK_VALUE"
 423     fi
 424   
 425     CFLAGS_JDK="$CFLAGS_JDK -xc99=%none -xCC -errshort=tags -Xa -v -mt -W0,-noglobal"
 426     CXXFLAGS_JDK="$CXXFLAGS_JDK -errtags=yes +w -mt -features=no%except -DCC_NOEX -norunpath -xnolib"
 427   elif test "x$TOOLCHAIN_TYPE" = xxlc; then
 428     CFLAGS_JDK="$CFLAGS_JDK -D_GNU_SOURCE -D_REENTRANT -D_LARGEFILE64_SOURCE -DSTDC"
 429     CXXFLAGS_JDK="$CXXFLAGS_JDK -D_GNU_SOURCE -D_REENTRANT -D_LARGEFILE64_SOURCE -DSTDC"
 430   elif test "x$TOOLCHAIN_TYPE" = xmicrosoft; then
 431     CCXXFLAGS_JDK="$CCXXFLAGS $CCXXFLAGS_JDK -Zi -MD -Zc:wchar_t- -W3 -wd4800 \
 432     -D_STATIC_CPPLIB -D_DISABLE_DEPRECATE_STATIC_CPPLIB -DWIN32_LEAN_AND_MEAN \
 433     -D_CRT_SECURE_NO_DEPRECATE -D_CRT_NONSTDC_NO_DEPRECATE \
 434     -DWIN32 -DIAL"
 435     if test "x$OPENJDK_TARGET_CPU" = xx86_64; then
 436       CCXXFLAGS_JDK="$CCXXFLAGS_JDK -D_AMD64_ -Damd64"
 437     else
 438       CCXXFLAGS_JDK="$CCXXFLAGS_JDK -D_X86_ -Dx86"
 439     fi
 440   fi
 441 
 442   ###############################################################################
 443 
 444   # Adjust flags according to debug level.
 445   case $DEBUG_LEVEL in
 446     fastdebug )
 447       CFLAGS_JDK="$CFLAGS_JDK $CFLAGS_DEBUG_SYMBOLS"
 448       CXXFLAGS_JDK="$CXXFLAGS_JDK $CXXFLAGS_DEBUG_SYMBOLS"
 449       C_O_FLAG_HI="$C_O_FLAG_NORM"
 450       C_O_FLAG_NORM="$C_O_FLAG_NORM"
 451       CXX_O_FLAG_HI="$CXX_O_FLAG_NORM"
 452       CXX_O_FLAG_NORM="$CXX_O_FLAG_NORM"
 453       JAVAC_FLAGS="$JAVAC_FLAGS -g"
 454       ;;
 455     slowdebug )
 456       CFLAGS_JDK="$CFLAGS_JDK $CFLAGS_DEBUG_SYMBOLS"
 457       CXXFLAGS_JDK="$CXXFLAGS_JDK $CXXFLAGS_DEBUG_SYMBOLS"
 458       C_O_FLAG_HI="$C_O_FLAG_NONE"
 459       C_O_FLAG_NORM="$C_O_FLAG_NONE"
 460       CXX_O_FLAG_HI="$CXX_O_FLAG_NONE"
 461       CXX_O_FLAG_NORM="$CXX_O_FLAG_NONE"
 462       JAVAC_FLAGS="$JAVAC_FLAGS -g"
 463       ;;
 464   esac
 465 
 466   # Setup LP64
 467   CCXXFLAGS_JDK="$CCXXFLAGS_JDK $ADD_LP64"
 468 
 469   # Set some common defines. These works for all compilers, but assume
 470   # -D is universally accepted.
 471 
 472   # Setup endianness
 473   if test "x$OPENJDK_TARGET_CPU_ENDIAN" = xlittle; then
 474     # The macro _LITTLE_ENDIAN needs to be defined the same to avoid the
 475     #   Sun C compiler warning message: warning: macro redefined: _LITTLE_ENDIAN
 476     #   (The Solaris X86 system defines this in file /usr/include/sys/isa_defs.h).
 477     #   Note: -Dmacro         is the same as    #define macro 1
 478     #         -Dmacro=        is the same as    #define macro
 479     if test "x$OPENJDK_TARGET_OS" = xsolaris; then
 480       CCXXFLAGS_JDK="$CCXXFLAGS_JDK -D_LITTLE_ENDIAN="
 481     else
 482       CCXXFLAGS_JDK="$CCXXFLAGS_JDK -D_LITTLE_ENDIAN"
 483     fi
 484   else
 485     CCXXFLAGS_JDK="$CCXXFLAGS_JDK -D_BIG_ENDIAN"
 486   fi
 487   
 488   # Setup target OS define. Use OS target name but in upper case.
 489   OPENJDK_TARGET_OS_UPPERCASE=`$ECHO $OPENJDK_TARGET_OS | $TR 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
 490   CCXXFLAGS_JDK="$CCXXFLAGS_JDK -D$OPENJDK_TARGET_OS_UPPERCASE"
 491 
 492   # Setup target CPU
 493   CCXXFLAGS_JDK="$CCXXFLAGS_JDK -DARCH='\"$OPENJDK_TARGET_CPU_LEGACY\"' -D$OPENJDK_TARGET_CPU_LEGACY"
 494   
 495   # Setup debug/release defines
 496   if test "x$DEBUG_LEVEL" = xrelease; then
 497     CCXXFLAGS_JDK="$CCXXFLAGS_JDK -DNDEBUG"
 498     if test "x$OPENJDK_TARGET_OS" = xsolaris; then
 499       CCXXFLAGS_JDK="$CCXXFLAGS_JDK -DTRIMMED"
 500     fi
 501   else
 502     CCXXFLAGS_JDK="$CCXXFLAGS_JDK -DDEBUG"
 503   fi
 504 
 505   # Setup release name
 506   CCXXFLAGS_JDK="$CCXXFLAGS_JDK -DRELEASE='\"\$(RELEASE)\"'"
 507 
 508 
 509   # Set some additional per-OS defines.
 510   if test "x$OPENJDK_TARGET_OS" = xmacosx; then
 511     CCXXFLAGS_JDK="$CCXXFLAGS_JDK -D_ALLBSD_SOURCE -D_DARWIN_UNLIMITED_SELECT"
 512   elif test "x$OPENJDK_TARGET_OS" = xaix; then
 513     # FIXME: PPC64 should not be here.
 514     CCXXFLAGS_JDK="$CCXXFLAGS_JDK -DPPC64"
 515   elif test "x$OPENJDK_TARGET_OS" = xbsd; then
 516     CCXXFLAGS_JDK="$CCXXFLAGS_JDK -D_ALLBSD_SOURCE"
 517   fi
 518 
 519   # Additional macosx handling
 520   if test "x$OPENJDK_TARGET_OS" = xmacosx; then
 521     if test "x$TOOLCHAIN_TYPE" = xgcc; then
 522       # FIXME: This needs to be exported in spec.gmk due to closed legacy code.
 523       # FIXME: clean this up, and/or move it elsewhere.
 524 
 525       # Setting these parameters makes it an error to link to macosx APIs that are
 526       # newer than the given OS version and makes the linked binaries compatible 
 527       # even if built on a newer version of the OS.
 528       # The expected format is X.Y.Z
 529       MACOSX_VERSION_MIN=10.7.0
 530       AC_SUBST(MACOSX_VERSION_MIN)
 531     
 532       # The macro takes the version with no dots, ex: 1070
 533       # Let the flags variables get resolved in make for easier override on make
 534       # command line.
 535       CCXXFLAGS_JDK="$CCXXFLAGS_JDK -DMAC_OS_X_VERSION_MAX_ALLOWED=\$(subst .,,\$(MACOSX_VERSION_MIN)) -mmacosx-version-min=\$(MACOSX_VERSION_MIN)"
 536       LDFLAGS_JDK="$LDFLAGS_JDK -mmacosx-version-min=\$(MACOSX_VERSION_MIN)"
 537     fi
 538   fi
 539 
 540   # Setup some hard coded includes
 541   CCXXFLAGS_JDK="$CCXXFLAGS_JDK \
 542       -I${JDK_OUTPUTDIR}/include \
 543       -I${JDK_OUTPUTDIR}/include/$OPENJDK_TARGET_OS \
 544       -I${JDK_TOPDIR}/src/share/javavm/export \
 545       -I${JDK_TOPDIR}/src/$OPENJDK_TARGET_OS_EXPORT_DIR/javavm/export \
 546       -I${JDK_TOPDIR}/src/share/native/common \
 547       -I${JDK_TOPDIR}/src/$OPENJDK_TARGET_OS_API_DIR/native/common"
 548 
 549   # The shared libraries are compiled using the picflag.
 550   CFLAGS_JDKLIB="$CCXXFLAGS_JDK $CFLAGS_JDK $PICFLAG $CFLAGS_JDKLIB_EXTRA"
 551   CXXFLAGS_JDKLIB="$CCXXFLAGS_JDK $CXXFLAGS_JDK $PICFLAG $CXXFLAGS_JDKLIB_EXTRA "
 552 
 553   # Executable flags
 554   CFLAGS_JDKEXE="$CCXXFLAGS_JDK $CFLAGS_JDK"
 555   CXXFLAGS_JDKEXE="$CCXXFLAGS_JDK $CXXFLAGS_JDK"
 556 
 557   AC_SUBST(CFLAGS_JDKLIB)
 558   AC_SUBST(CFLAGS_JDKEXE)
 559   AC_SUBST(CXXFLAGS_JDKLIB)
 560   AC_SUBST(CXXFLAGS_JDKEXE)
 561 
 562   # Setup LDFLAGS et al.
 563   #
 564   # Now this is odd. The JDK native libraries have to link against libjvm.so
 565   # On 32-bit machines there is normally two distinct libjvm.so:s, client and server.
 566   # Which should we link to? Are we lucky enough that the binary api to the libjvm.so library
 567   # is identical for client and server? Yes. Which is picked at runtime (client or server)?
 568   # Neither, since the chosen libjvm.so has already been loaded by the launcher, all the following
 569   # libraries will link to whatever is in memory. Yuck.
 570   #
 571   # Thus we offer the compiler to find libjvm.so first in server then in client. It works. Ugh.
 572   if test "x$TOOLCHAIN_TYPE" = xmicrosoft; then
 573     LDFLAGS_JDK="$LDFLAGS_JDK -nologo -opt:ref -incremental:no"
 574     if test "x$OPENJDK_TARGET_CPU_BITS" = "x32"; then
 575       LDFLAGS_JDK="$LDFLAGS_JDK -safeseh"
 576     fi
 577     # TODO: make -debug optional "--disable-full-debug-symbols"
 578     LDFLAGS_JDK="$LDFLAGS_JDK -debug"
 579     LDFLAGS_JDKLIB="${LDFLAGS_JDK} -dll -libpath:${JDK_OUTPUTDIR}/lib"
 580     LDFLAGS_JDKLIB_SUFFIX=""
 581     if test "x$OPENJDK_TARGET_CPU_BITS" = "x64"; then
 582       LDFLAGS_STACK_SIZE=1048576
 583     else
 584       LDFLAGS_STACK_SIZE=327680
 585     fi
 586     LDFLAGS_JDKEXE="${LDFLAGS_JDK} /STACK:$LDFLAGS_STACK_SIZE"
 587   else
 588     if test "x$TOOLCHAIN_TYPE" = xgcc; then
 589       # If this is a --hash-style=gnu system, use --hash-style=both, why?
 590       # We have previously set HAS_GNU_HASH if this is the case
 591       if test -n "$HAS_GNU_HASH"; then
 592         LDFLAGS_JDK="${LDFLAGS_JDK} -Xlinker --hash-style=both "
 593       fi
 594       if test "x$OPENJDK_TARGET_OS" = xlinux; then
 595         # And since we now know that the linker is gnu, then add -z defs, to forbid
 596         # undefined symbols in object files.
 597         LDFLAGS_JDK="${LDFLAGS_JDK} -Xlinker -z -Xlinker defs"
 598         if test "x$DEBUG_LEVEL" = "xrelease"; then
 599           # When building release libraries, tell the linker optimize them.
 600           # Should this be supplied to the OSS linker as well?
 601           LDFLAGS_JDK="${LDFLAGS_JDK} -Xlinker -O1"
 602         fi
 603       fi
 604     fi
 605 
 606     if test "x$TOOLCHAIN_TYPE" = xsolstudio; then
 607       LDFLAGS_JDK="$LDFLAGS_JDK -z defs -xildoff -ztext"
 608       LDFLAGS_CXX_JDK="$LDFLAGS_CXX_JDK -norunpath -xnolib"
 609     fi
 610 
 611     LDFLAGS_JDKLIB="${LDFLAGS_JDK} $SHARED_LIBRARY_FLAGS \
 612         -L${JDK_OUTPUTDIR}/lib${OPENJDK_TARGET_CPU_LIBDIR}"
 613 
 614     # On some platforms (mac) the linker warns about non existing -L dirs.
 615     # Add server first if available. Linking aginst client does not always produce the same results.
 616     # Only add client dir if client is being built. Add minimal (note not minimal1) if only building minimal1.
 617     # Default to server for other variants.
 618     if test "x$JVM_VARIANT_SERVER" = xtrue; then
 619       LDFLAGS_JDKLIB="${LDFLAGS_JDKLIB} -L${JDK_OUTPUTDIR}/lib${OPENJDK_TARGET_CPU_LIBDIR}/server"
 620     elif test "x$JVM_VARIANT_CLIENT" = xtrue; then
 621       LDFLAGS_JDKLIB="${LDFLAGS_JDKLIB} -L${JDK_OUTPUTDIR}/lib${OPENJDK_TARGET_CPU_LIBDIR}/client"
 622     elif test "x$JVM_VARIANT_MINIMAL1" = xtrue; then
 623       LDFLAGS_JDKLIB="${LDFLAGS_JDKLIB} -L${JDK_OUTPUTDIR}/lib${OPENJDK_TARGET_CPU_LIBDIR}/minimal"
 624     else
 625       LDFLAGS_JDKLIB="${LDFLAGS_JDKLIB} -L${JDK_OUTPUTDIR}/lib${OPENJDK_TARGET_CPU_LIBDIR}/server"
 626     fi
 627 
 628     LDFLAGS_JDKLIB_SUFFIX="-ljava -ljvm"
 629     if test "x$TOOLCHAIN_TYPE" = xsolstudio; then
 630       LDFLAGS_JDKLIB_SUFFIX="$LDFLAGS_JDKLIB_SUFFIX -lc"
 631     fi
 632 
 633     LDFLAGS_JDKEXE="${LDFLAGS_JDK}"
 634     if test "x$OPENJDK_TARGET_OS" = xlinux; then
 635       LDFLAGS_JDKEXE="$LDFLAGS_JDKEXE -Xlinker --allow-shlib-undefined"
 636     fi
 637   fi
 638   AC_SUBST(LDFLAGS_JDKLIB)
 639   AC_SUBST(LDFLAGS_JDKEXE)
 640   AC_SUBST(LDFLAGS_JDKLIB_SUFFIX)
 641   AC_SUBST(LDFLAGS_JDKEXE_SUFFIX)
 642   AC_SUBST(LDFLAGS_CXX_JDK)
 643 ])
 644 
 645 
 646 # FLAGS_COMPILER_CHECK_ARGUMENTS([ARGUMENT], [RUN-IF-TRUE],
 647 #                                   [RUN-IF-FALSE])
 648 # ------------------------------------------------------------
 649 # Check that the c and c++ compilers support an argument
 650 AC_DEFUN([FLAGS_COMPILER_CHECK_ARGUMENTS],
 651 [
 652   AC_MSG_CHECKING([if compiler supports "$1"])
 653   supports=yes
 654 
 655   saved_cflags="$CFLAGS"
 656   CFLAGS="$CFLAGS $1"
 657   AC_LANG_PUSH([C])
 658   AC_COMPILE_IFELSE([AC_LANG_SOURCE([[int i;]])], [], 
 659       [supports=no])
 660   AC_LANG_POP([C])
 661   CFLAGS="$saved_cflags"
 662 
 663   saved_cxxflags="$CXXFLAGS"
 664   CXXFLAGS="$CXXFLAG $1"
 665   AC_LANG_PUSH([C++])
 666   AC_COMPILE_IFELSE([AC_LANG_SOURCE([[int i;]])], [], 
 667       [supports=no])
 668   AC_LANG_POP([C++])
 669   CXXFLAGS="$saved_cxxflags"
 670 
 671   AC_MSG_RESULT([$supports])
 672   if test "x$supports" = "xyes" ; then
 673     m4_ifval([$2], [$2], [:])
 674   else
 675     m4_ifval([$3], [$3], [:])
 676   fi
 677 ])
 678 
 679 AC_DEFUN_ONCE([FLAGS_SETUP_COMPILER_FLAGS_MISC],
 680 [
 681   # Some Zero and Shark settings.
 682   # ZERO_ARCHFLAG tells the compiler which mode to build for
 683   case "${OPENJDK_TARGET_CPU}" in
 684     s390)
 685       ZERO_ARCHFLAG="${COMPILER_TARGET_BITS_FLAG}31"
 686       ;;
 687     *)
 688       ZERO_ARCHFLAG="${COMPILER_TARGET_BITS_FLAG}${OPENJDK_TARGET_CPU_BITS}"
 689   esac
 690   FLAGS_COMPILER_CHECK_ARGUMENTS([$ZERO_ARCHFLAG], [], [ZERO_ARCHFLAG=""])
 691   AC_SUBST(ZERO_ARCHFLAG)
 692 
 693   # Check that the compiler supports -mX (or -qX on AIX) flags
 694   # Set COMPILER_SUPPORTS_TARGET_BITS_FLAG to 'true' if it does
 695   FLAGS_COMPILER_CHECK_ARGUMENTS([${COMPILER_TARGET_BITS_FLAG}${OPENJDK_TARGET_CPU_BITS}],
 696       [COMPILER_SUPPORTS_TARGET_BITS_FLAG=true],
 697       [COMPILER_SUPPORTS_TARGET_BITS_FLAG=false])
 698   AC_SUBST(COMPILER_SUPPORTS_TARGET_BITS_FLAG)
 699 ])