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