common/autoconf/libraries.m4
changeset 14459 6213b3f9e08d
parent 14280 7d8ad47b2dbf
child 15178 5b28a4d0f57d
equal deleted inserted replaced
14458:8e22b637770a 14459:6213b3f9e08d
   599 ###############################################################################
   599 ###############################################################################
   600 #
   600 #
   601 # statically link libstdc++ before C++ ABI is stablized on Linux unless 
   601 # statically link libstdc++ before C++ ABI is stablized on Linux unless 
   602 # dynamic build is configured on command line.
   602 # dynamic build is configured on command line.
   603 #
   603 #
   604 AC_ARG_ENABLE([static-link-stdc++], [AS_HELP_STRING([--disable-static-link-stdc++],
   604 AC_ARG_WITH([stdc++lib], [AS_HELP_STRING([--with-stdc++lib=<static>,<dynamic>,<default>],
   605 	[disable static linking of the C++ runtime on Linux @<:@enabled@:>@])],,
   605   [force linking of the C++ runtime on Linux to either static or dynamic, default is static with dynamic as fallback])],
   606 	[
   606   [
   607 		enable_static_link_stdc__=yes
   607     if test "x$with_stdc__lib" != xdynamic && test "x$with_stdc__lib" != xstatic \
   608     ])
   608         && test "x$with_stdc__lib" != xdefault; then
       
   609       AC_MSG_ERROR([Bad parameter value --with-stdc++lib=$with_stdc__lib!])
       
   610     fi
       
   611   ],
       
   612   [with_stdc__lib=default]
       
   613 )
   609 
   614 
   610 if test "x$OPENJDK_TARGET_OS" = xlinux; then
   615 if test "x$OPENJDK_TARGET_OS" = xlinux; then
   611     # Test if -lstdc++ works.
   616     # Test if -lstdc++ works.
   612     AC_MSG_CHECKING([if dynamic link of stdc++ is possible])
   617     AC_MSG_CHECKING([if dynamic link of stdc++ is possible])
   613     AC_LANG_PUSH(C++)
   618     AC_LANG_PUSH(C++)
   634     LIBS="$OLD_LIBS"
   639     LIBS="$OLD_LIBS"
   635     CXX="$OLD_CXX"
   640     CXX="$OLD_CXX"
   636     AC_LANG_POP(C++)
   641     AC_LANG_POP(C++)
   637     AC_MSG_RESULT([$has_static_libstdcxx])
   642     AC_MSG_RESULT([$has_static_libstdcxx])
   638 
   643 
   639     if test "x$has_static_libcxx" = xno && test "x$has_dynamic_libcxx" = xno; then
   644     if test "x$has_static_libstdcxx" = xno && test "x$has_dynamic_libstdcxx" = xno; then
   640         AC_MSG_ERROR([I cannot link to stdc++! Neither dynamically nor statically.])
   645         AC_MSG_ERROR([Cannot link to stdc++, neither dynamically nor statically!])
   641     fi
   646     fi
   642 
   647 
   643     if test "x$enable_static_link_stdc__" = xyes && test "x$has_static_libstdcxx" = xno; then
   648     if test "x$with_stdc__lib" = xstatic && test "x$has_static_libstdcxx" = xno; then
   644         AC_MSG_NOTICE([Static linking of libstdc++ was not possible reverting to dynamic linking.])
   649         AC_MSG_ERROR([Static linking of libstdc++ was not possible!])
   645         enable_static_link_stdc__=no
   650     fi
   646     fi
   651 
   647 
   652     if test "x$with_stdc__lib" = xdynamic && test "x$has_dynamic_libstdcxx" = xno; then
   648     if test "x$enable_static_link_stdc__" = xno && test "x$has_dynamic_libstdcxx" = xno; then
   653         AC_MSG_ERROR([Dynamic linking of libstdc++ was not possible!])
   649         AC_MSG_NOTICE([Dynamic linking of libstdc++ was not possible reverting to static linking.])
       
   650         enable_static_link_stdc__=yes
       
   651     fi
   654     fi
   652 
   655 
   653     AC_MSG_CHECKING([how to link with libstdc++])
   656     AC_MSG_CHECKING([how to link with libstdc++])
   654     if test "x$enable_static_link_stdc__" = xyes; then
   657     # If dynamic was requested, it's available since it would fail above otherwise.
       
   658     # If dynamic wasn't requested, go with static unless it isn't available.
       
   659     if test "x$with_stdc__lib" = xdynamic || test "x$has_static_libstdcxx" = xno; then
       
   660         LIBCXX="$LIBCXX -lstdc++"
       
   661         LDCXX="$CXX"
       
   662         STATIC_CXX_SETTING="STATIC_CXX=false"
       
   663         AC_MSG_RESULT([dynamic])
       
   664     else
   655         LIBCXX="$LIBCXX $STATIC_STDCXX_FLAGS"
   665         LIBCXX="$LIBCXX $STATIC_STDCXX_FLAGS"
   656         LDCXX="$CC"
   666         LDCXX="$CC"
   657         STATIC_CXX_SETTING="STATIC_CXX=true"
   667         STATIC_CXX_SETTING="STATIC_CXX=true"
   658         AC_MSG_RESULT([static])
   668         AC_MSG_RESULT([static])
   659     else
       
   660         LIBCXX="$LIBCXX -lstdc++"
       
   661         LDCXX="$CXX"
       
   662         STATIC_CXX_SETTING="STATIC_CXX=false"
       
   663         AC_MSG_RESULT([dynamic])
       
   664     fi
   669     fi
   665 fi
   670 fi
   666 AC_SUBST(STATIC_CXX_SETTING)
   671 AC_SUBST(STATIC_CXX_SETTING)
   667 
   672 
   668 # libCrun is the c++ runtime-library with SunStudio (roughly the equivalent of gcc's libstdc++.so)
   673 # libCrun is the c++ runtime-library with SunStudio (roughly the equivalent of gcc's libstdc++.so)