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" = xaix; then
  47     AC_MSG_CHECKING([what is not needed on AIX?])
  48     ALSA_NOT_NEEDED=yes
  49     PULSE_NOT_NEEDED=yes
  50     AC_MSG_RESULT([alsa pulse])
  51 fi
  52 
  53 
  54 if test "x$OPENJDK_TARGET_OS" = xwindows; then
  55     AC_MSG_CHECKING([what is not needed on Windows?])
  56     CUPS_NOT_NEEDED=yes    
  57     ALSA_NOT_NEEDED=yes
  58     PULSE_NOT_NEEDED=yes
  59     X11_NOT_NEEDED=yes
  60     AC_MSG_RESULT([alsa cups pulse x11])
  61 fi
  62 
  63 if test "x$OPENJDK_TARGET_OS" = xmacosx; then
  64     AC_MSG_CHECKING([what is not needed on MacOSX?])
  65     ALSA_NOT_NEEDED=yes
  66     PULSE_NOT_NEEDED=yes
  67     X11_NOT_NEEDED=yes
  68     FREETYPE2_NOT_NEEDED=yes    
  69     # If the java runtime framework is disabled, then we need X11.
  70     # This will be adjusted below.
  71     AC_MSG_RESULT([alsa pulse x11])
  72 fi
  73 
  74 if test "x$OPENJDK_TARGET_OS" = xbsd; then
  75     AC_MSG_CHECKING([what is not needed on bsd?])
  76     ALSA_NOT_NEEDED=yes
  77     AC_MSG_RESULT([alsa])    
  78 fi
  79 
  80 if test "x$OPENJDK" = "xfalse"; then
  81     FREETYPE2_NOT_NEEDED=yes
  82 fi
  83 
  84 if test "x$SUPPORT_HEADFUL" = xno; then
  85     X11_NOT_NEEDED=yes
  86 fi
  87 
  88 ###############################################################################
  89 #
  90 # Check for MacOSX support for OpenJDK. If this exists, try to build a JVM
  91 # that uses this API. 
  92 #
  93 AC_ARG_ENABLE([macosx-runtime-support], [AS_HELP_STRING([--disable-macosx-runtime-support],
  94         [disable the use of MacOSX Java runtime support framework @<:@enabled@:>@])],
  95         [MACOSX_RUNTIME_SUPPORT="${enableval}"],[MACOSX_RUNTIME_SUPPORT="no"])
  96 
  97 USE_MACOSX_RUNTIME_SUPPORT=no
  98 AC_MSG_CHECKING([for explicit Java runtime support in the OS])
  99 if test -f /System/Library/Frameworks/JavaVM.framework/Frameworks/JavaRuntimeSupport.framework/Headers/JavaRuntimeSupport.h; then
 100     if test "x$MACOSX_RUNTIME_SUPPORT" != xno; then
 101         MACOSX_RUNTIME_SUPPORT=yes
 102         USE_MACOSX_RUNTIME_SUPPORT=yes
 103         AC_MSG_RESULT([yes, does not need alsa freetype2 pulse and X11])
 104     else
 105         AC_MSG_RESULT([yes, but explicitly disabled.])
 106     fi
 107 else
 108     AC_MSG_RESULT([no])
 109 fi
 110 
 111 if test "x$OPENJDK_TARGET_OS" = xmacosx && test "x$USE_MACOSX_RUNTIME_SUPPORT" = xno; then
 112     AC_MSG_CHECKING([what is not needed on an X11 build on MacOSX?])
 113     X11_NOT_NEEDED=
 114     FREETYPE2_NOT_NEEDED=
 115     AC_MSG_RESULT([alsa pulse])
 116 fi
 117 ])
 118 
 119 AC_DEFUN_ONCE([LIB_SETUP_X11],
 120 [
 121 
 122 ###############################################################################
 123 #
 124 # Check for X Windows
 125 #
 126 
 127 # Check if the user has specified sysroot, but not --x-includes or --x-libraries.
 128 # Make a simple check for the libraries at the sysroot, and setup --x-includes and
 129 # --x-libraries for the sysroot, if that seems to be correct.
 130 if test "x$SYS_ROOT" != "x/"; then
 131   if test "x$x_includes" = xNONE; then
 132     if test -f "$SYS_ROOT/usr/X11R6/include/X11/Xlib.h"; then
 133       x_includes="$SYS_ROOT/usr/X11R6/include"
 134     elif test -f "$SYS_ROOT/usr/include/X11/Xlib.h"; then
 135       x_includes="$SYS_ROOT/usr/include"
 136     fi
 137   fi
 138   if test "x$x_libraries" = xNONE; then
 139     if test -f "$SYS_ROOT/usr/X11R6/lib/libX11.so"; then
 140       x_libraries="$SYS_ROOT/usr/X11R6/lib"
 141     elif test "$SYS_ROOT/usr/lib64/libX11.so" && test "x$OPENJDK_TARGET_CPU_BITS" = x64; then
 142       x_libraries="$SYS_ROOT/usr/lib64"
 143     elif test -f "$SYS_ROOT/usr/lib/libX11.so"; then
 144       x_libraries="$SYS_ROOT/usr/lib"
 145     fi
 146   fi
 147 fi
 148 
 149 # Now let autoconf do it's magic
 150 AC_PATH_X
 151 AC_PATH_XTRA
 152 
 153 # AC_PATH_XTRA creates X_LIBS and sometimes adds -R flags. When cross compiling
 154 # this doesn't make sense so we remove it.
 155 if test "x$COMPILE_TYPE" = xcross; then
 156   X_LIBS=`$ECHO $X_LIBS | $SED 's/-R \{0,1\}[[^ ]]*//g'`
 157 fi
 158 
 159 if test "x$no_x" = xyes && test "x$X11_NOT_NEEDED" != xyes; then 
 160     HELP_MSG_MISSING_DEPENDENCY([x11])
 161     AC_MSG_ERROR([Could not find X11 libraries. $HELP_MSG])
 162 fi
 163 
 164 # Some of the old makefiles require a setting of OPENWIN_HOME
 165 # Since the X11R6 directory has disappeared on later Linuxes,
 166 # we need to probe for it.
 167 if test "x$OPENJDK_TARGET_OS" = xlinux; then
 168     if test -d "$SYS_ROOT/usr/X11R6"; then
 169         OPENWIN_HOME="$SYS_ROOT/usr/X11R6"
 170     elif test -d "$SYS_ROOT/usr/include/X11"; then
 171         OPENWIN_HOME="$SYS_ROOT/usr"
 172     fi
 173 fi
 174 if test "x$OPENJDK_TARGET_OS" = xsolaris; then
 175     OPENWIN_HOME="/usr/openwin"
 176 fi
 177 AC_SUBST(OPENWIN_HOME)
 178 
 179 
 180 #
 181 # Weird Sol10 something check...TODO change to try compile
 182 #
 183 if test "x${OPENJDK_TARGET_OS}" = xsolaris; then
 184   if test "`uname -r`" = "5.10"; then
 185      if test "`${EGREP} -c XLinearGradient ${OPENWIN_HOME}/share/include/X11/extensions/Xrender.h`" = "0"; then
 186         X_CFLAGS="${X_CFLAGS} -DSOLARIS10_NO_XRENDER_STRUCTS"
 187      fi
 188   fi
 189 fi
 190 
 191 AC_LANG_PUSH(C)
 192 OLD_CFLAGS="$CFLAGS"
 193 CFLAGS="$CFLAGS $X_CFLAGS"
 194 
 195 # Need to include Xlib.h and Xutil.h to avoid "present but cannot be compiled" warnings on Solaris 10
 196 AC_CHECK_HEADERS([X11/extensions/shape.h X11/extensions/Xrender.h X11/extensions/XTest.h],
 197                  [X11_A_OK=yes],
 198                  [X11_A_OK=no; break],
 199                  [ # include <X11/Xlib.h>
 200                    # include <X11/Xutil.h>
 201                  ])
 202 
 203 CFLAGS="$OLD_CFLAGS"
 204 AC_LANG_POP(C)
 205 
 206 if test "x$X11_A_OK" = xno && test "x$X11_NOT_NEEDED" != xyes; then 
 207     HELP_MSG_MISSING_DEPENDENCY([x11])
 208     AC_MSG_ERROR([Could not find all X11 headers (shape.h Xrender.h XTest.h). $HELP_MSG])
 209 fi
 210 
 211 AC_SUBST(X_CFLAGS)
 212 AC_SUBST(X_LIBS)
 213 ])
 214 
 215 AC_DEFUN_ONCE([LIB_SETUP_CUPS],
 216 [
 217 
 218 ###############################################################################
 219 #
 220 # The common unix printing system cups is used to print from java.
 221 #
 222 AC_ARG_WITH(cups, [AS_HELP_STRING([--with-cups],
 223     [specify prefix directory for the cups package
 224          (expecting the headers under PATH/include)])])
 225 AC_ARG_WITH(cups-include, [AS_HELP_STRING([--with-cups-include],
 226         [specify directory for the cups include files])])
 227 
 228 if test "x$CUPS_NOT_NEEDED" = xyes; then
 229         if test "x${with_cups}" != x || test "x${with_cups_include}" != x; then
 230                 AC_MSG_WARN([cups not used, so --with-cups is ignored])
 231         fi
 232         CUPS_CFLAGS=
 233 else
 234         CUPS_FOUND=no
 235 
 236         if test "x${with_cups}" = xno || test "x${with_cups_include}" = xno; then
 237             AC_MSG_ERROR([It is not possible to disable the use of cups. Remove the --without-cups option.])
 238         fi
 239 
 240         if test "x${with_cups}" != x; then
 241             CUPS_CFLAGS="-I${with_cups}/include"
 242             CUPS_FOUND=yes
 243         fi
 244         if test "x${with_cups_include}" != x; then
 245             CUPS_CFLAGS="-I${with_cups_include}"
 246             CUPS_FOUND=yes
 247         fi
 248         if test "x$CUPS_FOUND" = xno; then
 249             BDEPS_CHECK_MODULE(CUPS, cups, xxx, [CUPS_FOUND=yes])
 250         fi
 251         if test "x$CUPS_FOUND" = xno; then
 252             # Are the cups headers installed in the default /usr/include location?
 253             AC_CHECK_HEADERS([cups/cups.h cups/ppd.h],
 254                              [CUPS_FOUND=yes
 255                               CUPS_CFLAGS=
 256                               DEFAULT_CUPS=yes])
 257         fi
 258         if test "x$CUPS_FOUND" = xno; then
 259             # Getting nervous now? Lets poke around for standard Solaris third-party
 260             # package installation locations.
 261             AC_MSG_CHECKING([for cups headers])
 262             if test -s /opt/sfw/cups/include/cups/cups.h; then
 263                # An SFW package seems to be installed!
 264                CUPS_FOUND=yes
 265                CUPS_CFLAGS="-I/opt/sfw/cups/include"
 266             elif test -s /opt/csw/include/cups/cups.h; then
 267                # A CSW package seems to be installed!
 268                CUPS_FOUND=yes
 269                CUPS_CFLAGS="-I/opt/csw/include"
 270             fi
 271             AC_MSG_RESULT([$CUPS_FOUND])
 272         fi
 273         if test "x$CUPS_FOUND" = xno; then 
 274             HELP_MSG_MISSING_DEPENDENCY([cups])
 275             AC_MSG_ERROR([Could not find cups! $HELP_MSG ])
 276         fi
 277 fi
 278 
 279 AC_SUBST(CUPS_CFLAGS)
 280 
 281 ])
 282 
 283 AC_DEFUN_ONCE([LIB_SETUP_FREETYPE],
 284 [
 285 
 286 ###############################################################################
 287 #
 288 # The ubiquitous freetype2 library is used to render fonts.
 289 #
 290 AC_ARG_WITH(freetype, [AS_HELP_STRING([--with-freetype],
 291         [specify prefix directory for the freetype2 package
 292      (expecting the libraries under PATH/lib and the headers under PATH/include)])])
 293 
 294 # If we are using the OS installed system lib for freetype, then we do not need to copy it to the build tree
 295 USING_SYSTEM_FT_LIB=false
 296 
 297 if test "x$FREETYPE2_NOT_NEEDED" = xyes; then
 298         if test "x$with_freetype" != x || test "x$with_freetype_include" != x || test "x$with_freetype_lib" != x; then
 299                 AC_MSG_WARN([freetype not used, so --with-freetype is ignored])
 300         fi
 301         FREETYPE2_CFLAGS=
 302         FREETYPE2_LIBS=
 303         FREETYPE2_LIB_PATH=
 304 else
 305         FREETYPE2_FOUND=no
 306 
 307         if test "x$with_freetype" != x; then
 308             BASIC_FIXUP_PATH(with_freetype)
 309             FREETYPE2_LIBS="-L$with_freetype/lib -lfreetype"
 310             FREETYPE2_LIB_PATH="$with_freetype/lib"
 311             if test "x$OPENJDK_TARGET_OS" = xsolaris && test "x$OPENJDK_TARGET_CPU" = xx86_64 && test -d "$with_freetype/lib/amd64"; then
 312                 FREETYPE2_LIBS="-L$with_freetype/lib/amd64 -lfreetype"
 313                 FREETYPE2_LIB_PATH="$with_freetype/lib/amd64"
 314             fi
 315             if test "x$OPENJDK_TARGET_OS" = xwindows; then
 316                 FREETYPE2_LIBS="$with_freetype/lib/freetype.lib"
 317             fi
 318             FREETYPE2_CFLAGS="-I$with_freetype/include"
 319             if test -s $with_freetype/include/ft2build.h && test -d $with_freetype/include/freetype2/freetype; then
 320                 FREETYPE2_CFLAGS="-I$with_freetype/include/freetype2 -I$with_freetype/include"
 321             fi
 322             FREETYPE2_FOUND=yes
 323             if test "x$FREETYPE2_FOUND" = xyes; then
 324                 # Verify that the directories exist 
 325                 if ! test -d "$with_freetype/lib" || ! test -d "$with_freetype/include"; then
 326                    AC_MSG_ERROR([Could not find the expected directories $with_freetype/lib and $with_freetype/include])
 327                 fi
 328                 # List the contents of the lib.
 329                 FREETYPELIB=`ls $with_freetype/lib/libfreetype.so $with_freetype/lib/freetype.dll 2> /dev/null`
 330                 if test "x$FREETYPELIB" = x; then
 331                    AC_MSG_ERROR([Could not find libfreetype.so nor freetype.dll in $with_freetype/lib])
 332                 fi
 333                 # Check one h-file
 334                 if ! test -s "$with_freetype/include/ft2build.h"; then
 335                    AC_MSG_ERROR([Could not find $with_freetype/include/ft2build.h])
 336                 fi
 337             fi
 338         fi
 339         if test "x$FREETYPE2_FOUND" = xno; then
 340             BDEPS_CHECK_MODULE(FREETYPE2, freetype2, xxx, [FREETYPE2_FOUND=yes], [FREETYPE2_FOUND=no])
 341             USING_SYSTEM_FT_LIB=true
 342         fi
 343         if test "x$FREETYPE2_FOUND" = xno && test "x$OPENJDK_TARGET_OS" = xwindows; then
 344             FREETYPELOCATION="$PROGRAMFILES/GnuWin32"
 345             BASIC_FIXUP_PATH(FREETYPELOCATION)
 346             AC_MSG_CHECKING([for freetype in some standard windows locations])
 347             if test -s "$FREETYPELOCATION/include/ft2build.h" && test -d "$FREETYPELOCATION/include/freetype2/freetype"; then
 348                 FREETYPE2_CFLAGS="-I$FREETYPELOCATION/include/freetype2 -I$FREETYPELOCATION/include"
 349                 FREETYPE2_LIBS="$FREETYPELOCATION/lib/freetype.lib"
 350                 FREETYPE2_LIB_PATH="$FREETYPELOCATION/lib"
 351                 if ! test -s "$FREETYPE2_LIBS"; then
 352                    AC_MSG_ERROR([Could not find $FREETYPE2_LIBS])
 353                 fi
 354                 if ! test -s "$FREETYPE2_LIB_PATH/freetype.dll"; then
 355                    AC_MSG_ERROR([Could not find $FREETYPE2_LIB_PATH/freetype.dll])
 356                 fi
 357                 USING_SYSTEM_FT_LIB=true
 358                 FREETYPE2_FOUND=yes
 359             fi
 360             AC_MSG_RESULT([$FREETYPE2_FOUND])         
 361         fi
 362         if test "x$FREETYPE2_FOUND" = xno; then
 363             PKG_CHECK_MODULES(FREETYPE2, freetype2, [FREETYPE2_FOUND=yes], [FREETYPE2_FOUND=no])
 364             # On solaris, pkg_check adds -lz to freetype libs, which isn't necessary for us.
 365             FREETYPE2_LIBS=`$ECHO $FREETYPE2_LIBS | $SED 's/-lz//g'` 
 366             USING_SYSTEM_FT_LIB=true
 367             # 64-bit libs for Solaris x86 are installed in the amd64 subdirectory, change lib to lib/amd64
 368             if test "x$FREETYPE2_FOUND" = xyes && test "x$OPENJDK_TARGET_OS" = xsolaris && test "x$OPENJDK_TARGET_CPU" = xx86_64; then
 369               FREETYPE2_LIBS=`$ECHO $FREETYPE2_LIBS | $SED 's?/lib?/lib/amd64?g'`
 370             fi
 371         fi
 372         if test "x$FREETYPE2_FOUND" = xno; then
 373             AC_MSG_CHECKING([for freetype in some standard locations])
 374         
 375             if test -s $SYS_ROOT/usr/X11/include/ft2build.h && test -d $SYS_ROOT/usr/X11/include/freetype2/freetype; then
 376                 DEFAULT_FREETYPE_CFLAGS="-I$SYS_ROOT/usr/X11/include/freetype2 -I$SYS_ROOT/usr/X11/include"
 377                 DEFAULT_FREETYPE_LIBS="-L$SYS_ROOT/usr/X11/lib -lfreetype"
 378             fi
 379             if test -s $SYS_ROOT/usr/include/ft2build.h && test -d $SYS_ROOT/usr/include/freetype2/freetype; then
 380                 DEFAULT_FREETYPE_CFLAGS="-I$SYS_ROOT/usr/include/freetype2"
 381                 DEFAULT_FREETYPE_LIBS="-lfreetype"
 382             fi
 383         
 384             PREV_CXXCFLAGS="$CXXFLAGS"
 385             PREV_LDFLAGS="$LDFLAGS"
 386             CXXFLAGS="$CXXFLAGS $DEFAULT_FREETYPE_CFLAGS"
 387             LDFLAGS="$LDFLAGS $DEFAULT_FREETYPE_LIBS"
 388             AC_LINK_IFELSE([AC_LANG_SOURCE([[#include<ft2build.h>
 389                             #include FT_FREETYPE_H 
 390                            int main() { return 0; }
 391                           ]])],
 392                           [
 393                               # Yes, the default cflags and libs did the trick.
 394                               FREETYPE2_FOUND=yes
 395                               FREETYPE2_CFLAGS="$DEFAULT_FREETYPE_CFLAGS"
 396                               FREETYPE2_LIBS="$DEFAULT_FREETYPE_LIBS"
 397                           ],
 398                           [
 399                               FREETYPE2_FOUND=no
 400                           ])
 401             CXXCFLAGS="$PREV_CXXFLAGS"
 402             LDFLAGS="$PREV_LDFLAGS"
 403             AC_MSG_RESULT([$FREETYPE2_FOUND])
 404             USING_SYSTEM_FT_LIB=true
 405         fi
 406         if test "x$FREETYPE2_FOUND" = xno; then
 407                 HELP_MSG_MISSING_DEPENDENCY([freetype2])
 408                 AC_MSG_ERROR([Could not find freetype2! $HELP_MSG ])
 409         fi
 410 
 411         if test "x$OPENJDK_TARGET_OS" != xwindows; then
 412             # AC_CHECK_LIB does not support use of cl.exe
 413             PREV_LDFLAGS="$LDFLAGS"
 414             LDFLAGS="$FREETYPE2_LIBS"
 415             AC_CHECK_LIB(freetype, FT_Init_FreeType, 
 416                          FREETYPE2_FOUND=true, 
 417                          AC_MSG_ERROR([Could not find freetype2! $HELP_MSG ]))
 418             LDFLAGS="$PREV_LDFLAGS"
 419         fi
 420 fi
 421 
 422 AC_SUBST(USING_SYSTEM_FT_LIB)
 423 AC_SUBST(FREETYPE2_LIB_PATH)
 424 AC_SUBST(FREETYPE2_CFLAGS)
 425 AC_SUBST(FREETYPE2_LIBS)
 426 
 427 ])
 428 
 429 AC_DEFUN_ONCE([LIB_SETUP_ALSA],
 430 [
 431 
 432 ###############################################################################
 433 #
 434 # Check for alsa headers and libraries. Used on Linux/GNU systems.
 435 #
 436 AC_ARG_WITH(alsa, [AS_HELP_STRING([--with-alsa],
 437         [specify prefix directory for the alsa package
 438          (expecting the libraries under PATH/lib and the headers under PATH/include)])])
 439 AC_ARG_WITH(alsa-include, [AS_HELP_STRING([--with-alsa-include],
 440         [specify directory for the alsa include files])])
 441 AC_ARG_WITH(alsa-lib, [AS_HELP_STRING([--with-alsa-lib],
 442         [specify directory for the alsa library])])
 443 
 444 if test "x$ALSA_NOT_NEEDED" = xyes; then
 445         if test "x${with_alsa}" != x || test "x${with_alsa_include}" != x || test "x${with_alsa_lib}" != x; then
 446                 AC_MSG_WARN([alsa not used, so --with-alsa is ignored])
 447         fi
 448         ALSA_CFLAGS=
 449         ALSA_LIBS=
 450 else
 451         ALSA_FOUND=no
 452 
 453         if test "x${with_alsa}" = xno || test "x${with_alsa_include}" = xno || test "x${with_alsa_lib}" = xno; then
 454             AC_MSG_ERROR([It is not possible to disable the use of alsa. Remove the --without-alsa option.])
 455         fi
 456 
 457         if test "x${with_alsa}" != x; then
 458             ALSA_LIBS="-L${with_alsa}/lib -lalsa"
 459             ALSA_CFLAGS="-I${with_alsa}/include"
 460             ALSA_FOUND=yes
 461         fi
 462         if test "x${with_alsa_include}" != x; then
 463             ALSA_CFLAGS="-I${with_alsa_include}"
 464             ALSA_FOUND=yes
 465         fi
 466         if test "x${with_alsa_lib}" != x; then
 467             ALSA_LIBS="-L${with_alsa_lib} -lalsa"
 468             ALSA_FOUND=yes
 469         fi
 470         if test "x$ALSA_FOUND" = xno; then
 471             BDEPS_CHECK_MODULE(ALSA, alsa, xxx, [ALSA_FOUND=yes], [ALSA_FOUND=no])
 472         fi
 473         if test "x$ALSA_FOUND" = xno; then
 474             PKG_CHECK_MODULES(ALSA, alsa, [ALSA_FOUND=yes], [ALSA_FOUND=no])
 475         fi
 476         if test "x$ALSA_FOUND" = xno; then
 477             AC_CHECK_HEADERS([alsa/asoundlib.h],
 478                              [ALSA_FOUND=yes
 479                               ALSA_CFLAGS=-Iignoreme
 480                               ALSA_LIBS=-lasound
 481                               DEFAULT_ALSA=yes],
 482                              [ALSA_FOUND=no])
 483         fi
 484         if test "x$ALSA_FOUND" = xno; then 
 485             HELP_MSG_MISSING_DEPENDENCY([alsa])
 486             AC_MSG_ERROR([Could not find alsa! $HELP_MSG ])
 487         fi    
 488 fi
 489 
 490 AC_SUBST(ALSA_CFLAGS)
 491 AC_SUBST(ALSA_LIBS)
 492 
 493 ])
 494 
 495 AC_DEFUN_ONCE([LIB_SETUP_MISC_LIBS],
 496 [
 497 
 498 ###############################################################################
 499 #
 500 # Check for the jpeg library
 501 #
 502 
 503 USE_EXTERNAL_LIBJPEG=true
 504 AC_CHECK_LIB(jpeg, main, [],
 505              [ USE_EXTERNAL_LIBJPEG=false
 506                AC_MSG_NOTICE([Will use jpeg decoder bundled with the OpenJDK source])
 507              ])
 508 AC_SUBST(USE_EXTERNAL_LIBJPEG)
 509         
 510 ###############################################################################
 511 #
 512 # Check for the gif library
 513 #
 514 
 515 AC_ARG_WITH(giflib, [AS_HELP_STRING([--with-giflib],
 516         [use giflib from build system or OpenJDK source (system, bundled) @<:@bundled@:>@])])
 517 
 518 
 519 AC_MSG_CHECKING([for which giflib to use])
 520 
 521 # default is bundled
 522 DEFAULT_GIFLIB=bundled
 523 
 524 #
 525 # if user didn't specify, use DEFAULT_GIFLIB
 526 #
 527 if test "x${with_giflib}" = "x"; then
 528     with_giflib=${DEFAULT_GIFLIB}
 529 fi
 530 
 531 AC_MSG_RESULT(${with_giflib})
 532 
 533 if test "x${with_giflib}" = "xbundled"; then
 534     USE_EXTERNAL_LIBGIF=false
 535 elif test "x${with_giflib}" = "xsystem"; then
 536     AC_CHECK_HEADER(gif_lib.h, [],
 537              [ AC_MSG_ERROR([--with-giflib=system specified, but gif_lib.h not found!])])
 538     AC_CHECK_LIB(gif, DGifGetCode, [],
 539              [ AC_MSG_ERROR([--with-giflib=system specified, but no giflib found!])])
 540 
 541     USE_EXTERNAL_LIBGIF=true
 542 else
 543     AC_MSG_ERROR([Invalid value of --with-giflib: ${with_giflib}, use 'system' or 'bundled'])
 544 fi
 545 AC_SUBST(USE_EXTERNAL_LIBGIF)
 546 
 547 ###############################################################################
 548 #
 549 # Check for the zlib library
 550 #
 551 
 552 AC_ARG_WITH(zlib, [AS_HELP_STRING([--with-zlib],
 553         [use zlib from build system or OpenJDK source (system, bundled) @<:@bundled@:>@])])
 554 
 555 AC_CHECK_LIB(z, compress,
 556              [ ZLIB_FOUND=yes ],
 557              [ ZLIB_FOUND=no ])
 558 
 559 AC_MSG_CHECKING([for which zlib to use])
 560 
 561 DEFAULT_ZLIB=bundled
 562 if test "x$OPENJDK_TARGET_OS" = xmacosx; then
 563 #
 564 # On macosx default is system...on others default is 
 565 #
 566     DEFAULT_ZLIB=system
 567 fi
 568 
 569 if test "x${ZLIB_FOUND}" != "xyes"; then
 570 #
 571 # If we don't find any system...set default to bundled
 572 #
 573     DEFAULT_ZLIB=bundled
 574 fi
 575 
 576 #
 577 # If user didn't specify, use DEFAULT_ZLIB
 578 #
 579 if test "x${with_zlib}" = "x"; then
 580     with_zlib=${DEFAULT_ZLIB}
 581 fi
 582 
 583 if test "x${with_zlib}" = "xbundled"; then
 584     USE_EXTERNAL_LIBZ=false
 585     AC_MSG_RESULT([bundled])
 586 elif test "x${with_zlib}" = "xsystem"; then
 587     if test "x${ZLIB_FOUND}" = "xyes"; then
 588         USE_EXTERNAL_LIBZ=true
 589         AC_MSG_RESULT([system])
 590     else
 591         AC_MSG_RESULT([system not found])
 592         AC_MSG_ERROR([--with-zlib=system specified, but no zlib found!])  
 593     fi
 594 else
 595     AC_MSG_ERROR([Invalid value for --with-zlib: ${with_zlib}, use 'system' or 'bundled'])  
 596 fi
 597 
 598 AC_SUBST(USE_EXTERNAL_LIBZ)
 599 
 600 ###############################################################################
 601 LIBZIP_CAN_USE_MMAP=true
 602 
 603 AC_SUBST(LIBZIP_CAN_USE_MMAP)
 604 
 605 ###############################################################################
 606 #
 607 # Check if altzone exists in time.h
 608 #
 609 
 610 AC_LINK_IFELSE([AC_LANG_PROGRAM([#include <time.h>], [return (int)altzone;])],
 611             [has_altzone=yes],
 612             [has_altzone=no])
 613 if test "x$has_altzone" = xyes; then
 614     AC_DEFINE([HAVE_ALTZONE], 1, [Define if you have the external 'altzone' variable in time.h])
 615 fi
 616 
 617 ###############################################################################
 618 #
 619 # Check the maths library
 620 #
 621 
 622 AC_CHECK_LIB(m, cos, [],
 623              [ 
 624                   AC_MSG_NOTICE([Maths library was not found])
 625              ])
 626 AC_SUBST(LIBM)
 627 
 628 ###############################################################################
 629 #
 630 # Check for libdl.so
 631 
 632 save_LIBS="$LIBS"
 633 LIBS=""
 634 AC_CHECK_LIB(dl,dlopen)
 635 LIBDL="$LIBS"
 636 AC_SUBST(LIBDL)
 637 LIBS="$save_LIBS"
 638 
 639 ])
 640 
 641 AC_DEFUN_ONCE([LIB_SETUP_STATIC_LINK_LIBSTDCPP],
 642 [
 643 ###############################################################################
 644 #
 645 # statically link libstdc++ before C++ ABI is stablized on Linux unless 
 646 # dynamic build is configured on command line.
 647 #
 648 AC_ARG_WITH([stdc++lib], [AS_HELP_STRING([--with-stdc++lib=<static>,<dynamic>,<default>],
 649   [force linking of the C++ runtime on Linux to either static or dynamic, default is static with dynamic as fallback])],
 650   [
 651     if test "x$with_stdc__lib" != xdynamic && test "x$with_stdc__lib" != xstatic \
 652         && test "x$with_stdc__lib" != xdefault; then
 653       AC_MSG_ERROR([Bad parameter value --with-stdc++lib=$with_stdc__lib!])
 654     fi
 655   ],
 656   [with_stdc__lib=default]
 657 )
 658 
 659 if test "x$OPENJDK_TARGET_OS" = xlinux; then
 660     # Test if -lstdc++ works.
 661     AC_MSG_CHECKING([if dynamic link of stdc++ is possible])
 662     AC_LANG_PUSH(C++)
 663     OLD_CXXFLAGS="$CXXFLAGS"
 664     CXXFLAGS="$CXXFLAGS -lstdc++"
 665     AC_LINK_IFELSE([AC_LANG_PROGRAM([], [return 0;])],
 666             [has_dynamic_libstdcxx=yes],
 667             [has_dynamic_libstdcxx=no])
 668     CXXFLAGS="$OLD_CXXFLAGS"
 669     AC_LANG_POP(C++)
 670     AC_MSG_RESULT([$has_dynamic_libstdcxx])
 671 
 672     # Test if stdc++ can be linked statically.
 673     AC_MSG_CHECKING([if static link of stdc++ is possible])
 674     STATIC_STDCXX_FLAGS="-Wl,-Bstatic -lstdc++ -lgcc -Wl,-Bdynamic"
 675     AC_LANG_PUSH(C++)
 676     OLD_LIBS="$LIBS"
 677     OLD_CXX="$CXX"
 678     LIBS="$STATIC_STDCXX_FLAGS"
 679     CXX="$CC"                       
 680     AC_LINK_IFELSE([AC_LANG_PROGRAM([], [return 0;])],
 681             [has_static_libstdcxx=yes],
 682             [has_static_libstdcxx=no])
 683     LIBS="$OLD_LIBS"
 684     CXX="$OLD_CXX"
 685     AC_LANG_POP(C++)
 686     AC_MSG_RESULT([$has_static_libstdcxx])
 687 
 688     if test "x$has_static_libstdcxx" = xno && test "x$has_dynamic_libstdcxx" = xno; then
 689         AC_MSG_ERROR([Cannot link to stdc++, neither dynamically nor statically!])
 690     fi
 691 
 692     if test "x$with_stdc__lib" = xstatic && test "x$has_static_libstdcxx" = xno; then
 693         AC_MSG_ERROR([Static linking of libstdc++ was not possible!])
 694     fi
 695 
 696     if test "x$with_stdc__lib" = xdynamic && test "x$has_dynamic_libstdcxx" = xno; then
 697         AC_MSG_ERROR([Dynamic linking of libstdc++ was not possible!])
 698     fi
 699 
 700     AC_MSG_CHECKING([how to link with libstdc++])
 701     # If dynamic was requested, it's available since it would fail above otherwise.
 702     # If dynamic wasn't requested, go with static unless it isn't available.
 703     if test "x$with_stdc__lib" = xdynamic || test "x$has_static_libstdcxx" = xno || test "x$JVM_VARIANT_ZEROSHARK" = xtrue; then
 704         LIBCXX="$LIBCXX -lstdc++"
 705         LDCXX="$CXX"
 706         STATIC_CXX_SETTING="STATIC_CXX=false"
 707         AC_MSG_RESULT([dynamic])
 708     else
 709         LIBCXX="$LIBCXX $STATIC_STDCXX_FLAGS"
 710         LDCXX="$CC"
 711         STATIC_CXX_SETTING="STATIC_CXX=true"
 712         AC_MSG_RESULT([static])
 713     fi
 714 fi
 715 AC_SUBST(STATIC_CXX_SETTING)
 716 
 717 if test "x$JVM_VARIANT_ZERO" = xtrue || test "x$JVM_VARIANT_ZEROSHARK" = xtrue; then
 718     # Figure out LIBFFI_CFLAGS and LIBFFI_LIBS
 719     PKG_CHECK_MODULES([LIBFFI], [libffi])
 720 
 721 fi
 722 
 723 if test "x$JVM_VARIANT_ZEROSHARK" = xtrue; then
 724     AC_CHECK_PROG([LLVM_CONFIG], [llvm-config], [llvm-config])
 725 
 726     if test "x$LLVM_CONFIG" != xllvm-config; then
 727         AC_MSG_ERROR([llvm-config not found in $PATH.])
 728     fi
 729 
 730     llvm_components="jit mcjit engine nativecodegen native"
 731     unset LLVM_CFLAGS
 732     for flag in $("$LLVM_CONFIG" --cxxflags); do
 733       if echo "${flag}" | grep -q '^-@<:@ID@:>@'; then
 734         if test "${flag}" != "-D_DEBUG" ; then
 735           if test "${LLVM_CFLAGS}" != "" ; then
 736             LLVM_CFLAGS="${LLVM_CFLAGS} "
 737           fi
 738           LLVM_CFLAGS="${LLVM_CFLAGS}${flag}"
 739         fi
 740       fi
 741     done
 742     llvm_version=$("${LLVM_CONFIG}" --version | sed 's/\.//; s/svn.*//')
 743     LLVM_CFLAGS="${LLVM_CFLAGS} -DSHARK_LLVM_VERSION=${llvm_version}"
 744 
 745     unset LLVM_LDFLAGS
 746     for flag in $("${LLVM_CONFIG}" --ldflags); do
 747       if echo "${flag}" | grep -q '^-L'; then
 748         if test "${LLVM_LDFLAGS}" != ""; then
 749           LLVM_LDFLAGS="${LLVM_LDFLAGS} "
 750         fi
 751         LLVM_LDFLAGS="${LLVM_LDFLAGS}${flag}"
 752       fi
 753     done
 754 
 755     unset LLVM_LIBS
 756     for flag in $("${LLVM_CONFIG}" --libs ${llvm_components}); do
 757       if echo "${flag}" | grep -q '^-l'; then
 758         if test "${LLVM_LIBS}" != ""; then
 759           LLVM_LIBS="${LLVM_LIBS} "
 760         fi
 761         LLVM_LIBS="${LLVM_LIBS}${flag}"
 762       fi
 763     done
 764 
 765     AC_SUBST(LLVM_CFLAGS)
 766     AC_SUBST(LLVM_LDFLAGS)
 767     AC_SUBST(LLVM_LIBS)
 768 fi
 769 
 770 # libCrun is the c++ runtime-library with SunStudio (roughly the equivalent of gcc's libstdc++.so)
 771 if test "x$OPENJDK_TARGET_OS" = xsolaris && test "x$LIBCXX" = x; then
 772     LIBCXX="/usr/lib${OPENJDK_TARGET_CPU_ISADIR}/libCrun.so.1"
 773 fi
 774 
 775 # TODO better (platform agnostic) test
 776 if test "x$OPENJDK_TARGET_OS" = xmacosx && test "x$LIBCXX" = x && test "x$GCC" = xyes; then
 777     LIBCXX="-lstdc++"
 778 fi
 779 
 780 AC_SUBST(LIBCXX)
 781 
 782 ])