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$SYS_ROOT" != "x/"; then
 114     if test "x$x_includes" = xNONE; then
 115       if test -f "$SYS_ROOT/usr/X11R6/include/X11/Xlib.h"; then
 116         x_includes="$SYS_ROOT/usr/X11R6/include"
 117       elif test -f "$SYS_ROOT/usr/include/X11/Xlib.h"; then
 118         x_includes="$SYS_ROOT/usr/include"
 119       fi
 120     fi
 121     if test "x$x_libraries" = xNONE; then
 122       if test -f "$SYS_ROOT/usr/X11R6/lib/libX11.so"; then
 123         x_libraries="$SYS_ROOT/usr/X11R6/lib"
 124       elif test "$SYS_ROOT/usr/lib64/libX11.so" && test "x$OPENJDK_TARGET_CPU_BITS" = x64; then
 125         x_libraries="$SYS_ROOT/usr/lib64"
 126       elif test -f "$SYS_ROOT/usr/lib/libX11.so"; then
 127         x_libraries="$SYS_ROOT/usr/lib"
 128       fi
 129     fi
 130   fi
 131 
 132   # Now let autoconf do it's magic
 133   AC_PATH_X
 134   AC_PATH_XTRA
 135 
 136   # AC_PATH_XTRA creates X_LIBS and sometimes adds -R flags. When cross compiling
 137   # this doesn't make sense so we remove it.
 138   if test "x$COMPILE_TYPE" = xcross; then
 139     X_LIBS=`$ECHO $X_LIBS | $SED 's/-R \{0,1\}[[^ ]]*//g'`
 140   fi
 141 
 142   if test "x$no_x" = xyes && test "x$X11_NOT_NEEDED" != xyes; then
 143     HELP_MSG_MISSING_DEPENDENCY([x11])
 144     AC_MSG_ERROR([Could not find X11 libraries. $HELP_MSG])
 145   fi
 146 
 147   if test "x$OPENJDK_TARGET_OS" = xsolaris; then
 148     OPENWIN_HOME="/usr/openwin"
 149   fi
 150   AC_SUBST(OPENWIN_HOME)
 151 
 152 
 153   #
 154   # Weird Sol10 something check...TODO change to try compile
 155   #
 156   if test "x${OPENJDK_TARGET_OS}" = xsolaris; then
 157     if test "`uname -r`" = "5.10"; then
 158       if test "`${EGREP} -c XLinearGradient ${OPENWIN_HOME}/share/include/X11/extensions/Xrender.h`" = "0"; then
 159         X_CFLAGS="${X_CFLAGS} -DSOLARIS10_NO_XRENDER_STRUCTS"
 160       fi
 161     fi
 162   fi
 163 
 164   AC_LANG_PUSH(C)
 165   OLD_CFLAGS="$CFLAGS"
 166   CFLAGS="$CFLAGS $X_CFLAGS"
 167 
 168   # Need to include Xlib.h and Xutil.h to avoid "present but cannot be compiled" warnings on Solaris 10
 169   AC_CHECK_HEADERS([X11/extensions/shape.h X11/extensions/Xrender.h X11/extensions/XTest.h X11/Intrinsic.h],
 170       [X11_A_OK=yes],
 171       [X11_A_OK=no; break],
 172       [
 173         # include <X11/Xlib.h>
 174         # include <X11/Xutil.h>
 175       ]
 176   )
 177 
 178   CFLAGS="$OLD_CFLAGS"
 179   AC_LANG_POP(C)
 180 
 181   if test "x$X11_A_OK" = xno && test "x$X11_NOT_NEEDED" != xyes; then
 182     HELP_MSG_MISSING_DEPENDENCY([x11])
 183     AC_MSG_ERROR([Could not find all X11 headers (shape.h Xrender.h XTest.h Intrinsic.h). $HELP_MSG])
 184   fi
 185 
 186   AC_SUBST(X_CFLAGS)
 187   AC_SUBST(X_LIBS)
 188 ])
 189 
 190 AC_DEFUN_ONCE([LIB_SETUP_CUPS],
 191 [
 192 
 193   ###############################################################################
 194   #
 195   # The common unix printing system cups is used to print from java.
 196   #
 197   AC_ARG_WITH(cups, [AS_HELP_STRING([--with-cups],
 198       [specify prefix directory for the cups package
 199       (expecting the headers under PATH/include)])])
 200   AC_ARG_WITH(cups-include, [AS_HELP_STRING([--with-cups-include],
 201       [specify directory for the cups include files])])
 202 
 203   if test "x$CUPS_NOT_NEEDED" = xyes; then
 204     if test "x${with_cups}" != x || test "x${with_cups_include}" != x; then
 205       AC_MSG_WARN([cups not used, so --with-cups is ignored])
 206     fi
 207     CUPS_CFLAGS=
 208   else
 209     CUPS_FOUND=no
 210 
 211     if test "x${with_cups}" = xno || test "x${with_cups_include}" = xno; then
 212       AC_MSG_ERROR([It is not possible to disable the use of cups. Remove the --without-cups option.])
 213     fi
 214 
 215     if test "x${with_cups}" != x; then
 216       CUPS_CFLAGS="-I${with_cups}/include"
 217       CUPS_FOUND=yes
 218     fi
 219     if test "x${with_cups_include}" != x; then
 220       CUPS_CFLAGS="-I${with_cups_include}"
 221       CUPS_FOUND=yes
 222     fi
 223     if test "x$CUPS_FOUND" = xno; then
 224       BDEPS_CHECK_MODULE(CUPS, cups, xxx, [CUPS_FOUND=yes])
 225     fi
 226     if test "x$CUPS_FOUND" = xno; then
 227       # Are the cups headers installed in the default /usr/include location?
 228       AC_CHECK_HEADERS([cups/cups.h cups/ppd.h],
 229           [
 230             CUPS_FOUND=yes
 231             CUPS_CFLAGS=
 232             DEFAULT_CUPS=yes
 233           ]
 234       )
 235     fi
 236     if test "x$CUPS_FOUND" = xno; then
 237       # Getting nervous now? Lets poke around for standard Solaris third-party
 238       # package installation locations.
 239       AC_MSG_CHECKING([for cups headers])
 240       if test -s /opt/sfw/cups/include/cups/cups.h; then
 241         # An SFW package seems to be installed!
 242         CUPS_FOUND=yes
 243         CUPS_CFLAGS="-I/opt/sfw/cups/include"
 244       elif test -s /opt/csw/include/cups/cups.h; then
 245         # A CSW package seems to be installed!
 246         CUPS_FOUND=yes
 247         CUPS_CFLAGS="-I/opt/csw/include"
 248       fi
 249       AC_MSG_RESULT([$CUPS_FOUND])
 250     fi
 251     if test "x$CUPS_FOUND" = xno; then
 252       HELP_MSG_MISSING_DEPENDENCY([cups])
 253       AC_MSG_ERROR([Could not find cups! $HELP_MSG ])
 254     fi
 255   fi
 256 
 257   AC_SUBST(CUPS_CFLAGS)
 258 
 259 ])
 260 
 261 AC_DEFUN([LIB_CHECK_POTENTIAL_FREETYPE],
 262 [
 263   POTENTIAL_FREETYPE_INCLUDE_PATH="$1"
 264   POTENTIAL_FREETYPE_LIB_PATH="$2"
 265   METHOD="$3"
 266   
 267   # First check if the files exists.
 268   if test -s "$POTENTIAL_FREETYPE_INCLUDE_PATH/ft2build.h"; then
 269     # We found an arbitrary include file. That's a good sign.
 270     AC_MSG_NOTICE([Found freetype include files at $POTENTIAL_FREETYPE_INCLUDE_PATH using $METHOD])
 271     FOUND_FREETYPE=yes
 272 
 273     FREETYPE_LIB_NAME="${LIBRARY_PREFIX}freetype${SHARED_LIBRARY_SUFFIX}"
 274     if ! test -s "$POTENTIAL_FREETYPE_LIB_PATH/$FREETYPE_LIB_NAME"; then
 275       AC_MSG_NOTICE([Could not find $POTENTIAL_FREETYPE_LIB_PATH/$FREETYPE_LIB_NAME. Ignoring location.])
 276       FOUND_FREETYPE=no
 277     else
 278       if test "x$OPENJDK_TARGET_OS" = xwindows; then
 279         # On Windows, we will need both .lib and .dll file.
 280         if ! test -s "$POTENTIAL_FREETYPE_LIB_PATH/freetype.lib"; then
 281           AC_MSG_NOTICE([Could not find $POTENTIAL_FREETYPE_LIB_PATH/freetype.lib. Ignoring location.])
 282           FOUND_FREETYPE=no
 283         fi
 284       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
 285         # On solaris-x86_86, default is (normally) PATH/lib/amd64. Update our guess!
 286         POTENTIAL_FREETYPE_LIB_PATH="$POTENTIAL_FREETYPE_LIB_PATH/amd64"
 287       fi
 288     fi
 289   fi
 290 
 291   if test "x$FOUND_FREETYPE" = xyes; then
 292     BASIC_FIXUP_PATH(POTENTIAL_FREETYPE_INCLUDE_PATH)
 293     BASIC_FIXUP_PATH(POTENTIAL_FREETYPE_LIB_PATH)
 294 
 295     FREETYPE_INCLUDE_PATH="$POTENTIAL_FREETYPE_INCLUDE_PATH"
 296     AC_MSG_CHECKING([for freetype includes])
 297     AC_MSG_RESULT([$FREETYPE_INCLUDE_PATH])
 298     FREETYPE_LIB_PATH="$POTENTIAL_FREETYPE_LIB_PATH"
 299     AC_MSG_CHECKING([for freetype libraries])
 300     AC_MSG_RESULT([$FREETYPE_LIB_PATH])
 301   fi
 302 ])
 303 
 304 AC_DEFUN_ONCE([LIB_SETUP_FREETYPE],
 305 [
 306 
 307   ###############################################################################
 308   #
 309   # The ubiquitous freetype library is used to render fonts.
 310   #
 311   AC_ARG_WITH(freetype, [AS_HELP_STRING([--with-freetype],
 312       [specify prefix directory for the freetype package
 313       (expecting the libraries under PATH/lib and the headers under PATH/include)])])
 314   AC_ARG_WITH(freetype-include, [AS_HELP_STRING([--with-freetype-include],
 315       [specify directory for the freetype include files])])
 316   AC_ARG_WITH(freetype-lib, [AS_HELP_STRING([--with-freetype-lib],
 317       [specify directory for the freetype library])])
 318   AC_ARG_ENABLE(freetype-bundling, [AS_HELP_STRING([--disable-freetype-bundling],
 319       [disable bundling of the freetype library with the build result @<:@enabled on Windows or when using --with-freetype, disabled otherwise@:>@])])
 320 
 321   FREETYPE_CFLAGS=
 322   FREETYPE_LIBS=
 323   FREETYPE_BUNDLE_LIB_PATH=
 324 
 325   if test "x$FREETYPE_NOT_NEEDED" = xyes; then
 326     if test "x$with_freetype" != x || test "x$with_freetype_include" != x || test "x$with_freetype_lib" != x; then
 327       AC_MSG_WARN([freetype not used, so --with-freetype is ignored])
 328     fi
 329     if test "x$enable_freetype_bundling" != x; then
 330       AC_MSG_WARN([freetype not used, so --enable-freetype-bundling is ignored])
 331     fi
 332   else
 333     # freetype is needed to build; go get it!
 334 
 335     BUNDLE_FREETYPE="$enable_freetype_bundling"
 336 
 337     if test "x$with_freetype" != x || test "x$with_freetype_include" != x || test "x$with_freetype_lib" != x; then
 338       # User has specified settings
 339 
 340       if test "x$BUNDLE_FREETYPE" = x; then
 341         # If not specified, default is to bundle freetype
 342         BUNDLE_FREETYPE=yes
 343       fi
 344       
 345       if test "x$with_freetype" != x; then
 346         POTENTIAL_FREETYPE_INCLUDE_PATH="$with_freetype/include"
 347         POTENTIAL_FREETYPE_LIB_PATH="$with_freetype/lib"
 348       fi
 349       
 350       # Allow --with-freetype-lib and --with-freetype-include to override
 351       if test "x$with_freetype_include" != x; then
 352         POTENTIAL_FREETYPE_INCLUDE_PATH="$with_freetype_include"
 353       fi
 354       if test "x$with_freetype_lib" != x; then
 355         POTENTIAL_FREETYPE_LIB_PATH="$with_freetype_lib"
 356       fi
 357 
 358       if test "x$POTENTIAL_FREETYPE_INCLUDE_PATH" != x && test "x$POTENTIAL_FREETYPE_LIB_PATH" != x; then
 359         # Okay, we got it. Check that it works.
 360         LIB_CHECK_POTENTIAL_FREETYPE($POTENTIAL_FREETYPE_INCLUDE_PATH, $POTENTIAL_FREETYPE_LIB_PATH, [--with-freetype])
 361         if test "x$FOUND_FREETYPE" != xyes; then
 362           AC_MSG_ERROR([Can not find or use freetype at location given by --with-freetype])
 363         fi
 364       else
 365         # User specified only one of lib or include. This is an error.
 366         if test "x$POTENTIAL_FREETYPE_INCLUDE_PATH" = x ; then
 367           AC_MSG_NOTICE([User specified --with-freetype-lib but not --with-freetype-include])
 368           AC_MSG_ERROR([Need both freetype lib and include paths. Consider using --with-freetype instead.])
 369         else
 370           AC_MSG_NOTICE([User specified --with-freetype-include but not --with-freetype-lib])
 371           AC_MSG_ERROR([Need both freetype lib and include paths. Consider using --with-freetype instead.])
 372         fi
 373       fi
 374     else
 375       # User did not specify settings, but we need freetype. Try to locate it.
 376 
 377       if test "x$BUNDLE_FREETYPE" = x; then
 378         # If not specified, default is to bundle freetype only on windows
 379         if test "x$OPENJDK_TARGET_OS" = xwindows; then
 380           BUNDLE_FREETYPE=yes
 381         else
 382           BUNDLE_FREETYPE=no
 383         fi
 384       fi
 385 
 386       if test "x$FOUND_FREETYPE" != xyes; then
 387         # Check builddeps
 388         BDEPS_CHECK_MODULE(FREETYPE, freetype2, xxx, [FOUND_FREETYPE=yes], [FOUND_FREETYPE=no])
 389         # BDEPS_CHECK_MODULE will set FREETYPE_CFLAGS and _LIBS, but we don't get a lib path for bundling.
 390         if test "x$FOUND_FREETYPE" = xyes; then
 391           if test "x$BUNDLE_FREETYPE" = xyes; then
 392             AC_MSG_NOTICE([Found freetype using builddeps, but ignoring since we can not bundle that])
 393             FOUND_FREETYPE=no
 394           else
 395             AC_MSG_CHECKING([for freetype])
 396             AC_MSG_RESULT([yes (using builddeps)])
 397           fi
 398         fi
 399       fi
 400 
 401       if test "x$FOUND_FREETYPE" != xyes; then
 402         # Check modules using pkg-config, but only if we have it (ugly output results otherwise)
 403         if test "x$PKG_CONFIG" != x; then
 404           PKG_CHECK_MODULES(FREETYPE, freetype2, [FOUND_FREETYPE=yes], [FOUND_FREETYPE=no])
 405           if test "x$FOUND_FREETYPE" = xyes; then
 406             # On solaris, pkg_check adds -lz to freetype libs, which isn't necessary for us.
 407             FREETYPE_LIBS=`$ECHO $FREETYPE_LIBS | $SED 's/-lz//g'`
 408             # 64-bit libs for Solaris x86 are installed in the amd64 subdirectory, change lib to lib/amd64
 409             if test "x$OPENJDK_TARGET_OS" = xsolaris && test "x$OPENJDK_TARGET_CPU" = xx86_64; then
 410               FREETYPE_LIBS=`$ECHO $FREETYPE_LIBS | $SED 's?/lib?/lib/amd64?g'`
 411             fi
 412             # BDEPS_CHECK_MODULE will set FREETYPE_CFLAGS and _LIBS, but we don't get a lib path for bundling.
 413             if test "x$BUNDLE_FREETYPE" = xyes; then
 414               AC_MSG_NOTICE([Found freetype using pkg-config, but ignoring since we can not bundle that])
 415               FOUND_FREETYPE=no
 416             else
 417               AC_MSG_CHECKING([for freetype])
 418               AC_MSG_RESULT([yes (using pkg-config)])
 419             fi
 420           fi
 421         fi
 422       fi
 423 
 424       if test "x$FOUND_FREETYPE" != xyes; then
 425         # Check in well-known locations
 426         if test "x$OPENJDK_TARGET_OS" = xwindows; then
 427           FREETYPE_BASE_DIR="$PROGRAMFILES/GnuWin32"
 428           BASIC_WINDOWS_REWRITE_AS_UNIX_PATH(FREETYPE_BASE_DIR)
 429           LIB_CHECK_POTENTIAL_FREETYPE([$FREETYPE_BASE_DIR/include], [$FREETYPE_BASE_DIR/lib], [well-known location])
 430           if test "x$FOUND_FREETYPE" != xyes; then
 431             FREETYPE_BASE_DIR="$ProgramW6432/GnuWin32"
 432             BASIC_WINDOWS_REWRITE_AS_UNIX_PATH(FREETYPE_BASE_DIR)
 433             LIB_CHECK_POTENTIAL_FREETYPE([$FREETYPE_BASE_DIR/include], [$FREETYPE_BASE_DIR/lib], [well-known location])
 434           fi
 435         else
 436           if test "x$SYS_ROOT" = "x/"; then
 437             FREETYPE_ROOT=
 438           else
 439             FREETYPE_ROOT="$SYS_ROOT"
 440           fi
 441           FREETYPE_BASE_DIR="$FREETYPE_ROOT/usr"
 442           LIB_CHECK_POTENTIAL_FREETYPE([$FREETYPE_BASE_DIR/include], [$FREETYPE_BASE_DIR/lib], [well-known location])
 443 
 444           if test "x$FOUND_FREETYPE" != xyes; then
 445             FREETYPE_BASE_DIR="$FREETYPE_ROOT/usr/X11"
 446             LIB_CHECK_POTENTIAL_FREETYPE([$FREETYPE_BASE_DIR/include], [$FREETYPE_BASE_DIR/lib], [well-known location])
 447           fi
 448 
 449           if test "x$FOUND_FREETYPE" != xyes; then
 450             FREETYPE_BASE_DIR="$FREETYPE_ROOT/usr"
 451             if test "x$OPENJDK_TARGET_CPU_BITS" = x64; then
 452               LIB_CHECK_POTENTIAL_FREETYPE([$FREETYPE_BASE_DIR/include], [$FREETYPE_BASE_DIR/lib/x86_64-linux-gnu], [well-known location])
 453             else
 454               LIB_CHECK_POTENTIAL_FREETYPE([$FREETYPE_BASE_DIR/include], [$FREETYPE_BASE_DIR/lib/i386-linux-gnu], [well-known location])
 455               if test "x$FOUND_FREETYPE" != xyes; then
 456                 LIB_CHECK_POTENTIAL_FREETYPE([$FREETYPE_BASE_DIR/include], [$FREETYPE_BASE_DIR/lib32], [well-known location])
 457               fi
 458             fi
 459           fi
 460         fi
 461       fi # end check in well-known locations
 462 
 463       if test "x$FOUND_FREETYPE" != xyes; then
 464         HELP_MSG_MISSING_DEPENDENCY([freetype])
 465         AC_MSG_ERROR([Could not find freetype! $HELP_MSG ])
 466       fi
 467     fi # end user specified settings
 468 
 469     # Set FREETYPE_CFLAGS, _LIBS and _LIB_PATH from include and lib dir.
 470     if test "x$FREETYPE_CFLAGS" = x; then
 471       BASIC_FIXUP_PATH(FREETYPE_INCLUDE_PATH)
 472       if test -d $FREETYPE_INCLUDE_PATH/freetype2/freetype; then
 473         FREETYPE_CFLAGS="-I$FREETYPE_INCLUDE_PATH/freetype2 -I$FREETYPE_INCLUDE_PATH"
 474       else
 475         FREETYPE_CFLAGS="-I$FREETYPE_INCLUDE_PATH"
 476       fi
 477     fi
 478     
 479     if test "x$FREETYPE_LIBS" = x; then
 480       BASIC_FIXUP_PATH(FREETYPE_LIB_PATH)
 481       if test "x$OPENJDK_TARGET_OS" = xwindows; then
 482         FREETYPE_LIBS="$FREETYPE_LIB_PATH/freetype.lib"
 483       else
 484         FREETYPE_LIBS="-L$FREETYPE_LIB_PATH -lfreetype"
 485       fi
 486     fi
 487 
 488     # Try to compile it
 489     AC_MSG_CHECKING([if we can compile and link with freetype])
 490     AC_LANG_PUSH(C++)
 491     PREV_CXXCFLAGS="$CXXFLAGS"
 492     PREV_LIBS="$LIBS"
 493     PREV_CXX="$CXX"
 494     CXXFLAGS="$CXXFLAGS $FREETYPE_CFLAGS" 
 495     LIBS="$LIBS $FREETYPE_LIBS"
 496     CXX="$FIXPATH $CXX"
 497     AC_LINK_IFELSE([AC_LANG_SOURCE([[
 498           #include<ft2build.h>
 499           #include FT_FREETYPE_H
 500           int main () {
 501             FT_Init_FreeType(NULL);
 502             return 0;
 503           }
 504         ]])],
 505         [
 506           AC_MSG_RESULT([yes])
 507         ],
 508         [
 509           AC_MSG_RESULT([no])
 510           AC_MSG_NOTICE([Could not compile and link with freetype. This might be a 32/64-bit mismatch.])
 511           AC_MSG_NOTICE([Using FREETYPE_CFLAGS=$FREETYPE_CFLAGS and FREETYPE_LIBS=$FREETYPE_LIBS])
 512           
 513           HELP_MSG_MISSING_DEPENDENCY([freetype])
 514           
 515           AC_MSG_ERROR([Can not continue without freetype. $HELP_MSG])
 516         ]
 517     )
 518     CXXCFLAGS="$PREV_CXXFLAGS"
 519     LIBS="$PREV_LIBS"
 520     CXX="$PREV_CXX"
 521     AC_LANG_POP(C++)
 522 
 523     AC_MSG_CHECKING([if we should bundle freetype])
 524     if test "x$BUNDLE_FREETYPE" = xyes; then
 525       FREETYPE_BUNDLE_LIB_PATH="$FREETYPE_LIB_PATH"
 526     fi
 527     AC_MSG_RESULT([$BUNDLE_FREETYPE])
 528 
 529   fi # end freetype needed
 530 
 531   AC_SUBST(FREETYPE_BUNDLE_LIB_PATH)
 532   AC_SUBST(FREETYPE_CFLAGS)
 533   AC_SUBST(FREETYPE_LIBS)
 534 ])
 535 
 536 AC_DEFUN_ONCE([LIB_SETUP_ALSA],
 537 [
 538 
 539   ###############################################################################
 540   #
 541   # Check for alsa headers and libraries. Used on Linux/GNU systems.
 542   #
 543   AC_ARG_WITH(alsa, [AS_HELP_STRING([--with-alsa],
 544       [specify prefix directory for the alsa package
 545       (expecting the libraries under PATH/lib and the headers under PATH/include)])])
 546   AC_ARG_WITH(alsa-include, [AS_HELP_STRING([--with-alsa-include],
 547       [specify directory for the alsa include files])])
 548   AC_ARG_WITH(alsa-lib, [AS_HELP_STRING([--with-alsa-lib],
 549       [specify directory for the alsa library])])
 550 
 551   if test "x$ALSA_NOT_NEEDED" = xyes; then
 552     if test "x${with_alsa}" != x || test "x${with_alsa_include}" != x || test "x${with_alsa_lib}" != x; then
 553       AC_MSG_WARN([alsa not used, so --with-alsa is ignored])
 554     fi
 555     ALSA_CFLAGS=
 556     ALSA_LIBS=
 557   else
 558     ALSA_FOUND=no
 559 
 560     if test "x${with_alsa}" = xno || test "x${with_alsa_include}" = xno || test "x${with_alsa_lib}" = xno; then
 561       AC_MSG_ERROR([It is not possible to disable the use of alsa. Remove the --without-alsa option.])
 562     fi
 563 
 564     if test "x${with_alsa}" != x; then
 565       ALSA_LIBS="-L${with_alsa}/lib -lasound"
 566       ALSA_CFLAGS="-I${with_alsa}/include"
 567       ALSA_FOUND=yes
 568     fi
 569     if test "x${with_alsa_include}" != x; then
 570       ALSA_CFLAGS="-I${with_alsa_include}"
 571       ALSA_FOUND=yes
 572     fi
 573     if test "x${with_alsa_lib}" != x; then
 574       ALSA_LIBS="-L${with_alsa_lib} -lasound"
 575       ALSA_FOUND=yes
 576     fi
 577     if test "x$ALSA_FOUND" = xno; then
 578       BDEPS_CHECK_MODULE(ALSA, alsa, xxx, [ALSA_FOUND=yes], [ALSA_FOUND=no])
 579     fi
 580     if test "x$ALSA_FOUND" = xno; then
 581       PKG_CHECK_MODULES(ALSA, alsa, [ALSA_FOUND=yes], [ALSA_FOUND=no])
 582     fi
 583     if test "x$ALSA_FOUND" = xno; then
 584       AC_CHECK_HEADERS([alsa/asoundlib.h],
 585           [
 586             ALSA_FOUND=yes
 587             ALSA_CFLAGS=-Iignoreme
 588             ALSA_LIBS=-lasound
 589             DEFAULT_ALSA=yes
 590           ],
 591           [ALSA_FOUND=no])
 592     fi
 593     if test "x$ALSA_FOUND" = xno; then
 594       HELP_MSG_MISSING_DEPENDENCY([alsa])
 595       AC_MSG_ERROR([Could not find alsa! $HELP_MSG ])
 596     fi
 597   fi
 598 
 599   AC_SUBST(ALSA_CFLAGS)
 600   AC_SUBST(ALSA_LIBS)
 601 ])
 602 
 603 AC_DEFUN_ONCE([LIB_SETUP_MISC_LIBS],
 604 [
 605 
 606   ###############################################################################
 607   #
 608   # Check for the jpeg library
 609   #
 610 
 611   USE_EXTERNAL_LIBJPEG=true
 612   AC_CHECK_LIB(jpeg, main, [],
 613       [ USE_EXTERNAL_LIBJPEG=false
 614       AC_MSG_NOTICE([Will use jpeg decoder bundled with the OpenJDK source])
 615   ])
 616   AC_SUBST(USE_EXTERNAL_LIBJPEG)
 617 
 618   ###############################################################################
 619   #
 620   # Check for the gif library
 621   #
 622 
 623   AC_ARG_WITH(giflib, [AS_HELP_STRING([--with-giflib],
 624       [use giflib from build system or OpenJDK source (system, bundled) @<:@bundled@:>@])])
 625 
 626 
 627   AC_MSG_CHECKING([for which giflib to use])
 628 
 629   # default is bundled
 630   DEFAULT_GIFLIB=bundled
 631 
 632   #
 633   # if user didn't specify, use DEFAULT_GIFLIB
 634   #
 635   if test "x${with_giflib}" = "x"; then
 636     with_giflib=${DEFAULT_GIFLIB}
 637   fi
 638 
 639   AC_MSG_RESULT(${with_giflib})
 640 
 641   if test "x${with_giflib}" = "xbundled"; then
 642     USE_EXTERNAL_LIBGIF=false
 643   elif test "x${with_giflib}" = "xsystem"; then
 644     AC_CHECK_HEADER(gif_lib.h, [],
 645         [ AC_MSG_ERROR([--with-giflib=system specified, but gif_lib.h not found!])])
 646     AC_CHECK_LIB(gif, DGifGetCode, [],
 647         [ AC_MSG_ERROR([--with-giflib=system specified, but no giflib found!])])
 648 
 649     USE_EXTERNAL_LIBGIF=true
 650   else
 651     AC_MSG_ERROR([Invalid value of --with-giflib: ${with_giflib}, use 'system' or 'bundled'])
 652   fi
 653   AC_SUBST(USE_EXTERNAL_LIBGIF)
 654 
 655   ###############################################################################
 656   #
 657   # Check for the png library
 658   #
 659 
 660   AC_ARG_WITH(libpng, [AS_HELP_STRING([--with-libpng],
 661      [use libpng from build system or OpenJDK source (system, bundled) @<:@bundled@:>@])])
 662 
 663 
 664   AC_MSG_CHECKING([for which libpng to use])
 665 
 666   # default is bundled
 667   DEFAULT_LIBPNG=bundled
 668 
 669   #
 670   # if user didn't specify, use DEFAULT_LIBPNG
 671   #
 672   if test "x${with_libpng}" = "x"; then
 673       with_libpng=${DEFAULT_LIBPNG}
 674   fi
 675 
 676   if test "x${with_libpng}" = "xbundled"; then
 677       USE_EXTERNAL_LIBPNG=false
 678       AC_MSG_RESULT([bundled])
 679   elif test "x${with_libpng}" = "xsystem"; then
 680       PKG_CHECK_MODULES(PNG, libpng,
 681                    [ LIBPNG_FOUND=yes ],
 682                    [ LIBPNG_FOUND=no ])
 683       if test "x${LIBPNG_FOUND}" = "xyes"; then
 684           USE_EXTERNAL_LIBPNG=true
 685           AC_MSG_RESULT([system])
 686       else
 687           AC_MSG_RESULT([system not found])
 688           AC_MSG_ERROR([--with-libpng=system specified, but no libpng found!])
 689       fi
 690   else
 691       AC_MSG_ERROR([Invalid value of --with-libpng: ${with_libpng}, use 'system' or 'bundled'])
 692   fi
 693   AC_SUBST(USE_EXTERNAL_LIBPNG)
 694 
 695   ###############################################################################
 696   #
 697   # Check for the zlib library
 698   #
 699 
 700   AC_ARG_WITH(zlib, [AS_HELP_STRING([--with-zlib],
 701       [use zlib from build system or OpenJDK source (system, bundled) @<:@bundled@:>@])])
 702 
 703   AC_CHECK_LIB(z, compress,
 704       [ ZLIB_FOUND=yes ],
 705       [ ZLIB_FOUND=no ])
 706 
 707   AC_MSG_CHECKING([for which zlib to use])
 708 
 709   DEFAULT_ZLIB=bundled
 710   if test "x$OPENJDK_TARGET_OS" = xmacosx; then
 711     #
 712     # On macosx default is system...on others default is
 713     #
 714     DEFAULT_ZLIB=system
 715   fi
 716 
 717   if test "x${ZLIB_FOUND}" != "xyes"; then
 718     #
 719     # If we don't find any system...set default to bundled
 720     #
 721     DEFAULT_ZLIB=bundled
 722   fi
 723 
 724   #
 725   # If user didn't specify, use DEFAULT_ZLIB
 726   #
 727   if test "x${with_zlib}" = "x"; then
 728     with_zlib=${DEFAULT_ZLIB}
 729   fi
 730 
 731   if test "x${with_zlib}" = "xbundled"; then
 732     USE_EXTERNAL_LIBZ=false
 733     AC_MSG_RESULT([bundled])
 734   elif test "x${with_zlib}" = "xsystem"; then
 735     if test "x${ZLIB_FOUND}" = "xyes"; then
 736       USE_EXTERNAL_LIBZ=true
 737       AC_MSG_RESULT([system])
 738     else
 739       AC_MSG_RESULT([system not found])
 740       AC_MSG_ERROR([--with-zlib=system specified, but no zlib found!])
 741     fi
 742   else
 743     AC_MSG_ERROR([Invalid value for --with-zlib: ${with_zlib}, use 'system' or 'bundled'])
 744   fi
 745 
 746   AC_SUBST(USE_EXTERNAL_LIBZ)
 747 
 748   ###############################################################################
 749   LIBZIP_CAN_USE_MMAP=true
 750 
 751   AC_SUBST(LIBZIP_CAN_USE_MMAP)
 752 
 753   ###############################################################################
 754   #
 755   # Check if altzone exists in time.h
 756   #
 757 
 758   AC_LINK_IFELSE([AC_LANG_PROGRAM([#include <time.h>], [return (int)altzone;])],
 759       [has_altzone=yes],
 760       [has_altzone=no])
 761   if test "x$has_altzone" = xyes; then
 762     AC_DEFINE([HAVE_ALTZONE], 1, [Define if you have the external 'altzone' variable in time.h])
 763   fi
 764 
 765   ###############################################################################
 766   #
 767   # Check the maths library
 768   #
 769 
 770   AC_CHECK_LIB(m, cos, [],
 771       [
 772         AC_MSG_NOTICE([Maths library was not found])
 773       ]
 774   )
 775   AC_SUBST(LIBM)
 776 
 777   ###############################################################################
 778   #
 779   # Check for libdl.so
 780 
 781   save_LIBS="$LIBS"
 782   LIBS=""
 783   AC_CHECK_LIB(dl,dlopen)
 784   LIBDL="$LIBS"
 785   AC_SUBST(LIBDL)
 786   LIBS="$save_LIBS"
 787 ])
 788 
 789 AC_DEFUN_ONCE([LIB_SETUP_STATIC_LINK_LIBSTDCPP],
 790 [
 791   ###############################################################################
 792   #
 793   # statically link libstdc++ before C++ ABI is stablized on Linux unless
 794   # dynamic build is configured on command line.
 795   #
 796   AC_ARG_WITH([stdc++lib], [AS_HELP_STRING([--with-stdc++lib=<static>,<dynamic>,<default>],
 797       [force linking of the C++ runtime on Linux to either static or dynamic, default is static with dynamic as fallback])],
 798       [
 799         if test "x$with_stdc__lib" != xdynamic && test "x$with_stdc__lib" != xstatic \
 800                 && test "x$with_stdc__lib" != xdefault; then
 801           AC_MSG_ERROR([Bad parameter value --with-stdc++lib=$with_stdc__lib!])
 802         fi
 803       ],
 804       [with_stdc__lib=default]
 805   )
 806 
 807   if test "x$OPENJDK_TARGET_OS" = xlinux; then
 808     # Test if -lstdc++ works.
 809     AC_MSG_CHECKING([if dynamic link of stdc++ is possible])
 810     AC_LANG_PUSH(C++)
 811     OLD_CXXFLAGS="$CXXFLAGS"
 812     CXXFLAGS="$CXXFLAGS -lstdc++"
 813     AC_LINK_IFELSE([AC_LANG_PROGRAM([], [return 0;])],
 814         [has_dynamic_libstdcxx=yes],
 815         [has_dynamic_libstdcxx=no])
 816     CXXFLAGS="$OLD_CXXFLAGS"
 817     AC_LANG_POP(C++)
 818     AC_MSG_RESULT([$has_dynamic_libstdcxx])
 819 
 820     # Test if stdc++ can be linked statically.
 821     AC_MSG_CHECKING([if static link of stdc++ is possible])
 822     STATIC_STDCXX_FLAGS="-Wl,-Bstatic -lstdc++ -lgcc -Wl,-Bdynamic"
 823     AC_LANG_PUSH(C++)
 824     OLD_LIBS="$LIBS"
 825     OLD_CXX="$CXX"
 826     LIBS="$STATIC_STDCXX_FLAGS"
 827     CXX="$CC"
 828     AC_LINK_IFELSE([AC_LANG_PROGRAM([], [return 0;])],
 829         [has_static_libstdcxx=yes],
 830         [has_static_libstdcxx=no])
 831     LIBS="$OLD_LIBS"
 832     CXX="$OLD_CXX"
 833     AC_LANG_POP(C++)
 834     AC_MSG_RESULT([$has_static_libstdcxx])
 835 
 836     if test "x$has_static_libstdcxx" = xno && test "x$has_dynamic_libstdcxx" = xno; then
 837       AC_MSG_ERROR([Cannot link to stdc++, neither dynamically nor statically!])
 838     fi
 839 
 840     if test "x$with_stdc__lib" = xstatic && test "x$has_static_libstdcxx" = xno; then
 841       AC_MSG_ERROR([Static linking of libstdc++ was not possible!])
 842     fi
 843 
 844     if test "x$with_stdc__lib" = xdynamic && test "x$has_dynamic_libstdcxx" = xno; then
 845       AC_MSG_ERROR([Dynamic linking of libstdc++ was not possible!])
 846     fi
 847 
 848     AC_MSG_CHECKING([how to link with libstdc++])
 849     # If dynamic was requested, it's available since it would fail above otherwise.
 850     # If dynamic wasn't requested, go with static unless it isn't available.
 851     if test "x$with_stdc__lib" = xdynamic || test "x$has_static_libstdcxx" = xno || test "x$JVM_VARIANT_ZEROSHARK" = xtrue; then
 852       LIBCXX="$LIBCXX -lstdc++"
 853       LDCXX="$CXX"
 854       STATIC_CXX_SETTING="STATIC_CXX=false"
 855       AC_MSG_RESULT([dynamic])
 856     else
 857       LIBCXX="$LIBCXX $STATIC_STDCXX_FLAGS"
 858       LDCXX="$CC"
 859       STATIC_CXX_SETTING="STATIC_CXX=true"
 860       AC_MSG_RESULT([static])
 861     fi
 862   fi
 863   AC_SUBST(STATIC_CXX_SETTING)
 864 
 865   if test "x$JVM_VARIANT_ZERO" = xtrue || test "x$JVM_VARIANT_ZEROSHARK" = xtrue; then
 866     # Figure out LIBFFI_CFLAGS and LIBFFI_LIBS
 867     PKG_CHECK_MODULES([LIBFFI], [libffi])
 868 
 869   fi
 870 
 871   if test "x$JVM_VARIANT_ZEROSHARK" = xtrue; then
 872     AC_CHECK_PROG([LLVM_CONFIG], [llvm-config], [llvm-config])
 873 
 874     if test "x$LLVM_CONFIG" != xllvm-config; then
 875       AC_MSG_ERROR([llvm-config not found in $PATH.])
 876     fi
 877 
 878     llvm_components="jit mcjit engine nativecodegen native"
 879     unset LLVM_CFLAGS
 880     for flag in $("$LLVM_CONFIG" --cxxflags); do
 881       if echo "${flag}" | grep -q '^-@<:@ID@:>@'; then
 882         if test "${flag}" != "-D_DEBUG" ; then
 883           if test "${LLVM_CFLAGS}" != "" ; then
 884             LLVM_CFLAGS="${LLVM_CFLAGS} "
 885           fi
 886           LLVM_CFLAGS="${LLVM_CFLAGS}${flag}"
 887         fi
 888       fi
 889     done
 890     llvm_version=$("${LLVM_CONFIG}" --version | sed 's/\.//; s/svn.*//')
 891     LLVM_CFLAGS="${LLVM_CFLAGS} -DSHARK_LLVM_VERSION=${llvm_version}"
 892 
 893     unset LLVM_LDFLAGS
 894     for flag in $("${LLVM_CONFIG}" --ldflags); do
 895       if echo "${flag}" | grep -q '^-L'; then
 896         if test "${LLVM_LDFLAGS}" != ""; then
 897           LLVM_LDFLAGS="${LLVM_LDFLAGS} "
 898         fi
 899         LLVM_LDFLAGS="${LLVM_LDFLAGS}${flag}"
 900       fi
 901     done
 902 
 903     unset LLVM_LIBS
 904     for flag in $("${LLVM_CONFIG}" --libs ${llvm_components}); do
 905       if echo "${flag}" | grep -q '^-l'; then
 906         if test "${LLVM_LIBS}" != ""; then
 907           LLVM_LIBS="${LLVM_LIBS} "
 908         fi
 909         LLVM_LIBS="${LLVM_LIBS}${flag}"
 910       fi
 911     done
 912 
 913     AC_SUBST(LLVM_CFLAGS)
 914     AC_SUBST(LLVM_LDFLAGS)
 915     AC_SUBST(LLVM_LIBS)
 916   fi
 917 
 918   # libCrun is the c++ runtime-library with SunStudio (roughly the equivalent of gcc's libstdc++.so)
 919   if test "x$TOOLCHAIN_TYPE" = xsolstudio && test "x$LIBCXX" = x; then
 920     LIBCXX="/usr/lib${OPENJDK_TARGET_CPU_ISADIR}/libCrun.so.1"
 921   fi
 922 
 923   # TODO better (platform agnostic) test
 924   if test "x$OPENJDK_TARGET_OS" = xmacosx && test "x$LIBCXX" = x && test "x$TOOLCHAIN_TYPE" = xgcc; then
 925     LIBCXX="-lstdc++"
 926   fi
 927 
 928   AC_SUBST(LIBCXX)
 929 ])
 930 
 931 AC_DEFUN_ONCE([LIB_SETUP_ON_WINDOWS],
 932 [
 933   if test "x$OPENJDK_TARGET_OS" = "xwindows"; then
 934     TOOLCHAIN_SETUP_MSVCR_DLL
 935     BASIC_DEPRECATED_ARG_WITH([dxsdk])
 936     BASIC_DEPRECATED_ARG_WITH([dxsdk-lib])
 937     BASIC_DEPRECATED_ARG_WITH([dxsdk-include])
 938   fi
 939   AC_SUBST(MSVCR_DLL)
 940 ])