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; break],
 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_ICU],
 271 [
 272 
 273 ###############################################################################
 274 #
 275 # The ICU LayoutEngine library is used to select the best glyphs to display
 276 #
 277 
 278 AC_ARG_WITH(icu-le, [AS_HELP_STRING([--with-icu-le],
 279         [use icu-le from build system or OpenJDK source (system, bundled) @<:@bundled@:>@])])
 280 
 281 # default is bundled
 282 DEFAULT_ICU_LE=bundled
 283 
 284 AC_MSG_CHECKING([for which icu-le to use])
 285 
 286 #
 287 # if user didn't specify, use DEFAULT_ICU_LE
 288 #
 289 
 290 if test "x${with_icu_le}" = "x"; then
 291     with_icu_le=${DEFAULT_ICU_LE}
 292 fi
 293 
 294 AC_MSG_RESULT(${with_icu_le})
 295 
 296 if test "x${with_icu_le}" = "xbundled"; then
 297     USE_EXTERNAL_ICU_LE=false
 298 else
 299     PKG_CHECK_MODULES(ICU_LE, icu-le)
 300     USE_EXTERNAL_ICU_LE=true
 301 fi
 302 
 303 AC_SUBST(USE_EXTERNAL_ICU_LE)
 304 AC_SUBST(ICU_LE_CFLAGS)
 305 AC_SUBST(ICU_LE_LIBS)
 306 
 307 ])
 308 
 309 AC_DEFUN_ONCE([LIB_SETUP_FREETYPE],
 310 [
 311 
 312 ###############################################################################
 313 #
 314 # The ubiquitous freetype2 library is used to render fonts.
 315 #
 316 AC_ARG_WITH(freetype, [AS_HELP_STRING([--with-freetype],
 317         [specify prefix directory for the freetype2 package
 318      (expecting the libraries under PATH/lib and the headers under PATH/include)])])
 319 
 320 # If we are using the OS installed system lib for freetype, then we do not need to copy it to the build tree
 321 USING_SYSTEM_FT_LIB=false
 322 
 323 if test "x$FREETYPE2_NOT_NEEDED" = xyes; then
 324         if test "x$with_freetype" != x || test "x$with_freetype_include" != x || test "x$with_freetype_lib" != x; then
 325                 AC_MSG_WARN([freetype not used, so --with-freetype is ignored])
 326         fi
 327         FREETYPE2_CFLAGS=
 328         FREETYPE2_LIBS=
 329         FREETYPE2_LIB_PATH=
 330 else
 331         FREETYPE2_FOUND=no
 332 
 333         if test "x$with_freetype" != x; then
 334             BASIC_FIXUP_PATH(with_freetype)
 335             FREETYPE2_LIBS="-L$with_freetype/lib -lfreetype"
 336             FREETYPE2_LIB_PATH="$with_freetype/lib"
 337             if test "x$OPENJDK_TARGET_OS" = xsolaris && test "x$OPENJDK_TARGET_CPU" = xx86_64 && test -d "$with_freetype/lib/amd64"; then
 338                 FREETYPE2_LIBS="-L$with_freetype/lib/amd64 -lfreetype"
 339                 FREETYPE2_LIB_PATH="$with_freetype/lib/amd64"
 340             fi
 341             if test "x$OPENJDK_TARGET_OS" = xwindows; then
 342                 FREETYPE2_LIBS="$with_freetype/lib/freetype.lib"
 343             fi
 344             FREETYPE2_CFLAGS="-I$with_freetype/include"
 345             if test -s $with_freetype/include/ft2build.h && test -d $with_freetype/include/freetype2/freetype; then
 346                 FREETYPE2_CFLAGS="-I$with_freetype/include/freetype2 -I$with_freetype/include"
 347             fi
 348             FREETYPE2_FOUND=yes
 349             if test "x$FREETYPE2_FOUND" = xyes; then
 350                 # Verify that the directories exist 
 351                 if ! test -d "$with_freetype/lib" || ! test -d "$with_freetype/include"; then
 352                    AC_MSG_ERROR([Could not find the expected directories $with_freetype/lib and $with_freetype/include])
 353                 fi
 354                 # List the contents of the lib.
 355                 FREETYPELIB=`ls $with_freetype/lib/libfreetype.so $with_freetype/lib/freetype.dll 2> /dev/null`
 356                 if test "x$FREETYPELIB" = x; then
 357                    AC_MSG_ERROR([Could not find libfreetype.so nor freetype.dll in $with_freetype/lib])
 358                 fi
 359                 # Check one h-file
 360                 if ! test -s "$with_freetype/include/ft2build.h"; then
 361                    AC_MSG_ERROR([Could not find $with_freetype/include/ft2build.h])
 362                 fi
 363             fi
 364         fi
 365         if test "x$FREETYPE2_FOUND" = xno; then
 366             BDEPS_CHECK_MODULE(FREETYPE2, freetype2, xxx, [FREETYPE2_FOUND=yes], [FREETYPE2_FOUND=no])
 367             USING_SYSTEM_FT_LIB=true
 368         fi
 369         if test "x$FREETYPE2_FOUND" = xno && test "x$OPENJDK_TARGET_OS" = xwindows; then
 370             FREETYPELOCATION="$PROGRAMFILES/GnuWin32"
 371             BASIC_FIXUP_PATH(FREETYPELOCATION)
 372             AC_MSG_CHECKING([for freetype in some standard windows locations])
 373             if test -s "$FREETYPELOCATION/include/ft2build.h" && test -d "$FREETYPELOCATION/include/freetype2/freetype"; then
 374                 FREETYPE2_CFLAGS="-I$FREETYPELOCATION/include/freetype2 -I$FREETYPELOCATION/include"
 375                 FREETYPE2_LIBS="$FREETYPELOCATION/lib/freetype.lib"
 376                 FREETYPE2_LIB_PATH="$FREETYPELOCATION/lib"
 377                 if ! test -s "$FREETYPE2_LIBS"; then
 378                    AC_MSG_ERROR([Could not find $FREETYPE2_LIBS])
 379                 fi
 380                 if ! test -s "$FREETYPE2_LIB_PATH/freetype.dll"; then
 381                    AC_MSG_ERROR([Could not find $FREETYPE2_LIB_PATH/freetype.dll])
 382                 fi
 383                 USING_SYSTEM_FT_LIB=true
 384                 FREETYPE2_FOUND=yes
 385             fi
 386             AC_MSG_RESULT([$FREETYPE2_FOUND])         
 387         fi
 388         if test "x$FREETYPE2_FOUND" = xno; then
 389             PKG_CHECK_MODULES(FREETYPE2, freetype2, [FREETYPE2_FOUND=yes], [FREETYPE2_FOUND=no])
 390             # On solaris, pkg_check adds -lz to freetype libs, which isn't necessary for us.
 391             FREETYPE2_LIBS=`$ECHO $FREETYPE2_LIBS | $SED 's/-lz//g'` 
 392             USING_SYSTEM_FT_LIB=true
 393             # 64-bit libs for Solaris x86 are installed in the amd64 subdirectory, change lib to lib/amd64
 394             if test "x$FREETYPE2_FOUND" = xyes && test "x$OPENJDK_TARGET_OS" = xsolaris && test "x$OPENJDK_TARGET_CPU" = xx86_64; then
 395               FREETYPE2_LIBS=`$ECHO $FREETYPE2_LIBS | $SED 's?/lib?/lib/amd64?g'`
 396             fi
 397         fi
 398         if test "x$FREETYPE2_FOUND" = xno; then
 399             AC_MSG_CHECKING([for freetype in some standard locations])
 400         
 401             if test -s /usr/X11/include/ft2build.h && test -d /usr/X11/include/freetype2/freetype; then
 402                 DEFAULT_FREETYPE_CFLAGS="-I/usr/X11/include/freetype2 -I/usr/X11/include"
 403                 DEFAULT_FREETYPE_LIBS="-L/usr/X11/lib -lfreetype"
 404             fi
 405             if test -s /usr/include/ft2build.h && test -d /usr/include/freetype2/freetype; then
 406                 DEFAULT_FREETYPE_CFLAGS="-I/usr/include/freetype2"
 407                 DEFAULT_FREETYPE_LIBS="-lfreetype"
 408             fi
 409         
 410             PREV_CXXCFLAGS="$CXXFLAGS"
 411             PREV_LDFLAGS="$LDFLAGS"
 412             CXXFLAGS="$CXXFLAGS $DEFAULT_FREETYPE_CFLAGS"
 413             LDFLAGS="$LDFLAGS $DEFAULT_FREETYPE_LIBS"
 414             AC_LINK_IFELSE([AC_LANG_SOURCE([[#include<ft2build.h>
 415                             #include FT_FREETYPE_H 
 416                            int main() { return 0; }
 417                           ]])],
 418                           [
 419                               # Yes, the default cflags and libs did the trick.
 420                               FREETYPE2_FOUND=yes
 421                               FREETYPE2_CFLAGS="$DEFAULT_FREETYPE_CFLAGS"
 422                               FREETYPE2_LIBS="$DEFAULT_FREETYPE_LIBS"
 423                           ],
 424                           [
 425                               FREETYPE2_FOUND=no
 426                           ])
 427             CXXCFLAGS="$PREV_CXXFLAGS"
 428             LDFLAGS="$PREV_LDFLAGS"
 429             AC_MSG_RESULT([$FREETYPE2_FOUND])
 430             USING_SYSTEM_FT_LIB=true
 431         fi
 432         if test "x$FREETYPE2_FOUND" = xno; then
 433                 HELP_MSG_MISSING_DEPENDENCY([freetype2])
 434                 AC_MSG_ERROR([Could not find freetype2! $HELP_MSG ])
 435         fi
 436 
 437         if test "x$OPENJDK_TARGET_OS" != xwindows; then
 438             # AC_CHECK_LIB does not support use of cl.exe
 439             PREV_LDFLAGS="$LDFLAGS"
 440             LDFLAGS="$FREETYPE2_LIBS"
 441             AC_CHECK_LIB(freetype, FT_Init_FreeType, 
 442                          FREETYPE2_FOUND=true, 
 443                          AC_MSG_ERROR([Could not find freetype2! $HELP_MSG ]))
 444             LDFLAGS="$PREV_LDFLAGS"
 445         fi
 446 fi
 447 
 448 AC_SUBST(USING_SYSTEM_FT_LIB)
 449 AC_SUBST(FREETYPE2_LIB_PATH)
 450 AC_SUBST(FREETYPE2_CFLAGS)
 451 AC_SUBST(FREETYPE2_LIBS)
 452 
 453 ])
 454 
 455 AC_DEFUN_ONCE([LIB_SETUP_ALSA],
 456 [
 457 
 458 ###############################################################################
 459 #
 460 # Check for alsa headers and libraries. Used on Linux/GNU systems.
 461 #
 462 AC_ARG_WITH(alsa, [AS_HELP_STRING([--with-alsa],
 463         [specify prefix directory for the alsa package
 464          (expecting the libraries under PATH/lib and the headers under PATH/include)])])
 465 AC_ARG_WITH(alsa-include, [AS_HELP_STRING([--with-alsa-include],
 466         [specify directory for the alsa include files])])
 467 AC_ARG_WITH(alsa-lib, [AS_HELP_STRING([--with-alsa-lib],
 468         [specify directory for the alsa library])])
 469 
 470 if test "x$ALSA_NOT_NEEDED" = xyes; then
 471         if test "x${with_alsa}" != x || test "x${with_alsa_include}" != x || test "x${with_alsa_lib}" != x; then
 472                 AC_MSG_WARN([alsa not used, so --with-alsa is ignored])
 473         fi
 474         ALSA_CFLAGS=
 475         ALSA_LIBS=
 476 else
 477         ALSA_FOUND=no
 478 
 479         if test "x${with_alsa}" = xno || test "x${with_alsa_include}" = xno || test "x${with_alsa_lib}" = xno; then
 480             AC_MSG_ERROR([It is not possible to disable the use of alsa. Remove the --without-alsa option.])
 481         fi
 482 
 483         if test "x${with_alsa}" != x; then
 484             ALSA_LIBS="-L${with_alsa}/lib -lalsa"
 485             ALSA_CFLAGS="-I${with_alsa}/include"
 486             ALSA_FOUND=yes
 487         fi
 488         if test "x${with_alsa_include}" != x; then
 489             ALSA_CFLAGS="-I${with_alsa_include}"
 490             ALSA_FOUND=yes
 491         fi
 492         if test "x${with_alsa_lib}" != x; then
 493             ALSA_LIBS="-L${with_alsa_lib} -lalsa"
 494             ALSA_FOUND=yes
 495         fi
 496         if test "x$ALSA_FOUND" = xno; then
 497             BDEPS_CHECK_MODULE(ALSA, alsa, xxx, [ALSA_FOUND=yes], [ALSA_FOUND=no])
 498         fi
 499         if test "x$ALSA_FOUND" = xno; then
 500             PKG_CHECK_MODULES(ALSA, alsa, [ALSA_FOUND=yes], [ALSA_FOUND=no])
 501         fi
 502         if test "x$ALSA_FOUND" = xno; then
 503             AC_CHECK_HEADERS([alsa/asoundlib.h],
 504                              [ALSA_FOUND=yes
 505                               ALSA_CFLAGS=-Iignoreme
 506                               ALSA_LIBS=-lasound
 507                               DEFAULT_ALSA=yes],
 508                              [ALSA_FOUND=no])
 509         fi
 510         if test "x$ALSA_FOUND" = xno; then 
 511             HELP_MSG_MISSING_DEPENDENCY([alsa])
 512             AC_MSG_ERROR([Could not find alsa! $HELP_MSG ])
 513         fi    
 514 fi
 515 
 516 AC_SUBST(ALSA_CFLAGS)
 517 AC_SUBST(ALSA_LIBS)
 518 
 519 ])
 520 
 521 AC_DEFUN_ONCE([LIB_SETUP_MISC_LIBS],
 522 [
 523 
 524 ###############################################################################
 525 #
 526 # Check for the jpeg library
 527 #
 528 
 529 USE_EXTERNAL_LIBJPEG=true
 530 AC_CHECK_LIB(jpeg, main, [],
 531              [ USE_EXTERNAL_LIBJPEG=false
 532                AC_MSG_NOTICE([Will use jpeg decoder bundled with the OpenJDK source])
 533              ])
 534 AC_SUBST(USE_EXTERNAL_LIBJPEG)
 535         
 536 ###############################################################################
 537 #
 538 # Check for the gif library
 539 #
 540 
 541 AC_ARG_WITH(giflib, [AS_HELP_STRING([--with-giflib],
 542         [use giflib from build system or OpenJDK source (system, bundled) @<:@bundled@:>@])])
 543 
 544 
 545 AC_MSG_CHECKING([for which giflib to use])
 546 
 547 # default is bundled
 548 DEFAULT_GIFLIB=bundled
 549 
 550 #
 551 # if user didn't specify, use DEFAULT_GIFLIB
 552 #
 553 if test "x${with_giflib}" = "x"; then
 554     with_giflib=${DEFAULT_GIFLIB}
 555 fi
 556 
 557 AC_MSG_RESULT(${with_giflib})
 558 
 559 if test "x${with_giflib}" = "xbundled"; then
 560     USE_EXTERNAL_LIBGIF=false
 561 elif test "x${with_giflib}" = "xsystem"; then
 562     AC_CHECK_HEADER(gif_lib.h, [],
 563              [ AC_MSG_ERROR([--with-giflib=system specified, but gif_lib.h not found!])])
 564     AC_CHECK_LIB(gif, DGifGetCode, [],
 565              [ AC_MSG_ERROR([--with-giflib=system specified, but no giflib found!])])
 566 
 567     USE_EXTERNAL_LIBGIF=true
 568 else
 569     AC_MSG_ERROR([Invalid value of --with-giflib: ${with_giflib}, use 'system' or 'bundled'])
 570 fi
 571 AC_SUBST(USE_EXTERNAL_LIBGIF)
 572 
 573 ###############################################################################
 574 #
 575 # Check for the zlib library
 576 #
 577 
 578 AC_ARG_WITH(zlib, [AS_HELP_STRING([--with-zlib],
 579         [use zlib from build system or OpenJDK source (system, bundled) @<:@bundled@:>@])])
 580 
 581 AC_CHECK_LIB(z, compress,
 582              [ ZLIB_FOUND=yes ],
 583              [ ZLIB_FOUND=no ])
 584 
 585 AC_MSG_CHECKING([for which zlib to use])
 586 
 587 DEFAULT_ZLIB=bundled
 588 if test "x$OPENJDK_TARGET_OS" = xmacosx; then
 589 #
 590 # On macosx default is system...on others default is 
 591 #
 592     DEFAULT_ZLIB=system
 593 fi
 594 
 595 if test "x${ZLIB_FOUND}" != "xyes"; then
 596 #
 597 # If we don't find any system...set default to bundled
 598 #
 599     DEFAULT_ZLIB=bundled
 600 fi
 601 
 602 #
 603 # If user didn't specify, use DEFAULT_ZLIB
 604 #
 605 if test "x${with_zlib}" = "x"; then
 606     with_zlib=${DEFAULT_ZLIB}
 607 fi
 608 
 609 if test "x${with_zlib}" = "xbundled"; then
 610     USE_EXTERNAL_LIBZ=false
 611     AC_MSG_RESULT([bundled])
 612 elif test "x${with_zlib}" = "xsystem"; then
 613     if test "x${ZLIB_FOUND}" = "xyes"; then
 614         USE_EXTERNAL_LIBZ=true
 615         AC_MSG_RESULT([system])
 616     else
 617         AC_MSG_RESULT([system not found])
 618         AC_MSG_ERROR([--with-zlib=system specified, but no zlib found!])  
 619     fi
 620 else
 621     AC_MSG_ERROR([Invalid value for --with-zlib: ${with_zlib}, use 'system' or 'bundled'])  
 622 fi
 623 
 624 AC_SUBST(USE_EXTERNAL_LIBZ)
 625 
 626 ###############################################################################
 627 LIBZIP_CAN_USE_MMAP=true
 628 
 629 AC_SUBST(LIBZIP_CAN_USE_MMAP)
 630 
 631 ###############################################################################
 632 #
 633 # Check if altzone exists in time.h
 634 #
 635 
 636 AC_LINK_IFELSE([AC_LANG_PROGRAM([#include <time.h>], [return (int)altzone;])],
 637             [has_altzone=yes],
 638             [has_altzone=no])
 639 if test "x$has_altzone" = xyes; then
 640     AC_DEFINE([HAVE_ALTZONE], 1, [Define if you have the external 'altzone' variable in time.h])
 641 fi
 642 
 643 ###############################################################################
 644 #
 645 # Check the maths library
 646 #
 647 
 648 AC_CHECK_LIB(m, cos, [],
 649              [ 
 650                   AC_MSG_NOTICE([Maths library was not found])
 651              ])
 652 AC_SUBST(LIBM)
 653 
 654 ###############################################################################
 655 #
 656 # Check for libdl.so
 657 
 658 save_LIBS="$LIBS"
 659 LIBS=""
 660 AC_CHECK_LIB(dl,dlopen)
 661 LIBDL="$LIBS"
 662 AC_SUBST(LIBDL)
 663 LIBS="$save_LIBS"
 664 
 665 ])
 666 
 667 AC_DEFUN_ONCE([LIB_SETUP_STATIC_LINK_LIBSTDCPP],
 668 [
 669 ###############################################################################
 670 #
 671 # statically link libstdc++ before C++ ABI is stablized on Linux unless 
 672 # dynamic build is configured on command line.
 673 #
 674 AC_ARG_WITH([stdc++lib], [AS_HELP_STRING([--with-stdc++lib=<static>,<dynamic>,<default>],
 675   [force linking of the C++ runtime on Linux to either static or dynamic, default is static with dynamic as fallback])],
 676   [
 677     if test "x$with_stdc__lib" != xdynamic && test "x$with_stdc__lib" != xstatic \
 678         && test "x$with_stdc__lib" != xdefault; then
 679       AC_MSG_ERROR([Bad parameter value --with-stdc++lib=$with_stdc__lib!])
 680     fi
 681   ],
 682   [with_stdc__lib=default]
 683 )
 684 
 685 if test "x$OPENJDK_TARGET_OS" = xlinux; then
 686     # Test if -lstdc++ works.
 687     AC_MSG_CHECKING([if dynamic link of stdc++ is possible])
 688     AC_LANG_PUSH(C++)
 689     OLD_CXXFLAGS="$CXXFLAGS"
 690     CXXFLAGS="$CXXFLAGS -lstdc++"
 691     AC_LINK_IFELSE([AC_LANG_PROGRAM([], [return 0;])],
 692             [has_dynamic_libstdcxx=yes],
 693             [has_dynamic_libstdcxx=no])
 694     CXXFLAGS="$OLD_CXXFLAGS"
 695     AC_LANG_POP(C++)
 696     AC_MSG_RESULT([$has_dynamic_libstdcxx])
 697 
 698     # Test if stdc++ can be linked statically.
 699     AC_MSG_CHECKING([if static link of stdc++ is possible])
 700     STATIC_STDCXX_FLAGS="-Wl,-Bstatic -lstdc++ -lgcc -Wl,-Bdynamic"
 701     AC_LANG_PUSH(C++)
 702     OLD_LIBS="$LIBS"
 703     OLD_CXX="$CXX"
 704     LIBS="$STATIC_STDCXX_FLAGS"
 705     CXX="$CC"                       
 706     AC_LINK_IFELSE([AC_LANG_PROGRAM([], [return 0;])],
 707             [has_static_libstdcxx=yes],
 708             [has_static_libstdcxx=no])
 709     LIBS="$OLD_LIBS"
 710     CXX="$OLD_CXX"
 711     AC_LANG_POP(C++)
 712     AC_MSG_RESULT([$has_static_libstdcxx])
 713 
 714     if test "x$has_static_libstdcxx" = xno && test "x$has_dynamic_libstdcxx" = xno; then
 715         AC_MSG_ERROR([Cannot link to stdc++, neither dynamically nor statically!])
 716     fi
 717 
 718     if test "x$with_stdc__lib" = xstatic && test "x$has_static_libstdcxx" = xno; then
 719         AC_MSG_ERROR([Static linking of libstdc++ was not possible!])
 720     fi
 721 
 722     if test "x$with_stdc__lib" = xdynamic && test "x$has_dynamic_libstdcxx" = xno; then
 723         AC_MSG_ERROR([Dynamic linking of libstdc++ was not possible!])
 724     fi
 725 
 726     AC_MSG_CHECKING([how to link with libstdc++])
 727     # If dynamic was requested, it's available since it would fail above otherwise.
 728     # If dynamic wasn't requested, go with static unless it isn't available.
 729     if test "x$with_stdc__lib" = xdynamic || test "x$has_static_libstdcxx" = xno || test "x$JVM_VARIANT_ZEROSHARK" = xtrue; then
 730         LIBCXX="$LIBCXX -lstdc++"
 731         LDCXX="$CXX"
 732         STATIC_CXX_SETTING="STATIC_CXX=false"
 733         AC_MSG_RESULT([dynamic])
 734     else
 735         LIBCXX="$LIBCXX $STATIC_STDCXX_FLAGS"
 736         LDCXX="$CC"
 737         STATIC_CXX_SETTING="STATIC_CXX=true"
 738         AC_MSG_RESULT([static])
 739     fi
 740 fi
 741 AC_SUBST(STATIC_CXX_SETTING)
 742 
 743 if test "x$JVM_VARIANT_ZERO" = xtrue || test "x$JVM_VARIANT_ZEROSHARK" = xtrue; then
 744     # Figure out LIBFFI_CFLAGS and LIBFFI_LIBS
 745     PKG_CHECK_MODULES([LIBFFI], [libffi])
 746 
 747 fi
 748 
 749 if test "x$JVM_VARIANT_ZEROSHARK" = xtrue; then
 750     AC_CHECK_PROG([LLVM_CONFIG], [llvm-config], [llvm-config])
 751 
 752     if test "x$LLVM_CONFIG" != xllvm-config; then
 753         AC_MSG_ERROR([llvm-config not found in $PATH.])
 754     fi
 755 
 756     llvm_components="jit mcjit engine nativecodegen native"
 757     unset LLVM_CFLAGS
 758     for flag in $("$LLVM_CONFIG" --cxxflags); do
 759       if echo "${flag}" | grep -q '^-@<:@ID@:>@'; then
 760         if test "${flag}" != "-D_DEBUG" ; then
 761           if test "${LLVM_CFLAGS}" != "" ; then
 762             LLVM_CFLAGS="${LLVM_CFLAGS} "
 763           fi
 764           LLVM_CFLAGS="${LLVM_CFLAGS}${flag}"
 765         fi
 766       fi
 767     done
 768     llvm_version=$("${LLVM_CONFIG}" --version | sed 's/\.//; s/svn.*//')
 769     LLVM_CFLAGS="${LLVM_CFLAGS} -DSHARK_LLVM_VERSION=${llvm_version}"
 770 
 771     unset LLVM_LDFLAGS
 772     for flag in $("${LLVM_CONFIG}" --ldflags); do
 773       if echo "${flag}" | grep -q '^-L'; then
 774         if test "${LLVM_LDFLAGS}" != ""; then
 775           LLVM_LDFLAGS="${LLVM_LDFLAGS} "
 776         fi
 777         LLVM_LDFLAGS="${LLVM_LDFLAGS}${flag}"
 778       fi
 779     done
 780 
 781     unset LLVM_LIBS
 782     for flag in $("${LLVM_CONFIG}" --libs ${llvm_components}); do
 783       if echo "${flag}" | grep -q '^-l'; then
 784         if test "${LLVM_LIBS}" != ""; then
 785           LLVM_LIBS="${LLVM_LIBS} "
 786         fi
 787         LLVM_LIBS="${LLVM_LIBS}${flag}"
 788       fi
 789     done
 790 
 791     AC_SUBST(LLVM_CFLAGS)
 792     AC_SUBST(LLVM_LDFLAGS)
 793     AC_SUBST(LLVM_LIBS)
 794 fi
 795 
 796 # libCrun is the c++ runtime-library with SunStudio (roughly the equivalent of gcc's libstdc++.so)
 797 if test "x$OPENJDK_TARGET_OS" = xsolaris && test "x$LIBCXX" = x; then
 798     LIBCXX="/usr/lib${OPENJDK_TARGET_CPU_ISADIR}/libCrun.so.1"
 799 fi
 800 
 801 # TODO better (platform agnostic) test
 802 if test "x$OPENJDK_TARGET_OS" = xmacosx && test "x$LIBCXX" = x && test "x$GCC" = xyes; then
 803     LIBCXX="-lstdc++"
 804 fi
 805 
 806 AC_SUBST(LIBCXX)
 807 
 808 ])