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" = xclang; then
 152     PICFLAG=''
 153     C_FLAG_REORDER=''
 154     CXX_FLAG_REORDER=''
 155 
 156     if test "x$OPENJDK_TARGET_OS" = xmacosx; then
 157       # Linking is different on MacOSX
 158       SHARED_LIBRARY_FLAGS="-dynamiclib -compatibility_version 1.0.0 -current_version 1.0.0 $PICFLAG"
 159       SET_EXECUTABLE_ORIGIN='-Xlinker -rpath -Xlinker @loader_path/.'
 160       SET_SHARED_LIBRARY_ORIGIN="$SET_EXECUTABLE_ORIGIN"
 161       SET_SHARED_LIBRARY_NAME='-Xlinker -install_name -Xlinker @rpath/[$]1'
 162       SET_SHARED_LIBRARY_MAPFILE=''
 163     else
 164       # Default works for linux, might work on other platforms as well.
 165       SHARED_LIBRARY_FLAGS='-shared'
 166       SET_EXECUTABLE_ORIGIN='-Xlinker -rpath -Xlinker \$$$$ORIGIN[$]1'
 167       SET_SHARED_LIBRARY_ORIGIN="-Xlinker -z -Xlinker origin $SET_EXECUTABLE_ORIGIN"
 168       SET_SHARED_LIBRARY_NAME='-Xlinker -soname=[$]1'
 169       SET_SHARED_LIBRARY_MAPFILE='-Xlinker -version-script=[$]1'
 170     fi
 171   elif test "x$TOOLCHAIN_TYPE" = xsolstudio; then
 172     PICFLAG="-KPIC"
 173     C_FLAG_REORDER='-xF'
 174     CXX_FLAG_REORDER='-xF'
 175     SHARED_LIBRARY_FLAGS="-G"
 176     SET_EXECUTABLE_ORIGIN='-R\$$$$ORIGIN[$]1'
 177     SET_SHARED_LIBRARY_ORIGIN="$SET_EXECUTABLE_ORIGIN"
 178     SET_SHARED_LIBRARY_NAME=''
 179     SET_SHARED_LIBRARY_MAPFILE='-M[$]1'
 180   elif test "x$TOOLCHAIN_TYPE" = xxlc; then
 181     PICFLAG="-qpic=large"
 182     C_FLAG_REORDER=''
 183     CXX_FLAG_REORDER=''
 184     SHARED_LIBRARY_FLAGS="-qmkshrobj"
 185     SET_EXECUTABLE_ORIGIN=""
 186     SET_SHARED_LIBRARY_ORIGIN=''
 187     SET_SHARED_LIBRARY_NAME=''
 188     SET_SHARED_LIBRARY_MAPFILE=''
 189   elif test "x$TOOLCHAIN_TYPE" = xmicrosoft; then
 190     PICFLAG=""
 191     C_FLAG_REORDER=''
 192     CXX_FLAG_REORDER=''
 193     SHARED_LIBRARY_FLAGS="-LD"
 194     SET_EXECUTABLE_ORIGIN=''
 195     SET_SHARED_LIBRARY_ORIGIN=''
 196     SET_SHARED_LIBRARY_NAME=''
 197     SET_SHARED_LIBRARY_MAPFILE=''
 198   fi
 199 
 200   AC_SUBST(C_FLAG_REORDER)
 201   AC_SUBST(CXX_FLAG_REORDER)
 202   AC_SUBST(SHARED_LIBRARY_FLAGS)
 203   AC_SUBST(SET_EXECUTABLE_ORIGIN)
 204   AC_SUBST(SET_SHARED_LIBRARY_ORIGIN)
 205   AC_SUBST(SET_SHARED_LIBRARY_NAME)
 206   AC_SUBST(SET_SHARED_LIBRARY_MAPFILE)
 207 
 208   if test "x$OPENJDK_TARGET_OS" = xsolaris; then
 209     CFLAGS_JDK="${CFLAGS_JDK} -D__solaris__"
 210     CXXFLAGS_JDK="${CXXFLAGS_JDK} -D__solaris__"
 211     CFLAGS_JDKLIB_EXTRA='-xstrconst'
 212   fi
 213   # The (cross) compiler is now configured, we can now test capabilities
 214   # of the target platform.
 215 ])
 216 
 217 # Documentation on common flags used for solstudio in HIGHEST.
 218 #
 219 # WARNING: Use of OPTIMIZATION_LEVEL=HIGHEST in your Makefile needs to be
 220 #          done with care, there are some assumptions below that need to
 221 #          be understood about the use of pointers, and IEEE behavior.
 222 #
 223 # -fns: Use non-standard floating point mode (not IEEE 754)
 224 # -fsimple: Do some simplification of floating point arithmetic (not IEEE 754)
 225 # -fsingle: Use single precision floating point with 'float'
 226 # -xalias_level=basic: Assume memory references via basic pointer types do not alias
 227 #   (Source with excessing pointer casting and data access with mixed
 228 #    pointer types are not recommended)
 229 # -xbuiltin=%all: Use intrinsic or inline versions for math/std functions
 230 #   (If you expect perfect errno behavior, do not use this)
 231 # -xdepend: Loop data dependency optimizations (need -xO3 or higher)
 232 # -xrestrict: Pointer parameters to functions do not overlap
 233 #   (Similar to -xalias_level=basic usage, but less obvious sometimes.
 234 #    If you pass in multiple pointers to the same data, do not use this)
 235 # -xlibmil: Inline some library routines
 236 #   (If you expect perfect errno behavior, do not use this)
 237 # -xlibmopt: Use optimized math routines (CURRENTLY DISABLED)
 238 #   (If you expect perfect errno behavior, do not use this)
 239 #  Can cause undefined external on Solaris 8 X86 on __sincos, removing for now
 240 
 241     # FIXME: this will never happen since sparc != sparcv9, ie 32 bit, which we don't build anymore.
 242     # Bug?
 243     #if test "x$OPENJDK_TARGET_CPU" = xsparc; then
 244     #  CFLAGS_JDK="${CFLAGS_JDK} -xmemalign=4s"
 245     #  CXXFLAGS_JDK="${CXXFLAGS_JDK} -xmemalign=4s"
 246     #fi
 247 
 248 AC_DEFUN_ONCE([FLAGS_SETUP_COMPILER_FLAGS_FOR_OPTIMIZATION],
 249 [
 250 
 251   ###############################################################################
 252   #
 253   # Setup the opt flags for different compilers
 254   # and different operating systems.
 255   #
 256 
 257   # FIXME: this was indirectly the old default, but just inherited.
 258   # if test "x$TOOLCHAIN_TYPE" = xmicrosoft; then
 259   #   C_FLAG_DEPS="-MMD -MF"
 260   # fi
 261 
 262   # Generate make dependency files
 263   if test "x$TOOLCHAIN_TYPE" = xgcc; then
 264     C_FLAG_DEPS="-MMD -MF"
 265   elif test "x$TOOLCHAIN_TYPE" = xclang; then
 266     C_FLAG_DEPS="-MMD -MF"
 267   elif test "x$TOOLCHAIN_TYPE" = xsolstudio; then
 268     C_FLAG_DEPS="-xMMD -xMF"
 269   elif test "x$TOOLCHAIN_TYPE" = xxlc; then
 270     C_FLAG_DEPS="-qmakedep=gcc -MF"
 271   fi
 272   CXX_FLAG_DEPS="$C_FLAG_DEPS"
 273   AC_SUBST(C_FLAG_DEPS)
 274   AC_SUBST(CXX_FLAG_DEPS)
 275 
 276   # Debug symbols
 277   if test "x$TOOLCHAIN_TYPE" = xgcc; then
 278     if test "x$OPENJDK_TARGET_CPU_BITS" = "x64" && test "x$DEBUG_LEVEL" = "xfastdebug"; then
 279       CFLAGS_DEBUG_SYMBOLS="-g1"
 280       CXXFLAGS_DEBUG_SYMBOLS="-g1"
 281     else
 282       CFLAGS_DEBUG_SYMBOLS="-g"
 283       CXXFLAGS_DEBUG_SYMBOLS="-g"
 284     fi
 285   elif test "x$TOOLCHAIN_TYPE" = xclang; then
 286     CFLAGS_DEBUG_SYMBOLS="-g"
 287     CXXFLAGS_DEBUG_SYMBOLS="-g"
 288   elif test "x$TOOLCHAIN_TYPE" = xsolstudio; then
 289     CFLAGS_DEBUG_SYMBOLS="-g -xs"
 290     CXXFLAGS_DEBUG_SYMBOLS="-g0 -xs"
 291   elif test "x$TOOLCHAIN_TYPE" = xxlc; then
 292     CFLAGS_DEBUG_SYMBOLS="-g"
 293     CXXFLAGS_DEBUG_SYMBOLS="-g"
 294   fi
 295   AC_SUBST(CFLAGS_DEBUG_SYMBOLS)
 296   AC_SUBST(CXXFLAGS_DEBUG_SYMBOLS)
 297 
 298   # Optimization levels
 299   if test "x$TOOLCHAIN_TYPE" = xsolstudio; then
 300     CC_HIGHEST="$CC_HIGHEST -fns -fsimple -fsingle -xbuiltin=%all -xdepend -xrestrict -xlibmil"
 301 
 302     if test "x$OPENJDK_TARGET_CPU_ARCH" = "xx86"; then
 303       # FIXME: seems we always set -xregs=no%frameptr; put it elsewhere more global?
 304       C_O_FLAG_HIGHEST="-xO4 -Wu,-O4~yz $CC_HIGHEST -xalias_level=basic -xregs=no%frameptr"
 305       C_O_FLAG_HI="-xO4 -Wu,-O4~yz -xregs=no%frameptr"
 306       C_O_FLAG_NORM="-xO2 -Wu,-O2~yz -xregs=no%frameptr"
 307       C_O_FLAG_NONE="-xregs=no%frameptr"
 308       CXX_O_FLAG_HIGHEST="-xO4 -Qoption ube -O4~yz $CC_HIGHEST -xregs=no%frameptr"
 309       CXX_O_FLAG_HI="-xO4 -Qoption ube -O4~yz -xregs=no%frameptr"
 310       CXX_O_FLAG_NORM="-xO2 -Qoption ube -O2~yz -xregs=no%frameptr"
 311       CXX_O_FLAG_NONE="-xregs=no%frameptr"
 312       if test "x$OPENJDK_TARGET_CPU_BITS" = "x32"; then
 313         C_O_FLAG_HIGHEST="$C_O_FLAG_HIGHEST -xchip=pentium"
 314         CXX_O_FLAG_HIGHEST="$CXX_O_FLAG_HIGHEST -xchip=pentium"
 315       fi
 316     elif test "x$OPENJDK_TARGET_CPU_ARCH" = "xsparc"; then
 317       C_O_FLAG_HIGHEST="-xO4 -Wc,-Qrm-s -Wc,-Qiselect-T0 $CC_HIGHEST -xalias_level=basic -xprefetch=auto,explicit -xchip=ultra"
 318       C_O_FLAG_HI="-xO4 -Wc,-Qrm-s -Wc,-Qiselect-T0"
 319       C_O_FLAG_NORM="-xO2 -Wc,-Qrm-s -Wc,-Qiselect-T0"
 320       C_O_FLAG_NONE=""
 321       CXX_O_FLAG_HIGHEST="-xO4 -Qoption cg -Qrm-s -Qoption cg -Qiselect-T0 $CC_HIGHEST -xprefetch=auto,explicit -xchip=ultra"
 322       CXX_O_FLAG_HI="-xO4 -Qoption cg -Qrm-s -Qoption cg -Qiselect-T0"
 323       CXX_O_FLAG_NORM="-xO2 -Qoption cg -Qrm-s -Qoption cg -Qiselect-T0"
 324       CXX_O_FLAG_NONE=""
 325     fi
 326   else
 327     # The remaining toolchains share opt flags between CC and CXX;
 328     # setup for C and duplicate afterwards.
 329     if test "x$TOOLCHAIN_TYPE" = xgcc; then
 330       if test "x$OPENJDK_TARGET_OS" = xmacosx; then
 331         # On MacOSX we optimize for size, something
 332         # we should do for all platforms?
 333         C_O_FLAG_HIGHEST="-Os"
 334         C_O_FLAG_HI="-Os"
 335         C_O_FLAG_NORM="-Os"
 336         C_O_FLAG_NONE=""
 337       else
 338         C_O_FLAG_HIGHEST="-O3"
 339         C_O_FLAG_HI="-O3"
 340         C_O_FLAG_NORM="-O2"
 341         C_O_FLAG_NONE="-O0"
 342       fi
 343     elif test "x$TOOLCHAIN_TYPE" = xclang; then
 344       if test "x$OPENJDK_TARGET_OS" = xmacosx; then
 345         # On MacOSX we optimize for size, something
 346         # we should do for all platforms?
 347         C_O_FLAG_HIGHEST="-Os"
 348         C_O_FLAG_HI="-Os"
 349         C_O_FLAG_NORM="-Os"
 350         C_O_FLAG_NONE=""
 351       else
 352         C_O_FLAG_HIGHEST="-O3"
 353         C_O_FLAG_HI="-O3"
 354         C_O_FLAG_NORM="-O2"
 355         C_O_FLAG_NONE="-O0"
 356       fi
 357     elif test "x$TOOLCHAIN_TYPE" = xxlc; then
 358       C_O_FLAG_HIGHEST="-O3"
 359       C_O_FLAG_HI="-O3 -qstrict"
 360       C_O_FLAG_NORM="-O2"
 361       C_O_FLAG_NONE=""
 362     elif test "x$TOOLCHAIN_TYPE" = xmicrosoft; then
 363       C_O_FLAG_HIGHEST="-O2"
 364       C_O_FLAG_HI="-O1"
 365       C_O_FLAG_NORM="-O1"
 366       C_O_FLAG_NONE="-Od"
 367     fi
 368     CXX_O_FLAG_HIGHEST="$C_O_FLAG_HIGHEST"
 369     CXX_O_FLAG_HI="$C_O_FLAG_HI"
 370     CXX_O_FLAG_NORM="$C_O_FLAG_NORM"
 371     CXX_O_FLAG_NONE="$C_O_FLAG_NONE"
 372   fi
 373 
 374   AC_SUBST(C_O_FLAG_HIGHEST)
 375   AC_SUBST(C_O_FLAG_HI)
 376   AC_SUBST(C_O_FLAG_NORM)
 377   AC_SUBST(C_O_FLAG_NONE)
 378   AC_SUBST(CXX_O_FLAG_HIGHEST)
 379   AC_SUBST(CXX_O_FLAG_HI)
 380   AC_SUBST(CXX_O_FLAG_NORM)
 381   AC_SUBST(CXX_O_FLAG_NONE)
 382 ])
 383 
 384 AC_DEFUN_ONCE([FLAGS_SETUP_COMPILER_FLAGS_FOR_JDK],
 385 [
 386   # Special extras...
 387   if test "x$TOOLCHAIN_TYPE" = xsolstudio; then
 388     if test "x$OPENJDK_TARGET_CPU_ARCH" = "xsparc"; then
 389       CFLAGS_JDKLIB_EXTRA="${CFLAGS_JDKLIB_EXTRA} -xregs=no%appl"
 390       CXXFLAGS_JDKLIB_EXTRA="${CXXFLAGS_JDKLIB_EXTRA} -xregs=no%appl"
 391     fi
 392   elif test "x$TOOLCHAIN_TYPE" = xxlc; then
 393     LDFLAGS_JDK="${LDFLAGS_JDK} -q64 -brtl -bnolibpath -liconv -bexpall"
 394     CFLAGS_JDK="${CFLAGS_JDK} -qchars=signed -q64 -qfullpath -qsaveopt"
 395     CXXFLAGS_JDK="${CXXFLAGS_JDK} -qchars=signed -q64 -qfullpath -qsaveopt"
 396   fi
 397 
 398   if test "x$CFLAGS" != "x${ADDED_CFLAGS}"; then
 399     AC_MSG_WARN([Ignoring CFLAGS($CFLAGS) found in environment. Use --with-extra-cflags])
 400   fi
 401 
 402   if test "x$CXXFLAGS" != "x${ADDED_CXXFLAGS}"; then
 403     AC_MSG_WARN([Ignoring CXXFLAGS($CXXFLAGS) found in environment. Use --with-extra-cxxflags])
 404   fi
 405 
 406   if test "x$LDFLAGS" != "x${ADDED_LDFLAGS}"; then
 407     AC_MSG_WARN([Ignoring LDFLAGS($LDFLAGS) found in environment. Use --with-extra-ldflags])
 408   fi
 409 
 410   AC_ARG_WITH(extra-cflags, [AS_HELP_STRING([--with-extra-cflags],
 411       [extra flags to be used when compiling jdk c-files])])
 412 
 413   AC_ARG_WITH(extra-cxxflags, [AS_HELP_STRING([--with-extra-cxxflags],
 414       [extra flags to be used when compiling jdk c++-files])])
 415 
 416   AC_ARG_WITH(extra-ldflags, [AS_HELP_STRING([--with-extra-ldflags],
 417       [extra flags to be used when linking jdk])])
 418 
 419   CFLAGS_JDK="${CFLAGS_JDK} $with_extra_cflags"
 420   CXXFLAGS_JDK="${CXXFLAGS_JDK} $with_extra_cxxflags"
 421   LDFLAGS_JDK="${LDFLAGS_JDK} $with_extra_ldflags"
 422 
 423   # Hotspot needs these set in their legacy form
 424   LEGACY_EXTRA_CFLAGS=$with_extra_cflags
 425   LEGACY_EXTRA_CXXFLAGS=$with_extra_cxxflags
 426   LEGACY_EXTRA_LDFLAGS=$with_extra_ldflags
 427 
 428   AC_SUBST(LEGACY_EXTRA_CFLAGS)
 429   AC_SUBST(LEGACY_EXTRA_CXXFLAGS)
 430   AC_SUBST(LEGACY_EXTRA_LDFLAGS)
 431 
 432   ###############################################################################
 433   #
 434   # Now setup the CFLAGS and LDFLAGS for the JDK build.
 435   # Later we will also have CFLAGS and LDFLAGS for the hotspot subrepo build.
 436   #
 437 
 438   # Setup compiler/platform specific flags to CFLAGS_JDK,
 439   # CXXFLAGS_JDK and CCXXFLAGS_JDK (common to C and CXX?)
 440   if test "x$TOOLCHAIN_TYPE" = xgcc; then
 441     # these options are used for both C and C++ compiles
 442     CCXXFLAGS_JDK="$CCXXFLAGS $CCXXFLAGS_JDK -Wall -Wno-parentheses -Wextra -Wno-unused -Wno-unused-parameter -Wformat=2 \
 443         -pipe -D_GNU_SOURCE -D_REENTRANT -D_LARGEFILE64_SOURCE"
 444     case $OPENJDK_TARGET_CPU_ARCH in
 445       arm )
 446         # on arm we don't prevent gcc to omit frame pointer but do prevent strict aliasing
 447         CFLAGS_JDK="${CFLAGS_JDK} -fno-strict-aliasing"
 448         ;;
 449       ppc )
 450         # on ppc we don't prevent gcc to omit frame pointer nor strict-aliasing
 451         ;;
 452       * )
 453         CCXXFLAGS_JDK="$CCXXFLAGS_JDK -fno-omit-frame-pointer"
 454         CFLAGS_JDK="${CFLAGS_JDK} -fno-strict-aliasing"
 455         ;;
 456     esac
 457   elif test "x$TOOLCHAIN_TYPE" = xsolstudio; then
 458     CCXXFLAGS_JDK="$CCXXFLAGS $CCXXFLAGS_JDK -DTRACING -DMACRO_MEMSYS_OPS -DBREAKPTS"
 459     if test "x$OPENJDK_TARGET_CPU_ARCH" = xx86; then
 460       CCXXFLAGS_JDK="$CCXXFLAGS_JDK -DcpuIntel -Di586 -D$OPENJDK_TARGET_CPU_LEGACY_LIB"
 461       CFLAGS_JDK="$CFLAGS_JDK -erroff=E_BAD_PRAGMA_PACK_VALUE"
 462     fi
 463   
 464     CFLAGS_JDK="$CFLAGS_JDK -xc99=%none -xCC -errshort=tags -Xa -v -mt -W0,-noglobal"
 465     CXXFLAGS_JDK="$CXXFLAGS_JDK -errtags=yes +w -mt -features=no%except -DCC_NOEX -norunpath -xnolib"
 466   elif test "x$TOOLCHAIN_TYPE" = xxlc; then
 467     CFLAGS_JDK="$CFLAGS_JDK -D_GNU_SOURCE -D_REENTRANT -D_LARGEFILE64_SOURCE -DSTDC"
 468     CXXFLAGS_JDK="$CXXFLAGS_JDK -D_GNU_SOURCE -D_REENTRANT -D_LARGEFILE64_SOURCE -DSTDC"
 469   elif test "x$TOOLCHAIN_TYPE" = xmicrosoft; then
 470     CCXXFLAGS_JDK="$CCXXFLAGS $CCXXFLAGS_JDK -Zi -MD -Zc:wchar_t- -W3 -wd4800 \
 471     -D_STATIC_CPPLIB -D_DISABLE_DEPRECATE_STATIC_CPPLIB -DWIN32_LEAN_AND_MEAN \
 472     -D_CRT_SECURE_NO_DEPRECATE -D_CRT_NONSTDC_NO_DEPRECATE \
 473     -DWIN32 -DIAL"
 474     if test "x$OPENJDK_TARGET_CPU" = xx86_64; then
 475       CCXXFLAGS_JDK="$CCXXFLAGS_JDK -D_AMD64_ -Damd64"
 476     else
 477       CCXXFLAGS_JDK="$CCXXFLAGS_JDK -D_X86_ -Dx86"
 478     fi
 479   fi
 480 
 481   ###############################################################################
 482 
 483   # Adjust flags according to debug level.
 484   case $DEBUG_LEVEL in
 485     fastdebug )
 486       CFLAGS_JDK="$CFLAGS_JDK $CFLAGS_DEBUG_SYMBOLS"
 487       CXXFLAGS_JDK="$CXXFLAGS_JDK $CXXFLAGS_DEBUG_SYMBOLS"
 488       C_O_FLAG_HI="$C_O_FLAG_NORM"
 489       C_O_FLAG_NORM="$C_O_FLAG_NORM"
 490       CXX_O_FLAG_HI="$CXX_O_FLAG_NORM"
 491       CXX_O_FLAG_NORM="$CXX_O_FLAG_NORM"
 492       JAVAC_FLAGS="$JAVAC_FLAGS -g"
 493       ;;
 494     slowdebug )
 495       CFLAGS_JDK="$CFLAGS_JDK $CFLAGS_DEBUG_SYMBOLS"
 496       CXXFLAGS_JDK="$CXXFLAGS_JDK $CXXFLAGS_DEBUG_SYMBOLS"
 497       C_O_FLAG_HI="$C_O_FLAG_NONE"
 498       C_O_FLAG_NORM="$C_O_FLAG_NONE"
 499       CXX_O_FLAG_HI="$CXX_O_FLAG_NONE"
 500       CXX_O_FLAG_NORM="$CXX_O_FLAG_NONE"
 501       JAVAC_FLAGS="$JAVAC_FLAGS -g"
 502       ;;
 503   esac
 504 
 505   # Setup LP64
 506   CCXXFLAGS_JDK="$CCXXFLAGS_JDK $ADD_LP64"
 507 
 508   # Set some common defines. These works for all compilers, but assume
 509   # -D is universally accepted.
 510 
 511   # Setup endianness
 512   if test "x$OPENJDK_TARGET_CPU_ENDIAN" = xlittle; then
 513     # The macro _LITTLE_ENDIAN needs to be defined the same to avoid the
 514     #   Sun C compiler warning message: warning: macro redefined: _LITTLE_ENDIAN
 515     #   (The Solaris X86 system defines this in file /usr/include/sys/isa_defs.h).
 516     #   Note: -Dmacro         is the same as    #define macro 1
 517     #         -Dmacro=        is the same as    #define macro
 518     if test "x$OPENJDK_TARGET_OS" = xsolaris; then
 519       CCXXFLAGS_JDK="$CCXXFLAGS_JDK -D_LITTLE_ENDIAN="
 520     else
 521       CCXXFLAGS_JDK="$CCXXFLAGS_JDK -D_LITTLE_ENDIAN"
 522     fi
 523   else





 524     CCXXFLAGS_JDK="$CCXXFLAGS_JDK -D_BIG_ENDIAN"

 525   fi
 526   
 527   # Setup target OS define. Use OS target name but in upper case.
 528   OPENJDK_TARGET_OS_UPPERCASE=`$ECHO $OPENJDK_TARGET_OS | $TR 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
 529   CCXXFLAGS_JDK="$CCXXFLAGS_JDK -D$OPENJDK_TARGET_OS_UPPERCASE"
 530 
 531   # Setup target CPU
 532   CCXXFLAGS_JDK="$CCXXFLAGS_JDK -DARCH='\"$OPENJDK_TARGET_CPU_LEGACY\"' -D$OPENJDK_TARGET_CPU_LEGACY"
 533   
 534   # Setup debug/release defines
 535   if test "x$DEBUG_LEVEL" = xrelease; then
 536     CCXXFLAGS_JDK="$CCXXFLAGS_JDK -DNDEBUG"
 537     if test "x$OPENJDK_TARGET_OS" = xsolaris; then
 538       CCXXFLAGS_JDK="$CCXXFLAGS_JDK -DTRIMMED"
 539     fi
 540   else
 541     CCXXFLAGS_JDK="$CCXXFLAGS_JDK -DDEBUG"
 542   fi
 543 
 544   # Setup release name
 545   CCXXFLAGS_JDK="$CCXXFLAGS_JDK -DRELEASE='\"\$(RELEASE)\"'"
 546 
 547 
 548   # Set some additional per-OS defines.
 549   if test "x$OPENJDK_TARGET_OS" = xmacosx; then
 550     CCXXFLAGS_JDK="$CCXXFLAGS_JDK -D_ALLBSD_SOURCE -D_DARWIN_UNLIMITED_SELECT"
 551   elif test "x$OPENJDK_TARGET_OS" = xaix; then
 552     # FIXME: PPC64 should not be here.
 553     CCXXFLAGS_JDK="$CCXXFLAGS_JDK -DPPC64"
 554   elif test "x$OPENJDK_TARGET_OS" = xbsd; then
 555     CCXXFLAGS_JDK="$CCXXFLAGS_JDK -D_ALLBSD_SOURCE"
 556   fi
 557 
 558   # Additional macosx handling
 559   if test "x$OPENJDK_TARGET_OS" = xmacosx; then
 560     if test "x$TOOLCHAIN_TYPE" = xgcc; then
 561       # FIXME: This needs to be exported in spec.gmk due to closed legacy code.
 562       # FIXME: clean this up, and/or move it elsewhere.
 563 
 564       # Setting these parameters makes it an error to link to macosx APIs that are
 565       # newer than the given OS version and makes the linked binaries compatible 
 566       # even if built on a newer version of the OS.
 567       # The expected format is X.Y.Z
 568       MACOSX_VERSION_MIN=10.7.0
 569       AC_SUBST(MACOSX_VERSION_MIN)
 570     
 571       # The macro takes the version with no dots, ex: 1070
 572       # Let the flags variables get resolved in make for easier override on make
 573       # command line.
 574       CCXXFLAGS_JDK="$CCXXFLAGS_JDK -DMAC_OS_X_VERSION_MAX_ALLOWED=\$(subst .,,\$(MACOSX_VERSION_MIN)) -mmacosx-version-min=\$(MACOSX_VERSION_MIN)"
 575       LDFLAGS_JDK="$LDFLAGS_JDK -mmacosx-version-min=\$(MACOSX_VERSION_MIN)"
 576     fi
 577   fi
 578 
 579   # Setup some hard coded includes
 580   CCXXFLAGS_JDK="$CCXXFLAGS_JDK \
 581       -I${JDK_OUTPUTDIR}/include \
 582       -I${JDK_OUTPUTDIR}/include/$OPENJDK_TARGET_OS \
 583       -I${JDK_TOPDIR}/src/share/javavm/export \
 584       -I${JDK_TOPDIR}/src/$OPENJDK_TARGET_OS_EXPORT_DIR/javavm/export \
 585       -I${JDK_TOPDIR}/src/share/native/common \
 586       -I${JDK_TOPDIR}/src/$OPENJDK_TARGET_OS_API_DIR/native/common"
 587 
 588   # The shared libraries are compiled using the picflag.
 589   CFLAGS_JDKLIB="$CCXXFLAGS_JDK $CFLAGS_JDK $PICFLAG $CFLAGS_JDKLIB_EXTRA"
 590   CXXFLAGS_JDKLIB="$CCXXFLAGS_JDK $CXXFLAGS_JDK $PICFLAG $CXXFLAGS_JDKLIB_EXTRA "
 591 
 592   # Executable flags
 593   CFLAGS_JDKEXE="$CCXXFLAGS_JDK $CFLAGS_JDK"
 594   CXXFLAGS_JDKEXE="$CCXXFLAGS_JDK $CXXFLAGS_JDK"
 595 
 596   AC_SUBST(CFLAGS_JDKLIB)
 597   AC_SUBST(CFLAGS_JDKEXE)
 598   AC_SUBST(CXXFLAGS_JDKLIB)
 599   AC_SUBST(CXXFLAGS_JDKEXE)
 600 
 601   # Setup LDFLAGS et al.
 602   #
 603   # Now this is odd. The JDK native libraries have to link against libjvm.so
 604   # On 32-bit machines there is normally two distinct libjvm.so:s, client and server.
 605   # Which should we link to? Are we lucky enough that the binary api to the libjvm.so library
 606   # is identical for client and server? Yes. Which is picked at runtime (client or server)?
 607   # Neither, since the chosen libjvm.so has already been loaded by the launcher, all the following
 608   # libraries will link to whatever is in memory. Yuck.
 609   #
 610   # Thus we offer the compiler to find libjvm.so first in server then in client. It works. Ugh.
 611   if test "x$TOOLCHAIN_TYPE" = xmicrosoft; then
 612     LDFLAGS_JDK="$LDFLAGS_JDK -nologo -opt:ref -incremental:no"
 613     if test "x$OPENJDK_TARGET_CPU_BITS" = "x32"; then
 614       LDFLAGS_JDK="$LDFLAGS_JDK -safeseh"
 615     fi
 616     # TODO: make -debug optional "--disable-full-debug-symbols"
 617     LDFLAGS_JDK="$LDFLAGS_JDK -debug"
 618     LDFLAGS_JDKLIB="${LDFLAGS_JDK} -dll -libpath:${JDK_OUTPUTDIR}/lib"
 619     LDFLAGS_JDKLIB_SUFFIX=""
 620     if test "x$OPENJDK_TARGET_CPU_BITS" = "x64"; then
 621       LDFLAGS_STACK_SIZE=1048576
 622     else
 623       LDFLAGS_STACK_SIZE=327680
 624     fi
 625     LDFLAGS_JDKEXE="${LDFLAGS_JDK} /STACK:$LDFLAGS_STACK_SIZE"
 626   else
 627     if test "x$TOOLCHAIN_TYPE" = xgcc; then
 628       # If this is a --hash-style=gnu system, use --hash-style=both, why?
 629       # We have previously set HAS_GNU_HASH if this is the case
 630       if test -n "$HAS_GNU_HASH"; then
 631         LDFLAGS_JDK="${LDFLAGS_JDK} -Xlinker --hash-style=both "
 632       fi
 633       if test "x$OPENJDK_TARGET_OS" = xlinux; then
 634         # And since we now know that the linker is gnu, then add -z defs, to forbid
 635         # undefined symbols in object files.
 636         LDFLAGS_JDK="${LDFLAGS_JDK} -Xlinker -z -Xlinker defs"
 637         if test "x$DEBUG_LEVEL" = "xrelease"; then
 638           # When building release libraries, tell the linker optimize them.
 639           # Should this be supplied to the OSS linker as well?
 640           LDFLAGS_JDK="${LDFLAGS_JDK} -Xlinker -O1"
 641         fi
 642       fi
 643     fi
 644 
 645     if test "x$TOOLCHAIN_TYPE" = xsolstudio; then
 646       LDFLAGS_JDK="$LDFLAGS_JDK -z defs -xildoff -ztext"
 647       LDFLAGS_CXX_JDK="$LDFLAGS_CXX_JDK -norunpath -xnolib"
 648     fi
 649 
 650     LDFLAGS_JDKLIB="${LDFLAGS_JDK} $SHARED_LIBRARY_FLAGS \
 651         -L${JDK_OUTPUTDIR}/lib${OPENJDK_TARGET_CPU_LIBDIR}"
 652 
 653     # On some platforms (mac) the linker warns about non existing -L dirs.
 654     # Add server first if available. Linking aginst client does not always produce the same results.
 655     # Only add client dir if client is being built. Add minimal (note not minimal1) if only building minimal1.
 656     # Default to server for other variants.
 657     if test "x$JVM_VARIANT_SERVER" = xtrue; then
 658       LDFLAGS_JDKLIB="${LDFLAGS_JDKLIB} -L${JDK_OUTPUTDIR}/lib${OPENJDK_TARGET_CPU_LIBDIR}/server"
 659     elif test "x$JVM_VARIANT_CLIENT" = xtrue; then
 660       LDFLAGS_JDKLIB="${LDFLAGS_JDKLIB} -L${JDK_OUTPUTDIR}/lib${OPENJDK_TARGET_CPU_LIBDIR}/client"
 661     elif test "x$JVM_VARIANT_MINIMAL1" = xtrue; then
 662       LDFLAGS_JDKLIB="${LDFLAGS_JDKLIB} -L${JDK_OUTPUTDIR}/lib${OPENJDK_TARGET_CPU_LIBDIR}/minimal"
 663     else
 664       LDFLAGS_JDKLIB="${LDFLAGS_JDKLIB} -L${JDK_OUTPUTDIR}/lib${OPENJDK_TARGET_CPU_LIBDIR}/server"
 665     fi
 666 
 667     LDFLAGS_JDKLIB_SUFFIX="-ljava -ljvm"
 668     if test "x$TOOLCHAIN_TYPE" = xsolstudio; then
 669       LDFLAGS_JDKLIB_SUFFIX="$LDFLAGS_JDKLIB_SUFFIX -lc"
 670     fi
 671 
 672     LDFLAGS_JDKEXE="${LDFLAGS_JDK}"
 673     if test "x$OPENJDK_TARGET_OS" = xlinux; then
 674       LDFLAGS_JDKEXE="$LDFLAGS_JDKEXE -Xlinker --allow-shlib-undefined"
 675     fi
 676   fi
 677   AC_SUBST(LDFLAGS_JDKLIB)
 678   AC_SUBST(LDFLAGS_JDKEXE)
 679   AC_SUBST(LDFLAGS_JDKLIB_SUFFIX)
 680   AC_SUBST(LDFLAGS_JDKEXE_SUFFIX)
 681   AC_SUBST(LDFLAGS_CXX_JDK)
 682 ])
 683 
 684 
 685 # FLAGS_COMPILER_CHECK_ARGUMENTS([ARGUMENT], [RUN-IF-TRUE],
 686 #                                   [RUN-IF-FALSE])
 687 # ------------------------------------------------------------
 688 # Check that the c and c++ compilers support an argument
 689 AC_DEFUN([FLAGS_COMPILER_CHECK_ARGUMENTS],
 690 [
 691   AC_MSG_CHECKING([if compiler supports "$1"])
 692   supports=yes
 693 
 694   saved_cflags="$CFLAGS"
 695   CFLAGS="$CFLAGS $1"
 696   AC_LANG_PUSH([C])
 697   AC_COMPILE_IFELSE([AC_LANG_SOURCE([[int i;]])], [], 
 698       [supports=no])
 699   AC_LANG_POP([C])
 700   CFLAGS="$saved_cflags"
 701 
 702   saved_cxxflags="$CXXFLAGS"
 703   CXXFLAGS="$CXXFLAG $1"
 704   AC_LANG_PUSH([C++])
 705   AC_COMPILE_IFELSE([AC_LANG_SOURCE([[int i;]])], [], 
 706       [supports=no])
 707   AC_LANG_POP([C++])
 708   CXXFLAGS="$saved_cxxflags"
 709 
 710   AC_MSG_RESULT([$supports])
 711   if test "x$supports" = "xyes" ; then
 712     m4_ifval([$2], [$2], [:])
 713   else
 714     m4_ifval([$3], [$3], [:])
 715   fi
 716 ])
 717 
 718 AC_DEFUN_ONCE([FLAGS_SETUP_COMPILER_FLAGS_MISC],
 719 [
 720   # Some Zero and Shark settings.
 721   # ZERO_ARCHFLAG tells the compiler which mode to build for
 722   case "${OPENJDK_TARGET_CPU}" in
 723     s390)
 724       ZERO_ARCHFLAG="${COMPILER_TARGET_BITS_FLAG}31"
 725       ;;
 726     *)
 727       ZERO_ARCHFLAG="${COMPILER_TARGET_BITS_FLAG}${OPENJDK_TARGET_CPU_BITS}"
 728   esac
 729   FLAGS_COMPILER_CHECK_ARGUMENTS([$ZERO_ARCHFLAG], [], [ZERO_ARCHFLAG=""])
 730   AC_SUBST(ZERO_ARCHFLAG)
 731 
 732   # Check that the compiler supports -mX (or -qX on AIX) flags
 733   # Set COMPILER_SUPPORTS_TARGET_BITS_FLAG to 'true' if it does
 734   FLAGS_COMPILER_CHECK_ARGUMENTS([${COMPILER_TARGET_BITS_FLAG}${OPENJDK_TARGET_CPU_BITS}],
 735       [COMPILER_SUPPORTS_TARGET_BITS_FLAG=true],
 736       [COMPILER_SUPPORTS_TARGET_BITS_FLAG=false])
 737   AC_SUBST(COMPILER_SUPPORTS_TARGET_BITS_FLAG)
 738 
 739   case "${TOOLCHAIN_TYPE}" in
 740     microsoft)
 741       CFLAGS_WARNINGS_ARE_ERRORS="/WX"
 742       ;;
 743     solstudio)
 744       CFLAGS_WARNINGS_ARE_ERRORS="-errtags -errwarn=%all"
 745       ;;
 746     gcc)
 747       CFLAGS_WARNINGS_ARE_ERRORS="-Werror"
 748       ;;
 749     clang)
 750       CFLAGS_WARNINGS_ARE_ERRORS="-Werror"
 751       ;;
 752   esac
 753   AC_SUBST(CFLAGS_WARNINGS_ARE_ERRORS)
 754 ])
--- EOF ---