libraries.m4 revision 476:2ba6f4da4bf3
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# 25 26AC_DEFUN_ONCE([LIB_SETUP_INIT], 27[ 28 29############################################################################### 30# 31# OS specific settings that we never will need to probe. 32# 33if test "x$OPENJDK_TARGET_OS" = xlinux; then 34 AC_MSG_CHECKING([what is not needed on Linux?]) 35 PULSE_NOT_NEEDED=yes 36 AC_MSG_RESULT([pulse]) 37fi 38 39if test "x$OPENJDK_TARGET_OS" = xsolaris; then 40 AC_MSG_CHECKING([what is not needed on Solaris?]) 41 ALSA_NOT_NEEDED=yes 42 PULSE_NOT_NEEDED=yes 43 AC_MSG_RESULT([alsa pulse]) 44fi 45 46if test "x$OPENJDK_TARGET_OS" = xwindows; then 47 AC_MSG_CHECKING([what is not needed on Windows?]) 48 CUPS_NOT_NEEDED=yes 49 ALSA_NOT_NEEDED=yes 50 PULSE_NOT_NEEDED=yes 51 X11_NOT_NEEDED=yes 52 AC_MSG_RESULT([alsa cups pulse x11]) 53fi 54 55if test "x$OPENJDK_TARGET_OS" = xmacosx; then 56 AC_MSG_CHECKING([what is not needed on MacOSX?]) 57 ALSA_NOT_NEEDED=yes 58 PULSE_NOT_NEEDED=yes 59 X11_NOT_NEEDED=yes 60 FREETYPE2_NOT_NEEDED=yes 61 # If the java runtime framework is disabled, then we need X11. 62 # This will be adjusted below. 63 AC_MSG_RESULT([alsa pulse x11]) 64fi 65 66if test "x$OPENJDK_TARGET_OS" = xbsd; then 67 AC_MSG_CHECKING([what is not needed on bsd?]) 68 ALSA_NOT_NEEDED=yes 69 AC_MSG_RESULT([alsa]) 70fi 71 72if test "x$OPENJDK" = "xfalse"; then 73 FREETYPE2_NOT_NEEDED=yes 74fi 75 76if test "x$SUPPORT_HEADFUL" = xno; then 77 X11_NOT_NEEDED=yes 78fi 79 80############################################################################### 81# 82# Check for MacOSX support for OpenJDK. If this exists, try to build a JVM 83# that uses this API. 84# 85AC_ARG_ENABLE([macosx-runtime-support], [AS_HELP_STRING([--disable-macosx-runtime-support], 86 [disable the use of MacOSX Java runtime support framework @<:@enabled@:>@])], 87 [MACOSX_RUNTIME_SUPPORT="${enableval}"],[MACOSX_RUNTIME_SUPPORT="no"]) 88 89USE_MACOSX_RUNTIME_SUPPORT=no 90AC_MSG_CHECKING([for explicit Java runtime support in the OS]) 91if test -f /System/Library/Frameworks/JavaVM.framework/Frameworks/JavaRuntimeSupport.framework/Headers/JavaRuntimeSupport.h; then 92 if test "x$MACOSX_RUNTIME_SUPPORT" != xno; then 93 MACOSX_RUNTIME_SUPPORT=yes 94 USE_MACOSX_RUNTIME_SUPPORT=yes 95 AC_MSG_RESULT([yes, does not need alsa freetype2 pulse and X11]) 96 else 97 AC_MSG_RESULT([yes, but explicitly disabled.]) 98 fi 99else 100 AC_MSG_RESULT([no]) 101fi 102 103if test "x$OPENJDK_TARGET_OS" = xmacosx && test "x$USE_MACOSX_RUNTIME_SUPPORT" = xno; then 104 AC_MSG_CHECKING([what is not needed on an X11 build on MacOSX?]) 105 X11_NOT_NEEDED= 106 FREETYPE2_NOT_NEEDED= 107 AC_MSG_RESULT([alsa pulse]) 108fi 109]) 110 111AC_DEFUN_ONCE([LIB_SETUP_X11], 112[ 113 114############################################################################### 115# 116# Check for X Windows 117# 118 119# Check if the user has specified sysroot, but not --x-includes or --x-libraries. 120# Make a simple check for the libraries at the sysroot, and setup --x-includes and 121# --x-libraries for the sysroot, if that seems to be correct. 122if test "x$SYS_ROOT" != "x/"; then 123 if test "x$x_includes" = xNONE; then 124 if test -f "$SYS_ROOT/usr/X11R6/include/X11/Xlib.h"; then 125 x_includes="$SYS_ROOT/usr/X11R6/include" 126 fi 127 fi 128 if test "x$x_libraries" = xNONE; then 129 if test -f "$SYS_ROOT/usr/X11R6/lib/libX11.so"; then 130 x_libraries="$SYS_ROOT/usr/X11R6/lib" 131 fi 132 fi 133fi 134 135# Now let autoconf do it's magic 136AC_PATH_X 137AC_PATH_XTRA 138 139if test "x$no_x" = xyes && test "x$X11_NOT_NEEDED" != xyes; then 140 HELP_MSG_MISSING_DEPENDENCY([x11]) 141 AC_MSG_ERROR([Could not find X11 libraries. $HELP_MSG]) 142fi 143 144# Some of the old makefiles require a setting of OPENWIN_HOME 145# Since the X11R6 directory has disappeared on later Linuxes, 146# we need to probe for it. 147if test "x$OPENJDK_TARGET_OS" = xlinux; then 148 if test -d "$SYS_ROOT/usr/X11R6"; then 149 OPENWIN_HOME="$SYS_ROOT/usr/X11R6" 150 fi 151 if test -d "$SYS_ROOT/usr/include/X11"; then 152 OPENWIN_HOME="$SYS_ROOT/usr" 153 fi 154fi 155if test "x$OPENJDK_TARGET_OS" = xsolaris; then 156 OPENWIN_HOME="/usr/openwin" 157fi 158AC_SUBST(OPENWIN_HOME) 159 160 161# 162# Weird Sol10 something check...TODO change to try compile 163# 164if test "x${OPENJDK_TARGET_OS}" = xsolaris; then 165 if test "`uname -r`" = "5.10"; then 166 if test "`${EGREP} -c XLinearGradient ${OPENWIN_HOME}/share/include/X11/extensions/Xrender.h`" = "0"; then 167 X_CFLAGS="${X_CFLAGS} -DSOLARIS10_NO_XRENDER_STRUCTS" 168 fi 169 fi 170fi 171 172AC_LANG_PUSH(C) 173OLD_CFLAGS="$CFLAGS" 174CFLAGS="$CFLAGS $X_CFLAGS" 175AC_CHECK_HEADERS([X11/extensions/shape.h X11/extensions/Xrender.h X11/extensions/XTest.h], 176 [X11_A_OK=yes], 177 [X11_A_OK=no]) 178CFLAGS="$OLD_CFLAGS" 179AC_LANG_POP(C) 180 181if test "x$X11_A_OK" = xno && test "x$X11_NOT_NEEDED" != xyes; then 182 HELP_MSG_MISSING_DEPENDENCY([x11]) 183 AC_MSG_ERROR([Could not find all X11 headers (shape.h Xrender.h XTest.h). $HELP_MSG]) 184fi 185 186AC_SUBST(X_CFLAGS) 187AC_SUBST(X_LIBS) 188]) 189 190AC_DEFUN_ONCE([LIB_SETUP_CUPS], 191[ 192 193############################################################################### 194# 195# The common unix printing system cups is used to print from java. 196# 197AC_ARG_WITH(cups, [AS_HELP_STRING([--with-cups], 198 [specify prefix directory for the cups package 199 (expecting the libraries under PATH/lib and the headers under PATH/include)])]) 200AC_ARG_WITH(cups-include, [AS_HELP_STRING([--with-cups-include], 201 [specify directory for the cups include files])]) 202AC_ARG_WITH(cups-lib, [AS_HELP_STRING([--with-cups-lib], 203 [specify directory for the cups library])]) 204 205if test "x$CUPS_NOT_NEEDED" = xyes; then 206 if test "x${with_cups}" != x || test "x${with_cups_include}" != x || test "x${with_cups_lib}" != x; then 207 AC_MSG_WARN([cups not used, so --with-cups is ignored]) 208 fi 209 CUPS_CFLAGS= 210 CUPS_LIBS= 211else 212 CUPS_FOUND=no 213 214 if test "x${with_cups}" = xno || test "x${with_cups_include}" = xno || test "x${with_cups_lib}" = xno; then 215 AC_MSG_ERROR([It is not possible to disable the use of cups. Remove the --without-cups option.]) 216 fi 217 218 if test "x${with_cups}" != x; then 219 CUPS_LIBS="-L${with_cups}/lib -lcups" 220 CUPS_CFLAGS="-I${with_cups}/include" 221 CUPS_FOUND=yes 222 fi 223 if test "x${with_cups_include}" != x; then 224 CUPS_CFLAGS="-I${with_cups_include}" 225 CUPS_FOUND=yes 226 fi 227 if test "x${with_cups_lib}" != x; then 228 CUPS_LIBS="-L${with_cups_lib} -lcups" 229 CUPS_FOUND=yes 230 fi 231 if test "x$CUPS_FOUND" = xno; then 232 BDEPS_CHECK_MODULE(CUPS, cups, xxx, [CUPS_FOUND=yes]) 233 fi 234 if test "x$CUPS_FOUND" = xno; then 235 # Are the cups headers installed in the default /usr/include location? 236 AC_CHECK_HEADERS([cups/cups.h cups/ppd.h], 237 [CUPS_FOUND=yes 238 CUPS_CFLAGS= 239 CUPS_LIBS="-lcups" 240 DEFAULT_CUPS=yes]) 241 fi 242 if test "x$CUPS_FOUND" = xno; then 243 # Getting nervous now? Lets poke around for standard Solaris third-party 244 # package installation locations. 245 AC_MSG_CHECKING([for cups headers and libs]) 246 if test -s /opt/sfw/cups/include/cups/cups.h; then 247 # An SFW package seems to be installed! 248 CUPS_FOUND=yes 249 CUPS_CFLAGS="-I/opt/sfw/cups/include" 250 CUPS_LIBS="-L/opt/sfw/cups/lib -lcups" 251 elif test -s /opt/csw/include/cups/cups.h; then 252 # A CSW package seems to be installed! 253 CUPS_FOUND=yes 254 CUPS_CFLAGS="-I/opt/csw/include" 255 CUPS_LIBS="-L/opt/csw/lib -lcups" 256 fi 257 AC_MSG_RESULT([$CUPS_FOUND]) 258 fi 259 if test "x$CUPS_FOUND" = xno; then 260 HELP_MSG_MISSING_DEPENDENCY([cups]) 261 AC_MSG_ERROR([Could not find cups! $HELP_MSG ]) 262 fi 263fi 264 265AC_SUBST(CUPS_CFLAGS) 266AC_SUBST(CUPS_LIBS) 267 268]) 269 270AC_DEFUN_ONCE([LIB_SETUP_FREETYPE], 271[ 272 273############################################################################### 274# 275# The ubiquitous freetype2 library is used to render fonts. 276# 277AC_ARG_WITH(freetype, [AS_HELP_STRING([--with-freetype], 278 [specify prefix directory for the freetype2 package 279 (expecting the libraries under PATH/lib and the headers under PATH/include)])]) 280 281# If we are using the OS installed system lib for freetype, then we do not need to copy it to the build tree 282USING_SYSTEM_FT_LIB=false 283 284if test "x$FREETYPE2_NOT_NEEDED" = xyes; then 285 if test "x$with_freetype" != x || test "x$with_freetype_include" != x || test "x$with_freetype_lib" != x; then 286 AC_MSG_WARN([freetype not used, so --with-freetype is ignored]) 287 fi 288 FREETYPE2_CFLAGS= 289 FREETYPE2_LIBS= 290 FREETYPE2_LIB_PATH= 291else 292 FREETYPE2_FOUND=no 293 294 if test "x$with_freetype" != x; then 295 SPACESAFE(with_freetype,[the path to freetype]) 296 FREETYPE2_LIBS="-L$with_freetype/lib -lfreetype" 297 if test "x$OPENJDK_TARGET_OS" = xwindows; then 298 FREETYPE2_LIBS="$with_freetype/lib/freetype.lib" 299 fi 300 FREETYPE2_LIB_PATH="$with_freetype/lib" 301 FREETYPE2_CFLAGS="-I$with_freetype/include" 302 if test -s $with_freetype/include/ft2build.h && test -d $with_freetype/include/freetype2/freetype; then 303 FREETYPE2_CFLAGS="-I$with_freetype/include/freetype2 -I$with_freetype/include" 304 fi 305 FREETYPE2_FOUND=yes 306 if test "x$FREETYPE2_FOUND" = xyes; then 307 # Verify that the directories exist 308 if ! test -d "$with_freetype/lib" || ! test -d "$with_freetype/include"; then 309 AC_MSG_ERROR([Could not find the expected directories $with_freetype/lib and $with_freetype/include]) 310 fi 311 # List the contents of the lib. 312 FREETYPELIB=`ls $with_freetype/lib/libfreetype.so $with_freetype/lib/freetype.dll 2> /dev/null` 313 if test "x$FREETYPELIB" = x; then 314 AC_MSG_ERROR([Could not find libfreetype.se nor freetype.dll in $with_freetype/lib]) 315 fi 316 # Check one h-file 317 if ! test -s "$with_freetype/include/ft2build.h"; then 318 AC_MSG_ERROR([Could not find $with_freetype/include/ft2build.h]) 319 fi 320 fi 321 fi 322 if test "x$FREETYPE2_FOUND" = xno; then 323 BDEPS_CHECK_MODULE(FREETYPE2, freetype2, xxx, [FREETYPE2_FOUND=yes], [FREETYPE2_FOUND=no]) 324 USING_SYSTEM_FT_LIB=true 325 fi 326 if test "x$FREETYPE2_FOUND" = xno; then 327 PKG_CHECK_MODULES(FREETYPE2, freetype2, [FREETYPE2_FOUND=yes], [FREETYPE2_FOUND=no]) 328 USING_SYSTEM_FT_LIB=true 329 fi 330 if test "x$FREETYPE2_FOUND" = xno; then 331 AC_MSG_CHECKING([for freetype in some standard locations]) 332 333 if test -s /usr/X11/include/ft2build.h && test -d /usr/X11/include/freetype2/freetype; then 334 DEFAULT_FREETYPE_CFLAGS="-I/usr/X11/include/freetype2 -I/usr/X11/include" 335 DEFAULT_FREETYPE_LIBS="-L/usr/X11/lib -lfreetype" 336 fi 337 if test -s /usr/include/ft2build.h && test -d /usr/include/freetype2/freetype; then 338 DEFAULT_FREETYPE_CFLAGS="-I/usr/include/freetype2" 339 DEFAULT_FREETYPE_LIBS="-lfreetype" 340 fi 341 342 PREV_CXXCFLAGS="$CXXFLAGS" 343 PREV_LDFLAGS="$LDFLAGS" 344 CXXFLAGS="$CXXFLAGS $DEFAULT_FREETYPE_CFLAGS" 345 LDFLAGS="$LDFLAGS $DEFAULT_FREETYPE_LIBS" 346 AC_LINK_IFELSE([AC_LANG_SOURCE([[#include<ft2build.h> 347 #include FT_FREETYPE_H 348 int main() { return 0; } 349 ]])], 350 [ 351 # Yes, the default cflags and libs did the trick. 352 FREETYPE2_FOUND=yes 353 FREETYPE2_CFLAGS="$DEFAULT_FREETYPE_CFLAGS" 354 FREETYPE2_LIBS="$DEFAULT_FREETYPE_LIBS" 355 ], 356 [ 357 FREETYPE2_FOUND=no 358 ]) 359 CXXCFLAGS="$PREV_CXXFLAGS" 360 LDFLAGS="$PREV_LDFLAGS" 361 AC_MSG_RESULT([$FREETYPE2_FOUND]) 362 USING_SYSTEM_FT_LIB=true 363 fi 364 if test "x$FREETYPE2_FOUND" = xno; then 365 HELP_MSG_MISSING_DEPENDENCY([freetype2]) 366 AC_MSG_ERROR([Could not find freetype2! $HELP_MSG ]) 367 fi 368fi 369 370AC_SUBST(USING_SYSTEM_FT_LIB) 371AC_SUBST(FREETYPE2_LIB_PATH) 372AC_SUBST(FREETYPE2_CFLAGS) 373AC_SUBST(FREETYPE2_LIBS) 374 375]) 376 377AC_DEFUN_ONCE([LIB_SETUP_ALSA], 378[ 379 380############################################################################### 381# 382# Check for alsa headers and libraries. Used on Linux/GNU systems. 383# 384AC_ARG_WITH(alsa, [AS_HELP_STRING([--with-alsa], 385 [specify prefix directory for the alsa package 386 (expecting the libraries under PATH/lib and the headers under PATH/include)])]) 387AC_ARG_WITH(alsa-include, [AS_HELP_STRING([--with-alsa-include], 388 [specify directory for the alsa include files])]) 389AC_ARG_WITH(alsa-lib, [AS_HELP_STRING([--with-alsa-lib], 390 [specify directory for the alsa library])]) 391 392if test "x$ALSA_NOT_NEEDED" = xyes; then 393 if test "x${with_alsa}" != x || test "x${with_alsa_include}" != x || test "x${with_alsa_lib}" != x; then 394 AC_MSG_WARN([alsa not used, so --with-alsa is ignored]) 395 fi 396 ALSA_CFLAGS= 397 ALSA_LIBS= 398else 399 ALSA_FOUND=no 400 401 if test "x${with_alsa}" = xno || test "x${with_alsa_include}" = xno || test "x${with_alsa_lib}" = xno; then 402 AC_MSG_ERROR([It is not possible to disable the use of alsa. Remove the --without-alsa option.]) 403 fi 404 405 if test "x${with_alsa}" != x; then 406 ALSA_LIBS="-L${with_alsa}/lib -lalsa" 407 ALSA_CFLAGS="-I${with_alsa}/include" 408 ALSA_FOUND=yes 409 fi 410 if test "x${with_alsa_include}" != x; then 411 ALSA_CFLAGS="-I${with_alsa_include}" 412 ALSA_FOUND=yes 413 fi 414 if test "x${with_alsa_lib}" != x; then 415 ALSA_LIBS="-L${with_alsa_lib} -lalsa" 416 ALSA_FOUND=yes 417 fi 418 if test "x$ALSA_FOUND" = xno; then 419 BDEPS_CHECK_MODULE(ALSA, alsa, xxx, [ALSA_FOUND=yes], [ALSA_FOUND=no]) 420 fi 421 if test "x$ALSA_FOUND" = xno; then 422 PKG_CHECK_MODULES(ALSA, alsa, [ALSA_FOUND=yes], [ALSA_FOUND=no]) 423 fi 424 if test "x$ALSA_FOUND" = xno; then 425 AC_CHECK_HEADERS([alsa/asoundlib.h], 426 [ALSA_FOUND=yes 427 ALSA_CFLAGS=-Iignoreme 428 ALSA_LIBS=-lasound 429 DEFAULT_ALSA=yes], 430 [ALSA_FOUND=no]) 431 fi 432 if test "x$ALSA_FOUND" = xno; then 433 HELP_MSG_MISSING_DEPENDENCY([alsa]) 434 AC_MSG_ERROR([Could not find alsa! $HELP_MSG ]) 435 fi 436fi 437 438AC_SUBST(ALSA_CFLAGS) 439AC_SUBST(ALSA_LIBS) 440 441]) 442 443AC_DEFUN_ONCE([LIB_SETUP_MISC_LIBS], 444[ 445 446############################################################################### 447# 448# Check for the jpeg library 449# 450 451USE_EXTERNAL_LIBJPEG=true 452AC_CHECK_LIB(jpeg, main, [], 453 [ USE_EXTERNAL_LIBJPEG=false 454 AC_MSG_NOTICE([Will use jpeg decoder bundled with the OpenJDK source]) 455 ]) 456AC_SUBST(USE_EXTERNAL_LIBJPEG) 457 458############################################################################### 459# 460# Check for the gif library 461# 462 463USE_EXTERNAL_LIBJPEG=true 464AC_CHECK_LIB(gif, main, [], 465 [ USE_EXTERNAL_LIBGIF=false 466 AC_MSG_NOTICE([Will use gif decoder bundled with the OpenJDK source]) 467 ]) 468AC_SUBST(USE_EXTERNAL_LIBGIF) 469 470############################################################################### 471# 472# Check for the zlib library 473# 474 475AC_ARG_WITH(zlib, [AS_HELP_STRING([--with-zlib], 476 [use zlib from build system or OpenJDK source (system, bundled) @<:@bundled@:>@])]) 477 478AC_CHECK_LIB(z, compress, 479 [ ZLIB_FOUND=yes ], 480 [ ZLIB_FOUND=no ]) 481 482AC_MSG_CHECKING([for which zlib to use]) 483 484DEFAULT_ZLIB=bundled 485if test "x$OPENJDK_TARGET_OS" = xmacosx; then 486# 487# On macosx default is system...on others default is 488# 489 DEFAULT_ZLIB=system 490fi 491 492if test "x${ZLIB_FOUND}" != "xyes"; then 493# 494# If we don't find any system...set default to bundled 495# 496 DEFAULT_ZLIB=bundled 497fi 498 499# 500# If user didn't specify, use DEFAULT_ZLIB 501# 502if test "x${with_zlib}" = "x"; then 503 with_zlib=${DEFAULT_ZLIB} 504fi 505 506if test "x${with_zlib}" = "xbundled"; then 507 USE_EXTERNAL_LIBZ=false 508 AC_MSG_RESULT([bundled]) 509elif test "x${with_zlib}" = "xsystem"; then 510 if test "x${ZLIB_FOUND}" = "xyes"; then 511 USE_EXTERNAL_LIBZ=true 512 AC_MSG_RESULT([system]) 513 else 514 AC_MSG_RESULT([system not found]) 515 AC_MSG_ERROR([--with-zlib=system specified, but no zlib found!]) 516 fi 517else 518 AC_MSG_ERROR([Invalid value for --with-zlib: ${with_zlib}, use 'system' or 'bundled']) 519fi 520 521AC_SUBST(USE_EXTERNAL_LIBZ) 522 523############################################################################### 524LIBZIP_CAN_USE_MMAP=true 525 526AC_SUBST(LIBZIP_CAN_USE_MMAP) 527 528############################################################################### 529# 530# Check if altzone exists in time.h 531# 532 533AC_LINK_IFELSE([AC_LANG_PROGRAM([#include <time.h>], [return (int)altzone;])], 534 [has_altzone=yes], 535 [has_altzone=no]) 536if test "x$has_altzone" = xyes; then 537 AC_DEFINE([HAVE_ALTZONE], 1, [Define if you have the external 'altzone' variable in time.h]) 538fi 539 540############################################################################### 541# 542# Check the maths library 543# 544 545AC_CHECK_LIB(m, cos, [], 546 [ 547 AC_MSG_NOTICE([Maths library was not found]) 548 ]) 549AC_SUBST(LIBM) 550 551############################################################################### 552# 553# Check for libdl.so 554 555save_LIBS="$LIBS" 556LIBS="" 557AC_CHECK_LIB(dl,dlopen) 558LIBDL="$LIBS" 559AC_SUBST(LIBDL) 560LIBS="$save_LIBS" 561 562]) 563 564AC_DEFUN_ONCE([LIB_SETUP_STATIC_LINK_LIBSTDCPP], 565[ 566############################################################################### 567# 568# statically link libstdc++ before C++ ABI is stablized on Linux unless 569# dynamic build is configured on command line. 570# 571AC_ARG_ENABLE([static-link-stdc++], [AS_HELP_STRING([--disable-static-link-stdc++], 572 [disable static linking of the C++ runtime on Linux @<:@enabled@:>@])],, 573 [ 574 enable_static_link_stdc__=yes 575 ]) 576 577if test "x$OPENJDK_TARGET_OS" = xlinux; then 578 # Test if -lstdc++ works. 579 AC_MSG_CHECKING([if dynamic link of stdc++ is possible]) 580 AC_LANG_PUSH(C++) 581 OLD_CXXFLAGS="$CXXFLAGS" 582 CXXFLAGS="$CXXFLAGS -lstdc++" 583 AC_LINK_IFELSE([AC_LANG_PROGRAM([], [return 0;])], 584 [has_dynamic_libstdcxx=yes], 585 [has_dynamic_libstdcxx=no]) 586 CXXFLAGS="$OLD_CXXFLAGS" 587 AC_LANG_POP(C++) 588 AC_MSG_RESULT([$has_dynamic_libstdcxx]) 589 590 # Test if stdc++ can be linked statically. 591 AC_MSG_CHECKING([if static link of stdc++ is possible]) 592 STATIC_STDCXX_FLAGS="-Wl,-Bstatic -lstdc++ -lgcc -Wl,-Bdynamic" 593 AC_LANG_PUSH(C++) 594 OLD_LIBS="$LIBS" 595 OLD_CXX="$CXX" 596 LIBS="$STATIC_STDCXX_FLAGS" 597 CXX="$CC" 598 AC_LINK_IFELSE([AC_LANG_PROGRAM([], [return 0;])], 599 [has_static_libstdcxx=yes], 600 [has_static_libstdcxx=no]) 601 LIBS="$OLD_LIBS" 602 CXX="$OLD_CXX" 603 AC_LANG_POP(C++) 604 AC_MSG_RESULT([$has_static_libstdcxx]) 605 606 if test "x$has_static_libcxx" = xno && test "x$has_dynamic_libcxx" = xno; then 607 AC_MSG_ERROR([I cannot link to stdc++! Neither dynamically nor statically.]) 608 fi 609 610 if test "x$enable_static_link_stdc__" = xyes && test "x$has_static_libstdcxx" = xno; then 611 AC_MSG_NOTICE([Static linking of libstdc++ was not possible reverting to dynamic linking.]) 612 enable_static_link_stdc__=no 613 fi 614 615 if test "x$enable_static_link_stdc__" = xno && test "x$has_dynamic_libstdcxx" = xno; then 616 AC_MSG_NOTICE([Dynamic linking of libstdc++ was not possible reverting to static linking.]) 617 enable_static_link_stdc__=yes 618 fi 619 620 AC_MSG_CHECKING([how to link with libstdc++]) 621 if test "x$enable_static_link_stdc__" = xyes; then 622 LIBCXX="$LIBCXX $STATIC_STDCXX_FLAGS" 623 LDCXX="$CC" 624 AC_MSG_RESULT([static]) 625 else 626 LIBCXX="$LIBCXX -lstdc++" 627 LDCXX="$CXX" 628 AC_MSG_RESULT([dynamic]) 629 fi 630fi 631 632# libCrun is the c++ runtime-library with SunStudio (roughly the equivalent of gcc's libstdc++.so) 633if test "x$OPENJDK_TARGET_OS" = xsolaris && test "x$LIBCXX" = x; then 634 LIBCXX="/usr/lib${OPENJDK_TARGET_CPU_ISADIR}/libCrun.so.1" 635fi 636 637# TODO better (platform agnostic) test 638if test "x$OPENJDK_TARGET_OS" = xmacosx && test "x$LIBCXX" = x && test "x$GCC" = xyes; then 639 LIBCXX="-lstdc++" 640fi 641 642AC_SUBST(LIBCXX) 643 644]) 645