common/autoconf/toolchain.m4

changeset 459
3156dff953b1
child 478
2ba6f4da4bf3
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/common/autoconf/toolchain.m4	Thu Jul 05 18:27:07 2012 -0700
     1.3 @@ -0,0 +1,908 @@
     1.4 +#
     1.5 +# Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
     1.6 +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     1.7 +#
     1.8 +# This code is free software; you can redistribute it and/or modify it
     1.9 +# under the terms of the GNU General Public License version 2 only, as
    1.10 +# published by the Free Software Foundation.  Oracle designates this
    1.11 +# particular file as subject to the "Classpath" exception as provided
    1.12 +# by Oracle in the LICENSE file that accompanied this code.
    1.13 +#
    1.14 +# This code is distributed in the hope that it will be useful, but WITHOUT
    1.15 +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    1.16 +# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    1.17 +# version 2 for more details (a copy is included in the LICENSE file that
    1.18 +# accompanied this code).
    1.19 +#
    1.20 +# You should have received a copy of the GNU General Public License version
    1.21 +# 2 along with this work; if not, write to the Free Software Foundation,
    1.22 +# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    1.23 +#
    1.24 +# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    1.25 +# or visit www.oracle.com if you need additional information or have any
    1.26 +# questions.
    1.27 +#
    1.28 +
    1.29 +AC_DEFUN_ONCE([TOOLCHAIN_SETUP_VISUAL_STUDIO_ENV],
    1.30 +[
    1.31 +
    1.32 +# Check if the VS env variables were setup prior to running configure.
    1.33 +# If not, then find vcvarsall.bat and run it automatically, and integrate
    1.34 +# the set env variables into the spec file.
    1.35 +SETUPDEVENV="# No special vars"
    1.36 +if test "x$OPENJDK_BUILD_OS" = "xwindows"; then
    1.37 +    # If vcvarsall.bat has been run, then VCINSTALLDIR is set.
    1.38 +    if test "x$VCINSTALLDIR" != x; then
    1.39 +        # No further setup is needed. The build will happen from this kind
    1.40 +        # of shell.
    1.41 +        SETUPDEVENV="# This spec file expects that you are running bash from within a VS command prompt."
    1.42 +        # Make sure to remind you, if you forget to run make from a cygwin bash shell
    1.43 +        # that is spawned "bash -l" from a VS command prompt.
    1.44 +        CHECK_FOR_VCINSTALLDIR=yes
    1.45 +        AC_MSG_CHECKING([if you are running from within a VS command prompt])
    1.46 +        AC_MSG_RESULT([yes])
    1.47 +    else
    1.48 +        # Ah, we have not yet run vcvarsall.bat/vsvars32.bat/vsvars64.bat. Lets do that. First find it.
    1.49 +        if test "x$VS100COMNTOOLS" != x; then
    1.50 +            VARSBAT=`find "$VS100COMNTOOLS/../.." -name vcvarsall.bat`
    1.51 +	    SEARCH_ROOT="$VS100COMNTOOLS"
    1.52 +        else
    1.53 +            VARSBAT=`find "$PROGRAMFILES" -name vcvarsall.bat`
    1.54 +	    SEARCH_ROOT="$PROGRAMFILES"
    1.55 +        fi
    1.56 +        VCPATH=`dirname "$VARSBAT"`
    1.57 +        VCPATH=`cygpath -w "$VCPATH"`
    1.58 +	if test "x$VARSBAT" = x || test ! -d "$VCPATH"; then
    1.59 +            AC_MSG_CHECKING([if we can find the VS installation])
    1.60 +            AC_MSG_RESULT([no])
    1.61 +            AC_MSG_ERROR([Tried to find a VS installation using both $SEARCH_ROOT but failed. Please run "c:\\cygwin\\bin\\bash.exe -l" from a VS command prompt and then run configure/make from there.])
    1.62 +        fi
    1.63 +        case "$LEGACY_OPENJDK_TARGET_CPU1" in
    1.64 +          i?86)
    1.65 +            VARSBAT_ARCH=x86
    1.66 +            ;;
    1.67 +          *)
    1.68 +            VARSBAT_ARCH=$LEGACY_OPENJDK_TARGET_CPU1
    1.69 +            ;;
    1.70 +        esac
    1.71 +        # Lets extract the variables that are set by vcvarsall.bat/vsvars32.bat/vsvars64.bat
    1.72 +        cd $OUTPUT_ROOT
    1.73 +        bash $SRC_ROOT/common/bin/extractvcvars.sh "$VARSBAT" "$VARSBAT_ARCH"
    1.74 +	cd $CURDIR
    1.75 +	if test ! -s $OUTPUT_ROOT/localdevenv.sh || test ! -s $OUTPUT_ROOT/localdevenv.gmk; then
    1.76 +            AC_MSG_CHECKING([if we can extract the needed env variables])
    1.77 +            AC_MSG_RESULT([no])
    1.78 +            AC_MSG_ERROR([Could not succesfully extract the env variables needed for the VS setup. Please run "c:\\cygwin\\bin\\bash.exe -l" from a VS command prompt and then run configure/make from there.])
    1.79 +        fi 
    1.80 +        # Now set all paths and other env variables. This will allow the rest of 
    1.81 +        # the configure script to find and run the compiler in the proper way.
    1.82 +        . $OUTPUT_ROOT/localdevenv.sh
    1.83 +        AC_MSG_CHECKING([if we can find the VS installation])
    1.84 +	if test "x$VCINSTALLDIR" != x; then 
    1.85 +            AC_MSG_RESULT([$VCINSTALLDIR])
    1.86 +        else 
    1.87 +            AC_MSG_RESULT([no])
    1.88 +            AC_MSG_ERROR([Could not find VS installation. Please install. If you are sure you have installed VS, then please run "c:\\cygwin\\bin\\bash.exe -l" from a VS command prompt and then run configure/make from there.])
    1.89 +        fi
    1.90 +        CHECK_FOR_VCINSTALLDIR=no
    1.91 +	SETUPDEVENV="include $OUTPUT_ROOT/localdevenv.gmk"
    1.92 +
    1.93 +	AC_MSG_CHECKING([for msvcr100.dll])
    1.94 +        AC_ARG_WITH(msvcr100dll, [AS_HELP_STRING([--with-msvcr100dll],
    1.95 +            [copy this msvcr100.dll into the built JDK])])
    1.96 +        if test "x$with_msvcr100dll" != x; then
    1.97 +            MSVCR100DLL="$with_msvcr100dll"
    1.98 +        else
    1.99 +            if test "x$OPENJDK_TARGET_CPU_BITS" = x64; then
   1.100 +                MSVCR100DLL=`find "$VCINSTALLDIR/.." -name msvcr100.dll | grep x64 | head --lines 1`
   1.101 +            else
   1.102 +                MSVCR100DLL=`find "$VCINSTALLDIR/.." -name msvcr100.dll | grep x86 | grep -v ia64 | grep -v x64 | head --lines 1`
   1.103 +                if test "x$MSVCR100DLL" = x; then
   1.104 +                    MSVCR100DLL=`find "$VCINSTALLDIR/.." -name msvcr100.dll | head --lines 1`
   1.105 +                fi
   1.106 +            fi
   1.107 +        fi
   1.108 +	if test "x$MSVCR100DLL" = x; then
   1.109 +           AC_MSG_RESULT([no])
   1.110 +	   AC_MSG_ERROR([Could not find msvcr100.dll !])
   1.111 +        fi
   1.112 +        AC_MSG_RESULT([$MSVCR100DLL])
   1.113 +	SPACESAFE(MSVCR100DLL,[the path to msvcr100.dll])
   1.114 +    fi
   1.115 +fi
   1.116 +AC_SUBST(SETUPDEVENV)
   1.117 +AC_SUBST(CHECK_FOR_VCINSTALLDIR)
   1.118 +AC_SUBST(MSVCR100DLL)
   1.119 +])
   1.120 +
   1.121 +AC_DEFUN_ONCE([TOOLCHAIN_SETUP_SYSROOT_AND_OUT_OPTIONS],
   1.122 +[
   1.123 +###############################################################################
   1.124 +#
   1.125 +# Configure the development tool paths and potential sysroot.
   1.126 +#
   1.127 +AC_LANG(C++)
   1.128 +DEVKIT=
   1.129 +SYS_ROOT=/
   1.130 +AC_SUBST(SYS_ROOT)
   1.131 +
   1.132 +# The option used to specify the target .o,.a or .so file.
   1.133 +# When compiling, how to specify the to be created object file.
   1.134 +CC_OUT_OPTION='-o$(SPACE)'
   1.135 +# When linking, how to specify the to be created executable.
   1.136 +EXE_OUT_OPTION='-o$(SPACE)'
   1.137 +# When linking, how to specify the to be created dynamically linkable library.
   1.138 +LD_OUT_OPTION='-o$(SPACE)'
   1.139 +# When archiving, how to specify the to be create static archive for object files.
   1.140 +AR_OUT_OPTION='rcs$(SPACE)'
   1.141 +AC_SUBST(CC_OUT_OPTION)
   1.142 +AC_SUBST(EXE_OUT_OPTION)
   1.143 +AC_SUBST(LD_OUT_OPTION)
   1.144 +AC_SUBST(AR_OUT_OPTION)
   1.145 +])
   1.146 +
   1.147 +AC_DEFUN_ONCE([TOOLCHAIN_SETUP_PATHS],
   1.148 +[
   1.149 +# If --build AND --host is set, then the configure script will find any
   1.150 +# cross compilation tools in the PATH. Cross compilation tools
   1.151 +# follows the cross compilation standard where they are prefixed with ${host}.
   1.152 +# For example the binary i686-sun-solaris2.10-gcc
   1.153 +# will cross compile for i686-sun-solaris2.10
   1.154 +# If neither of build and host is not set, then build=host and the
   1.155 +# default compiler found in the path will be used.
   1.156 +# Setting only --host, does not seem to be really supported.
   1.157 +# Please set both --build and --host if you want to cross compile.
   1.158 +
   1.159 +DEFINE_CROSS_COMPILE_ARCH=""
   1.160 +HOSTCC=""
   1.161 +HOSTCXX=""
   1.162 +HOSTLD=""
   1.163 +AC_SUBST(DEFINE_CROSS_COMPILE_ARCH)
   1.164 +AC_MSG_CHECKING([if this is a cross compile])
   1.165 +if test "x$OPENJDK_BUILD_SYSTEM" != "x$OPENJDK_TARGET_SYSTEM"; then
   1.166 +    AC_MSG_RESULT([yes, from $OPENJDK_BUILD_SYSTEM to $OPENJDK_TARGET_SYSTEM])
   1.167 +    # We have detected a cross compile!
   1.168 +    DEFINE_CROSS_COMPILE_ARCH="CROSS_COMPILE_ARCH:=$LEGACY_OPENJDK_TARGET_CPU1"
   1.169 +    # Now we to find a C/C++ compiler that can build executables for the build
   1.170 +    # platform. We can't use the AC_PROG_CC macro, since it can only be used
   1.171 +    # once.
   1.172 +    AC_PATH_PROGS(HOSTCC, [cl cc gcc])
   1.173 +    WHICHCMD(HOSTCC)
   1.174 +    AC_PATH_PROGS(HOSTCXX, [cl CC g++])
   1.175 +    WHICHCMD(HOSTCXX)
   1.176 +    AC_PATH_PROG(HOSTLD, ld)
   1.177 +    WHICHCMD(HOSTLD)
   1.178 +    # Building for the build platform should be easy. Therefore
   1.179 +    # we do not need any linkers or assemblers etc.    
   1.180 +else
   1.181 +    AC_MSG_RESULT([no])
   1.182 +fi
   1.183 +
   1.184 +# You can force the sys-root if the sys-root encoded into the cross compiler tools
   1.185 +# is not correct.
   1.186 +AC_ARG_WITH(sys-root, [AS_HELP_STRING([--with-sys-root],
   1.187 +    [pass this sys-root to the compilers and linker (useful if the sys-root encoded in
   1.188 +     the cross compiler tools is incorrect)])])
   1.189 +
   1.190 +if test "x$with_sys_root" != x; then
   1.191 +    SYS_ROOT=$with_sys_root
   1.192 +fi
   1.193 +                     
   1.194 +# If a devkit is found on the builddeps server, then prepend its path to the
   1.195 +# PATH variable. If there are cross compilers available in the devkit, these
   1.196 +# will be found by AC_PROG_CC et al.
   1.197 +BDEPS_CHECK_MODULE(DEVKIT, devkit, xxx,
   1.198 +                    [# Found devkit
   1.199 +                     PATH="$DEVKIT/bin:$PATH"
   1.200 +                     SYS_ROOT="$DEVKIT/${rewritten_target}/sys-root"
   1.201 +                     if test "x$x_includes" = "xNONE"; then
   1.202 +                         x_includes="$SYS_ROOT/usr/include/X11"
   1.203 +                     fi
   1.204 +                     if test "x$x_libraries" = "xNONE"; then
   1.205 +                         x_libraries="$SYS_ROOT/usr/lib"
   1.206 +                     fi
   1.207 +                    ],
   1.208 +                    [])
   1.209 +
   1.210 +if test "x$SYS_ROOT" != "x/" ; then                    
   1.211 +    CFLAGS="--sysroot=$SYS_ROOT $CFLAGS"
   1.212 +    CXXFLAGS="--sysroot=$SYS_ROOT $CXXFLAGS"
   1.213 +    OBJCFLAGS="--sysroot=$SYS_ROOT $OBJCFLAGS" 
   1.214 +    OBJCXXFLAGS="--sysroot=$SYS_ROOT $OBJCFLAGS" 
   1.215 +    CPPFLAGS="--sysroot=$SYS_ROOT $CPPFLAGS"
   1.216 +    LDFLAGS="--sysroot=$SYS_ROOT $LDFLAGS"
   1.217 +fi
   1.218 +
   1.219 +# Store the CFLAGS etal passed to the configure script.
   1.220 +ORG_CFLAGS="$CFLAGS"
   1.221 +ORG_CXXFLAGS="$CXXFLAGS"
   1.222 +ORG_OBJCFLAGS="$OBJCFLAGS"
   1.223 +
   1.224 +AC_ARG_WITH([tools-dir], [AS_HELP_STRING([--with-tools-dir],
   1.225 +	[search this directory for compilers and tools])], [TOOLS_DIR=$with_tools_dir])
   1.226 +
   1.227 +AC_ARG_WITH([devkit], [AS_HELP_STRING([--with-devkit],
   1.228 +	[use this directory as base for tools-dir and sys-root])], [
   1.229 +    if test "x$with_sys_root" != x; then
   1.230 +      AC_MSG_ERROR([Cannot specify both --with-devkit and --with-sys-root at the same time])
   1.231 +    fi
   1.232 +    if test "x$with_tools_dir" != x; then
   1.233 +      AC_MSG_ERROR([Cannot specify both --with-devkit and --with-tools-dir at the same time])
   1.234 +    fi
   1.235 +    TOOLS_DIR=$with_devkit/bin
   1.236 +    SYS_ROOT=$with_devkit/$host_alias/libc
   1.237 +    ])
   1.238 +
   1.239 +# autoconf magic only relies on PATH, so update it if tools dir is specified
   1.240 +OLD_PATH="$PATH"
   1.241 +if test "x$TOOLS_DIR" != x; then
   1.242 +  PATH=$TOOLS_DIR:$PATH
   1.243 +fi
   1.244 +
   1.245 +# gcc is almost always present, but on Windows we
   1.246 +# prefer cl.exe and on Solaris we prefer CC.
   1.247 +# Thus test for them in this order.
   1.248 +AC_PROG_CC([cl cc gcc])
   1.249 +if test "x$CC" = x; then
   1.250 +    HELP_MSG_MISSING_DEPENDENCY([devkit])
   1.251 +    AC_MSG_ERROR([Could not find a compiler. $HELP_MSG])
   1.252 +fi
   1.253 +if test "x$CC" = xcc && test "x$OPENJDK_BUILD_OS" = xmacosx; then
   1.254 +    # Do not use cc on MacOSX use gcc instead.
   1.255 +    CC="gcc"
   1.256 +fi
   1.257 +WHICHCMD(CC)
   1.258 +
   1.259 +AC_PROG_CXX([cl CC g++])
   1.260 +if test "x$CXX" = xCC && test "x$OPENJDK_BUILD_OS" = xmacosx; then
   1.261 +    # The found CC, even though it seems to be a g++ derivate, cannot compile
   1.262 +    # c++ code. Override.
   1.263 +    CXX="g++"
   1.264 +fi
   1.265 +WHICHCMD(CXX)
   1.266 +
   1.267 +if test "x$CXX" = x || test "x$CC" = x; then
   1.268 +    HELP_MSG_MISSING_DEPENDENCY([devkit])
   1.269 +    AC_MSG_ERROR([Could not find the needed compilers! $HELP_MSG ])
   1.270 +fi
   1.271 +
   1.272 +if test "x$OPENJDK_BUILD_OS" != xwindows; then
   1.273 +    AC_PROG_OBJC
   1.274 +    WHICHCMD(OBJC)
   1.275 +else
   1.276 +    OBJC=
   1.277 +fi
   1.278 +
   1.279 +# Restore the flags to the user specified values.
   1.280 +# This is necessary since AC_PROG_CC defaults CFLAGS to "-g -O2"
   1.281 +CFLAGS="$ORG_CFLAGS"
   1.282 +CXXFLAGS="$ORG_CXXFLAGS"
   1.283 +OBJCFLAGS="$ORG_OBJCFLAGS"
   1.284 +
   1.285 +# If we are not cross compiling, use the same compilers for
   1.286 +# building the build platform executables.
   1.287 +if test "x$DEFINE_CROSS_COMPILE_ARCH" = x; then
   1.288 +    HOSTCC="$CC"
   1.289 +    HOSTCXX="$CXX"
   1.290 +fi
   1.291 +
   1.292 +AC_CHECK_TOOL(LD, ld)
   1.293 +WHICHCMD(LD)
   1.294 +LD="$CC"
   1.295 +LDEXE="$CC"
   1.296 +LDCXX="$CXX"
   1.297 +LDEXECXX="$CXX"
   1.298 +# LDEXE is the linker to use, when creating executables.
   1.299 +AC_SUBST(LDEXE)
   1.300 +# Linking C++ libraries.
   1.301 +AC_SUBST(LDCXX)
   1.302 +# Linking C++ executables.
   1.303 +AC_SUBST(LDEXECXX)
   1.304 +
   1.305 +AC_CHECK_TOOL(AR, ar)
   1.306 +WHICHCMD(AR)
   1.307 +if test "x$OPENJDK_BUILD_OS" = xmacosx; then
   1.308 +    ARFLAGS="-r"
   1.309 +else
   1.310 +    ARFLAGS=""
   1.311 +fi
   1.312 +AC_SUBST(ARFLAGS)
   1.313 +
   1.314 +COMPILER_NAME=gcc
   1.315 +COMPILER_TYPE=CC
   1.316 +AS_IF([test "x$OPENJDK_BUILD_OS" = xwindows], [
   1.317 +    # For now, assume that we are always compiling using cl.exe. 
   1.318 +    CC_OUT_OPTION=-Fo
   1.319 +    EXE_OUT_OPTION=-out:
   1.320 +    LD_OUT_OPTION=-out:
   1.321 +    AR_OUT_OPTION=-out:
   1.322 +    # On Windows, reject /usr/bin/link, which is a cygwin
   1.323 +    # program for something completely different.
   1.324 +    AC_CHECK_PROG([WINLD], [link],[link],,, [/usr/bin/link])
   1.325 +    # Since we must ignore the first found link, WINLD will contain
   1.326 +    # the full path to the link.exe program.
   1.327 +    WHICHCMD_SPACESAFE([WINLD])
   1.328 +    LD="$WINLD"
   1.329 +    LDEXE="$WINLD"
   1.330 +    LDCXX="$WINLD"
   1.331 +    LDEXECXX="$WINLD"
   1.332 +    # Set HOSTLD to same as LD until we fully support cross compilation
   1.333 +    # on windows.
   1.334 +    HOSTLD="$WINLD"
   1.335 +
   1.336 +    AC_CHECK_PROG([MT], [mt], [mt],,, [/usr/bin/mt])
   1.337 +    WHICHCMD_SPACESAFE([MT])
   1.338 +    # The resource compiler
   1.339 +    AC_CHECK_PROG([RC], [rc], [rc],,, [/usr/bin/rc])
   1.340 +    WHICHCMD_SPACESAFE([RC])
   1.341 +
   1.342 +    RC_FLAGS="-nologo /l 0x409 /r"
   1.343 +    AS_IF([test "x$VARIANT" = xOPT], [
   1.344 +        RC_FLAGS="$RC_FLAGS -d NDEBUG"
   1.345 +    ])
   1.346 +    JDK_UPDATE_VERSION_NOTNULL=$JDK_UPDATE_VERSION
   1.347 +    AS_IF([test "x$JDK_UPDATE_VERSION" = x], [
   1.348 +        JDK_UPDATE_VERSION_NOTNULL=0
   1.349 +    ])
   1.350 +    RC_FLAGS="$RC_FLAGS -d \"JDK_BUILD_ID=$FULL_VERSION\""
   1.351 +    RC_FLAGS="$RC_FLAGS -d \"JDK_COMPANY=$COMPANY_NAME\""
   1.352 +    RC_FLAGS="$RC_FLAGS -d \"JDK_COMPONENT=$PRODUCT_NAME $JDK_RC_PLATFORM_NAME binary\""
   1.353 +    RC_FLAGS="$RC_FLAGS -d \"JDK_VER=$JDK_MINOR_VERSION.$JDK_MICRO_VERSION.$JDK_UPDATE_VERSION_NOTNULL.$COOKED_BUILD_NUMBER\""
   1.354 +    RC_FLAGS="$RC_FLAGS -d \"JDK_COPYRIGHT=Copyright \xA9 $COPYRIGHT_YEAR\""
   1.355 +    RC_FLAGS="$RC_FLAGS -d \"JDK_NAME=$PRODUCT_NAME $JDK_RC_PLATFORM_NAME $JDK_MINOR_VERSION $JDK_UPDATE_META_TAG\""
   1.356 +    RC_FLAGS="$RC_FLAGS -d \"JDK_FVER=$JDK_MINOR_VERSION,$JDK_MICRO_VERSION,$JDK_UPDATE_VERSION_NOTNULL,$COOKED_BUILD_NUMBER\""
   1.357 +
   1.358 +    # lib.exe is used to create static libraries.
   1.359 +    AC_CHECK_PROG([WINAR], [lib],[lib],,,)
   1.360 +    WHICHCMD_SPACESAFE([WINAR])
   1.361 +    AR="$WINAR"
   1.362 +    ARFLAGS="-nologo -NODEFAULTLIB:MSVCRT"
   1.363 +
   1.364 +    AC_CHECK_PROG([DUMPBIN], [dumpbin], [dumpbin],,,)
   1.365 +    WHICHCMD_SPACESAFE([DUMPBIN])
   1.366 +
   1.367 +    COMPILER_TYPE=CL
   1.368 +    CCXXFLAGS="$CCXXFLAGS -nologo"
   1.369 +])
   1.370 +AC_SUBST(RC_FLAGS)
   1.371 +AC_SUBST(COMPILER_TYPE)
   1.372 +
   1.373 +AC_PROG_CPP
   1.374 +WHICHCMD(CPP)
   1.375 +
   1.376 +AC_PROG_CXXCPP
   1.377 +WHICHCMD(CXXCPP)
   1.378 +
   1.379 +# for solaris we really need solaris tools, and not gnu equivalent
   1.380 +#   these seems to normally reside in /usr/ccs/bin so add that to path before
   1.381 +#   starting to probe
   1.382 +#
   1.383 +#   NOTE: I add this /usr/ccs/bin after TOOLS but before OLD_PATH
   1.384 +#         so that it can be overriden --with-tools-dir
   1.385 +if test "x$OPENJDK_BUILD_OS" = xsolaris; then
   1.386 +    PATH="${TOOLS_DIR}:/usr/ccs/bin:${OLD_PATH}"
   1.387 +fi
   1.388 +
   1.389 +# Find the right assembler.
   1.390 +if test "x$OPENJDK_BUILD_OS" = xsolaris; then
   1.391 +    AC_PATH_PROG(AS, as)
   1.392 +    WHICHCMD(AS)
   1.393 +    ASFLAGS=" "
   1.394 +else
   1.395 +    AS="$CC -c"
   1.396 +    ASFLAGS=" "
   1.397 +fi
   1.398 +AC_SUBST(AS)
   1.399 +AC_SUBST(ASFLAGS)
   1.400 +
   1.401 +if test "x$OPENJDK_BUILD_OS" = xsolaris; then
   1.402 +    AC_PATH_PROG(NM, nm)
   1.403 +    WHICHCMD(NM)
   1.404 +    AC_PATH_PROG(STRIP, strip)
   1.405 +    WHICHCMD(STRIP)
   1.406 +    AC_PATH_PROG(MCS, mcs)
   1.407 +    WHICHCMD(MCS)
   1.408 +else
   1.409 +    AC_CHECK_TOOL(NM, nm)
   1.410 +    WHICHCMD(NM)
   1.411 +    AC_CHECK_TOOL(STRIP, strip)
   1.412 +    WHICHCMD(STRIP)
   1.413 +fi
   1.414 +
   1.415 +###
   1.416 +#
   1.417 +# Check for objcopy
   1.418 +#
   1.419 +#   but search for gobjcopy first...
   1.420 +#   since I on solaris found a broken objcopy...buhh
   1.421 +#
   1.422 +AC_PATH_TOOL(OBJCOPY, gobjcopy)
   1.423 +if test "x$OBJCOPY" = x; then
   1.424 +   AC_PATH_TOOL(OBJCOPY, objcopy)
   1.425 +fi
   1.426 +
   1.427 +# Restore old path without tools dir
   1.428 +PATH="$OLD_PATH"
   1.429 +])
   1.430 +
   1.431 +
   1.432 +AC_DEFUN_ONCE([TOOLCHAIN_SETUP_COMPILER_FLAGS_FOR_LIBS],
   1.433 +[
   1.434 +
   1.435 +###############################################################################
   1.436 +#
   1.437 +# How to compile shared libraries. 
   1.438 +#
   1.439 +
   1.440 +if test "x$GCC" = xyes; then
   1.441 +    COMPILER_NAME=gcc
   1.442 +    PICFLAG="-fPIC"
   1.443 +    LIBRARY_PREFIX=lib
   1.444 +    SHARED_LIBRARY='lib[$]1.so'
   1.445 +    STATIC_LIBRARY='lib[$]1.a'
   1.446 +    SHARED_LIBRARY_FLAGS="-shared"
   1.447 +    SHARED_LIBRARY_SUFFIX='.so'
   1.448 +    STATIC_LIBRARY_SUFFIX='.a'
   1.449 +    OBJ_SUFFIX='.o'
   1.450 +    EXE_SUFFIX=''
   1.451 +    SET_SHARED_LIBRARY_NAME='-Xlinker -soname=[$]1'
   1.452 +    SET_SHARED_LIBRARY_MAPFILE='-Xlinker -version-script=[$]1'
   1.453 +    C_FLAG_REORDER=''
   1.454 +    CXX_FLAG_REORDER=''
   1.455 +    SET_SHARED_LIBRARY_ORIGIN='-Xlinker -z -Xlinker origin -Xlinker -rpath -Xlinker \$$$$ORIGIN/[$]1'
   1.456 +    LD="$CC"
   1.457 +    LDEXE="$CC"
   1.458 +    LDCXX="$CXX"
   1.459 +    LDEXECXX="$CXX"
   1.460 +    POST_STRIP_CMD="$STRIP -g"
   1.461 +    if test "x$JDK_VARIANT" = xembedded; then
   1.462 +        POST_STRIP_CMD="$STRIP --strip-unneeded"
   1.463 +    fi
   1.464 +
   1.465 +    # Linking is different on MacOSX
   1.466 +    if test "x$OPENJDK_BUILD_OS" = xmacosx; then
   1.467 +        # Might change in the future to clang.
   1.468 +        COMPILER_NAME=gcc
   1.469 +        SHARED_LIBRARY='lib[$]1.dylib'
   1.470 +        SHARED_LIBRARY_FLAGS="-dynamiclib -compatibility_version 1.0.0 -current_version 1.0.0 $PICFLAG"
   1.471 +        SHARED_LIBRARY_SUFFIX='.dylib'
   1.472 +        EXE_SUFFIX=''
   1.473 +        SET_SHARED_LIBRARY_NAME='-Xlinker -install_name -Xlinker @rpath/[$]1' 
   1.474 +        SET_SHARED_LIBRARY_MAPFILE=''
   1.475 +        SET_SHARED_LIBRARY_ORIGIN='-Xlinker -rpath -Xlinker @loader_path/.'
   1.476 +        POST_STRIP_CMD="$STRIP -S"
   1.477 +    fi
   1.478 +else
   1.479 +    if test "x$OPENJDK_BUILD_OS" = xsolaris; then
   1.480 +        # If it is not gcc, then assume it is the Oracle Solaris Studio Compiler
   1.481 +        COMPILER_NAME=ossc
   1.482 +        PICFLAG="-KPIC"
   1.483 +        LIBRARY_PREFIX=lib
   1.484 +        SHARED_LIBRARY='lib[$]1.so'
   1.485 +        STATIC_LIBRARY='lib[$]1.a'
   1.486 +        SHARED_LIBRARY_FLAGS="-z defs -xildoff -ztext -G"
   1.487 +        SHARED_LIBRARY_SUFFIX='.so'
   1.488 +        STATIC_LIBRARY_SUFFIX='.a'
   1.489 +        OBJ_SUFFIX='.o'
   1.490 +        EXE_SUFFIX=''
   1.491 +        SET_SHARED_LIBRARY_NAME=''
   1.492 +        SET_SHARED_LIBRARY_MAPFILE='-M[$]1'
   1.493 +	C_FLAG_REORDER='-xF'
   1.494 +	CXX_FLAG_REORDER='-xF'
   1.495 +        SET_SHARED_LIBRARY_ORIGIN='-R \$$$$ORIGIN/[$]1'
   1.496 +        CFLAGS_JDK="${CFLAGS_JDK} -D__solaris__"
   1.497 +        CXXFLAGS_JDK="${CXXFLAGS_JDK} -D__solaris__"
   1.498 +        CFLAGS_JDKLIB_EXTRA='-xstrconst'
   1.499 +        POST_STRIP_CMD="$STRIP -x"
   1.500 +        POST_MCS_CMD="$MCS -d -a \"JDK $FULL_VERSION\""
   1.501 +    fi
   1.502 +    if test "x$OPENJDK_BUILD_OS" = xwindows; then
   1.503 +        # If it is not gcc, then assume it is the MS Visual Studio compiler
   1.504 +        COMPILER_NAME=cl
   1.505 +        PICFLAG=""
   1.506 +        LIBRARY_PREFIX=
   1.507 +        SHARED_LIBRARY='[$]1.dll'
   1.508 +        STATIC_LIBRARY='[$]1.lib'
   1.509 +        SHARED_LIBRARY_FLAGS="-LD"
   1.510 +        SHARED_LIBRARY_SUFFIX='.dll'
   1.511 +        STATIC_LIBRARY_SUFFIX='.lib'
   1.512 +        OBJ_SUFFIX='.obj'
   1.513 +        EXE_SUFFIX='.exe'
   1.514 +        SET_SHARED_LIBRARY_NAME=''
   1.515 +        SET_SHARED_LIBRARY_MAPFILE=''
   1.516 +        SET_SHARED_LIBRARY_ORIGIN=''
   1.517 +    fi
   1.518 +fi
   1.519 +
   1.520 +AC_SUBST(OBJ_SUFFIX)
   1.521 +AC_SUBST(SHARED_LIBRARY)
   1.522 +AC_SUBST(STATIC_LIBRARY)
   1.523 +AC_SUBST(LIBRARY_PREFIX)
   1.524 +AC_SUBST(SHARED_LIBRARY_SUFFIX)
   1.525 +AC_SUBST(STATIC_LIBRARY_SUFFIX)
   1.526 +AC_SUBST(EXE_SUFFIX)
   1.527 +AC_SUBST(SHARED_LIBRARY_FLAGS)
   1.528 +AC_SUBST(SET_SHARED_LIBRARY_NAME)
   1.529 +AC_SUBST(SET_SHARED_LIBRARY_MAPFILE)
   1.530 +AC_SUBST(C_FLAG_REORDER)
   1.531 +AC_SUBST(CXX_FLAG_REORDER)
   1.532 +AC_SUBST(SET_SHARED_LIBRARY_ORIGIN)
   1.533 +AC_SUBST(POST_STRIP_CMD)
   1.534 +AC_SUBST(POST_MCS_CMD)
   1.535 +
   1.536 +# The (cross) compiler is now configured, we can now test capabilities
   1.537 +# of the target platform.
   1.538 +])
   1.539 +
   1.540 +AC_DEFUN_ONCE([TOOLCHAIN_SETUP_COMPILER_FLAGS_FOR_OPTIMIZATION],
   1.541 +[
   1.542 +
   1.543 +###############################################################################
   1.544 +#
   1.545 +# Setup the opt flags for different compilers
   1.546 +# and different operating systems.
   1.547 +#
   1.548 +C_FLAG_DEPS="-MMD -MF"
   1.549 +CXX_FLAG_DEPS="-MMD -MF"
   1.550 +
   1.551 +case $COMPILER_TYPE in
   1.552 +  CC )
   1.553 +    D_FLAG="-g"
   1.554 +    case $COMPILER_NAME in
   1.555 +      gcc )
   1.556 +      	case $OPENJDK_TARGET_OS in
   1.557 +	  macosx )
   1.558 +	    # On MacOSX we optimize for size, something
   1.559 +	    # we should do for all platforms?
   1.560 +	    C_O_FLAG_HI="-Os"
   1.561 +	    C_O_FLAG_NORM="-Os"
   1.562 +	    C_O_FLAG_NONE=""
   1.563 +	    ;;
   1.564 +	  *)
   1.565 +	    C_O_FLAG_HI="-O3"
   1.566 +	    C_O_FLAG_NORM="-O2"
   1.567 +	    C_O_FLAG_NONE="-O0"
   1.568 +	    CFLAGS_DEBUG_SYMBOLS="-g"
   1.569 +	    CXXFLAGS_DEBUG_SYMBOLS="-g"
   1.570 +	    if test "x$OPENJDK_TARGET_CPU_BITS" = "x64" && test "x$DEBUG_LEVEL" = "xfastdebug"; then
   1.571 +	       CFLAGS_DEBUG_SYMBOLS="-g1"
   1.572 +	       CXXFLAGS_DEBUG_SYMBOLSG="-g1"
   1.573 +	    fi
   1.574 +	    ;;
   1.575 +	esac
   1.576 +        CXX_O_FLAG_HI="$C_O_FLAG_HI"
   1.577 +        CXX_O_FLAG_NORM="$C_O_FLAG_NORM"
   1.578 +        CXX_O_FLAG_NONE="$C_O_FLAG_NONE"
   1.579 +        ;;
   1.580 +      ossc )
   1.581 +        #
   1.582 +        # Forte has different names for this with their C++ compiler...
   1.583 +        #
   1.584 +	C_FLAG_DEPS="-xMMD -xMF"
   1.585 +	CXX_FLAG_DEPS="-xMMD -xMF"
   1.586 +
   1.587 +# Extra options used with HIGHEST
   1.588 +#
   1.589 +# WARNING: Use of OPTIMIZATION_LEVEL=HIGHEST in your Makefile needs to be
   1.590 +#          done with care, there are some assumptions below that need to
   1.591 +#          be understood about the use of pointers, and IEEE behavior.
   1.592 +#
   1.593 +# Use non-standard floating point mode (not IEEE 754)
   1.594 +CC_HIGHEST="$CC_HIGHEST -fns"
   1.595 +# Do some simplification of floating point arithmetic (not IEEE 754)
   1.596 +CC_HIGHEST="$CC_HIGHEST -fsimple"
   1.597 +# Use single precision floating point with 'float'
   1.598 +CC_HIGHEST="$CC_HIGHEST -fsingle"
   1.599 +# Assume memory references via basic pointer types do not alias
   1.600 +#   (Source with excessing pointer casting and data access with mixed 
   1.601 +#    pointer types are not recommended)
   1.602 +CC_HIGHEST="$CC_HIGHEST -xalias_level=basic"
   1.603 +# Use intrinsic or inline versions for math/std functions
   1.604 +#   (If you expect perfect errno behavior, do not use this)
   1.605 +CC_HIGHEST="$CC_HIGHEST -xbuiltin=%all"
   1.606 +# Loop data dependency optimizations (need -xO3 or higher)
   1.607 +CC_HIGHEST="$CC_HIGHEST -xdepend"
   1.608 +# Pointer parameters to functions do not overlap
   1.609 +#   (Similar to -xalias_level=basic usage, but less obvious sometimes.
   1.610 +#    If you pass in multiple pointers to the same data, do not use this)
   1.611 +CC_HIGHEST="$CC_HIGHEST -xrestrict"
   1.612 +# Inline some library routines
   1.613 +#   (If you expect perfect errno behavior, do not use this)
   1.614 +CC_HIGHEST="$CC_HIGHEST -xlibmil"
   1.615 +# Use optimized math routines
   1.616 +#   (If you expect perfect errno behavior, do not use this)
   1.617 +#  Can cause undefined external on Solaris 8 X86 on __sincos, removing for now
   1.618 +#CC_HIGHEST="$CC_HIGHEST -xlibmopt"
   1.619 +
   1.620 +        case $LEGACY_OPENJDK_TARGET_CPU1 in
   1.621 +          i586)
   1.622 +            C_O_FLAG_HIGHEST="-xO4 -Wu,-O4~yz $CC_HIGHEST -xchip=pentium"
   1.623 +            C_O_FLAG_HI="-xO4 -Wu,-O4~yz"
   1.624 +            C_O_FLAG_NORM="-xO2 -Wu,-O2~yz"
   1.625 +            C_O_FLAG_NONE=""
   1.626 +            CXX_O_FLAG_HIGHEST="-xO4 -Qoption ube -O4~yz $CC_HIGHEST -xchip=pentium"
   1.627 +            CXX_O_FLAG_HI="-xO4 -Qoption ube -O4~yz"
   1.628 +            CXX_O_FLAG_NORM="-xO2 -Qoption ube -O2~yz"
   1.629 +            CXX_O_FLAG_NONE=""
   1.630 +            ;;
   1.631 +          sparc)
   1.632 +            CFLAGS_JDK="${CFLAGS_JDK} -xmemalign=4s"
   1.633 +            CXXFLAGS_JDK="${CXXFLAGS_JDK} -xmemalign=4s"
   1.634 +            CFLAGS_JDKLIB_EXTRA="${CFLAGS_JDKLIB_EXTRA} -xregs=no%appl"
   1.635 +            CXXFLAGS_JDKLIB_EXTRA="${CXXFLAGS_JDKLIB_EXTRA} -xregs=no%appl"
   1.636 +            C_O_FLAG_HIGHEST="-xO4 -Wc,-Qrm-s -Wc,-Qiselect-T0 $CC_HIGHEST -xprefetch=auto,explicit -xchip=ultra"
   1.637 +            C_O_FLAG_HI="-xO4 -Wc,-Qrm-s -Wc,-Qiselect-T0"
   1.638 +            C_O_FLAG_NORM="-xO2 -Wc,-Qrm-s -Wc,-Qiselect-T0"
   1.639 +            C_O_FLAG_NONE=""
   1.640 +            CXX_O_FLAG_HIGHEST="-xO4 -Qoption cg -Qrm-s -Qoption cg -Qiselect-T0 $CC_HIGHEST -xprefetch=auto,explicit -xchip=ultra"
   1.641 +            CXX_O_FLAG_HI="-xO4 -Qoption cg -Qrm-s -Qoption cg -Qiselect-T0"
   1.642 +            CXX_O_FLAG_NORM="-xO2 -Qoption cg -Qrm-s -Qoption cg -Qiselect-T0"
   1.643 +            CXX_O_FLAG_NONE=""
   1.644 +            ;;
   1.645 +        esac
   1.646 +
   1.647 +    CFLAGS_DEBUG_SYMBOLS="-g -xs"
   1.648 +    CXXFLAGS_DEBUG_SYMBOLS="-g0 -xs"
   1.649 +    esac
   1.650 +    ;;
   1.651 +  CL )
   1.652 +    D_FLAG=
   1.653 +    C_O_FLAG_HI="-O2"
   1.654 +    C_O_FLAG_NORM="-O1"
   1.655 +    C_O_FLAG_NONE="-Od"
   1.656 +    CXX_O_FLAG_HI="$C_O_FLAG_HI"
   1.657 +    CXX_O_FLAG_NORM="$C_O_FLAG_NORM"
   1.658 +    CXX_O_FLAG_NONE="$C_O_FLAG_NONE"
   1.659 +    ;;
   1.660 +esac
   1.661 +
   1.662 +if test -z "$C_O_FLAG_HIGHEST"; then
   1.663 +   C_O_FLAG_HIGHEST="$C_O_FLAG_HI"
   1.664 +fi
   1.665 +
   1.666 +if test -z "$CXX_O_FLAG_HIGHEST"; then
   1.667 +   CXX_O_FLAG_HIGHEST="$CXX_O_FLAG_HI"
   1.668 +fi
   1.669 +
   1.670 +AC_SUBST(C_O_FLAG_HIGHEST)
   1.671 +AC_SUBST(C_O_FLAG_HI)
   1.672 +AC_SUBST(C_O_FLAG_NORM)
   1.673 +AC_SUBST(C_O_FLAG_NONE)
   1.674 +AC_SUBST(CXX_O_FLAG_HIGHEST)
   1.675 +AC_SUBST(CXX_O_FLAG_HI)
   1.676 +AC_SUBST(CXX_O_FLAG_NORM)
   1.677 +AC_SUBST(CXX_O_FLAG_NONE)
   1.678 +AC_SUBST(C_FLAG_DEPS)
   1.679 +AC_SUBST(CXX_FLAG_DEPS)
   1.680 +])
   1.681 +
   1.682 +AC_DEFUN_ONCE([TOOLCHAIN_SETUP_COMPILER_FLAGS_FOR_JDK],
   1.683 +[
   1.684 +
   1.685 +if test "x$CFLAGS" != "x${ADDED_CFLAGS}"; then
   1.686 +   AC_MSG_WARN([Ignoring CFLAGS($CFLAGS) found in environment. Use --with-extra-cflags"])
   1.687 +fi
   1.688 +
   1.689 +if test "x$CXXFLAGS" != "x${ADDED_CXXFLAGS}"; then
   1.690 +   AC_MSG_WARN([Ignoring CXXFLAGS($CXXFLAGS) found in environment. Use --with-extra-cxxflags"])
   1.691 +fi
   1.692 +
   1.693 +if test "x$LDFLAGS" != "x${ADDED_LDFLAGS}"; then
   1.694 +   AC_MSG_WARN([Ignoring LDFLAGS($LDFLAGS) found in environment. Use --with-extra-ldflags"])
   1.695 +fi
   1.696 +
   1.697 +AC_ARG_WITH(extra-cflags, [AS_HELP_STRING([--with-extra-cflags],
   1.698 +    [extra flags to be used when compiling jdk c-files])])
   1.699 +
   1.700 +AC_ARG_WITH(extra-cxxflags, [AS_HELP_STRING([--with-extra-cxxflags],
   1.701 +    [extra flags to be used when compiling jdk c++-files])])
   1.702 +
   1.703 +AC_ARG_WITH(extra-ldflags, [AS_HELP_STRING([--with-extra-ldflags],
   1.704 +    [extra flags to be used when linking jdk])])
   1.705 +
   1.706 +CFLAGS_JDK="${CFLAGS_JDK} $with_extra_cflags"
   1.707 +CXXFLAGS_JDK="${CXXFLAGS_JDK} $with_extra_cxxflags"
   1.708 +LDFLAGS_JDK="${LDFLAGS_JDK} $with_extra_ldflags"
   1.709 +
   1.710 +###############################################################################
   1.711 +#
   1.712 +# Now setup the CFLAGS and LDFLAGS for the JDK build.
   1.713 +# Later we will also have CFLAGS and LDFLAGS for the hotspot subrepo build.
   1.714 +#
   1.715 +case $COMPILER_NAME in
   1.716 +      gcc )
   1.717 +      	  CCXXFLAGS_JDK="$CCXXFLAGS $CCXXFLAGS_JDK -W -Wall -Wno-unused -Wno-parentheses \
   1.718 +                          -pipe \
   1.719 +                          -D_GNU_SOURCE -D_REENTRANT -D_LARGEFILE64_SOURCE"
   1.720 +	  case $OPENJDK_TARGET_CPU_ARCH in
   1.721 +	  arm )
   1.722 +            # on arm we don't prevent gcc to omit frame pointer but do prevent strict aliasing
   1.723 +	    CFLAGS_JDK="${CFLAGS_JDK} -fno-strict-aliasing"
   1.724 +	  ;;
   1.725 +	  ppc )
   1.726 +            # on ppc we don't prevent gcc to omit frame pointer nor strict-aliasing
   1.727 +	  ;;
   1.728 +	  * )
   1.729 +	    CCXXFLAGS_JDK="$CCXXFLAGS_JDK -fno-omit-frame-pointer"
   1.730 +	    CFLAGS_JDK="${CFLAGS_JDK} -fno-strict-aliasing"
   1.731 +          ;;
   1.732 +	  esac
   1.733 +          ;;
   1.734 +      ossc )
   1.735 +      	  CFLAGS_JDK="$CFLAGS_JDK -xc99=%none -xCC -errshort=tags -Xa -v -mt -norunpath -xnolib"
   1.736 +      	  CXXFLAGS_JDK="$CXXFLAGS_JDK -errtags=yes +w -mt -features=no%except -DCC_NOEX"
   1.737 +          ;;
   1.738 +      cl )
   1.739 +          CCXXFLAGS_JDK="$CCXXFLAGS $CCXXFLAGS_JDK -Zi -MD -Zc:wchar_t- -W3 -wd4800 \
   1.740 +               -D_STATIC_CPPLIB -D_DISABLE_DEPRECATE_STATIC_CPPLIB -DWIN32_LEAN_AND_MEAN \
   1.741 +	       -D_CRT_SECURE_NO_DEPRECATE -D_CRT_NONSTDC_NO_DEPRECATE \
   1.742 +	       -DWIN32 -DIAL"
   1.743 +          case $LEGACY_OPENJDK_TARGET_CPU1 in
   1.744 +              i?86 )
   1.745 +                  CCXXFLAGS_JDK="$CCXXFLAGS_JDK -D_X86_ -Dx86"
   1.746 +                  ;;
   1.747 +              amd64 )
   1.748 +                  CCXXFLAGS_JDK="$CCXXFLAGS_JDK -D_AMD64_ -Damd64"
   1.749 +                  ;;
   1.750 +          esac
   1.751 +          ;;
   1.752 +esac
   1.753 +
   1.754 +###############################################################################
   1.755 +#
   1.756 +# Cross-compile arch specific flags
   1.757 +
   1.758 +#
   1.759 +if test "x$JDK_VARIANT" = "xembedded"; then
   1.760 +   CCXXFLAGS_JDK="$CCXXFLAGS_JDK -DJAVASE_EMBEDDED"
   1.761 +fi
   1.762 +
   1.763 +case $OPENJDK_TARGET_CPU_ARCH in
   1.764 +arm )
   1.765 +    CCXXFLAGS_JDK="$CCXXFLAGS_JDK -fsigned-char"
   1.766 +    ;;
   1.767 +ppc )
   1.768 +    CCXXFLAGS_JDK="$CCXXFLAGS_JDK -fsigned-char"
   1.769 +    ;;
   1.770 +esac
   1.771 +
   1.772 +###############################################################################
   1.773 +
   1.774 +CCXXFLAGS_JDK="$CCXXFLAGS_JDK $ADD_LP64"
   1.775 +
   1.776 +# The package path is used only on macosx?
   1.777 +PACKAGE_PATH=/opt/local
   1.778 +AC_SUBST(PACKAGE_PATH)
   1.779 +
   1.780 +# Sometimes we use a cpu dir (.../lib/amd64/server) 
   1.781 +# Sometimes not (.../lib/server) 
   1.782 +LIBARCHDIR="$LEGACY_OPENJDK_TARGET_CPU2/"
   1.783 +if test "x$ENDIAN" = xlittle; then
   1.784 +    CCXXFLAGS_JDK="$CCXXFLAGS_JDK -D_LITTLE_ENDIAN"
   1.785 +else
   1.786 +    CCXXFLAGS_JDK="$CCXXFLAGS_JDK -D_BIG_ENDIAN"
   1.787 +fi
   1.788 +if test "x$OPENJDK_TARGET_OS" = xlinux; then
   1.789 +    CCXXFLAGS_JDK="$CCXXFLAGS_JDK -DLINUX"
   1.790 +fi
   1.791 +if test "x$OPENJDK_TARGET_OS" = xwindows; then
   1.792 +    CCXXFLAGS_JDK="$CCXXFLAGS_JDK -DWINDOWS"
   1.793 +fi
   1.794 +if test "x$OPENJDK_TARGET_OS" = xsolaris; then
   1.795 +    CCXXFLAGS_JDK="$CCXXFLAGS_JDK -DSOLARIS"
   1.796 +fi
   1.797 +if test "x$OPENJDK_TARGET_OS" = xmacosx; then
   1.798 +    CCXXFLAGS_JDK="$CCXXFLAGS_JDK -DMACOSX -D_ALLBSD_SOURCE"
   1.799 +    LIBARCHDIR=""
   1.800 +fi
   1.801 +if test "x$OPENJDK_TARGET_OS" = xbsd; then
   1.802 +    CCXXFLAGS_JDK="$CCXXFLAGS_JDK -DBSD -D_ALLBSD_SOURCE"
   1.803 +fi
   1.804 +if test "x$DEBUG_LEVEL" = xrelease; then
   1.805 +    CCXXFLAGS_JDK="$CCXXFLAGS_JDK -DNDEBUG"
   1.806 +else
   1.807 +    CCXXFLAGS_JDK="$CCXXFLAGS_JDK -DDEBUG"
   1.808 +fi
   1.809 +
   1.810 +CCXXFLAGS_JDK="$CCXXFLAGS_JDK -DARCH='\"$LEGACY_OPENJDK_TARGET_CPU1\"' -D$LEGACY_OPENJDK_TARGET_CPU1"
   1.811 +CCXXFLAGS_JDK="$CCXXFLAGS_JDK -DRELEASE='\"$RELEASE\"'"
   1.812 +
   1.813 +CCXXFLAGS_JDK="$CCXXFLAGS_JDK \
   1.814 +        -I${JDK_OUTPUTDIR}/include \
   1.815 +        -I${JDK_OUTPUTDIR}/include/$OPENJDK_TARGET_OS \
   1.816 +        -I${JDK_TOPDIR}/src/share/javavm/export \
   1.817 +        -I${JDK_TOPDIR}/src/$LEGACY_OPENJDK_TARGET_OS_API/javavm/export \
   1.818 +        -I${JDK_TOPDIR}/src/share/native/common \
   1.819 +        -I${JDK_TOPDIR}/src/$LEGACY_OPENJDK_TARGET_OS_API/native/common"
   1.820 +
   1.821 +# The shared libraries are compiled using the picflag.
   1.822 +CFLAGS_JDKLIB="$CCXXFLAGS_JDK $CFLAGS_JDK $PICFLAG $CFLAGS_JDKLIB_EXTRA"
   1.823 +CXXFLAGS_JDKLIB="$CCXXFLAGS_JDK $CXXFLAGS_JDK $PICFLAG $CXXFLAGS_JDKLIB_EXTRA "
   1.824 +
   1.825 +# Executable flags
   1.826 +CFLAGS_JDKEXE="$CCXXFLAGS_JDK $CFLAGS_JDK"
   1.827 +CXXFLAGS_JDKEXE="$CCXXFLAGS_JDK $CXXFLAGS_JDK"
   1.828 +
   1.829 +# Now this is odd. The JDK native libraries have to link against libjvm.so
   1.830 +# On 32-bit machines there is normally two distinct libjvm.so:s, client and server.
   1.831 +# Which should we link to? Are we lucky enough that the binary api to the libjvm.so library
   1.832 +# is identical for client and server? Yes. Which is picked at runtime (client or server)?
   1.833 +# Neither, since the chosen libjvm.so has already been loaded by the launcher, all the following
   1.834 +# libraries will link to whatever is in memory. Yuck. 
   1.835 +#
   1.836 +# Thus we offer the compiler to find libjvm.so first in server then in client. It works. Ugh.
   1.837 +if test "x$COMPILER_TYPE" = xCL; then
   1.838 +    LDFLAGS_JDK="$LDFLAGS_JDK -nologo -opt:ref -incremental:no"
   1.839 +    if test "x$LEGACY_OPENJDK_TARGET_CPU1" = xi586; then 
   1.840 +        LDFLAGS_JDK="$LDFLAGS_JDK -safeseh"
   1.841 +    fi
   1.842 +    # TODO: make -debug optional "--disable-full-debug-symbols"
   1.843 +    LDFLAGS_JDK="$LDFLAGS_JDK -debug"
   1.844 +    LDFLAGS_JDKLIB="${LDFLAGS_JDK} -dll -libpath:${JDK_OUTPUTDIR}/lib"
   1.845 +    LDFLAGS_JDKLIB_SUFFIX=""
   1.846 +    if test "x$OPENJDK_TARGET_CPU_BITS" = "x64"; then
   1.847 +        LDFLAGS_STACK_SIZE=1048576
   1.848 +    else
   1.849 +        LDFLAGS_STACK_SIZE=327680
   1.850 +    fi
   1.851 +    LDFLAGS_JDKEXE="${LDFLAGS_JDK} /STACK:$LDFLAGS_STACK_SIZE"
   1.852 +else
   1.853 +    # If this is a --hash-style=gnu system, use --hash-style=both, why?
   1.854 +    HAS_GNU_HASH=`$CC -dumpspecs 2>/dev/null | $GREP 'hash-style=gnu'`
   1.855 +    if test -n "$HAS_GNU_HASH"; then
   1.856 +        # And since we now know that the linker is gnu, then add -z defs, to forbid
   1.857 +        # undefined symbols in object files.
   1.858 +        LDFLAGS_JDK="${LDFLAGS_JDK} -Xlinker --hash-style=both -Xlinker -z -Xlinker defs"
   1.859 +        if test "x$DEBUG_LEVEL" == "xrelease"; then
   1.860 +            # When building release libraries, tell the linker optimize them.
   1.861 +            # Should this be supplied to the OSS linker as well?
   1.862 +            LDFLAGS_JDK="${LDFLAGS_JDK} -Xlinker -O1"
   1.863 +        fi
   1.864 +    fi
   1.865 +
   1.866 +    LDFLAGS_JDKLIB="${LDFLAGS_JDK} $SHARED_LIBRARY_FLAGS \
   1.867 +                    -L${JDK_OUTPUTDIR}/lib/${LIBARCHDIR}server \
   1.868 +                    -L${JDK_OUTPUTDIR}/lib/${LIBARCHDIR}client \
   1.869 +  	            -L${JDK_OUTPUTDIR}/lib/${LIBARCHDIR}"
   1.870 +    LDFLAGS_JDKLIB_SUFFIX="-ljvm -ljava"
   1.871 +    if test "x$COMPILER_NAME" = xossc; then
   1.872 +        LDFLAGS_JDKLIB_SUFFIX="$LDFLAGS_JDKLIB_SUFFIX -lc"
   1.873 +    fi
   1.874 +
   1.875 +    # Only the jli library is explicitly linked when the launchers are built.
   1.876 +    # The libjvm is then dynamically loaded/linked by the launcher.
   1.877 +    LDFLAGS_JDKEXE="${LDFLAGS_JDK}"
   1.878 +    if test "x$OPENJDK_TARGET_OS" != "xmacosx"; then
   1.879 +       LDFLAGS_JDKEXE="$LDFLAGS_JDKEXE -L${JDK_OUTPUTDIR}/lib/${LIBARCHDIR}jli"
   1.880 +       LDFLAGS_JDKEXE_SUFFIX="-ljli"
   1.881 +    fi
   1.882 +fi
   1.883 +
   1.884 +# Adjust flags according to debug level.
   1.885 +case $DEBUG_LEVEL in
   1.886 +      fastdebug ) 
   1.887 +              CFLAGS="$CFLAGS $D_FLAG"
   1.888 +              JAVAC_FLAGS="$JAVAC_FLAGS -g"
   1.889 +              ;;
   1.890 +      slowdebug )
   1.891 +              CFLAGS="$CFLAGS $D_FLAG"
   1.892 +	      C_O_FLAG_HI="$C_O_FLAG_NONE"
   1.893 +	      C_O_FLAG_NORM="$C_O_FLAG_NONE"
   1.894 +	      CXX_O_FLAG_HI="$CXX_O_FLAG_NONE"
   1.895 +	      CXX_O_FLAG_NORM="$CXX_O_FLAG_NONE"
   1.896 +              JAVAC_FLAGS="$JAVAC_FLAGS -g"
   1.897 +              ;;
   1.898 +esac              
   1.899 +
   1.900 +                
   1.901 +AC_SUBST(CFLAGS_JDKLIB)
   1.902 +AC_SUBST(CFLAGS_JDKEXE)
   1.903 +
   1.904 +AC_SUBST(CXXFLAGS_JDKLIB)
   1.905 +AC_SUBST(CXXFLAGS_JDKEXE)
   1.906 +
   1.907 +AC_SUBST(LDFLAGS_JDKLIB)
   1.908 +AC_SUBST(LDFLAGS_JDKEXE)
   1.909 +AC_SUBST(LDFLAGS_JDKLIB_SUFFIX)
   1.910 +AC_SUBST(LDFLAGS_JDKEXE_SUFFIX)
   1.911 +])

mercurial