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