common/autoconf/toolchain.m4

Tue, 18 Sep 2012 11:29:16 -0700

author
ohair
date
Tue, 18 Sep 2012 11:29:16 -0700
changeset 478
2ba6f4da4bf3
parent 459
3156dff953b1
child 494
e64f2cb57d05
permissions
-rw-r--r--

7197849: Update new build-infra makefiles
Reviewed-by: ihse, erikj, ohrstrom, tbell

     1 #
     2 # Copyright (c) 2011, 2012, 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 #
    26 AC_DEFUN_ONCE([TOOLCHAIN_SETUP_VISUAL_STUDIO_ENV],
    27 [
    29 # Check if the VS env variables were setup prior to running configure.
    30 # If not, then find vcvarsall.bat and run it automatically, and integrate
    31 # the set env variables into the spec file.
    32 SETUPDEVENV="# No special vars"
    33 if test "x$OPENJDK_BUILD_OS" = "xwindows"; then
    34     # Store path to cygwin link.exe to help excluding it when searching for 
    35     # VS linker.
    36     AC_PATH_PROG(CYGWIN_LINK, link)
    37     AC_MSG_CHECKING([if the first found link.exe is actually the Cygwin link tool])
    38     "$CYGWIN_LINK" --version > /dev/null
    39     if test $? -eq 0 ; then
    40       AC_MSG_RESULT([yes])
    41     else
    42       AC_MSG_RESULT([no])
    43       # This might be the VS linker. Don't exclude it later on.
    44       CYGWIN_LINK=""
    45     fi
    47     # If vcvarsall.bat has been run, then VCINSTALLDIR is set.
    48     if test "x$VCINSTALLDIR" != x; then
    49         # No further setup is needed. The build will happen from this kind
    50         # of shell.
    51         SETUPDEVENV="# This spec file expects that you are running bash from within a VS command prompt."
    52         # Make sure to remind you, if you forget to run make from a cygwin bash shell
    53         # that is spawned "bash -l" from a VS command prompt.
    54         CHECK_FOR_VCINSTALLDIR=yes
    55         AC_MSG_CHECKING([if you are running from within a VS command prompt])
    56         AC_MSG_RESULT([yes])
    57     else
    58         # Ah, we have not yet run vcvarsall.bat/vsvars32.bat/vsvars64.bat. Lets do that. First find it.
    59         if test "x$VS100COMNTOOLS" != x; then
    60             VARSBAT=`find "$VS100COMNTOOLS/../.." -name vcvarsall.bat`
    61 	    SEARCH_ROOT="$VS100COMNTOOLS"
    62         else
    63             VARSBAT=`find "$PROGRAMFILES" -name vcvarsall.bat`
    64 	    SEARCH_ROOT="$PROGRAMFILES"
    65         fi
    66         VCPATH=`dirname "$VARSBAT"`
    67         VCPATH=`cygpath -w "$VCPATH"`
    68 	if test "x$VARSBAT" = x || test ! -d "$VCPATH"; then
    69             AC_MSG_CHECKING([if we can find the VS installation])
    70             AC_MSG_RESULT([no])
    71             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.])
    72         fi
    73         case "$OPENJDK_TARGET_CPU" in
    74           x86)
    75             VARSBAT_ARCH=x86
    76             ;;
    77           x86_64)
    78             VARSBAT_ARCH=amd64
    79             ;;
    80         esac
    81         # Lets extract the variables that are set by vcvarsall.bat/vsvars32.bat/vsvars64.bat
    82         cd $OUTPUT_ROOT
    83         bash $SRC_ROOT/common/bin/extractvcvars.sh "$VARSBAT" "$VARSBAT_ARCH"
    84 	cd $CURDIR
    85 	if test ! -s $OUTPUT_ROOT/localdevenv.sh || test ! -s $OUTPUT_ROOT/localdevenv.gmk; then
    86             AC_MSG_CHECKING([if we can extract the needed env variables])
    87             AC_MSG_RESULT([no])
    88             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.])
    89         fi 
    90         # Now set all paths and other env variables. This will allow the rest of 
    91         # the configure script to find and run the compiler in the proper way.
    92         . $OUTPUT_ROOT/localdevenv.sh
    93         AC_MSG_CHECKING([if we can find the VS installation])
    94 	if test "x$VCINSTALLDIR" != x; then 
    95             AC_MSG_RESULT([$VCINSTALLDIR])
    96         else 
    97             AC_MSG_RESULT([no])
    98             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.])
    99         fi
   100         CHECK_FOR_VCINSTALLDIR=no
   101 	SETUPDEVENV="include $OUTPUT_ROOT/localdevenv.gmk"
   103 	AC_MSG_CHECKING([for msvcr100.dll])
   104         AC_ARG_WITH(msvcr100dll, [AS_HELP_STRING([--with-msvcr100dll],
   105             [copy this msvcr100.dll into the built JDK])])
   106         if test "x$with_msvcr100dll" != x; then
   107             MSVCR100DLL="$with_msvcr100dll"
   108         else
   109             if test "x$OPENJDK_TARGET_CPU_BITS" = x64; then
   110                 MSVCR100DLL=`find "$VCINSTALLDIR/.." -name msvcr100.dll | grep x64 | head --lines 1`
   111             else
   112                 MSVCR100DLL=`find "$VCINSTALLDIR/.." -name msvcr100.dll | grep x86 | grep -v ia64 | grep -v x64 | head --lines 1`
   113                 if test "x$MSVCR100DLL" = x; then
   114                     MSVCR100DLL=`find "$VCINSTALLDIR/.." -name msvcr100.dll | head --lines 1`
   115                 fi
   116             fi
   117         fi
   118 	if test "x$MSVCR100DLL" = x; then
   119            AC_MSG_RESULT([no])
   120 	   AC_MSG_ERROR([Could not find msvcr100.dll !])
   121         fi
   122         AC_MSG_RESULT([$MSVCR100DLL])
   123 	SPACESAFE(MSVCR100DLL,[the path to msvcr100.dll])
   124     fi
   125 fi
   126 AC_SUBST(SETUPDEVENV)
   127 AC_SUBST(CHECK_FOR_VCINSTALLDIR)
   128 AC_SUBST(MSVCR100DLL)
   129 ])
   131 AC_DEFUN_ONCE([TOOLCHAIN_SETUP_SYSROOT_AND_OUT_OPTIONS],
   132 [
   133 ###############################################################################
   134 #
   135 # Configure the development tool paths and potential sysroot.
   136 #
   137 AC_LANG(C++)
   139 # The option used to specify the target .o,.a or .so file.
   140 # When compiling, how to specify the to be created object file.
   141 CC_OUT_OPTION='-o$(SPACE)'
   142 # When linking, how to specify the to be created executable.
   143 EXE_OUT_OPTION='-o$(SPACE)'
   144 # When linking, how to specify the to be created dynamically linkable library.
   145 LD_OUT_OPTION='-o$(SPACE)'
   146 # When archiving, how to specify the to be create static archive for object files.
   147 AR_OUT_OPTION='rcs$(SPACE)'
   148 AC_SUBST(CC_OUT_OPTION)
   149 AC_SUBST(EXE_OUT_OPTION)
   150 AC_SUBST(LD_OUT_OPTION)
   151 AC_SUBST(AR_OUT_OPTION)
   152 ])
   154 AC_DEFUN_ONCE([TOOLCHAIN_SETUP_PATHS],
   155 [
   156 # If --build AND --host is set, then the configure script will find any
   157 # cross compilation tools in the PATH. Cross compilation tools
   158 # follows the cross compilation standard where they are prefixed with ${host}.
   159 # For example the binary i686-sun-solaris2.10-gcc
   160 # will cross compile for i686-sun-solaris2.10
   161 # If neither of build and host is not set, then build=host and the
   162 # default compiler found in the path will be used.
   163 # Setting only --host, does not seem to be really supported.
   164 # Please set both --build and --host if you want to cross compile.
   166 if test "x$COMPILE_TYPE" = "xcross"; then
   167     # Now we to find a C/C++ compiler that can build executables for the build
   168     # platform. We can't use the AC_PROG_CC macro, since it can only be used
   169     # once. Also, we need to do this before adding a tools dir to the path,
   170     # otherwise we might pick up cross-compilers which don't use standard naming.
   171     # Otherwise, we'll set the BUILD_tools to the native tools, but that'll have
   172     # to wait until they are properly discovered.
   173     AC_PATH_PROGS(BUILD_CC, [cl cc gcc])
   174     SET_FULL_PATH(BUILD_CC)
   175     AC_PATH_PROGS(BUILD_CXX, [cl CC g++])
   176     SET_FULL_PATH(BUILD_CXX)
   177     AC_PATH_PROG(BUILD_LD, ld)
   178     SET_FULL_PATH(BUILD_LD)
   179 fi
   180 AC_SUBST(BUILD_CC)
   181 AC_SUBST(BUILD_CXX)
   182 AC_SUBST(BUILD_LD)
   184 # If a devkit is found on the builddeps server, then prepend its path to the
   185 # PATH variable. If there are cross compilers available in the devkit, these
   186 # will be found by AC_PROG_CC et al.
   187 DEVKIT=
   188 BDEPS_CHECK_MODULE(DEVKIT, devkit, xxx,
   189                     [# Found devkit
   190                      PATH="$DEVKIT/bin:$PATH"
   191                      SYS_ROOT="$DEVKIT/${rewritten_target}/sys-root"
   192                      if test "x$x_includes" = "xNONE"; then
   193                          x_includes="$SYS_ROOT/usr/include/X11"
   194                      fi
   195                      if test "x$x_libraries" = "xNONE"; then
   196                          x_libraries="$SYS_ROOT/usr/lib"
   197                      fi
   198                     ],
   199                     [])
   201 if test "x$SYS_ROOT" != "x/" ; then                    
   202     CFLAGS="--sysroot=$SYS_ROOT $CFLAGS"
   203     CXXFLAGS="--sysroot=$SYS_ROOT $CXXFLAGS"
   204     OBJCFLAGS="--sysroot=$SYS_ROOT $OBJCFLAGS" 
   205     OBJCXXFLAGS="--sysroot=$SYS_ROOT $OBJCFLAGS" 
   206     CPPFLAGS="--sysroot=$SYS_ROOT $CPPFLAGS"
   207     LDFLAGS="--sysroot=$SYS_ROOT $LDFLAGS"
   208 fi
   210 # Store the CFLAGS etal passed to the configure script.
   211 ORG_CFLAGS="$CFLAGS"
   212 ORG_CXXFLAGS="$CXXFLAGS"
   213 ORG_OBJCFLAGS="$OBJCFLAGS"
   215 # autoconf magic only relies on PATH, so update it if tools dir is specified
   216 OLD_PATH="$PATH"
   217 if test "x$TOOLS_DIR" != x; then
   218   PATH=$TOOLS_DIR:$PATH
   219 fi
   221 # gcc is almost always present, but on Windows we
   222 # prefer cl.exe and on Solaris we prefer CC.
   223 # Thus test for them in this order.
   224 AC_PROG_CC([cl cc gcc])
   225 if test "x$CC" = x; then
   226     HELP_MSG_MISSING_DEPENDENCY([devkit])
   227     AC_MSG_ERROR([Could not find a compiler. $HELP_MSG])
   228 fi
   229 if test "x$CC" = xcc && test "x$OPENJDK_BUILD_OS" = xmacosx; then
   230     # Do not use cc on MacOSX use gcc instead.
   231     CC="gcc"
   232 fi
   233 SET_FULL_PATH(CC)
   235 AC_PROG_CXX([cl CC g++])
   236 if test "x$CXX" = xCC && test "x$OPENJDK_BUILD_OS" = xmacosx; then
   237     # The found CC, even though it seems to be a g++ derivate, cannot compile
   238     # c++ code. Override.
   239     CXX="g++"
   240 fi
   241 SET_FULL_PATH(CXX)
   243 if test "x$CXX" = x || test "x$CC" = x; then
   244     HELP_MSG_MISSING_DEPENDENCY([devkit])
   245     AC_MSG_ERROR([Could not find the needed compilers! $HELP_MSG ])
   246 fi
   248 if test "x$OPENJDK_BUILD_OS" != xwindows; then
   249     AC_PROG_OBJC
   250     SET_FULL_PATH(OBJC)
   251 else
   252     OBJC=
   253 fi
   255 # Restore the flags to the user specified values.
   256 # This is necessary since AC_PROG_CC defaults CFLAGS to "-g -O2"
   257 CFLAGS="$ORG_CFLAGS"
   258 CXXFLAGS="$ORG_CXXFLAGS"
   259 OBJCFLAGS="$ORG_OBJCFLAGS"
   261 LD="$CC"
   262 LDEXE="$CC"
   263 LDCXX="$CXX"
   264 LDEXECXX="$CXX"
   265 AC_SUBST(LD)
   266 # LDEXE is the linker to use, when creating executables.
   267 AC_SUBST(LDEXE)
   268 # Linking C++ libraries.
   269 AC_SUBST(LDCXX)
   270 # Linking C++ executables.
   271 AC_SUBST(LDEXECXX)
   273 if test "x$OPENJDK_BUILD_OS" != xwindows; then
   274     AC_CHECK_TOOL(AR, ar)
   275     SET_FULL_PATH(AR)
   276 fi
   277 if test "x$OPENJDK_BUILD_OS" = xmacosx; then
   278     ARFLAGS="-r"
   279 else
   280     ARFLAGS=""
   281 fi
   282 AC_SUBST(ARFLAGS)
   284 COMPILER_NAME=gcc
   285 COMPILER_TYPE=CC
   286 AS_IF([test "x$OPENJDK_BUILD_OS" = xwindows], [
   287     # For now, assume that we are always compiling using cl.exe. 
   288     CC_OUT_OPTION=-Fo
   289     EXE_OUT_OPTION=-out:
   290     LD_OUT_OPTION=-out:
   291     AR_OUT_OPTION=-out:
   292     # On Windows, reject /usr/bin/link (as determined in CYGWIN_LINK), which is a cygwin
   293     # program for something completely different.
   294     AC_CHECK_PROG([WINLD], [link],[link],,, [$CYGWIN_LINK])
   295     # Since we must ignore the first found link, WINLD will contain
   296     # the full path to the link.exe program.
   297     SET_FULL_PATH_SPACESAFE([WINLD])
   298     printf "Windows linker was found at $WINLD\n"
   299     AC_MSG_CHECKING([if the found link.exe is actually the Visual Studio linker])
   300     "$WINLD" --version > /dev/null
   301     if test $? -eq 0 ; then
   302       AC_MSG_RESULT([no])
   303       AC_MSG_ERROR([This is the Cygwin link tool. Please check your PATH and rerun configure.])
   304     else
   305       AC_MSG_RESULT([yes])
   306     fi
   307     LD="$WINLD"
   308     LDEXE="$WINLD"
   309     LDCXX="$WINLD"
   310     LDEXECXX="$WINLD"
   312     AC_CHECK_PROG([MT], [mt], [mt],,, [/usr/bin/mt])
   313     SET_FULL_PATH_SPACESAFE([MT])
   314     # The resource compiler
   315     AC_CHECK_PROG([RC], [rc], [rc],,, [/usr/bin/rc])
   316     SET_FULL_PATH_SPACESAFE([RC])
   318     RC_FLAGS="-nologo /l 0x409 /r"
   319     AS_IF([test "x$VARIANT" = xOPT], [
   320         RC_FLAGS="$RC_FLAGS -d NDEBUG"
   321     ])
   322     JDK_UPDATE_VERSION_NOTNULL=$JDK_UPDATE_VERSION
   323     AS_IF([test "x$JDK_UPDATE_VERSION" = x], [
   324         JDK_UPDATE_VERSION_NOTNULL=0
   325     ])
   326     RC_FLAGS="$RC_FLAGS -d \"JDK_BUILD_ID=$FULL_VERSION\""
   327     RC_FLAGS="$RC_FLAGS -d \"JDK_COMPANY=$COMPANY_NAME\""
   328     RC_FLAGS="$RC_FLAGS -d \"JDK_COMPONENT=$PRODUCT_NAME $JDK_RC_PLATFORM_NAME binary\""
   329     RC_FLAGS="$RC_FLAGS -d \"JDK_VER=$JDK_MINOR_VERSION.$JDK_MICRO_VERSION.$JDK_UPDATE_VERSION_NOTNULL.$COOKED_BUILD_NUMBER\""
   330     RC_FLAGS="$RC_FLAGS -d \"JDK_COPYRIGHT=Copyright \xA9 $COPYRIGHT_YEAR\""
   331     RC_FLAGS="$RC_FLAGS -d \"JDK_NAME=$PRODUCT_NAME $JDK_RC_PLATFORM_NAME $JDK_MINOR_VERSION $JDK_UPDATE_META_TAG\""
   332     RC_FLAGS="$RC_FLAGS -d \"JDK_FVER=$JDK_MINOR_VERSION,$JDK_MICRO_VERSION,$JDK_UPDATE_VERSION_NOTNULL,$COOKED_BUILD_NUMBER\""
   334     # lib.exe is used to create static libraries.
   335     AC_CHECK_PROG([WINAR], [lib],[lib],,,)
   336     SET_FULL_PATH_SPACESAFE([WINAR])
   337     AR="$WINAR"
   338     ARFLAGS="-nologo -NODEFAULTLIB:MSVCRT"
   340     AC_CHECK_PROG([DUMPBIN], [dumpbin], [dumpbin],,,)
   341     SET_FULL_PATH_SPACESAFE([DUMPBIN])
   343     COMPILER_TYPE=CL
   344     CCXXFLAGS="$CCXXFLAGS -nologo"
   345 ])
   346 AC_SUBST(RC_FLAGS)
   347 AC_SUBST(COMPILER_TYPE)
   349 AC_PROG_CPP
   350 SET_FULL_PATH(CPP)
   352 AC_PROG_CXXCPP
   353 SET_FULL_PATH(CXXCPP)
   355 if test "x$COMPILE_TYPE" != "xcross"; then
   356     # If we are not cross compiling, use the same compilers for
   357     # building the build platform executables. The cross-compilation
   358     # case needed to be done earlier, but this can only be done after
   359     # the native tools have been localized.
   360     BUILD_CC="$CC"
   361     BUILD_CXX="$CXX"
   362     BUILD_LD="$LD"
   363 fi
   365 # for solaris we really need solaris tools, and not gnu equivalent
   366 #   these seems to normally reside in /usr/ccs/bin so add that to path before
   367 #   starting to probe
   368 #
   369 #   NOTE: I add this /usr/ccs/bin after TOOLS but before OLD_PATH
   370 #         so that it can be overriden --with-tools-dir
   371 if test "x$OPENJDK_BUILD_OS" = xsolaris; then
   372     PATH="${TOOLS_DIR}:/usr/ccs/bin:${OLD_PATH}"
   373 fi
   375 # Find the right assembler.
   376 if test "x$OPENJDK_BUILD_OS" = xsolaris; then
   377     AC_PATH_PROG(AS, as)
   378     SET_FULL_PATH(AS)
   379 else
   380     AS="$CC -c"
   381 fi
   382 AC_SUBST(AS)
   384 if test "x$OPENJDK_BUILD_OS" = xsolaris; then
   385     AC_PATH_PROGS(NM, [gnm nm])
   386     SET_FULL_PATH(NM)
   387     AC_PATH_PROG(STRIP, strip)
   388     SET_FULL_PATH(STRIP)
   389     AC_PATH_PROG(MCS, mcs)
   390     SET_FULL_PATH(MCS)
   391 elif test "x$OPENJDK_BUILD_OS" != xwindows; then
   392     AC_CHECK_TOOL(NM, nm)
   393     SET_FULL_PATH(NM)
   394     AC_CHECK_TOOL(STRIP, strip)
   395     SET_FULL_PATH(STRIP)
   396 fi
   398 ###
   399 #
   400 # Check for objcopy
   401 #
   402 #   but search for gobjcopy first...
   403 #   since I on solaris found a broken objcopy...buhh
   404 #
   405 AC_PATH_TOOL(OBJCOPY, gobjcopy)
   406 if test "x$OBJCOPY" = x; then
   407    AC_PATH_TOOL(OBJCOPY, objcopy)
   408 fi
   410 if test "x$OPENJDK_TARGET_OS" = "xmacosx"; then
   411    AC_PATH_PROG(LIPO, lipo)
   412    SET_FULL_PATH(LIPO)
   413 fi
   415 # Restore old path without tools dir
   416 PATH="$OLD_PATH"
   417 ])
   420 AC_DEFUN_ONCE([TOOLCHAIN_SETUP_COMPILER_FLAGS_FOR_LIBS],
   421 [
   423 ###############################################################################
   424 #
   425 # How to compile shared libraries. 
   426 #
   428 if test "x$GCC" = xyes; then
   429     COMPILER_NAME=gcc
   430     PICFLAG="-fPIC"
   431     LIBRARY_PREFIX=lib
   432     SHARED_LIBRARY='lib[$]1.so'
   433     STATIC_LIBRARY='lib[$]1.a'
   434     SHARED_LIBRARY_FLAGS="-shared"
   435     SHARED_LIBRARY_SUFFIX='.so'
   436     STATIC_LIBRARY_SUFFIX='.a'
   437     OBJ_SUFFIX='.o'
   438     EXE_SUFFIX=''
   439     SET_SHARED_LIBRARY_NAME='-Xlinker -soname=[$]1'
   440     SET_SHARED_LIBRARY_MAPFILE='-Xlinker -version-script=[$]1'
   441     C_FLAG_REORDER=''
   442     CXX_FLAG_REORDER=''
   443     SET_SHARED_LIBRARY_ORIGIN='-Xlinker -z -Xlinker origin -Xlinker -rpath -Xlinker \$$$$ORIGIN[$]1'
   444     SET_EXECUTABLE_ORIGIN='-Xlinker -rpath -Xlinker \$$$$ORIGIN[$]1'
   445     LD="$CC"
   446     LDEXE="$CC"
   447     LDCXX="$CXX"
   448     LDEXECXX="$CXX"
   449     POST_STRIP_CMD="$STRIP -g"
   451     # Linking is different on MacOSX
   452     if test "x$OPENJDK_BUILD_OS" = xmacosx; then
   453         # Might change in the future to clang.
   454         COMPILER_NAME=gcc
   455         SHARED_LIBRARY='lib[$]1.dylib'
   456         SHARED_LIBRARY_FLAGS="-dynamiclib -compatibility_version 1.0.0 -current_version 1.0.0 $PICFLAG"
   457         SHARED_LIBRARY_SUFFIX='.dylib'
   458         EXE_SUFFIX=''
   459         SET_SHARED_LIBRARY_NAME='-Xlinker -install_name -Xlinker @rpath/[$]1' 
   460         SET_SHARED_LIBRARY_MAPFILE=''
   461         SET_SHARED_LIBRARY_ORIGIN='-Xlinker -rpath -Xlinker @loader_path/.'
   462         SET_EXECUTABLE_ORIGIN="$SET_SHARED_LIBRARY_ORIGIN"
   463         POST_STRIP_CMD="$STRIP -S"
   464     fi
   465 else
   466     if test "x$OPENJDK_BUILD_OS" = xsolaris; then
   467         # If it is not gcc, then assume it is the Oracle Solaris Studio Compiler
   468         COMPILER_NAME=ossc
   469         PICFLAG="-KPIC"
   470         LIBRARY_PREFIX=lib
   471         SHARED_LIBRARY='lib[$]1.so'
   472         STATIC_LIBRARY='lib[$]1.a'
   473         SHARED_LIBRARY_FLAGS="-G"
   474         SHARED_LIBRARY_SUFFIX='.so'
   475         STATIC_LIBRARY_SUFFIX='.a'
   476         OBJ_SUFFIX='.o'
   477         EXE_SUFFIX=''
   478         SET_SHARED_LIBRARY_NAME=''
   479         SET_SHARED_LIBRARY_MAPFILE='-M[$]1'
   480 	C_FLAG_REORDER='-xF'
   481 	CXX_FLAG_REORDER='-xF'
   482         SET_SHARED_LIBRARY_ORIGIN='-R\$$$$ORIGIN[$]1'
   483         SET_EXECUTABLE_ORIGIN="$SET_SHARED_LIBRARY_ORIGIN"
   484         CFLAGS_JDK="${CFLAGS_JDK} -D__solaris__"
   485         CXXFLAGS_JDK="${CXXFLAGS_JDK} -D__solaris__"
   486         CFLAGS_JDKLIB_EXTRA='-xstrconst'
   487         POST_STRIP_CMD="$STRIP -x"
   488         POST_MCS_CMD="$MCS -d -a \"JDK $FULL_VERSION\""
   489     fi
   490     if test "x$OPENJDK_BUILD_OS" = xwindows; then
   491         # If it is not gcc, then assume it is the MS Visual Studio compiler
   492         COMPILER_NAME=cl
   493         PICFLAG=""
   494         LIBRARY_PREFIX=
   495         SHARED_LIBRARY='[$]1.dll'
   496         STATIC_LIBRARY='[$]1.lib'
   497         SHARED_LIBRARY_FLAGS="-LD"
   498         SHARED_LIBRARY_SUFFIX='.dll'
   499         STATIC_LIBRARY_SUFFIX='.lib'
   500         OBJ_SUFFIX='.obj'
   501         EXE_SUFFIX='.exe'
   502         SET_SHARED_LIBRARY_NAME=''
   503         SET_SHARED_LIBRARY_MAPFILE=''
   504         SET_SHARED_LIBRARY_ORIGIN=''
   505         SET_EXECUTABLE_ORIGIN=''
   506     fi
   507 fi
   509 AC_SUBST(OBJ_SUFFIX)
   510 AC_SUBST(SHARED_LIBRARY)
   511 AC_SUBST(STATIC_LIBRARY)
   512 AC_SUBST(LIBRARY_PREFIX)
   513 AC_SUBST(SHARED_LIBRARY_SUFFIX)
   514 AC_SUBST(STATIC_LIBRARY_SUFFIX)
   515 AC_SUBST(EXE_SUFFIX)
   516 AC_SUBST(SHARED_LIBRARY_FLAGS)
   517 AC_SUBST(SET_SHARED_LIBRARY_NAME)
   518 AC_SUBST(SET_SHARED_LIBRARY_MAPFILE)
   519 AC_SUBST(C_FLAG_REORDER)
   520 AC_SUBST(CXX_FLAG_REORDER)
   521 AC_SUBST(SET_SHARED_LIBRARY_ORIGIN)
   522 AC_SUBST(SET_EXECUTABLE_ORIGIN)
   523 AC_SUBST(POST_STRIP_CMD)
   524 AC_SUBST(POST_MCS_CMD)
   526 # The (cross) compiler is now configured, we can now test capabilities
   527 # of the target platform.
   528 ])
   530 AC_DEFUN_ONCE([TOOLCHAIN_SETUP_COMPILER_FLAGS_FOR_OPTIMIZATION],
   531 [
   533 ###############################################################################
   534 #
   535 # Setup the opt flags for different compilers
   536 # and different operating systems.
   537 #
   539 #
   540 # NOTE: check for -mstackrealign needs to be below potential addition of -m32
   541 #
   542 if test "x$OPENJDK_TARGET_CPU_BITS" = x32 && test "x$OPENJDK_TARGET_OS" = xmacosx; then
   543     # On 32-bit MacOSX the OS requires C-entry points to be 16 byte aligned.
   544     # While waiting for a better solution, the current workaround is to use -mstackrealign.
   545     CFLAGS="$CFLAGS -mstackrealign"
   546     AC_MSG_CHECKING([if 32-bit compiler supports -mstackrealign])
   547     AC_LINK_IFELSE([AC_LANG_SOURCE([[int main() { return 0; }]])],
   548                    [
   549 		        AC_MSG_RESULT([yes])
   550                    ],
   551 	           [
   552 		        AC_MSG_RESULT([no])
   553 	                AC_MSG_ERROR([The selected compiler $CXX does not support -mstackrealign! Try to put another compiler in the path.])
   554 	           ])
   555 fi
   557 C_FLAG_DEPS="-MMD -MF"
   558 CXX_FLAG_DEPS="-MMD -MF"
   560 case $COMPILER_TYPE in
   561   CC )
   562     D_FLAG="-g"
   563     case $COMPILER_NAME in
   564       gcc )
   565       	case $OPENJDK_TARGET_OS in
   566 	  macosx )
   567 	    # On MacOSX we optimize for size, something
   568 	    # we should do for all platforms?
   569 	    C_O_FLAG_HI="-Os"
   570 	    C_O_FLAG_NORM="-Os"
   571 	    C_O_FLAG_NONE=""
   572 	    ;;
   573 	  *)
   574 	    C_O_FLAG_HI="-O3"
   575 	    C_O_FLAG_NORM="-O2"
   576 	    C_O_FLAG_NONE="-O0"
   577 	    CFLAGS_DEBUG_SYMBOLS="-g"
   578 	    CXXFLAGS_DEBUG_SYMBOLS="-g"
   579 	    if test "x$OPENJDK_TARGET_CPU_BITS" = "x64" && test "x$DEBUG_LEVEL" = "xfastdebug"; then
   580 	       CFLAGS_DEBUG_SYMBOLS="-g1"
   581 	       CXXFLAGS_DEBUG_SYMBOLS="-g1"
   582 	    fi
   583 	    ;;
   584 	esac
   585         CXX_O_FLAG_HI="$C_O_FLAG_HI"
   586         CXX_O_FLAG_NORM="$C_O_FLAG_NORM"
   587         CXX_O_FLAG_NONE="$C_O_FLAG_NONE"
   588         ;;
   589       ossc )
   590         #
   591         # Forte has different names for this with their C++ compiler...
   592         #
   593         C_FLAG_DEPS="-xMMD -xMF"
   594         CXX_FLAG_DEPS="-xMMD -xMF"
   596         # Extra options used with HIGHEST
   597         #
   598         # WARNING: Use of OPTIMIZATION_LEVEL=HIGHEST in your Makefile needs to be
   599         #          done with care, there are some assumptions below that need to
   600         #          be understood about the use of pointers, and IEEE behavior.
   601         #
   602         # Use non-standard floating point mode (not IEEE 754)
   603         CC_HIGHEST="$CC_HIGHEST -fns"
   604         # Do some simplification of floating point arithmetic (not IEEE 754)
   605         CC_HIGHEST="$CC_HIGHEST -fsimple"
   606         # Use single precision floating point with 'float'
   607         CC_HIGHEST="$CC_HIGHEST -fsingle"
   608         # Assume memory references via basic pointer types do not alias
   609         #   (Source with excessing pointer casting and data access with mixed 
   610         #    pointer types are not recommended)
   611         CC_HIGHEST="$CC_HIGHEST -xalias_level=basic"
   612         # Use intrinsic or inline versions for math/std functions
   613         #   (If you expect perfect errno behavior, do not use this)
   614         CC_HIGHEST="$CC_HIGHEST -xbuiltin=%all"
   615         # Loop data dependency optimizations (need -xO3 or higher)
   616         CC_HIGHEST="$CC_HIGHEST -xdepend"
   617         # Pointer parameters to functions do not overlap
   618         #   (Similar to -xalias_level=basic usage, but less obvious sometimes.
   619         #    If you pass in multiple pointers to the same data, do not use this)
   620         CC_HIGHEST="$CC_HIGHEST -xrestrict"
   621         # Inline some library routines
   622         #   (If you expect perfect errno behavior, do not use this)
   623         CC_HIGHEST="$CC_HIGHEST -xlibmil"
   624         # Use optimized math routines
   625         #   (If you expect perfect errno behavior, do not use this)
   626         #  Can cause undefined external on Solaris 8 X86 on __sincos, removing for now
   627         #CC_HIGHEST="$CC_HIGHEST -xlibmopt"
   629         case $OPENJDK_TARGET_CPU_ARCH in
   630           x86)
   631             C_O_FLAG_HIGHEST="-xO4 -Wu,-O4~yz $CC_HIGHEST -xregs=no%frameptr"
   632             C_O_FLAG_HI="-xO4 -Wu,-O4~yz -xregs=no%frameptr"
   633             C_O_FLAG_NORM="-xO2 -Wu,-O2~yz -xregs=no%frameptr"
   634             C_O_FLAG_NONE="-xregs=no%frameptr"
   635             CXX_O_FLAG_HIGHEST="-xO4 -Qoption ube -O4~yz $CC_HIGHEST -xregs=no%frameptr"
   636             CXX_O_FLAG_HI="-xO4 -Qoption ube -O4~yz -xregs=no%frameptr"
   637             CXX_O_FLAG_NORM="-xO2 -Qoption ube -O2~yz -xregs=no%frameptr"
   638             CXX_O_FLAG_NONE="-xregs=no%frameptr"
   639             if test "x$OPENJDK_TARGET_CPU" = xx86; then
   640                C_O_FLAG_HIGHEST="$C_O_FLAG_HIGHEST -xchip=pentium"
   641                CXX_O_FLAG_HIGHEST="$CXX_O_FLAG_HIGHEST -xchip=pentium"
   642             fi
   643             ;;
   644           sparc)
   645             CFLAGS_JDK="${CFLAGS_JDK} -xmemalign=4s"
   646             CXXFLAGS_JDK="${CXXFLAGS_JDK} -xmemalign=4s"
   647             CFLAGS_JDKLIB_EXTRA="${CFLAGS_JDKLIB_EXTRA} -xregs=no%appl"
   648             CXXFLAGS_JDKLIB_EXTRA="${CXXFLAGS_JDKLIB_EXTRA} -xregs=no%appl"
   649             C_O_FLAG_HIGHEST="-xO4 -Wc,-Qrm-s -Wc,-Qiselect-T0 $CC_HIGHEST -xprefetch=auto,explicit -xchip=ultra"
   650             C_O_FLAG_HI="-xO4 -Wc,-Qrm-s -Wc,-Qiselect-T0"
   651             C_O_FLAG_NORM="-xO2 -Wc,-Qrm-s -Wc,-Qiselect-T0"
   652             C_O_FLAG_NONE=""
   653             CXX_O_FLAG_HIGHEST="-xO4 -Qoption cg -Qrm-s -Qoption cg -Qiselect-T0 $CC_HIGHEST -xprefetch=auto,explicit -xchip=ultra"
   654             CXX_O_FLAG_HI="-xO4 -Qoption cg -Qrm-s -Qoption cg -Qiselect-T0"
   655             CXX_O_FLAG_NORM="-xO2 -Qoption cg -Qrm-s -Qoption cg -Qiselect-T0"
   656             CXX_O_FLAG_NONE=""
   657             ;;
   658         esac
   660     CFLAGS_DEBUG_SYMBOLS="-g -xs"
   661     CXXFLAGS_DEBUG_SYMBOLS="-g0 -xs"
   662     esac
   663     ;;
   664   CL )
   665     D_FLAG=
   666     C_O_FLAG_HIGHEST="-O2"
   667     C_O_FLAG_HI="-O1"
   668     C_O_FLAG_NORM="-O1"
   669     C_O_FLAG_NONE="-Od"
   670     CXX_O_FLAG_HIGHEST="$C_O_FLAG_HIGHEST"
   671     CXX_O_FLAG_HI="$C_O_FLAG_HI"
   672     CXX_O_FLAG_NORM="$C_O_FLAG_NORM"
   673     CXX_O_FLAG_NONE="$C_O_FLAG_NONE"
   674     ;;
   675 esac
   677 if test -z "$C_O_FLAG_HIGHEST"; then
   678    C_O_FLAG_HIGHEST="$C_O_FLAG_HI"
   679 fi
   681 if test -z "$CXX_O_FLAG_HIGHEST"; then
   682    CXX_O_FLAG_HIGHEST="$CXX_O_FLAG_HI"
   683 fi
   685 AC_SUBST(C_O_FLAG_HIGHEST)
   686 AC_SUBST(C_O_FLAG_HI)
   687 AC_SUBST(C_O_FLAG_NORM)
   688 AC_SUBST(C_O_FLAG_NONE)
   689 AC_SUBST(CXX_O_FLAG_HIGHEST)
   690 AC_SUBST(CXX_O_FLAG_HI)
   691 AC_SUBST(CXX_O_FLAG_NORM)
   692 AC_SUBST(CXX_O_FLAG_NONE)
   693 AC_SUBST(C_FLAG_DEPS)
   694 AC_SUBST(CXX_FLAG_DEPS)
   695 ])
   697 AC_DEFUN_ONCE([TOOLCHAIN_SETUP_COMPILER_FLAGS_FOR_JDK],
   698 [
   700 if test "x$CFLAGS" != "x${ADDED_CFLAGS}"; then
   701    AC_MSG_WARN([Ignoring CFLAGS($CFLAGS) found in environment. Use --with-extra-cflags])
   702 fi
   704 if test "x$CXXFLAGS" != "x${ADDED_CXXFLAGS}"; then
   705    AC_MSG_WARN([Ignoring CXXFLAGS($CXXFLAGS) found in environment. Use --with-extra-cxxflags])
   706 fi
   708 if test "x$LDFLAGS" != "x${ADDED_LDFLAGS}"; then
   709    AC_MSG_WARN([Ignoring LDFLAGS($LDFLAGS) found in environment. Use --with-extra-ldflags])
   710 fi
   712 AC_ARG_WITH(extra-cflags, [AS_HELP_STRING([--with-extra-cflags],
   713     [extra flags to be used when compiling jdk c-files])])
   715 AC_ARG_WITH(extra-cxxflags, [AS_HELP_STRING([--with-extra-cxxflags],
   716     [extra flags to be used when compiling jdk c++-files])])
   718 AC_ARG_WITH(extra-ldflags, [AS_HELP_STRING([--with-extra-ldflags],
   719     [extra flags to be used when linking jdk])])
   721 CFLAGS_JDK="${CFLAGS_JDK} $with_extra_cflags"
   722 CXXFLAGS_JDK="${CXXFLAGS_JDK} $with_extra_cxxflags"
   723 LDFLAGS_JDK="${LDFLAGS_JDK} $with_extra_ldflags"
   725 # Hotspot needs these set in their legacy form
   726 LEGACY_EXTRA_CFLAGS=$with_extra_cflags
   727 LEGACY_EXTRA_CXXFLAGS=$with_extra_cxxflags
   728 LEGACY_EXTRA_LDFLAGS=$with_extra_ldflags
   730 AC_SUBST(LEGACY_EXTRA_CFLAGS)
   731 AC_SUBST(LEGACY_EXTRA_CXXFLAGS)
   732 AC_SUBST(LEGACY_EXTRA_LDFLAGS)
   734 ###############################################################################
   735 #
   736 # Now setup the CFLAGS and LDFLAGS for the JDK build.
   737 # Later we will also have CFLAGS and LDFLAGS for the hotspot subrepo build.
   738 #
   739 case $COMPILER_NAME in
   740       gcc )
   741       	  CCXXFLAGS_JDK="$CCXXFLAGS $CCXXFLAGS_JDK -W -Wall -Wno-unused -Wno-parentheses \
   742                           -pipe \
   743                           -D_GNU_SOURCE -D_REENTRANT -D_LARGEFILE64_SOURCE"
   744 	  case $OPENJDK_TARGET_CPU_ARCH in
   745 	  arm )
   746             # on arm we don't prevent gcc to omit frame pointer but do prevent strict aliasing
   747 	    CFLAGS_JDK="${CFLAGS_JDK} -fno-strict-aliasing"
   748 	  ;;
   749 	  ppc )
   750             # on ppc we don't prevent gcc to omit frame pointer nor strict-aliasing
   751 	  ;;
   752 	  * )
   753 	    CCXXFLAGS_JDK="$CCXXFLAGS_JDK -fno-omit-frame-pointer"
   754 	    CFLAGS_JDK="${CFLAGS_JDK} -fno-strict-aliasing"
   755           ;;
   756 	  esac
   757           ;;
   758       ossc )
   759           CCXXFLAGS_JDK="$CCXXFLAGS $CCXXFLAGS_JDK -DTRACING -DMACRO_MEMSYS_OPS -DBREAKPTS"
   760           case $OPENJDK_TARGET_CPU_ARCH in
   761           x86 )
   762             CCXXFLAGS_JDK="$CCXXFLAGS_JDK -DcpuIntel -Di586 -Di386"
   763        	    CFLAGS_JDK="$CFLAGS_JDK -erroff=E_BAD_PRAGMA_PACK_VALUE"
   764           ;;
   765           esac
   767       	  CFLAGS_JDK="$CFLAGS_JDK -xc99=%none -xCC -errshort=tags -Xa -v -mt -W0,-noglobal"
   768       	  CXXFLAGS_JDK="$CXXFLAGS_JDK -errtags=yes +w -mt -features=no%except -DCC_NOEX -norunpath -xnolib"
   770           LDFLAGS_JDK="$LDFLAGS_JDK -z defs -xildoff -ztext"
   771           LDFLAGS_CXX_JDK="$LDFLAGS_CXX_JDK -norunpath -xnolib"
   772           ;;
   773       cl )
   774           CCXXFLAGS_JDK="$CCXXFLAGS $CCXXFLAGS_JDK -Zi -MD -Zc:wchar_t- -W3 -wd4800 \
   775                -D_STATIC_CPPLIB -D_DISABLE_DEPRECATE_STATIC_CPPLIB -DWIN32_LEAN_AND_MEAN \
   776 	       -D_CRT_SECURE_NO_DEPRECATE -D_CRT_NONSTDC_NO_DEPRECATE \
   777 	       -DWIN32 -DIAL"
   778           case $OPENJDK_TARGET_CPU in
   779               x86 )
   780                   CCXXFLAGS_JDK="$CCXXFLAGS_JDK -D_X86_ -Dx86"
   781                   ;;
   782               x86_64 )
   783                   CCXXFLAGS_JDK="$CCXXFLAGS_JDK -D_AMD64_ -Damd64"
   784                   ;;
   785           esac
   786           ;;
   787 esac
   789 ###############################################################################
   791 CCXXFLAGS_JDK="$CCXXFLAGS_JDK $ADD_LP64"
   793 # The package path is used only on macosx?
   794 PACKAGE_PATH=/opt/local
   795 AC_SUBST(PACKAGE_PATH)
   797 if test "x$OPENJDK_TARGET_CPU_ENDIAN" = xlittle; then
   798     # The macro _LITTLE_ENDIAN needs to be defined the same to avoid the
   799     #   Sun C compiler warning message: warning: macro redefined: _LITTLE_ENDIAN
   800     #   (The Solaris X86 system defines this in file /usr/include/sys/isa_defs.h).
   801     #   Note: -Dmacro         is the same as    #define macro 1
   802     #         -Dmacro=	    is the same as    #define macro
   803     if test "x$OPENJDK_TARGET_OS" = xsolaris; then
   804         CCXXFLAGS_JDK="$CCXXFLAGS_JDK -D_LITTLE_ENDIAN="
   805     else
   806         CCXXFLAGS_JDK="$CCXXFLAGS_JDK -D_LITTLE_ENDIAN"
   807     fi
   808 else
   809     CCXXFLAGS_JDK="$CCXXFLAGS_JDK -D_BIG_ENDIAN"
   810 fi
   811 if test "x$OPENJDK_TARGET_OS" = xlinux; then
   812     CCXXFLAGS_JDK="$CCXXFLAGS_JDK -DLINUX"
   813 fi
   814 if test "x$OPENJDK_TARGET_OS" = xwindows; then
   815     CCXXFLAGS_JDK="$CCXXFLAGS_JDK -DWINDOWS"
   816 fi
   817 if test "x$OPENJDK_TARGET_OS" = xsolaris; then
   818     CCXXFLAGS_JDK="$CCXXFLAGS_JDK -DSOLARIS"
   819 fi
   820 if test "x$OPENJDK_TARGET_OS" = xmacosx; then
   821     CCXXFLAGS_JDK="$CCXXFLAGS_JDK -DMACOSX -D_ALLBSD_SOURCE"
   822 fi
   823 if test "x$OPENJDK_TARGET_OS" = xbsd; then
   824     CCXXFLAGS_JDK="$CCXXFLAGS_JDK -DBSD -D_ALLBSD_SOURCE"
   825 fi
   826 if test "x$DEBUG_LEVEL" = xrelease; then
   827     CCXXFLAGS_JDK="$CCXXFLAGS_JDK -DNDEBUG"
   828     if test "x$OPENJDK_TARGET_OS" = xsolaris; then
   829         CCXXFLAGS_JDK="$CCXXFLAGS_JDK -DTRIMMED"
   830     fi
   831 else
   832     CCXXFLAGS_JDK="$CCXXFLAGS_JDK -DDEBUG"
   833 fi
   835 CCXXFLAGS_JDK="$CCXXFLAGS_JDK -DARCH='\"$OPENJDK_TARGET_CPU_LEGACY\"' -D$OPENJDK_TARGET_CPU_LEGACY"
   836 CCXXFLAGS_JDK="$CCXXFLAGS_JDK -DRELEASE='\"$RELEASE\"'"
   838 CCXXFLAGS_JDK="$CCXXFLAGS_JDK \
   839         -I${JDK_OUTPUTDIR}/include \
   840         -I${JDK_OUTPUTDIR}/include/$OPENJDK_TARGET_OS \
   841         -I${JDK_TOPDIR}/src/share/javavm/export \
   842         -I${JDK_TOPDIR}/src/$OPENJDK_TARGET_OS_API_DIR/javavm/export \
   843         -I${JDK_TOPDIR}/src/share/native/common \
   844         -I${JDK_TOPDIR}/src/$OPENJDK_TARGET_OS_API_DIR/native/common"
   846 # The shared libraries are compiled using the picflag.
   847 CFLAGS_JDKLIB="$CCXXFLAGS_JDK $CFLAGS_JDK $PICFLAG $CFLAGS_JDKLIB_EXTRA"
   848 CXXFLAGS_JDKLIB="$CCXXFLAGS_JDK $CXXFLAGS_JDK $PICFLAG $CXXFLAGS_JDKLIB_EXTRA "
   850 # Executable flags
   851 CFLAGS_JDKEXE="$CCXXFLAGS_JDK $CFLAGS_JDK"
   852 CXXFLAGS_JDKEXE="$CCXXFLAGS_JDK $CXXFLAGS_JDK"
   854 # Now this is odd. The JDK native libraries have to link against libjvm.so
   855 # On 32-bit machines there is normally two distinct libjvm.so:s, client and server.
   856 # Which should we link to? Are we lucky enough that the binary api to the libjvm.so library
   857 # is identical for client and server? Yes. Which is picked at runtime (client or server)?
   858 # Neither, since the chosen libjvm.so has already been loaded by the launcher, all the following
   859 # libraries will link to whatever is in memory. Yuck. 
   860 #
   861 # Thus we offer the compiler to find libjvm.so first in server then in client. It works. Ugh.
   862 if test "x$COMPILER_TYPE" = xCL; then
   863     LDFLAGS_JDK="$LDFLAGS_JDK -nologo -opt:ref -incremental:no"
   864     if test "x$OPENJDK_TARGET_CPU" = xx86; then 
   865         LDFLAGS_JDK="$LDFLAGS_JDK -safeseh"
   866     fi
   867     # TODO: make -debug optional "--disable-full-debug-symbols"
   868     LDFLAGS_JDK="$LDFLAGS_JDK -debug"
   869     LDFLAGS_JDKLIB="${LDFLAGS_JDK} -dll -libpath:${JDK_OUTPUTDIR}/lib"
   870     LDFLAGS_JDKLIB_SUFFIX=""
   871     if test "x$OPENJDK_TARGET_CPU_BITS" = "x64"; then
   872         LDFLAGS_STACK_SIZE=1048576
   873     else
   874         LDFLAGS_STACK_SIZE=327680
   875     fi
   876     LDFLAGS_JDKEXE="${LDFLAGS_JDK} /STACK:$LDFLAGS_STACK_SIZE"
   877 else
   878     # If this is a --hash-style=gnu system, use --hash-style=both, why?
   879     HAS_GNU_HASH=`$CC -dumpspecs 2>/dev/null | $GREP 'hash-style=gnu'`
   880     if test -n "$HAS_GNU_HASH"; then
   881         # And since we now know that the linker is gnu, then add -z defs, to forbid
   882         # undefined symbols in object files.
   883         LDFLAGS_JDK="${LDFLAGS_JDK} -Xlinker --hash-style=both -Xlinker -z -Xlinker defs"
   884         if test "x$DEBUG_LEVEL" == "xrelease"; then
   885             # When building release libraries, tell the linker optimize them.
   886             # Should this be supplied to the OSS linker as well?
   887             LDFLAGS_JDK="${LDFLAGS_JDK} -Xlinker -O1"
   888         fi
   889     fi
   891     LDFLAGS_JDKLIB="${LDFLAGS_JDK} $SHARED_LIBRARY_FLAGS \
   892                     -L${JDK_OUTPUTDIR}/lib${OPENJDK_TARGET_CPU_LIBDIR}/server \
   893                     -L${JDK_OUTPUTDIR}/lib${OPENJDK_TARGET_CPU_LIBDIR}/client \
   894                     -L${JDK_OUTPUTDIR}/lib${OPENJDK_TARGET_CPU_LIBDIR}"
   896     LDFLAGS_JDKLIB_SUFFIX="-ljava -ljvm"
   897     if test "x$COMPILER_NAME" = xossc; then
   898         LDFLAGS_JDKLIB_SUFFIX="$LDFLAGS_JDKLIB_SUFFIX -lc"
   899     fi
   901     LDFLAGS_JDKEXE="${LDFLAGS_JDK}"
   902     if test "x$OPENJDK_TARGET_OS" = xlinux; then
   903         LDFLAGS_JDKEXE="$LDFLAGS_JDKEXE -Xlinker --allow-shlib-undefined"
   904     fi
   905 fi
   907 # Adjust flags according to debug level.
   908 case $DEBUG_LEVEL in
   909       fastdebug ) 
   910               CFLAGS="$CFLAGS $D_FLAG"
   911               JAVAC_FLAGS="$JAVAC_FLAGS -g"
   912               ;;
   913       slowdebug )
   914               CFLAGS="$CFLAGS $D_FLAG"
   915 	      C_O_FLAG_HI="$C_O_FLAG_NONE"
   916 	      C_O_FLAG_NORM="$C_O_FLAG_NONE"
   917 	      CXX_O_FLAG_HI="$CXX_O_FLAG_NONE"
   918 	      CXX_O_FLAG_NORM="$CXX_O_FLAG_NONE"
   919               JAVAC_FLAGS="$JAVAC_FLAGS -g"
   920               ;;
   921 esac              
   924 AC_SUBST(CFLAGS_JDKLIB)
   925 AC_SUBST(CFLAGS_JDKEXE)
   927 AC_SUBST(CXXFLAGS_JDKLIB)
   928 AC_SUBST(CXXFLAGS_JDKEXE)
   930 AC_SUBST(LDFLAGS_JDKLIB)
   931 AC_SUBST(LDFLAGS_JDKEXE)
   932 AC_SUBST(LDFLAGS_JDKLIB_SUFFIX)
   933 AC_SUBST(LDFLAGS_JDKEXE_SUFFIX)
   934 AC_SUBST(LDFLAGS_CXX_JDK)
   935 ])

mercurial