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 if test "x$SUPPORT_HEADFUL" = xno; then
  77     X11_NOT_NEEDED=yes
  78 fi
  79 
  80 ###############################################################################
  81 #
  82 # Check for MacOSX support for OpenJDK. If this exists, try to build a JVM
  83 # that uses this API. 
  84 #
  85 AC_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 
  89 USE_MACOSX_RUNTIME_SUPPORT=no
  90 AC_MSG_CHECKING([for explicit Java runtime support in the OS])
  91 if 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
  99 else
 100     AC_MSG_RESULT([no])
 101 fi
 102 
 103 if 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])
 108 fi
 109 ])
 110 
 111 AC_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.
 122 if 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
 133 fi
 134 
 135 # Now let autoconf do it's magic
 136 AC_PATH_X
 137 AC_PATH_XTRA
 138 
 139 # AC_PATH_XTRA creates X_LIBS and sometimes adds -R flags. When cross compiling
 140 # this doesn't make sense so we remove it.
 141 if test "x$COMPILE_TYPE" = xcross; then
 142   X_LIBS=`$ECHO $X_LIBS | $SED 's/-R \{0,1\}[[^ ]]*//g'`
 143 fi
 144 
 145 if test "x$no_x" = xyes && test "x$X11_NOT_NEEDED" != xyes; then 
 146     HELP_MSG_MISSING_DEPENDENCY([x11])
 147     AC_MSG_ERROR([Could not find X11 libraries. $HELP_MSG])
 148 fi
 149 
 150 # Some of the old makefiles require a setting of OPENWIN_HOME
 151 # Since the X11R6 directory has disappeared on later Linuxes,
 152 # we need to probe for it.
 153 if test "x$OPENJDK_TARGET_OS" = xlinux; then
 154     if test -d "$SYS_ROOT/usr/X11R6"; then
 155         OPENWIN_HOME="$SYS_ROOT/usr/X11R6"
 156     fi
 157     if test -d "$SYS_ROOT/usr/include/X11"; then
 158         OPENWIN_HOME="$SYS_ROOT/usr"
 159     fi
 160 fi
 161 if test "x$OPENJDK_TARGET_OS" = xsolaris; then
 162     OPENWIN_HOME="/usr/openwin"
 163 fi
 164 AC_SUBST(OPENWIN_HOME)
 165 
 166 
 167 #
 168 # Weird Sol10 something check...TODO change to try compile
 169 #
 170 if test "x${OPENJDK_TARGET_OS}" = xsolaris; then
 171   if test "`uname -r`" = "5.10"; then
 172      if test "`${EGREP} -c XLinearGradient ${OPENWIN_HOME}/share/include/X11/extensions/Xrender.h`" = "0"; then
 173         X_CFLAGS="${X_CFLAGS} -DSOLARIS10_NO_XRENDER_STRUCTS"
 174      fi
 175   fi
 176 fi
 177 
 178 AC_LANG_PUSH(C)
 179 OLD_CFLAGS="$CFLAGS"
 180 CFLAGS="$CFLAGS $X_CFLAGS"
 181 
 182 # Need to include Xlib.h and Xutil.h to avoid "present but cannot be compiled" warnings on Solaris 10
 183 AC_CHECK_HEADERS([X11/extensions/shape.h X11/extensions/Xrender.h X11/extensions/XTest.h],
 184                  [X11_A_OK=yes],
 185                  [X11_A_OK=no],
 186                  [ # include <X11/Xlib.h>
 187                    # include <X11/Xutil.h>
 188                  ])
 189 
 190 CFLAGS="$OLD_CFLAGS"
 191 AC_LANG_POP(C)
 192 
 193 if test "x$X11_A_OK" = xno && test "x$X11_NOT_NEEDED" != xyes; then 
 194     HELP_MSG_MISSING_DEPENDENCY([x11])
 195     AC_MSG_ERROR([Could not find all X11 headers (shape.h Xrender.h XTest.h). $HELP_MSG])
 196 fi
 197 
 198 AC_SUBST(X_CFLAGS)
 199 AC_SUBST(X_LIBS)
 200 ])
 201 
 202 AC_DEFUN_ONCE([LIB_SETUP_CUPS],
 203 [
 204 
 205 ###############################################################################
 206 #
 207 # The common unix printing system cups is used to print from java.
 208 #
 209 AC_ARG_WITH(cups, [AS_HELP_STRING([--with-cups],
 210     [specify prefix directory for the cups package
 211          (expecting the headers under PATH/include)])])
 212 AC_ARG_WITH(cups-include, [AS_HELP_STRING([--with-cups-include],
 213         [specify directory for the cups include files])])
 214 
 215 if test "x$CUPS_NOT_NEEDED" = xyes; then
 216         if test "x${with_cups}" != x || test "x${with_cups_include}" != x; then
 217                 AC_MSG_WARN([cups not used, so --with-cups is ignored])
 218         fi
 219         CUPS_CFLAGS=
 220 else
 221         CUPS_FOUND=no
 222 
 223         if test "x${with_cups}" = xno || test "x${with_cups_include}" = xno; then
 224             AC_MSG_ERROR([It is not possible to disable the use of cups. Remove the --without-cups option.])
 225         fi
 226 
 227         if test "x${with_cups}" != x; then
 228             CUPS_CFLAGS="-I${with_cups}/include"
 229             CUPS_FOUND=yes
 230         fi
 231         if test "x${with_cups_include}" != x; then
 232             CUPS_CFLAGS="-I${with_cups_include}"
 233             CUPS_FOUND=yes
 234         fi
 235         if test "x$CUPS_FOUND" = xno; then
 236             BDEPS_CHECK_MODULE(CUPS, cups, xxx, [CUPS_FOUND=yes])
 237         fi
 238         if test "x$CUPS_FOUND" = xno; then
 239             # Are the cups headers installed in the default /usr/include location?
 240             AC_CHECK_HEADERS([cups/cups.h cups/ppd.h],
 241                              [CUPS_FOUND=yes
 242                               CUPS_CFLAGS=
 243                               DEFAULT_CUPS=yes])
 244         fi
 245         if test "x$CUPS_FOUND" = xno; then
 246             # Getting nervous now? Lets poke around for standard Solaris third-party
 247             # package installation locations.
 248             AC_MSG_CHECKING([for cups headers])
 249             if test -s /opt/sfw/cups/include/cups/cups.h; then
 250                # An SFW package seems to be installed!
 251                CUPS_FOUND=yes
 252                CUPS_CFLAGS="-I/opt/sfw/cups/include"
 253             elif test -s /opt/csw/include/cups/cups.h; then
 254                # A CSW package seems to be installed!
 255                CUPS_FOUND=yes
 256                CUPS_CFLAGS="-I/opt/csw/include"
 257             fi
 258             AC_MSG_RESULT([$CUPS_FOUND])
 259         fi
 260         if test "x$CUPS_FOUND" = xno; then 
 261             HELP_MSG_MISSING_DEPENDENCY([cups])
 262             AC_MSG_ERROR([Could not find cups! $HELP_MSG ])
 263         fi
 264 fi
 265 
 266 AC_SUBST(CUPS_CFLAGS)
 267 
 268 ])
 269 
 270 AC_DEFUN_ONCE([LIB_SETUP_FREETYPE],
 271 [
 272 
 273 ###############################################################################
 274 #
 275 # The ubiquitous freetype2 library is used to render fonts.
 276 #
 277 AC_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
 282 USING_SYSTEM_FT_LIB=false
 283 
 284 if 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=
 291 else
 292         FREETYPE2_FOUND=no
 293 
 294         if test "x$with_freetype" != x; then
 295             BASIC_FIXUP_PATH(with_freetype)
 296             FREETYPE2_LIBS="-L$with_freetype/lib -lfreetype"
 297             FREETYPE2_LIB_PATH="$with_freetype/lib"
 298             if test "x$OPENJDK_TARGET_OS" = xsolaris && test "x$OPENJDK_TARGET_CPU" = xx86_64 && test -d "$with_freetype/lib/amd64"; then
 299                 FREETYPE2_LIBS="-L$with_freetype/lib/amd64 -lfreetype"
 300                 FREETYPE2_LIB_PATH="$with_freetype/lib/amd64"
 301             fi
 302             if test "x$OPENJDK_TARGET_OS" = xwindows; then
 303                 FREETYPE2_LIBS="$with_freetype/lib/freetype.lib"
 304             fi
 305             FREETYPE2_CFLAGS="-I$with_freetype/include"
 306             if test -s $with_freetype/include/ft2build.h && test -d $with_freetype/include/freetype2/freetype; then
 307                 FREETYPE2_CFLAGS="-I$with_freetype/include/freetype2 -I$with_freetype/include"
 308             fi
 309             FREETYPE2_FOUND=yes
 310             if test "x$FREETYPE2_FOUND" = xyes; then
 311                 # Verify that the directories exist 
 312                 if ! test -d "$with_freetype/lib" || ! test -d "$with_freetype/include"; then
 313                    AC_MSG_ERROR([Could not find the expected directories $with_freetype/lib and $with_freetype/include])
 314                 fi
 315                 # List the contents of the lib.
 316                 FREETYPELIB=`ls $with_freetype/lib/libfreetype.so $with_freetype/lib/freetype.dll 2> /dev/null`
 317                 if test "x$FREETYPELIB" = x; then
 318                    AC_MSG_ERROR([Could not find libfreetype.so nor freetype.dll in $with_freetype/lib])
 319                 fi
 320                 # Check one h-file
 321                 if ! test -s "$with_freetype/include/ft2build.h"; then
 322                    AC_MSG_ERROR([Could not find $with_freetype/include/ft2build.h])
 323                 fi
 324             fi
 325         fi
 326         if test "x$FREETYPE2_FOUND" = xno; then
 327             BDEPS_CHECK_MODULE(FREETYPE2, freetype2, xxx, [FREETYPE2_FOUND=yes], [FREETYPE2_FOUND=no])
 328             USING_SYSTEM_FT_LIB=true
 329         fi
 330         if test "x$FREETYPE2_FOUND" = xno && test "x$OPENJDK_TARGET_OS" = xwindows; then
 331             FREETYPELOCATION="$PROGRAMFILES/GnuWin32"
 332             BASIC_FIXUP_PATH(FREETYPELOCATION)
 333             AC_MSG_CHECKING([for freetype in some standard windows locations])
 334             if test -s "$FREETYPELOCATION/include/ft2build.h" && test -d "$FREETYPELOCATION/include/freetype2/freetype"; then
 335                 FREETYPE2_CFLAGS="-I$FREETYPELOCATION/include/freetype2 -I$FREETYPELOCATION/include"
 336                 FREETYPE2_LIBS="$FREETYPELOCATION/lib/freetype.lib"
 337                 FREETYPE2_LIB_PATH="$FREETYPELOCATION/lib"
 338                 if ! test -s "$FREETYPE2_LIBS"; then
 339                    AC_MSG_ERROR([Could not find $FREETYPE2_LIBS])
 340                 fi
 341                 if ! test -s "$FREETYPE2_LIB_PATH/freetype.dll"; then
 342                    AC_MSG_ERROR([Could not find $FREETYPE2_LIB_PATH/freetype.dll])
 343                 fi
 344                 USING_SYSTEM_FT_LIB=true
 345                 FREETYPE2_FOUND=yes
 346             fi
 347             AC_MSG_RESULT([$FREETYPE2_FOUND])         
 348         fi
 349         if test "x$FREETYPE2_FOUND" = xno; then
 350             PKG_CHECK_MODULES(FREETYPE2, freetype2, [FREETYPE2_FOUND=yes], [FREETYPE2_FOUND=no])
 351             # On solaris, pkg_check adds -lz to freetype libs, which isn't necessary for us.
 352             FREETYPE2_LIBS=`$ECHO $FREETYPE2_LIBS | $SED 's/-lz//g'` 
 353             USING_SYSTEM_FT_LIB=true
 354             # 64-bit libs for Solaris x86 are installed in the amd64 subdirectory, change lib to lib/amd64
 355             if test "x$FREETYPE2_FOUND" = xyes && test "x$OPENJDK_TARGET_OS" = xsolaris && test "x$OPENJDK_TARGET_CPU" = xx86_64; then
 356               FREETYPE2_LIBS=`$ECHO $FREETYPE2_LIBS | $SED 's?/lib?/lib/amd64?g'`
 357             fi
 358         fi
 359         if test "x$FREETYPE2_FOUND" = xno; then
 360             AC_MSG_CHECKING([for freetype in some standard locations])
 361         
 362             if test -s /usr/X11/include/ft2build.h && test -d /usr/X11/include/freetype2/freetype; then
 363                 DEFAULT_FREETYPE_CFLAGS="-I/usr/X11/include/freetype2 -I/usr/X11/include"
 364                 DEFAULT_FREETYPE_LIBS="-L/usr/X11/lib -lfreetype"
 365             fi
 366             if test -s /usr/include/ft2build.h && test -d /usr/include/freetype2/freetype; then
 367                 DEFAULT_FREETYPE_CFLAGS="-I/usr/include/freetype2"
 368                 DEFAULT_FREETYPE_LIBS="-lfreetype"
 369             fi
 370         
 371             PREV_CXXCFLAGS="$CXXFLAGS"
 372             PREV_LDFLAGS="$LDFLAGS"
 373             CXXFLAGS="$CXXFLAGS $DEFAULT_FREETYPE_CFLAGS"
 374             LDFLAGS="$LDFLAGS $DEFAULT_FREETYPE_LIBS"
 375             AC_LINK_IFELSE([AC_LANG_SOURCE([[#include<ft2build.h>
 376                             #include FT_FREETYPE_H 
 377                            int main() { return 0; }
 378                           ]])],
 379                           [
 380                               # Yes, the default cflags and libs did the trick.
 381                               FREETYPE2_FOUND=yes
 382                               FREETYPE2_CFLAGS="$DEFAULT_FREETYPE_CFLAGS"
 383                               FREETYPE2_LIBS="$DEFAULT_FREETYPE_LIBS"
 384                           ],
 385                           [
 386                               FREETYPE2_FOUND=no
 387                           ])
 388             CXXCFLAGS="$PREV_CXXFLAGS"
 389             LDFLAGS="$PREV_LDFLAGS"
 390             AC_MSG_RESULT([$FREETYPE2_FOUND])
 391             USING_SYSTEM_FT_LIB=true
 392         fi
 393         if test "x$FREETYPE2_FOUND" = xno; then
 394                 HELP_MSG_MISSING_DEPENDENCY([freetype2])
 395                 AC_MSG_ERROR([Could not find freetype2! $HELP_MSG ])
 396         fi
 397 
 398         if test "x$OPENJDK_TARGET_OS" != xwindows; then
 399             # AC_CHECK_LIB does not support use of cl.exe
 400             PREV_LDFLAGS="$LDFLAGS"
 401             LDFLAGS="$FREETYPE2_LIBS"
 402             AC_CHECK_LIB(freetype, FT_Init_FreeType, 
 403                          FREETYPE2_FOUND=true, 
 404                          AC_MSG_ERROR([Could not find freetype2! $HELP_MSG ]))
 405             LDFLAGS="$PREV_LDFLAGS"
 406         fi
 407 fi
 408 
 409 AC_SUBST(USING_SYSTEM_FT_LIB)
 410 AC_SUBST(FREETYPE2_LIB_PATH)
 411 AC_SUBST(FREETYPE2_CFLAGS)
 412 AC_SUBST(FREETYPE2_LIBS)
 413 
 414 ])
 415 
 416 AC_DEFUN_ONCE([LIB_SETUP_ALSA],
 417 [
 418 
 419 ###############################################################################
 420 #
 421 # Check for alsa headers and libraries. Used on Linux/GNU systems.
 422 #
 423 AC_ARG_WITH(alsa, [AS_HELP_STRING([--with-alsa],
 424         [specify prefix directory for the alsa package
 425          (expecting the libraries under PATH/lib and the headers under PATH/include)])])
 426 AC_ARG_WITH(alsa-include, [AS_HELP_STRING([--with-alsa-include],
 427         [specify directory for the alsa include files])])
 428 AC_ARG_WITH(alsa-lib, [AS_HELP_STRING([--with-alsa-lib],
 429         [specify directory for the alsa library])])
 430 
 431 if test "x$ALSA_NOT_NEEDED" = xyes; then
 432         if test "x${with_alsa}" != x || test "x${with_alsa_include}" != x || test "x${with_alsa_lib}" != x; then
 433                 AC_MSG_WARN([alsa not used, so --with-alsa is ignored])
 434         fi
 435         ALSA_CFLAGS=
 436         ALSA_LIBS=
 437 else
 438         ALSA_FOUND=no
 439 
 440         if test "x${with_alsa}" = xno || test "x${with_alsa_include}" = xno || test "x${with_alsa_lib}" = xno; then
 441             AC_MSG_ERROR([It is not possible to disable the use of alsa. Remove the --without-alsa option.])
 442         fi
 443 
 444         if test "x${with_alsa}" != x; then
 445             ALSA_LIBS="-L${with_alsa}/lib -lalsa"
 446             ALSA_CFLAGS="-I${with_alsa}/include"
 447             ALSA_FOUND=yes
 448         fi
 449         if test "x${with_alsa_include}" != x; then
 450             ALSA_CFLAGS="-I${with_alsa_include}"
 451             ALSA_FOUND=yes
 452         fi
 453         if test "x${with_alsa_lib}" != x; then
 454             ALSA_LIBS="-L${with_alsa_lib} -lalsa"
 455             ALSA_FOUND=yes
 456         fi
 457         if test "x$ALSA_FOUND" = xno; then
 458             BDEPS_CHECK_MODULE(ALSA, alsa, xxx, [ALSA_FOUND=yes], [ALSA_FOUND=no])
 459         fi
 460         if test "x$ALSA_FOUND" = xno; then
 461             PKG_CHECK_MODULES(ALSA, alsa, [ALSA_FOUND=yes], [ALSA_FOUND=no])
 462         fi
 463         if test "x$ALSA_FOUND" = xno; then
 464             AC_CHECK_HEADERS([alsa/asoundlib.h],
 465                              [ALSA_FOUND=yes
 466                               ALSA_CFLAGS=-Iignoreme
 467                               ALSA_LIBS=-lasound
 468                               DEFAULT_ALSA=yes],
 469                              [ALSA_FOUND=no])
 470         fi
 471         if test "x$ALSA_FOUND" = xno; then 
 472             HELP_MSG_MISSING_DEPENDENCY([alsa])
 473             AC_MSG_ERROR([Could not find alsa! $HELP_MSG ])
 474         fi    
 475 fi
 476 
 477 AC_SUBST(ALSA_CFLAGS)
 478 AC_SUBST(ALSA_LIBS)
 479 
 480 ])
 481 
 482 AC_DEFUN_ONCE([LIB_SETUP_MISC_LIBS],
 483 [
 484 
 485 ###############################################################################
 486 #
 487 # Check for the jpeg library
 488 #
 489 
 490 USE_EXTERNAL_LIBJPEG=true
 491 AC_CHECK_LIB(jpeg, main, [],
 492              [ USE_EXTERNAL_LIBJPEG=false
 493                AC_MSG_NOTICE([Will use jpeg decoder bundled with the OpenJDK source])
 494              ])
 495 AC_SUBST(USE_EXTERNAL_LIBJPEG)
 496         
 497 ###############################################################################
 498 #
 499 # Check for the gif library
 500 #
 501 
 502 USE_EXTERNAL_LIBJPEG=true
 503 AC_CHECK_LIB(gif, main, [],
 504              [ USE_EXTERNAL_LIBGIF=false
 505                AC_MSG_NOTICE([Will use gif decoder bundled with the OpenJDK source])
 506              ])
 507 AC_SUBST(USE_EXTERNAL_LIBGIF)
 508 
 509 ###############################################################################
 510 #
 511 # Check for the zlib library
 512 #
 513 
 514 AC_ARG_WITH(zlib, [AS_HELP_STRING([--with-zlib],
 515         [use zlib from build system or OpenJDK source (system, bundled) @<:@bundled@:>@])])
 516 
 517 AC_CHECK_LIB(z, compress,
 518              [ ZLIB_FOUND=yes ],
 519              [ ZLIB_FOUND=no ])
 520 
 521 AC_MSG_CHECKING([for which zlib to use])
 522 
 523 DEFAULT_ZLIB=bundled
 524 if test "x$OPENJDK_TARGET_OS" = xmacosx; then
 525 #
 526 # On macosx default is system...on others default is 
 527 #
 528     DEFAULT_ZLIB=system
 529 fi
 530 
 531 if test "x${ZLIB_FOUND}" != "xyes"; then
 532 #
 533 # If we don't find any system...set default to bundled
 534 #
 535     DEFAULT_ZLIB=bundled
 536 fi
 537 
 538 #
 539 # If user didn't specify, use DEFAULT_ZLIB
 540 #
 541 if test "x${with_zlib}" = "x"; then
 542     with_zlib=${DEFAULT_ZLIB}
 543 fi
 544 
 545 if test "x${with_zlib}" = "xbundled"; then
 546     USE_EXTERNAL_LIBZ=false
 547     AC_MSG_RESULT([bundled])
 548 elif test "x${with_zlib}" = "xsystem"; then
 549     if test "x${ZLIB_FOUND}" = "xyes"; then
 550         USE_EXTERNAL_LIBZ=true
 551         AC_MSG_RESULT([system])
 552     else
 553         AC_MSG_RESULT([system not found])
 554         AC_MSG_ERROR([--with-zlib=system specified, but no zlib found!])  
 555     fi
 556 else
 557     AC_MSG_ERROR([Invalid value for --with-zlib: ${with_zlib}, use 'system' or 'bundled'])  
 558 fi
 559 
 560 AC_SUBST(USE_EXTERNAL_LIBZ)
 561 
 562 ###############################################################################
 563 LIBZIP_CAN_USE_MMAP=true
 564 
 565 AC_SUBST(LIBZIP_CAN_USE_MMAP)
 566 
 567 ###############################################################################
 568 #
 569 # Check if altzone exists in time.h
 570 #
 571 
 572 AC_LINK_IFELSE([AC_LANG_PROGRAM([#include <time.h>], [return (int)altzone;])],
 573             [has_altzone=yes],
 574             [has_altzone=no])
 575 if test "x$has_altzone" = xyes; then
 576     AC_DEFINE([HAVE_ALTZONE], 1, [Define if you have the external 'altzone' variable in time.h])
 577 fi
 578 
 579 ###############################################################################
 580 #
 581 # Check the maths library
 582 #
 583 
 584 AC_CHECK_LIB(m, cos, [],
 585              [ 
 586                   AC_MSG_NOTICE([Maths library was not found])
 587              ])
 588 AC_SUBST(LIBM)
 589 
 590 ###############################################################################
 591 #
 592 # Check for libdl.so
 593 
 594 save_LIBS="$LIBS"
 595 LIBS=""
 596 AC_CHECK_LIB(dl,dlopen)
 597 LIBDL="$LIBS"
 598 AC_SUBST(LIBDL)
 599 LIBS="$save_LIBS"
 600 
 601 ])
 602 
 603 AC_DEFUN_ONCE([LIB_SETUP_STATIC_LINK_LIBSTDCPP],
 604 [
 605 ###############################################################################
 606 #
 607 # statically link libstdc++ before C++ ABI is stablized on Linux unless 
 608 # dynamic build is configured on command line.
 609 #
 610 AC_ARG_WITH([stdc++lib], [AS_HELP_STRING([--with-stdc++lib=<static>,<dynamic>,<default>],
 611   [force linking of the C++ runtime on Linux to either static or dynamic, default is static with dynamic as fallback])],
 612   [
 613     if test "x$with_stdc__lib" != xdynamic && test "x$with_stdc__lib" != xstatic \
 614         && test "x$with_stdc__lib" != xdefault; then
 615       AC_MSG_ERROR([Bad parameter value --with-stdc++lib=$with_stdc__lib!])
 616     fi
 617   ],
 618   [with_stdc__lib=default]
 619 )
 620 
 621 if test "x$OPENJDK_TARGET_OS" = xlinux; then
 622     # Test if -lstdc++ works.
 623     AC_MSG_CHECKING([if dynamic link of stdc++ is possible])
 624     AC_LANG_PUSH(C++)
 625     OLD_CXXFLAGS="$CXXFLAGS"
 626     CXXFLAGS="$CXXFLAGS -lstdc++"
 627     AC_LINK_IFELSE([AC_LANG_PROGRAM([], [return 0;])],
 628             [has_dynamic_libstdcxx=yes],
 629             [has_dynamic_libstdcxx=no])
 630     CXXFLAGS="$OLD_CXXFLAGS"
 631     AC_LANG_POP(C++)
 632     AC_MSG_RESULT([$has_dynamic_libstdcxx])
 633 
 634     # Test if stdc++ can be linked statically.
 635     AC_MSG_CHECKING([if static link of stdc++ is possible])
 636     STATIC_STDCXX_FLAGS="-Wl,-Bstatic -lstdc++ -lgcc -Wl,-Bdynamic"
 637     AC_LANG_PUSH(C++)
 638     OLD_LIBS="$LIBS"
 639     OLD_CXX="$CXX"
 640     LIBS="$STATIC_STDCXX_FLAGS"
 641     CXX="$CC"                       
 642     AC_LINK_IFELSE([AC_LANG_PROGRAM([], [return 0;])],
 643             [has_static_libstdcxx=yes],
 644             [has_static_libstdcxx=no])
 645     LIBS="$OLD_LIBS"
 646     CXX="$OLD_CXX"
 647     AC_LANG_POP(C++)
 648     AC_MSG_RESULT([$has_static_libstdcxx])
 649 
 650     if test "x$has_static_libstdcxx" = xno && test "x$has_dynamic_libstdcxx" = xno; then
 651         AC_MSG_ERROR([Cannot link to stdc++, neither dynamically nor statically!])
 652     fi
 653 
 654     if test "x$with_stdc__lib" = xstatic && test "x$has_static_libstdcxx" = xno; then
 655         AC_MSG_ERROR([Static linking of libstdc++ was not possible!])
 656     fi
 657 
 658     if test "x$with_stdc__lib" = xdynamic && test "x$has_dynamic_libstdcxx" = xno; then
 659         AC_MSG_ERROR([Dynamic linking of libstdc++ was not possible!])
 660     fi
 661 
 662     AC_MSG_CHECKING([how to link with libstdc++])
 663     # If dynamic was requested, it's available since it would fail above otherwise.
 664     # If dynamic wasn't requested, go with static unless it isn't available.
 665     if test "x$with_stdc__lib" = xdynamic || test "x$has_static_libstdcxx" = xno; then
 666         LIBCXX="$LIBCXX -lstdc++"
 667         LDCXX="$CXX"
 668         STATIC_CXX_SETTING="STATIC_CXX=false"
 669         AC_MSG_RESULT([dynamic])
 670     else
 671         LIBCXX="$LIBCXX $STATIC_STDCXX_FLAGS"
 672         LDCXX="$CC"
 673         STATIC_CXX_SETTING="STATIC_CXX=true"
 674         AC_MSG_RESULT([static])
 675     fi
 676 fi
 677 AC_SUBST(STATIC_CXX_SETTING)
 678 
 679 # libCrun is the c++ runtime-library with SunStudio (roughly the equivalent of gcc's libstdc++.so)
 680 if test "x$OPENJDK_TARGET_OS" = xsolaris && test "x$LIBCXX" = x; then
 681     LIBCXX="/usr/lib${OPENJDK_TARGET_CPU_ISADIR}/libCrun.so.1"
 682 fi
 683 
 684 # TODO better (platform agnostic) test
 685 if test "x$OPENJDK_TARGET_OS" = xmacosx && test "x$LIBCXX" = x && test "x$GCC" = xyes; then
 686     LIBCXX="-lstdc++"
 687 fi
 688 
 689 AC_SUBST(LIBCXX)
 690 
 691 ])
--- EOF ---