1 #
   2 # Copyright (c) 2011, 2014, 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     # If the java runtime framework is disabled, then we need X11.
  69     # This will be adjusted below.
  70     AC_MSG_RESULT([alsa pulse x11])
  71   fi
  72 
  73   if test "x$OPENJDK_TARGET_OS" = xbsd; then
  74     AC_MSG_CHECKING([what is not needed on bsd?])
  75     ALSA_NOT_NEEDED=yes
  76     AC_MSG_RESULT([alsa])
  77   fi
  78 
  79   if test "x$OPENJDK" = "xfalse"; then
  80     FREETYPE_NOT_NEEDED=yes
  81   fi
  82 
  83   if test "x$SUPPORT_HEADFUL" = xno; then
  84     X11_NOT_NEEDED=yes
  85   fi
  86 
  87   ###############################################################################
  88   #
  89   # Check for MacOSX support for OpenJDK.
  90   #
  91 
  92   BASIC_DEPRECATED_ARG_ENABLE(macosx-runtime-support, macosx_runtime_support)
  93 
  94   AC_MSG_CHECKING([for Mac OS X Java Framework])
  95   if test -f /System/Library/Frameworks/JavaVM.framework/Frameworks/JavaRuntimeSupport.framework/Headers/JavaRuntimeSupport.h; then
  96     AC_MSG_RESULT([/System/Library/Frameworks/JavaVM.framework])
  97   else
  98     AC_MSG_RESULT([no])
  99   fi
 100 ])
 101 
 102 AC_DEFUN_ONCE([LIB_SETUP_X11],
 103 [
 104 
 105   ###############################################################################
 106   #
 107   # Check for X Windows
 108   #
 109 
 110   # Check if the user has specified sysroot, but not --x-includes or --x-libraries.
 111   # Make a simple check for the libraries at the sysroot, and setup --x-includes and
 112   # --x-libraries for the sysroot, if that seems to be correct.
 113   if test "x$OPENJDK_TARGET_OS" = "xlinux"; then
 114     if test "x$SYSROOT" != "x"; then
 115       if test "x$x_includes" = xNONE; then
 116         if test -f "$SYSROOT/usr/X11R6/include/X11/Xlib.h"; then
 117           x_includes="$SYSROOT/usr/X11R6/include"
 118         elif test -f "$SYSROOT/usr/include/X11/Xlib.h"; then
 119           x_includes="$SYSROOT/usr/include"
 120         fi
 121       fi
 122       if test "x$x_libraries" = xNONE; then
 123         if test -f "$SYSROOT/usr/X11R6/lib/libX11.so"; then
 124           x_libraries="$SYSROOT/usr/X11R6/lib"
 125         elif test "$SYSROOT/usr/lib64/libX11.so" && test "x$OPENJDK_TARGET_CPU_BITS" = x64; then
 126           x_libraries="$SYSROOT/usr/lib64"
 127         elif test -f "$SYSROOT/usr/lib/libX11.so"; then
 128           x_libraries="$SYSROOT/usr/lib"
 129         fi
 130       fi
 131     fi
 132   fi
 133 
 134   # Now let autoconf do it's magic
 135   AC_PATH_X
 136   AC_PATH_XTRA
 137 
 138   # AC_PATH_XTRA creates X_LIBS and sometimes adds -R flags. When cross compiling
 139   # this doesn't make sense so we remove it.
 140   if test "x$COMPILE_TYPE" = xcross; then
 141     X_LIBS=`$ECHO $X_LIBS | $SED 's/-R \{0,1\}[[^ ]]*//g'`
 142   fi
 143 
 144   if test "x$no_x" = xyes && test "x$X11_NOT_NEEDED" != xyes; then
 145     HELP_MSG_MISSING_DEPENDENCY([x11])
 146     AC_MSG_ERROR([Could not find X11 libraries. $HELP_MSG])
 147   fi
 148 
 149   if test "x$OPENJDK_TARGET_OS" = xsolaris; then
 150     OPENWIN_HOME="/usr/openwin"
 151     X_CFLAGS="-I$SYSROOT$OPENWIN_HOME/include -I$SYSROOT$OPENWIN_HOME/include/X11/extensions"
 152     X_LIBS="-L$SYSROOT$OPENWIN_HOME/sfw/lib$OPENJDK_TARGET_CPU_ISADIR \
 153         -L$SYSROOT$OPENWIN_HOME/lib$OPENJDK_TARGET_CPU_ISADIR \
 154         -R$OPENWIN_HOME/sfw/lib$OPENJDK_TARGET_CPU_ISADIR \
 155         -R$OPENWIN_HOME/lib$OPENJDK_TARGET_CPU_ISADIR"
 156   fi


 157 
 158   #
 159   # Weird Sol10 something check...TODO change to try compile
 160   #
 161   if test "x${OPENJDK_TARGET_OS}" = xsolaris; then
 162     if test "`uname -r`" = "5.10"; then
 163       if test "`${EGREP} -c XLinearGradient ${OPENWIN_HOME}/share/include/X11/extensions/Xrender.h`" = "0"; then
 164         X_CFLAGS="${X_CFLAGS} -DSOLARIS10_NO_XRENDER_STRUCTS"
 165       fi
 166     fi
 167   fi
 168 
 169   AC_LANG_PUSH(C)
 170   OLD_CFLAGS="$CFLAGS"
 171   CFLAGS="$CFLAGS $X_CFLAGS"
 172 
 173   # Need to include Xlib.h and Xutil.h to avoid "present but cannot be compiled" warnings on Solaris 10
 174   AC_CHECK_HEADERS([X11/extensions/shape.h X11/extensions/Xrender.h X11/extensions/XTest.h X11/Intrinsic.h],
 175       [X11_A_OK=yes],
 176       [X11_A_OK=no; break],
 177       [
 178         # include <X11/Xlib.h>
 179         # include <X11/Xutil.h>
 180       ]
 181   )
 182 
 183   CFLAGS="$OLD_CFLAGS"
 184   AC_LANG_POP(C)
 185 
 186   if test "x$X11_A_OK" = xno && test "x$X11_NOT_NEEDED" != xyes; then
 187     HELP_MSG_MISSING_DEPENDENCY([x11])
 188     AC_MSG_ERROR([Could not find all X11 headers (shape.h Xrender.h XTest.h Intrinsic.h). $HELP_MSG])
 189   fi
 190 
 191   AC_SUBST(X_CFLAGS)
 192   AC_SUBST(X_LIBS)
 193 ])
 194 
 195 AC_DEFUN_ONCE([LIB_SETUP_CUPS],
 196 [
 197 
 198   ###############################################################################
 199   #
 200   # The common unix printing system cups is used to print from java.
 201   #
 202   AC_ARG_WITH(cups, [AS_HELP_STRING([--with-cups],
 203       [specify prefix directory for the cups package
 204       (expecting the headers under PATH/include)])])
 205   AC_ARG_WITH(cups-include, [AS_HELP_STRING([--with-cups-include],
 206       [specify directory for the cups include files])])
 207 
 208   if test "x$CUPS_NOT_NEEDED" = xyes; then
 209     if test "x${with_cups}" != x || test "x${with_cups_include}" != x; then
 210       AC_MSG_WARN([cups not used, so --with-cups is ignored])
 211     fi
 212     CUPS_CFLAGS=
 213   else
 214     CUPS_FOUND=no
 215 
 216     if test "x${with_cups}" = xno || test "x${with_cups_include}" = xno; then
 217       AC_MSG_ERROR([It is not possible to disable the use of cups. Remove the --without-cups option.])
 218     fi
 219 
 220     if test "x${with_cups}" != x; then
 221       CUPS_CFLAGS="-I${with_cups}/include"
 222       CUPS_FOUND=yes
 223     fi
 224     if test "x${with_cups_include}" != x; then
 225       CUPS_CFLAGS="-I${with_cups_include}"
 226       CUPS_FOUND=yes
 227     fi
 228     if test "x$CUPS_FOUND" = xno; then
 229       BDEPS_CHECK_MODULE(CUPS, cups, xxx, [CUPS_FOUND=yes])
 230     fi
 231     if test "x$CUPS_FOUND" = xno; then
 232       # Are the cups headers installed in the default /usr/include location?
 233       AC_CHECK_HEADERS([cups/cups.h cups/ppd.h],
 234           [
 235             CUPS_FOUND=yes
 236             CUPS_CFLAGS=
 237             DEFAULT_CUPS=yes
 238           ]
 239       )
 240     fi
 241     if test "x$CUPS_FOUND" = xno; then
 242       # Getting nervous now? Lets poke around for standard Solaris third-party
 243       # package installation locations.
 244       AC_MSG_CHECKING([for cups headers])
 245       if test -s $SYSROOT/opt/sfw/cups/include/cups/cups.h; then
 246         # An SFW package seems to be installed!
 247         CUPS_FOUND=yes
 248         CUPS_CFLAGS="-I$SYSROOT/opt/sfw/cups/include"
 249       elif test -s $SYSROOT/opt/csw/include/cups/cups.h; then
 250         # A CSW package seems to be installed!
 251         CUPS_FOUND=yes
 252         CUPS_CFLAGS="-I$SYSROOT/opt/csw/include"
 253       fi
 254       AC_MSG_RESULT([$CUPS_FOUND])
 255     fi
 256     if test "x$CUPS_FOUND" = xno; then
 257       HELP_MSG_MISSING_DEPENDENCY([cups])
 258       AC_MSG_ERROR([Could not find cups! $HELP_MSG ])
 259     fi
 260   fi
 261 
 262   AC_SUBST(CUPS_CFLAGS)
 263 
 264 ])
 265 
 266 AC_DEFUN([LIB_CHECK_POTENTIAL_FREETYPE],
 267 [
 268   POTENTIAL_FREETYPE_INCLUDE_PATH="$1"
 269   POTENTIAL_FREETYPE_LIB_PATH="$2"
 270   METHOD="$3"
 271   
 272   # First check if the files exists.
 273   if test -s "$POTENTIAL_FREETYPE_INCLUDE_PATH/ft2build.h"; then
 274     # We found an arbitrary include file. That's a good sign.
 275     AC_MSG_NOTICE([Found freetype include files at $POTENTIAL_FREETYPE_INCLUDE_PATH using $METHOD])
 276     FOUND_FREETYPE=yes
 277 
 278     FREETYPE_LIB_NAME="${LIBRARY_PREFIX}freetype${SHARED_LIBRARY_SUFFIX}"
 279     if ! test -s "$POTENTIAL_FREETYPE_LIB_PATH/$FREETYPE_LIB_NAME"; then
 280       AC_MSG_NOTICE([Could not find $POTENTIAL_FREETYPE_LIB_PATH/$FREETYPE_LIB_NAME. Ignoring location.])
 281       FOUND_FREETYPE=no
 282     else
 283       if test "x$OPENJDK_TARGET_OS" = xwindows; then
 284         # On Windows, we will need both .lib and .dll file.
 285         if ! test -s "$POTENTIAL_FREETYPE_LIB_PATH/freetype.lib"; then
 286           AC_MSG_NOTICE([Could not find $POTENTIAL_FREETYPE_LIB_PATH/freetype.lib. Ignoring location.])
 287           FOUND_FREETYPE=no
 288         fi
 289       elif test "x$OPENJDK_TARGET_OS" = xsolaris && test "x$OPENJDK_TARGET_CPU" = xx86_64 && test -s "$POTENTIAL_FREETYPE_LIB_PATH/amd64/$FREETYPE_LIB_NAME"; then
 290         # On solaris-x86_86, default is (normally) PATH/lib/amd64. Update our guess!
 291         POTENTIAL_FREETYPE_LIB_PATH="$POTENTIAL_FREETYPE_LIB_PATH/amd64"
 292       fi
 293     fi
 294   fi
 295 
 296   if test "x$FOUND_FREETYPE" = xyes; then
 297     BASIC_FIXUP_PATH(POTENTIAL_FREETYPE_INCLUDE_PATH)
 298     BASIC_FIXUP_PATH(POTENTIAL_FREETYPE_LIB_PATH)
 299 
 300     FREETYPE_INCLUDE_PATH="$POTENTIAL_FREETYPE_INCLUDE_PATH"
 301     AC_MSG_CHECKING([for freetype includes])
 302     AC_MSG_RESULT([$FREETYPE_INCLUDE_PATH])
 303     FREETYPE_LIB_PATH="$POTENTIAL_FREETYPE_LIB_PATH"
 304     AC_MSG_CHECKING([for freetype libraries])
 305     AC_MSG_RESULT([$FREETYPE_LIB_PATH])
 306   fi
 307 ])
 308 
 309 AC_DEFUN_ONCE([LIB_SETUP_FREETYPE],
 310 [
 311 
 312   ###############################################################################
 313   #
 314   # The ubiquitous freetype library is used to render fonts.
 315   #
 316   AC_ARG_WITH(freetype, [AS_HELP_STRING([--with-freetype],
 317       [specify prefix directory for the freetype package
 318       (expecting the libraries under PATH/lib and the headers under PATH/include)])])
 319   AC_ARG_WITH(freetype-include, [AS_HELP_STRING([--with-freetype-include],
 320       [specify directory for the freetype include files])])
 321   AC_ARG_WITH(freetype-lib, [AS_HELP_STRING([--with-freetype-lib],
 322       [specify directory for the freetype library])])
 323   AC_ARG_ENABLE(freetype-bundling, [AS_HELP_STRING([--disable-freetype-bundling],
 324       [disable bundling of the freetype library with the build result @<:@enabled on Windows or when using --with-freetype, disabled otherwise@:>@])])
 325 
 326   FREETYPE_CFLAGS=
 327   FREETYPE_LIBS=
 328   FREETYPE_BUNDLE_LIB_PATH=
 329 
 330   if test "x$FREETYPE_NOT_NEEDED" = xyes; then
 331     if test "x$with_freetype" != x || test "x$with_freetype_include" != x || test "x$with_freetype_lib" != x; then
 332       AC_MSG_WARN([freetype not used, so --with-freetype is ignored])
 333     fi
 334     if test "x$enable_freetype_bundling" != x; then
 335       AC_MSG_WARN([freetype not used, so --enable-freetype-bundling is ignored])
 336     fi
 337   else
 338     # freetype is needed to build; go get it!
 339 
 340     BUNDLE_FREETYPE="$enable_freetype_bundling"
 341 
 342     if test "x$with_freetype" != x || test "x$with_freetype_include" != x || test "x$with_freetype_lib" != x; then
 343       # User has specified settings
 344 
 345       if test "x$BUNDLE_FREETYPE" = x; then
 346         # If not specified, default is to bundle freetype
 347         BUNDLE_FREETYPE=yes
 348       fi
 349       
 350       if test "x$with_freetype" != x; then
 351         POTENTIAL_FREETYPE_INCLUDE_PATH="$with_freetype/include"
 352         POTENTIAL_FREETYPE_LIB_PATH="$with_freetype/lib"
 353       fi
 354       
 355       # Allow --with-freetype-lib and --with-freetype-include to override
 356       if test "x$with_freetype_include" != x; then
 357         POTENTIAL_FREETYPE_INCLUDE_PATH="$with_freetype_include"
 358       fi
 359       if test "x$with_freetype_lib" != x; then
 360         POTENTIAL_FREETYPE_LIB_PATH="$with_freetype_lib"
 361       fi
 362 
 363       if test "x$POTENTIAL_FREETYPE_INCLUDE_PATH" != x && test "x$POTENTIAL_FREETYPE_LIB_PATH" != x; then
 364         # Okay, we got it. Check that it works.
 365         LIB_CHECK_POTENTIAL_FREETYPE($POTENTIAL_FREETYPE_INCLUDE_PATH, $POTENTIAL_FREETYPE_LIB_PATH, [--with-freetype])
 366         if test "x$FOUND_FREETYPE" != xyes; then
 367           AC_MSG_ERROR([Can not find or use freetype at location given by --with-freetype])
 368         fi
 369       else
 370         # User specified only one of lib or include. This is an error.
 371         if test "x$POTENTIAL_FREETYPE_INCLUDE_PATH" = x ; then
 372           AC_MSG_NOTICE([User specified --with-freetype-lib but not --with-freetype-include])
 373           AC_MSG_ERROR([Need both freetype lib and include paths. Consider using --with-freetype instead.])
 374         else
 375           AC_MSG_NOTICE([User specified --with-freetype-include but not --with-freetype-lib])
 376           AC_MSG_ERROR([Need both freetype lib and include paths. Consider using --with-freetype instead.])
 377         fi
 378       fi
 379     else
 380       # User did not specify settings, but we need freetype. Try to locate it.
 381 
 382       if test "x$BUNDLE_FREETYPE" = x; then
 383         # If not specified, default is to bundle freetype only on windows
 384         if test "x$OPENJDK_TARGET_OS" = xwindows; then
 385           BUNDLE_FREETYPE=yes
 386         else
 387           BUNDLE_FREETYPE=no
 388         fi
 389       fi
 390 
 391       if test "x$FOUND_FREETYPE" != xyes; then
 392         # Check builddeps
 393         BDEPS_CHECK_MODULE(FREETYPE, freetype2, xxx, [FOUND_FREETYPE=yes], [FOUND_FREETYPE=no])
 394         # BDEPS_CHECK_MODULE will set FREETYPE_CFLAGS and _LIBS, but we don't get a lib path for bundling.
 395         if test "x$FOUND_FREETYPE" = xyes; then
 396           if test "x$BUNDLE_FREETYPE" = xyes; then
 397             AC_MSG_NOTICE([Found freetype using builddeps, but ignoring since we can not bundle that])
 398             FOUND_FREETYPE=no
 399           else
 400             AC_MSG_CHECKING([for freetype])
 401             AC_MSG_RESULT([yes (using builddeps)])
 402           fi
 403         fi
 404       fi
 405 
 406       # If we have a sysroot, assume that's where we are supposed to look and skip pkg-config.
 407       if test "x$SYSROOT" = x; then
 408         if test "x$FOUND_FREETYPE" != xyes; then
 409           # Check modules using pkg-config, but only if we have it (ugly output results otherwise)
 410           if test "x$PKG_CONFIG" != x; then
 411             PKG_CHECK_MODULES(FREETYPE, freetype2, [FOUND_FREETYPE=yes], [FOUND_FREETYPE=no])
 412             if test "x$FOUND_FREETYPE" = xyes; then
 413               # On solaris, pkg_check adds -lz to freetype libs, which isn't necessary for us.
 414               FREETYPE_LIBS=`$ECHO $FREETYPE_LIBS | $SED 's/-lz//g'`
 415               # 64-bit libs for Solaris x86 are installed in the amd64 subdirectory, change lib to lib/amd64
 416               if test "x$OPENJDK_TARGET_OS" = xsolaris && test "x$OPENJDK_TARGET_CPU" = xx86_64; then
 417                 FREETYPE_LIBS=`$ECHO $FREETYPE_LIBS | $SED 's?/lib?/lib/amd64?g'`
 418               fi
 419               # BDEPS_CHECK_MODULE will set FREETYPE_CFLAGS and _LIBS, but we don't get a lib path for bundling.
 420               if test "x$BUNDLE_FREETYPE" = xyes; then
 421                 AC_MSG_NOTICE([Found freetype using pkg-config, but ignoring since we can not bundle that])
 422                 FOUND_FREETYPE=no
 423               else
 424                 AC_MSG_CHECKING([for freetype])
 425                 AC_MSG_RESULT([yes (using pkg-config)])
 426               fi
 427             fi
 428           fi
 429         fi
 430       fi
 431 
 432       if test "x$FOUND_FREETYPE" != xyes; then
 433         # Check in well-known locations
 434         if test "x$OPENJDK_TARGET_OS" = xwindows; then
 435           FREETYPE_BASE_DIR="$PROGRAMFILES/GnuWin32"
 436           BASIC_WINDOWS_REWRITE_AS_UNIX_PATH(FREETYPE_BASE_DIR)
 437           LIB_CHECK_POTENTIAL_FREETYPE([$FREETYPE_BASE_DIR/include], [$FREETYPE_BASE_DIR/lib], [well-known location])
 438           if test "x$FOUND_FREETYPE" != xyes; then
 439             FREETYPE_BASE_DIR="$ProgramW6432/GnuWin32"
 440             BASIC_WINDOWS_REWRITE_AS_UNIX_PATH(FREETYPE_BASE_DIR)
 441             LIB_CHECK_POTENTIAL_FREETYPE([$FREETYPE_BASE_DIR/include], [$FREETYPE_BASE_DIR/lib], [well-known location])
 442           fi
 443         else
 444           FREETYPE_BASE_DIR="$SYSROOT/usr"





 445           LIB_CHECK_POTENTIAL_FREETYPE([$FREETYPE_BASE_DIR/include], [$FREETYPE_BASE_DIR/lib], [well-known location])
 446 
 447           if test "x$FOUND_FREETYPE" != xyes; then
 448             FREETYPE_BASE_DIR="$SYSROOT/usr/X11"
 449             LIB_CHECK_POTENTIAL_FREETYPE([$FREETYPE_BASE_DIR/include], [$FREETYPE_BASE_DIR/lib], [well-known location])
 450           fi
 451 
 452           if test "x$FOUND_FREETYPE" != xyes; then
 453             FREETYPE_BASE_DIR="$SYSROOT/usr/sfw"
 454             LIB_CHECK_POTENTIAL_FREETYPE([$FREETYPE_BASE_DIR/include], [$FREETYPE_BASE_DIR/lib], [well-known location])
 455           fi
 456 
 457           if test "x$FOUND_FREETYPE" != xyes; then
 458             FREETYPE_BASE_DIR="$SYSROOT/usr"
 459             if test "x$OPENJDK_TARGET_CPU_BITS" = x64; then
 460               LIB_CHECK_POTENTIAL_FREETYPE([$FREETYPE_BASE_DIR/include], [$FREETYPE_BASE_DIR/lib/x86_64-linux-gnu], [well-known location])
 461             else
 462               LIB_CHECK_POTENTIAL_FREETYPE([$FREETYPE_BASE_DIR/include], [$FREETYPE_BASE_DIR/lib/i386-linux-gnu], [well-known location])
 463               if test "x$FOUND_FREETYPE" != xyes; then
 464                 LIB_CHECK_POTENTIAL_FREETYPE([$FREETYPE_BASE_DIR/include], [$FREETYPE_BASE_DIR/lib32], [well-known location])
 465               fi
 466             fi
 467           fi
 468         fi
 469       fi # end check in well-known locations
 470 
 471       if test "x$FOUND_FREETYPE" != xyes; then
 472         HELP_MSG_MISSING_DEPENDENCY([freetype])
 473         AC_MSG_ERROR([Could not find freetype! $HELP_MSG ])
 474       fi
 475     fi # end user specified settings
 476 
 477     # Set FREETYPE_CFLAGS, _LIBS and _LIB_PATH from include and lib dir.
 478     if test "x$FREETYPE_CFLAGS" = x; then
 479       BASIC_FIXUP_PATH(FREETYPE_INCLUDE_PATH)
 480       if test -d $FREETYPE_INCLUDE_PATH/freetype2/freetype; then
 481         FREETYPE_CFLAGS="-I$FREETYPE_INCLUDE_PATH/freetype2 -I$FREETYPE_INCLUDE_PATH"
 482       else
 483         FREETYPE_CFLAGS="-I$FREETYPE_INCLUDE_PATH"
 484       fi
 485     fi
 486     
 487     if test "x$FREETYPE_LIBS" = x; then
 488       BASIC_FIXUP_PATH(FREETYPE_LIB_PATH)
 489       if test "x$OPENJDK_TARGET_OS" = xwindows; then
 490         FREETYPE_LIBS="$FREETYPE_LIB_PATH/freetype.lib"
 491       else
 492         FREETYPE_LIBS="-L$FREETYPE_LIB_PATH -lfreetype"
 493       fi
 494     fi
 495 
 496     # Try to compile it
 497     AC_MSG_CHECKING([if we can compile and link with freetype])
 498     AC_LANG_PUSH(C++)
 499     PREV_CXXCFLAGS="$CXXFLAGS"
 500     PREV_LIBS="$LIBS"
 501     PREV_CXX="$CXX"
 502     CXXFLAGS="$CXXFLAGS $FREETYPE_CFLAGS" 
 503     LIBS="$LIBS $FREETYPE_LIBS"
 504     CXX="$FIXPATH $CXX"
 505     AC_LINK_IFELSE([AC_LANG_SOURCE([[
 506           #include<ft2build.h>
 507           #include FT_FREETYPE_H
 508           int main () {
 509             FT_Init_FreeType(NULL);
 510             return 0;
 511           }
 512         ]])],
 513         [
 514           AC_MSG_RESULT([yes])
 515         ],
 516         [
 517           AC_MSG_RESULT([no])
 518           AC_MSG_NOTICE([Could not compile and link with freetype. This might be a 32/64-bit mismatch.])
 519           AC_MSG_NOTICE([Using FREETYPE_CFLAGS=$FREETYPE_CFLAGS and FREETYPE_LIBS=$FREETYPE_LIBS])
 520           
 521           HELP_MSG_MISSING_DEPENDENCY([freetype])
 522           
 523           AC_MSG_ERROR([Can not continue without freetype. $HELP_MSG])
 524         ]
 525     )
 526     CXXCFLAGS="$PREV_CXXFLAGS"
 527     LIBS="$PREV_LIBS"
 528     CXX="$PREV_CXX"
 529     AC_LANG_POP(C++)
 530 
 531     AC_MSG_CHECKING([if we should bundle freetype])
 532     if test "x$BUNDLE_FREETYPE" = xyes; then
 533       FREETYPE_BUNDLE_LIB_PATH="$FREETYPE_LIB_PATH"
 534     fi
 535     AC_MSG_RESULT([$BUNDLE_FREETYPE])
 536 
 537   fi # end freetype needed
 538 
 539   AC_SUBST(FREETYPE_BUNDLE_LIB_PATH)
 540   AC_SUBST(FREETYPE_CFLAGS)
 541   AC_SUBST(FREETYPE_LIBS)
 542 ])
 543 
 544 AC_DEFUN_ONCE([LIB_SETUP_ALSA],
 545 [
 546 
 547   ###############################################################################
 548   #
 549   # Check for alsa headers and libraries. Used on Linux/GNU systems.
 550   #
 551   AC_ARG_WITH(alsa, [AS_HELP_STRING([--with-alsa],
 552       [specify prefix directory for the alsa package
 553       (expecting the libraries under PATH/lib and the headers under PATH/include)])])
 554   AC_ARG_WITH(alsa-include, [AS_HELP_STRING([--with-alsa-include],
 555       [specify directory for the alsa include files])])
 556   AC_ARG_WITH(alsa-lib, [AS_HELP_STRING([--with-alsa-lib],
 557       [specify directory for the alsa library])])
 558 
 559   if test "x$ALSA_NOT_NEEDED" = xyes; then
 560     if test "x${with_alsa}" != x || test "x${with_alsa_include}" != x || test "x${with_alsa_lib}" != x; then
 561       AC_MSG_WARN([alsa not used, so --with-alsa is ignored])
 562     fi
 563     ALSA_CFLAGS=
 564     ALSA_LIBS=
 565   else
 566     ALSA_FOUND=no
 567 
 568     if test "x${with_alsa}" = xno || test "x${with_alsa_include}" = xno || test "x${with_alsa_lib}" = xno; then
 569       AC_MSG_ERROR([It is not possible to disable the use of alsa. Remove the --without-alsa option.])
 570     fi
 571 
 572     if test "x${with_alsa}" != x; then
 573       ALSA_LIBS="-L${with_alsa}/lib -lasound"
 574       ALSA_CFLAGS="-I${with_alsa}/include"
 575       ALSA_FOUND=yes
 576     fi
 577     if test "x${with_alsa_include}" != x; then
 578       ALSA_CFLAGS="-I${with_alsa_include}"
 579       ALSA_FOUND=yes
 580     fi
 581     if test "x${with_alsa_lib}" != x; then
 582       ALSA_LIBS="-L${with_alsa_lib} -lasound"
 583       ALSA_FOUND=yes
 584     fi
 585     if test "x$ALSA_FOUND" = xno; then
 586       BDEPS_CHECK_MODULE(ALSA, alsa, xxx, [ALSA_FOUND=yes], [ALSA_FOUND=no])
 587     fi
 588     # Do not try pkg-config if we have a sysroot set.
 589     if test "x$SYSROOT" = x; then
 590       if test "x$ALSA_FOUND" = xno; then
 591         PKG_CHECK_MODULES(ALSA, alsa, [ALSA_FOUND=yes], [ALSA_FOUND=no])
 592       fi
 593     fi
 594     if test "x$ALSA_FOUND" = xno; then
 595       AC_CHECK_HEADERS([alsa/asoundlib.h],
 596           [
 597             ALSA_FOUND=yes
 598             ALSA_CFLAGS=-Iignoreme
 599             ALSA_LIBS=-lasound
 600             DEFAULT_ALSA=yes
 601           ],
 602           [ALSA_FOUND=no])
 603     fi
 604     if test "x$ALSA_FOUND" = xno; then
 605       HELP_MSG_MISSING_DEPENDENCY([alsa])
 606       AC_MSG_ERROR([Could not find alsa! $HELP_MSG ])
 607     fi
 608   fi
 609 
 610   AC_SUBST(ALSA_CFLAGS)
 611   AC_SUBST(ALSA_LIBS)
 612 ])
 613 
 614 AC_DEFUN_ONCE([LIB_SETUP_MISC_LIBS],
 615 [
 616 
 617   ###############################################################################
 618   #
 619   # Check for the jpeg library
 620   #
 621 
 622   USE_EXTERNAL_LIBJPEG=true
 623   AC_CHECK_LIB(jpeg, main, [],
 624       [ USE_EXTERNAL_LIBJPEG=false
 625       AC_MSG_NOTICE([Will use jpeg decoder bundled with the OpenJDK source])
 626   ])
 627   AC_SUBST(USE_EXTERNAL_LIBJPEG)
 628 
 629   ###############################################################################
 630   #
 631   # Check for the gif library
 632   #
 633 
 634   AC_ARG_WITH(giflib, [AS_HELP_STRING([--with-giflib],
 635       [use giflib from build system or OpenJDK source (system, bundled) @<:@bundled@:>@])])
 636 
 637 
 638   AC_MSG_CHECKING([for which giflib to use])
 639 
 640   # default is bundled
 641   DEFAULT_GIFLIB=bundled
 642 
 643   #
 644   # if user didn't specify, use DEFAULT_GIFLIB
 645   #
 646   if test "x${with_giflib}" = "x"; then
 647     with_giflib=${DEFAULT_GIFLIB}
 648   fi
 649 
 650   AC_MSG_RESULT(${with_giflib})
 651 
 652   if test "x${with_giflib}" = "xbundled"; then
 653     USE_EXTERNAL_LIBGIF=false
 654   elif test "x${with_giflib}" = "xsystem"; then
 655     AC_CHECK_HEADER(gif_lib.h, [],
 656         [ AC_MSG_ERROR([--with-giflib=system specified, but gif_lib.h not found!])])
 657     AC_CHECK_LIB(gif, DGifGetCode, [],
 658         [ AC_MSG_ERROR([--with-giflib=system specified, but no giflib found!])])
 659 
 660     USE_EXTERNAL_LIBGIF=true
 661   else
 662     AC_MSG_ERROR([Invalid value of --with-giflib: ${with_giflib}, use 'system' or 'bundled'])
 663   fi
 664   AC_SUBST(USE_EXTERNAL_LIBGIF)
 665 
 666   ###############################################################################
 667   #
 668   # Check for the png library
 669   #
 670 
 671   AC_ARG_WITH(libpng, [AS_HELP_STRING([--with-libpng],
 672      [use libpng from build system or OpenJDK source (system, bundled) @<:@bundled@:>@])])
 673 
 674 
 675   AC_MSG_CHECKING([for which libpng to use])
 676 
 677   # default is bundled
 678   DEFAULT_LIBPNG=bundled
 679 
 680   #
 681   # if user didn't specify, use DEFAULT_LIBPNG
 682   #
 683   if test "x${with_libpng}" = "x"; then
 684       with_libpng=${DEFAULT_LIBPNG}
 685   fi
 686 
 687   if test "x${with_libpng}" = "xbundled"; then
 688       USE_EXTERNAL_LIBPNG=false
 689       AC_MSG_RESULT([bundled])
 690   elif test "x${with_libpng}" = "xsystem"; then
 691       PKG_CHECK_MODULES(PNG, libpng,
 692                    [ LIBPNG_FOUND=yes ],
 693                    [ LIBPNG_FOUND=no ])
 694       if test "x${LIBPNG_FOUND}" = "xyes"; then
 695           USE_EXTERNAL_LIBPNG=true
 696           AC_MSG_RESULT([system])
 697       else
 698           AC_MSG_RESULT([system not found])
 699           AC_MSG_ERROR([--with-libpng=system specified, but no libpng found!])
 700       fi
 701   else
 702       AC_MSG_ERROR([Invalid value of --with-libpng: ${with_libpng}, use 'system' or 'bundled'])
 703   fi
 704   AC_SUBST(USE_EXTERNAL_LIBPNG)
 705 
 706   ###############################################################################
 707   #
 708   # Check for the zlib library
 709   #
 710 
 711   AC_ARG_WITH(zlib, [AS_HELP_STRING([--with-zlib],
 712       [use zlib from build system or OpenJDK source (system, bundled) @<:@bundled@:>@])])
 713 
 714   AC_CHECK_LIB(z, compress,
 715       [ ZLIB_FOUND=yes ],
 716       [ ZLIB_FOUND=no ])
 717 
 718   AC_MSG_CHECKING([for which zlib to use])
 719 
 720   DEFAULT_ZLIB=bundled
 721   if test "x$OPENJDK_TARGET_OS" = xmacosx; then
 722     #
 723     # On macosx default is system...on others default is
 724     #
 725     DEFAULT_ZLIB=system
 726   fi
 727 
 728   if test "x${ZLIB_FOUND}" != "xyes"; then
 729     #
 730     # If we don't find any system...set default to bundled
 731     #
 732     DEFAULT_ZLIB=bundled
 733   fi
 734 
 735   #
 736   # If user didn't specify, use DEFAULT_ZLIB
 737   #
 738   if test "x${with_zlib}" = "x"; then
 739     with_zlib=${DEFAULT_ZLIB}
 740   fi
 741 
 742   if test "x${with_zlib}" = "xbundled"; then
 743     USE_EXTERNAL_LIBZ=false
 744     AC_MSG_RESULT([bundled])
 745   elif test "x${with_zlib}" = "xsystem"; then
 746     if test "x${ZLIB_FOUND}" = "xyes"; then
 747       USE_EXTERNAL_LIBZ=true
 748       AC_MSG_RESULT([system])
 749     else
 750       AC_MSG_RESULT([system not found])
 751       AC_MSG_ERROR([--with-zlib=system specified, but no zlib found!])
 752     fi
 753   else
 754     AC_MSG_ERROR([Invalid value for --with-zlib: ${with_zlib}, use 'system' or 'bundled'])
 755   fi
 756 
 757   AC_SUBST(USE_EXTERNAL_LIBZ)
 758 
 759   ###############################################################################
 760   LIBZIP_CAN_USE_MMAP=true
 761 
 762   AC_SUBST(LIBZIP_CAN_USE_MMAP)
 763 
 764   ###############################################################################
 765   #
 766   # Check if altzone exists in time.h
 767   #
 768 
 769   AC_LINK_IFELSE([AC_LANG_PROGRAM([#include <time.h>], [return (int)altzone;])],
 770       [has_altzone=yes],
 771       [has_altzone=no])
 772   if test "x$has_altzone" = xyes; then
 773     AC_DEFINE([HAVE_ALTZONE], 1, [Define if you have the external 'altzone' variable in time.h])
 774   fi
 775 
 776   ###############################################################################
 777   #
 778   # Check the maths library
 779   #
 780 
 781   AC_CHECK_LIB(m, cos, [],
 782       [
 783         AC_MSG_NOTICE([Maths library was not found])
 784       ]
 785   )
 786   AC_SUBST(LIBM)
 787 
 788   ###############################################################################
 789   #
 790   # Check for libdl.so
 791 
 792   save_LIBS="$LIBS"
 793   LIBS=""
 794   AC_CHECK_LIB(dl,dlopen)
 795   LIBDL="$LIBS"
 796   AC_SUBST(LIBDL)
 797   LIBS="$save_LIBS"
 798 ])
 799 
 800 AC_DEFUN_ONCE([LIB_SETUP_STATIC_LINK_LIBSTDCPP],
 801 [
 802   ###############################################################################
 803   #
 804   # statically link libstdc++ before C++ ABI is stablized on Linux unless
 805   # dynamic build is configured on command line.
 806   #
 807   AC_ARG_WITH([stdc++lib], [AS_HELP_STRING([--with-stdc++lib=<static>,<dynamic>,<default>],
 808       [force linking of the C++ runtime on Linux to either static or dynamic, default is static with dynamic as fallback])],
 809       [
 810         if test "x$with_stdc__lib" != xdynamic && test "x$with_stdc__lib" != xstatic \
 811                 && test "x$with_stdc__lib" != xdefault; then
 812           AC_MSG_ERROR([Bad parameter value --with-stdc++lib=$with_stdc__lib!])
 813         fi
 814       ],
 815       [with_stdc__lib=default]
 816   )
 817 
 818   if test "x$OPENJDK_TARGET_OS" = xlinux; then
 819     # Test if -lstdc++ works.
 820     AC_MSG_CHECKING([if dynamic link of stdc++ is possible])
 821     AC_LANG_PUSH(C++)
 822     OLD_CXXFLAGS="$CXXFLAGS"
 823     CXXFLAGS="$CXXFLAGS -lstdc++"
 824     AC_LINK_IFELSE([AC_LANG_PROGRAM([], [return 0;])],
 825         [has_dynamic_libstdcxx=yes],
 826         [has_dynamic_libstdcxx=no])
 827     CXXFLAGS="$OLD_CXXFLAGS"
 828     AC_LANG_POP(C++)
 829     AC_MSG_RESULT([$has_dynamic_libstdcxx])
 830 
 831     # Test if stdc++ can be linked statically.
 832     AC_MSG_CHECKING([if static link of stdc++ is possible])
 833     STATIC_STDCXX_FLAGS="-Wl,-Bstatic -lstdc++ -lgcc -Wl,-Bdynamic"
 834     AC_LANG_PUSH(C++)
 835     OLD_LIBS="$LIBS"
 836     OLD_CXX="$CXX"
 837     LIBS="$STATIC_STDCXX_FLAGS"
 838     CXX="$CC"
 839     AC_LINK_IFELSE([AC_LANG_PROGRAM([], [return 0;])],
 840         [has_static_libstdcxx=yes],
 841         [has_static_libstdcxx=no])
 842     LIBS="$OLD_LIBS"
 843     CXX="$OLD_CXX"
 844     AC_LANG_POP(C++)
 845     AC_MSG_RESULT([$has_static_libstdcxx])
 846 
 847     if test "x$has_static_libstdcxx" = xno && test "x$has_dynamic_libstdcxx" = xno; then
 848       AC_MSG_ERROR([Cannot link to stdc++, neither dynamically nor statically!])
 849     fi
 850 
 851     if test "x$with_stdc__lib" = xstatic && test "x$has_static_libstdcxx" = xno; then
 852       AC_MSG_ERROR([Static linking of libstdc++ was not possible!])
 853     fi
 854 
 855     if test "x$with_stdc__lib" = xdynamic && test "x$has_dynamic_libstdcxx" = xno; then
 856       AC_MSG_ERROR([Dynamic linking of libstdc++ was not possible!])
 857     fi
 858 
 859     AC_MSG_CHECKING([how to link with libstdc++])
 860     # If dynamic was requested, it's available since it would fail above otherwise.
 861     # If dynamic wasn't requested, go with static unless it isn't available.
 862     if test "x$with_stdc__lib" = xdynamic || test "x$has_static_libstdcxx" = xno || test "x$JVM_VARIANT_ZEROSHARK" = xtrue; then
 863       LIBCXX="$LIBCXX -lstdc++"
 864       LDCXX="$CXX"
 865       STATIC_CXX_SETTING="STATIC_CXX=false"
 866       AC_MSG_RESULT([dynamic])
 867     else
 868       LIBCXX="$LIBCXX $STATIC_STDCXX_FLAGS"
 869       LDCXX="$CC"
 870       STATIC_CXX_SETTING="STATIC_CXX=true"
 871       AC_MSG_RESULT([static])
 872     fi
 873   fi
 874   AC_SUBST(STATIC_CXX_SETTING)
 875 
 876   if test "x$JVM_VARIANT_ZERO" = xtrue || test "x$JVM_VARIANT_ZEROSHARK" = xtrue; then
 877     # Figure out LIBFFI_CFLAGS and LIBFFI_LIBS
 878     PKG_CHECK_MODULES([LIBFFI], [libffi])
 879 
 880   fi
 881 
 882   if test "x$JVM_VARIANT_ZEROSHARK" = xtrue; then
 883     AC_CHECK_PROG([LLVM_CONFIG], [llvm-config], [llvm-config])
 884 
 885     if test "x$LLVM_CONFIG" != xllvm-config; then
 886       AC_MSG_ERROR([llvm-config not found in $PATH.])
 887     fi
 888 
 889     llvm_components="jit mcjit engine nativecodegen native"
 890     unset LLVM_CFLAGS
 891     for flag in $("$LLVM_CONFIG" --cxxflags); do
 892       if echo "${flag}" | grep -q '^-@<:@ID@:>@'; then
 893         if test "${flag}" != "-D_DEBUG" ; then
 894           if test "${LLVM_CFLAGS}" != "" ; then
 895             LLVM_CFLAGS="${LLVM_CFLAGS} "
 896           fi
 897           LLVM_CFLAGS="${LLVM_CFLAGS}${flag}"
 898         fi
 899       fi
 900     done
 901     llvm_version=$("${LLVM_CONFIG}" --version | sed 's/\.//; s/svn.*//')
 902     LLVM_CFLAGS="${LLVM_CFLAGS} -DSHARK_LLVM_VERSION=${llvm_version}"
 903 
 904     unset LLVM_LDFLAGS
 905     for flag in $("${LLVM_CONFIG}" --ldflags); do
 906       if echo "${flag}" | grep -q '^-L'; then
 907         if test "${LLVM_LDFLAGS}" != ""; then
 908           LLVM_LDFLAGS="${LLVM_LDFLAGS} "
 909         fi
 910         LLVM_LDFLAGS="${LLVM_LDFLAGS}${flag}"
 911       fi
 912     done
 913 
 914     unset LLVM_LIBS
 915     for flag in $("${LLVM_CONFIG}" --libs ${llvm_components}); do
 916       if echo "${flag}" | grep -q '^-l'; then
 917         if test "${LLVM_LIBS}" != ""; then
 918           LLVM_LIBS="${LLVM_LIBS} "
 919         fi
 920         LLVM_LIBS="${LLVM_LIBS}${flag}"
 921       fi
 922     done
 923 
 924     AC_SUBST(LLVM_CFLAGS)
 925     AC_SUBST(LLVM_LDFLAGS)
 926     AC_SUBST(LLVM_LIBS)
 927   fi
 928 
 929   # libCrun is the c++ runtime-library with SunStudio (roughly the equivalent of gcc's libstdc++.so)
 930   if test "x$TOOLCHAIN_TYPE" = xsolstudio && test "x$LIBCXX" = x; then
 931     LIBCXX="${SYSROOT}/usr/lib${OPENJDK_TARGET_CPU_ISADIR}/libCrun.so.1"
 932   fi
 933 
 934   # TODO better (platform agnostic) test
 935   if test "x$OPENJDK_TARGET_OS" = xmacosx && test "x$LIBCXX" = x && test "x$TOOLCHAIN_TYPE" = xgcc; then
 936     LIBCXX="-lstdc++"
 937   fi
 938 
 939   AC_SUBST(LIBCXX)
 940 ])
 941 
 942 AC_DEFUN_ONCE([LIB_SETUP_ON_WINDOWS],
 943 [
 944   if test "x$OPENJDK_TARGET_OS" = "xwindows"; then
 945     TOOLCHAIN_SETUP_MSVCR_DLL
 946     BASIC_DEPRECATED_ARG_WITH([dxsdk])
 947     BASIC_DEPRECATED_ARG_WITH([dxsdk-lib])
 948     BASIC_DEPRECATED_ARG_WITH([dxsdk-include])
 949   fi
 950   AC_SUBST(MSVCR_DLL)
 951 ])
--- EOF ---