libraries.m4 29.8 KB
Newer Older
1
#
2
# Copyright (c) 2011, 2018, Oracle and/or its affiliates. All rights reserved.
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License version 2 only, as
# published by the Free Software Foundation.  Oracle designates this
# particular file as subject to the "Classpath" exception as provided
# by Oracle in the LICENSE file that accompanied this code.
#
# This code is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
# version 2 for more details (a copy is included in the LICENSE file that
# accompanied this code).
#
# You should have received a copy of the GNU General Public License version
# 2 along with this work; if not, write to the Free Software Foundation,
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
#
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
# or visit www.oracle.com if you need additional information or have any
# questions.
#

AC_DEFUN_ONCE([LIB_SETUP_INIT],
[
28 29 30 31 32 33

  ###############################################################################
  #
  # OS specific settings that we never will need to probe.
  #
  if test "x$OPENJDK_TARGET_OS" = xlinux; then
34 35 36
    AC_MSG_CHECKING([what is not needed on Linux?])
    PULSE_NOT_NEEDED=yes
    AC_MSG_RESULT([pulse])
37
  fi
38

39
  if test "x$OPENJDK_TARGET_OS" = xsolaris; then
40 41 42 43
    AC_MSG_CHECKING([what is not needed on Solaris?])
    ALSA_NOT_NEEDED=yes
    PULSE_NOT_NEEDED=yes
    AC_MSG_RESULT([alsa pulse])
44
  fi
45

K
Merge  
kvn 已提交
46
  if test "x$OPENJDK_TARGET_OS" = xaix; then
S
simonis 已提交
47 48 49 50
    AC_MSG_CHECKING([what is not needed on AIX?])
    ALSA_NOT_NEEDED=yes
    PULSE_NOT_NEEDED=yes
    AC_MSG_RESULT([alsa pulse])
K
Merge  
kvn 已提交
51
  fi
S
simonis 已提交
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 58 59 60
    ALSA_NOT_NEEDED=yes
    PULSE_NOT_NEEDED=yes
    X11_NOT_NEEDED=yes
    AC_MSG_RESULT([alsa cups pulse x11])
61
  fi
62

63
  if test "x$OPENJDK_TARGET_OS" = xmacosx; then
64 65 66 67 68
    AC_MSG_CHECKING([what is not needed on MacOSX?])
    ALSA_NOT_NEEDED=yes
    PULSE_NOT_NEEDED=yes
    X11_NOT_NEEDED=yes
    AC_MSG_RESULT([alsa pulse x11])
69
  fi
70

71
  if test "x$OPENJDK_TARGET_OS" = xbsd; then
72 73
    AC_MSG_CHECKING([what is not needed on bsd?])
    ALSA_NOT_NEEDED=yes
74 75
    AC_MSG_RESULT([alsa])
  fi
76

77
  if test "x$OPENJDK" = "xfalse"; then
I
ihse 已提交
78
    FREETYPE_NOT_NEEDED=yes
79
  fi
80

81
  if test "x$SUPPORT_HEADFUL" = xno; then
82
    X11_NOT_NEEDED=yes
83
  fi
84

85
  # Deprecated and now ignored
86
  BASIC_DEPRECATED_ARG_ENABLE(macosx-runtime-support, macosx_runtime_support)
87 88 89 90 91
])

AC_DEFUN_ONCE([LIB_SETUP_X11],
[

92 93 94 95 96 97 98 99 100 101 102 103 104 105 106
  ###############################################################################
  #
  # Check for X Windows
  #

  # Check if the user has specified sysroot, but not --x-includes or --x-libraries.
  # Make a simple check for the libraries at the sysroot, and setup --x-includes and
  # --x-libraries for the sysroot, if that seems to be correct.
  if test "x$SYS_ROOT" != "x/"; then
    if test "x$x_includes" = xNONE; then
      if test -f "$SYS_ROOT/usr/X11R6/include/X11/Xlib.h"; then
        x_includes="$SYS_ROOT/usr/X11R6/include"
      elif test -f "$SYS_ROOT/usr/include/X11/Xlib.h"; then
        x_includes="$SYS_ROOT/usr/include"
      fi
107
    fi
108 109 110 111 112 113 114 115
    if test "x$x_libraries" = xNONE; then
      if test -f "$SYS_ROOT/usr/X11R6/lib/libX11.so"; then
        x_libraries="$SYS_ROOT/usr/X11R6/lib"
      elif test "$SYS_ROOT/usr/lib64/libX11.so" && test "x$OPENJDK_TARGET_CPU_BITS" = x64; then
        x_libraries="$SYS_ROOT/usr/lib64"
      elif test -f "$SYS_ROOT/usr/lib/libX11.so"; then
        x_libraries="$SYS_ROOT/usr/lib"
      fi
116 117 118
    fi
  fi

119 120 121
  # Now let autoconf do it's magic
  AC_PATH_X
  AC_PATH_XTRA
122

123 124 125 126 127
  # AC_PATH_XTRA creates X_LIBS and sometimes adds -R flags. When cross compiling
  # this doesn't make sense so we remove it.
  if test "x$COMPILE_TYPE" = xcross; then
    X_LIBS=`$ECHO $X_LIBS | $SED 's/-R \{0,1\}[[^ ]]*//g'`
  fi
128

129
  if test "x$no_x" = xyes && test "x$X11_NOT_NEEDED" != xyes; then
130 131
    HELP_MSG_MISSING_DEPENDENCY([x11])
    AC_MSG_ERROR([Could not find X11 libraries. $HELP_MSG])
132
  fi
133

134
  if test "x$OPENJDK_TARGET_OS" = xsolaris; then
135
    OPENWIN_HOME="/usr/openwin"
136 137
  fi
  AC_SUBST(OPENWIN_HOME)
138 139


140 141 142 143 144 145 146 147 148
  #
  # Weird Sol10 something check...TODO change to try compile
  #
  if test "x${OPENJDK_TARGET_OS}" = xsolaris; then
    if test "`uname -r`" = "5.10"; then
      if test "`${EGREP} -c XLinearGradient ${OPENWIN_HOME}/share/include/X11/extensions/Xrender.h`" = "0"; then
        X_CFLAGS="${X_CFLAGS} -DSOLARIS10_NO_XRENDER_STRUCTS"
      fi
    fi
149 150
  fi

151 152 153
  AC_LANG_PUSH(C)
  OLD_CFLAGS="$CFLAGS"
  CFLAGS="$CFLAGS $X_CFLAGS"
O
ohair 已提交
154

155 156 157 158 159 160 161 162 163
  # Need to include Xlib.h and Xutil.h to avoid "present but cannot be compiled" warnings on Solaris 10
  AC_CHECK_HEADERS([X11/extensions/shape.h X11/extensions/Xrender.h X11/extensions/XTest.h X11/Intrinsic.h],
      [X11_A_OK=yes],
      [X11_A_OK=no; break],
      [
        # include <X11/Xlib.h>
        # include <X11/Xutil.h>
      ]
  )
O
ohair 已提交
164

165 166
  CFLAGS="$OLD_CFLAGS"
  AC_LANG_POP(C)
167

168
  if test "x$X11_A_OK" = xno && test "x$X11_NOT_NEEDED" != xyes; then
169
    HELP_MSG_MISSING_DEPENDENCY([x11])
170
    AC_MSG_ERROR([Could not find all X11 headers (shape.h Xrender.h XTest.h Intrinsic.h). $HELP_MSG])
171
  fi
172

173 174
  AC_SUBST(X_CFLAGS)
  AC_SUBST(X_LIBS)
175 176 177 178 179
])

AC_DEFUN_ONCE([LIB_SETUP_CUPS],
[

180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244
  ###############################################################################
  #
  # The common unix printing system cups is used to print from java.
  #
  AC_ARG_WITH(cups, [AS_HELP_STRING([--with-cups],
      [specify prefix directory for the cups package
      (expecting the headers under PATH/include)])])
  AC_ARG_WITH(cups-include, [AS_HELP_STRING([--with-cups-include],
      [specify directory for the cups include files])])

  if test "x$CUPS_NOT_NEEDED" = xyes; then
    if test "x${with_cups}" != x || test "x${with_cups_include}" != x; then
      AC_MSG_WARN([cups not used, so --with-cups is ignored])
    fi
    CUPS_CFLAGS=
  else
    CUPS_FOUND=no

    if test "x${with_cups}" = xno || test "x${with_cups_include}" = xno; then
      AC_MSG_ERROR([It is not possible to disable the use of cups. Remove the --without-cups option.])
    fi

    if test "x${with_cups}" != x; then
      CUPS_CFLAGS="-I${with_cups}/include"
      CUPS_FOUND=yes
    fi
    if test "x${with_cups_include}" != x; then
      CUPS_CFLAGS="-I${with_cups_include}"
      CUPS_FOUND=yes
    fi
    if test "x$CUPS_FOUND" = xno; then
      BDEPS_CHECK_MODULE(CUPS, cups, xxx, [CUPS_FOUND=yes])
    fi
    if test "x$CUPS_FOUND" = xno; then
      # Are the cups headers installed in the default /usr/include location?
      AC_CHECK_HEADERS([cups/cups.h cups/ppd.h],
          [
            CUPS_FOUND=yes
            CUPS_CFLAGS=
            DEFAULT_CUPS=yes
          ]
      )
    fi
    if test "x$CUPS_FOUND" = xno; then
      # Getting nervous now? Lets poke around for standard Solaris third-party
      # package installation locations.
      AC_MSG_CHECKING([for cups headers])
      if test -s /opt/sfw/cups/include/cups/cups.h; then
        # An SFW package seems to be installed!
        CUPS_FOUND=yes
        CUPS_CFLAGS="-I/opt/sfw/cups/include"
      elif test -s /opt/csw/include/cups/cups.h; then
        # A CSW package seems to be installed!
        CUPS_FOUND=yes
        CUPS_CFLAGS="-I/opt/csw/include"
      fi
      AC_MSG_RESULT([$CUPS_FOUND])
    fi
    if test "x$CUPS_FOUND" = xno; then
      HELP_MSG_MISSING_DEPENDENCY([cups])
      AC_MSG_ERROR([Could not find cups! $HELP_MSG ])
    fi
  fi

  AC_SUBST(CUPS_CFLAGS)
245 246 247

])

I
ihse 已提交
248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290
AC_DEFUN([LIB_CHECK_POTENTIAL_FREETYPE],
[
  POTENTIAL_FREETYPE_INCLUDE_PATH="$1"
  POTENTIAL_FREETYPE_LIB_PATH="$2"
  METHOD="$3"
  
  # First check if the files exists.
  if test -s "$POTENTIAL_FREETYPE_INCLUDE_PATH/ft2build.h"; then
    # We found an arbitrary include file. That's a good sign.
    AC_MSG_NOTICE([Found freetype include files at $POTENTIAL_FREETYPE_INCLUDE_PATH using $METHOD])
    FOUND_FREETYPE=yes

    FREETYPE_LIB_NAME="${LIBRARY_PREFIX}freetype${SHARED_LIBRARY_SUFFIX}"
    if ! test -s "$POTENTIAL_FREETYPE_LIB_PATH/$FREETYPE_LIB_NAME"; then
      AC_MSG_NOTICE([Could not find $POTENTIAL_FREETYPE_LIB_PATH/$FREETYPE_LIB_NAME. Ignoring location.])
      FOUND_FREETYPE=no
    else
      if test "x$OPENJDK_TARGET_OS" = xwindows; then
        # On Windows, we will need both .lib and .dll file.
        if ! test -s "$POTENTIAL_FREETYPE_LIB_PATH/freetype.lib"; then
          AC_MSG_NOTICE([Could not find $POTENTIAL_FREETYPE_LIB_PATH/freetype.lib. Ignoring location.])
          FOUND_FREETYPE=no
        fi
      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
        # On solaris-x86_86, default is (normally) PATH/lib/amd64. Update our guess!
        POTENTIAL_FREETYPE_LIB_PATH="$POTENTIAL_FREETYPE_LIB_PATH/amd64"
      fi
    fi
  fi

  if test "x$FOUND_FREETYPE" = xyes; then
    BASIC_FIXUP_PATH(POTENTIAL_FREETYPE_INCLUDE_PATH)
    BASIC_FIXUP_PATH(POTENTIAL_FREETYPE_LIB_PATH)

    FREETYPE_INCLUDE_PATH="$POTENTIAL_FREETYPE_INCLUDE_PATH"
    AC_MSG_CHECKING([for freetype includes])
    AC_MSG_RESULT([$FREETYPE_INCLUDE_PATH])
    FREETYPE_LIB_PATH="$POTENTIAL_FREETYPE_LIB_PATH"
    AC_MSG_CHECKING([for freetype libraries])
    AC_MSG_RESULT([$FREETYPE_LIB_PATH])
  fi
])

291 292 293
AC_DEFUN_ONCE([LIB_SETUP_FREETYPE],
[

294 295
  ###############################################################################
  #
I
ihse 已提交
296
  # The ubiquitous freetype library is used to render fonts.
297 298
  #
  AC_ARG_WITH(freetype, [AS_HELP_STRING([--with-freetype],
I
ihse 已提交
299
      [specify prefix directory for the freetype package
300
      (expecting the libraries under PATH/lib and the headers under PATH/include)])])
I
ihse 已提交
301 302 303 304 305 306 307 308 309 310 311 312
  AC_ARG_WITH(freetype-include, [AS_HELP_STRING([--with-freetype-include],
      [specify directory for the freetype include files])])
  AC_ARG_WITH(freetype-lib, [AS_HELP_STRING([--with-freetype-lib],
      [specify directory for the freetype library])])
  AC_ARG_ENABLE(freetype-bundling, [AS_HELP_STRING([--disable-freetype-bundling],
      [disable bundling of the freetype library with the build result @<:@enabled on Windows or when using --with-freetype, disabled otherwise@:>@])])

  FREETYPE_CFLAGS=
  FREETYPE_LIBS=
  FREETYPE_BUNDLE_LIB_PATH=

  if test "x$FREETYPE_NOT_NEEDED" = xyes; then
313 314 315
    if test "x$with_freetype" != x || test "x$with_freetype_include" != x || test "x$with_freetype_lib" != x; then
      AC_MSG_WARN([freetype not used, so --with-freetype is ignored])
    fi
I
ihse 已提交
316 317 318
    if test "x$enable_freetype_bundling" != x; then
      AC_MSG_WARN([freetype not used, so --enable-freetype-bundling is ignored])
    fi
319
  else
I
ihse 已提交
320 321 322 323 324 325 326 327 328 329
    # freetype is needed to build; go get it!

    BUNDLE_FREETYPE="$enable_freetype_bundling"

    if test "x$with_freetype" != x || test "x$with_freetype_include" != x || test "x$with_freetype_lib" != x; then
      # User has specified settings

      if test "x$BUNDLE_FREETYPE" = x; then
        # If not specified, default is to bundle freetype
        BUNDLE_FREETYPE=yes
330
      fi
I
ihse 已提交
331 332 333 334
      
      if test "x$with_freetype" != x; then
        POTENTIAL_FREETYPE_INCLUDE_PATH="$with_freetype/include"
        POTENTIAL_FREETYPE_LIB_PATH="$with_freetype/lib"
335
      fi
I
ihse 已提交
336 337 338 339
      
      # Allow --with-freetype-lib and --with-freetype-include to override
      if test "x$with_freetype_include" != x; then
        POTENTIAL_FREETYPE_INCLUDE_PATH="$with_freetype_include"
340
      fi
I
ihse 已提交
341 342 343 344 345 346 347 348 349
      if test "x$with_freetype_lib" != x; then
        POTENTIAL_FREETYPE_LIB_PATH="$with_freetype_lib"
      fi

      if test "x$POTENTIAL_FREETYPE_INCLUDE_PATH" != x && test "x$POTENTIAL_FREETYPE_LIB_PATH" != x; then
        # Okay, we got it. Check that it works.
        LIB_CHECK_POTENTIAL_FREETYPE($POTENTIAL_FREETYPE_INCLUDE_PATH, $POTENTIAL_FREETYPE_LIB_PATH, [--with-freetype])
        if test "x$FOUND_FREETYPE" != xyes; then
          AC_MSG_ERROR([Can not find or use freetype at location given by --with-freetype])
350
        fi
I
ihse 已提交
351 352 353 354 355 356 357 358
      else
        # User specified only one of lib or include. This is an error.
        if test "x$POTENTIAL_FREETYPE_INCLUDE_PATH" = x ; then
          AC_MSG_NOTICE([User specified --with-freetype-lib but not --with-freetype-include])
          AC_MSG_ERROR([Need both freetype lib and include paths. Consider using --with-freetype instead.])
        else
          AC_MSG_NOTICE([User specified --with-freetype-include but not --with-freetype-lib])
          AC_MSG_ERROR([Need both freetype lib and include paths. Consider using --with-freetype instead.])
O
ohair 已提交
359
        fi
360
      fi
I
ihse 已提交
361 362 363 364 365 366 367 368 369
    else
      # User did not specify settings, but we need freetype. Try to locate it.

      if test "x$BUNDLE_FREETYPE" = x; then
        # If not specified, default is to bundle freetype only on windows
        if test "x$OPENJDK_TARGET_OS" = xwindows; then
          BUNDLE_FREETYPE=yes
        else
          BUNDLE_FREETYPE=no
370
        fi
I
ihse 已提交
371 372 373 374 375 376 377 378 379 380 381 382 383 384
      fi

      if test "x$FOUND_FREETYPE" != xyes; then
        # Check builddeps
        BDEPS_CHECK_MODULE(FREETYPE, freetype2, xxx, [FOUND_FREETYPE=yes], [FOUND_FREETYPE=no])
        # BDEPS_CHECK_MODULE will set FREETYPE_CFLAGS and _LIBS, but we don't get a lib path for bundling.
        if test "x$FOUND_FREETYPE" = xyes; then
          if test "x$BUNDLE_FREETYPE" = xyes; then
            AC_MSG_NOTICE([Found freetype using builddeps, but ignoring since we can not bundle that])
            FOUND_FREETYPE=no
          else
            AC_MSG_CHECKING([for freetype])
            AC_MSG_RESULT([yes (using builddeps)])
          fi
O
ohair 已提交
385
        fi
386
      fi
I
ihse 已提交
387 388 389 390 391 392

      if test "x$FOUND_FREETYPE" != xyes; then
        # Check modules using pkg-config, but only if we have it (ugly output results otherwise)
        if test "x$PKG_CONFIG" != x; then
          PKG_CHECK_MODULES(FREETYPE, freetype2, [FOUND_FREETYPE=yes], [FOUND_FREETYPE=no])
          if test "x$FOUND_FREETYPE" = xyes; then
O
ohair 已提交
393
            # On solaris, pkg_check adds -lz to freetype libs, which isn't necessary for us.
I
ihse 已提交
394
            FREETYPE_LIBS=`$ECHO $FREETYPE_LIBS | $SED 's/-lz//g'`
O
ohair 已提交
395
            # 64-bit libs for Solaris x86 are installed in the amd64 subdirectory, change lib to lib/amd64
I
ihse 已提交
396 397 398 399 400 401 402 403 404 405
            if test "x$OPENJDK_TARGET_OS" = xsolaris && test "x$OPENJDK_TARGET_CPU" = xx86_64; then
              FREETYPE_LIBS=`$ECHO $FREETYPE_LIBS | $SED 's?/lib?/lib/amd64?g'`
            fi
            # BDEPS_CHECK_MODULE will set FREETYPE_CFLAGS and _LIBS, but we don't get a lib path for bundling.
            if test "x$BUNDLE_FREETYPE" = xyes; then
              AC_MSG_NOTICE([Found freetype using pkg-config, but ignoring since we can not bundle that])
              FOUND_FREETYPE=no
            else
              AC_MSG_CHECKING([for freetype])
              AC_MSG_RESULT([yes (using pkg-config)])
O
ohair 已提交
406
            fi
I
ihse 已提交
407
          fi
O
ohair 已提交
408
        fi
409
      fi
410

I
ihse 已提交
411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452
      if test "x$FOUND_FREETYPE" != xyes; then
        # Check in well-known locations
        if test "x$OPENJDK_TARGET_OS" = xwindows; then
          FREETYPE_BASE_DIR="$PROGRAMFILES/GnuWin32"
          BASIC_WINDOWS_REWRITE_AS_UNIX_PATH(FREETYPE_BASE_DIR)
          LIB_CHECK_POTENTIAL_FREETYPE([$FREETYPE_BASE_DIR/include], [$FREETYPE_BASE_DIR/lib], [well-known location])
          if test "x$FOUND_FREETYPE" != xyes; then
            FREETYPE_BASE_DIR="$ProgramW6432/GnuWin32"
            BASIC_WINDOWS_REWRITE_AS_UNIX_PATH(FREETYPE_BASE_DIR)
            LIB_CHECK_POTENTIAL_FREETYPE([$FREETYPE_BASE_DIR/include], [$FREETYPE_BASE_DIR/lib], [well-known location])
          fi
        else
          if test "x$SYS_ROOT" = "x/"; then
            FREETYPE_ROOT=
          else
            FREETYPE_ROOT="$SYS_ROOT"
          fi
          FREETYPE_BASE_DIR="$FREETYPE_ROOT/usr"
          LIB_CHECK_POTENTIAL_FREETYPE([$FREETYPE_BASE_DIR/include], [$FREETYPE_BASE_DIR/lib], [well-known location])

          if test "x$FOUND_FREETYPE" != xyes; then
            FREETYPE_BASE_DIR="$FREETYPE_ROOT/usr/X11"
            LIB_CHECK_POTENTIAL_FREETYPE([$FREETYPE_BASE_DIR/include], [$FREETYPE_BASE_DIR/lib], [well-known location])
          fi

          if test "x$FOUND_FREETYPE" != xyes; then
            FREETYPE_BASE_DIR="$FREETYPE_ROOT/usr"
            if test "x$OPENJDK_TARGET_CPU_BITS" = x64; then
              LIB_CHECK_POTENTIAL_FREETYPE([$FREETYPE_BASE_DIR/include], [$FREETYPE_BASE_DIR/lib/x86_64-linux-gnu], [well-known location])
            else
              LIB_CHECK_POTENTIAL_FREETYPE([$FREETYPE_BASE_DIR/include], [$FREETYPE_BASE_DIR/lib/i386-linux-gnu], [well-known location])
              if test "x$FOUND_FREETYPE" != xyes; then
                LIB_CHECK_POTENTIAL_FREETYPE([$FREETYPE_BASE_DIR/include], [$FREETYPE_BASE_DIR/lib32], [well-known location])
              fi
            fi
          fi
        fi
      fi # end check in well-known locations

      if test "x$FOUND_FREETYPE" != xyes; then
        HELP_MSG_MISSING_DEPENDENCY([freetype])
        AC_MSG_ERROR([Could not find freetype! $HELP_MSG ])
453
      fi
I
ihse 已提交
454 455 456 457 458 459 460 461 462
    fi # end user specified settings

    # Set FREETYPE_CFLAGS, _LIBS and _LIB_PATH from include and lib dir.
    if test "x$FREETYPE_CFLAGS" = x; then
      BASIC_FIXUP_PATH(FREETYPE_INCLUDE_PATH)
      if test -d $FREETYPE_INCLUDE_PATH/freetype2/freetype; then
        FREETYPE_CFLAGS="-I$FREETYPE_INCLUDE_PATH/freetype2 -I$FREETYPE_INCLUDE_PATH"
      else
        FREETYPE_CFLAGS="-I$FREETYPE_INCLUDE_PATH"
463 464
      fi
    fi
I
ihse 已提交
465 466 467 468 469 470 471 472
    
    if test "x$FREETYPE_LIBS" = x; then
      BASIC_FIXUP_PATH(FREETYPE_LIB_PATH)
      if test "x$OPENJDK_TARGET_OS" = xwindows; then
        FREETYPE_LIBS="$FREETYPE_LIB_PATH/freetype.lib"
      else
        FREETYPE_LIBS="-L$FREETYPE_LIB_PATH -lfreetype"
      fi
473
    fi
474

I
ihse 已提交
475 476 477 478
    # Try to compile it
    AC_MSG_CHECKING([if we can compile and link with freetype])
    AC_LANG_PUSH(C++)
    PREV_CXXCFLAGS="$CXXFLAGS"
479
    PREV_LIBS="$LIBS"
I
ihse 已提交
480 481
    PREV_CXX="$CXX"
    CXXFLAGS="$CXXFLAGS $FREETYPE_CFLAGS" 
482
    LIBS="$LIBS $FREETYPE_LIBS"
I
ihse 已提交
483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505
    CXX="$FIXPATH $CXX"
    AC_LINK_IFELSE([AC_LANG_SOURCE([[
          #include<ft2build.h>
          #include FT_FREETYPE_H
          int main () {
            FT_Init_FreeType(NULL);
            return 0;
          }
        ]])],
        [
          AC_MSG_RESULT([yes])
        ],
        [
          AC_MSG_RESULT([no])
          AC_MSG_NOTICE([Could not compile and link with freetype. This might be a 32/64-bit mismatch.])
          AC_MSG_NOTICE([Using FREETYPE_CFLAGS=$FREETYPE_CFLAGS and FREETYPE_LIBS=$FREETYPE_LIBS])
          
          HELP_MSG_MISSING_DEPENDENCY([freetype])
          
          AC_MSG_ERROR([Can not continue without freetype. $HELP_MSG])
        ]
    )
    CXXCFLAGS="$PREV_CXXFLAGS"
506
    LIBS="$PREV_LIBS"
I
ihse 已提交
507 508 509 510 511 512
    CXX="$PREV_CXX"
    AC_LANG_POP(C++)

    AC_MSG_CHECKING([if we should bundle freetype])
    if test "x$BUNDLE_FREETYPE" = xyes; then
      FREETYPE_BUNDLE_LIB_PATH="$FREETYPE_LIB_PATH"
513
    fi
I
ihse 已提交
514 515 516
    AC_MSG_RESULT([$BUNDLE_FREETYPE])

  fi # end freetype needed
517

I
ihse 已提交
518 519 520
  AC_SUBST(FREETYPE_BUNDLE_LIB_PATH)
  AC_SUBST(FREETYPE_CFLAGS)
  AC_SUBST(FREETYPE_LIBS)
521 522 523 524 525
])

AC_DEFUN_ONCE([LIB_SETUP_ALSA],
[

526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551
  ###############################################################################
  #
  # Check for alsa headers and libraries. Used on Linux/GNU systems.
  #
  AC_ARG_WITH(alsa, [AS_HELP_STRING([--with-alsa],
      [specify prefix directory for the alsa package
      (expecting the libraries under PATH/lib and the headers under PATH/include)])])
  AC_ARG_WITH(alsa-include, [AS_HELP_STRING([--with-alsa-include],
      [specify directory for the alsa include files])])
  AC_ARG_WITH(alsa-lib, [AS_HELP_STRING([--with-alsa-lib],
      [specify directory for the alsa library])])

  if test "x$ALSA_NOT_NEEDED" = xyes; then
    if test "x${with_alsa}" != x || test "x${with_alsa_include}" != x || test "x${with_alsa_lib}" != x; then
      AC_MSG_WARN([alsa not used, so --with-alsa is ignored])
    fi
    ALSA_CFLAGS=
    ALSA_LIBS=
  else
    ALSA_FOUND=no

    if test "x${with_alsa}" = xno || test "x${with_alsa_include}" = xno || test "x${with_alsa_lib}" = xno; then
      AC_MSG_ERROR([It is not possible to disable the use of alsa. Remove the --without-alsa option.])
    fi

    if test "x${with_alsa}" != x; then
552
      ALSA_LIBS="-L${with_alsa}/lib -lasound"
553 554 555 556 557 558 559 560
      ALSA_CFLAGS="-I${with_alsa}/include"
      ALSA_FOUND=yes
    fi
    if test "x${with_alsa_include}" != x; then
      ALSA_CFLAGS="-I${with_alsa_include}"
      ALSA_FOUND=yes
    fi
    if test "x${with_alsa_lib}" != x; then
561
      ALSA_LIBS="-L${with_alsa_lib} -lasound"
562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584
      ALSA_FOUND=yes
    fi
    if test "x$ALSA_FOUND" = xno; then
      BDEPS_CHECK_MODULE(ALSA, alsa, xxx, [ALSA_FOUND=yes], [ALSA_FOUND=no])
    fi
    if test "x$ALSA_FOUND" = xno; then
      PKG_CHECK_MODULES(ALSA, alsa, [ALSA_FOUND=yes], [ALSA_FOUND=no])
    fi
    if test "x$ALSA_FOUND" = xno; then
      AC_CHECK_HEADERS([alsa/asoundlib.h],
          [
            ALSA_FOUND=yes
            ALSA_CFLAGS=-Iignoreme
            ALSA_LIBS=-lasound
            DEFAULT_ALSA=yes
          ],
          [ALSA_FOUND=no])
    fi
    if test "x$ALSA_FOUND" = xno; then
      HELP_MSG_MISSING_DEPENDENCY([alsa])
      AC_MSG_ERROR([Could not find alsa! $HELP_MSG ])
    fi
  fi
585

586 587
  AC_SUBST(ALSA_CFLAGS)
  AC_SUBST(ALSA_LIBS)
588 589 590 591 592
])

AC_DEFUN_ONCE([LIB_SETUP_MISC_LIBS],
[

593 594 595 596
  ###############################################################################
  #
  # Check for the jpeg library
  #
597

598 599 600 601 602 603
  USE_EXTERNAL_LIBJPEG=true
  AC_CHECK_LIB(jpeg, main, [],
      [ USE_EXTERNAL_LIBJPEG=false
      AC_MSG_NOTICE([Will use jpeg decoder bundled with the OpenJDK source])
  ])
  AC_SUBST(USE_EXTERNAL_LIBJPEG)
604

605 606 607 608
  ###############################################################################
  #
  # Check for the gif library
  #
609

610 611
  AC_ARG_WITH(giflib, [AS_HELP_STRING([--with-giflib],
      [use giflib from build system or OpenJDK source (system, bundled) @<:@bundled@:>@])])
612 613


614
  AC_MSG_CHECKING([for which giflib to use])
615

616 617 618 619 620 621 622
  # default is bundled
  DEFAULT_GIFLIB=bundled

  #
  # if user didn't specify, use DEFAULT_GIFLIB
  #
  if test "x${with_giflib}" = "x"; then
623
    with_giflib=${DEFAULT_GIFLIB}
624
  fi
625

626
  AC_MSG_RESULT(${with_giflib})
627

628
  if test "x${with_giflib}" = "xbundled"; then
629
    USE_EXTERNAL_LIBGIF=false
630
  elif test "x${with_giflib}" = "xsystem"; then
631
    AC_CHECK_HEADER(gif_lib.h, [],
632
        [ AC_MSG_ERROR([--with-giflib=system specified, but gif_lib.h not found!])])
633
    AC_CHECK_LIB(gif, DGifGetCode, [],
634
        [ AC_MSG_ERROR([--with-giflib=system specified, but no giflib found!])])
635 636

    USE_EXTERNAL_LIBGIF=true
637
  else
638
    AC_MSG_ERROR([Invalid value of --with-giflib: ${with_giflib}, use 'system' or 'bundled'])
639 640
  fi
  AC_SUBST(USE_EXTERNAL_LIBGIF)
641

642 643 644 645
  ###############################################################################
  #
  # Check for the zlib library
  #
646

647 648
  AC_ARG_WITH(zlib, [AS_HELP_STRING([--with-zlib],
      [use zlib from build system or OpenJDK source (system, bundled) @<:@bundled@:>@])])
649

650 651 652
  AC_CHECK_LIB(z, compress,
      [ ZLIB_FOUND=yes ],
      [ ZLIB_FOUND=no ])
653

654
  AC_MSG_CHECKING([for which zlib to use])
655

656 657 658 659 660
  DEFAULT_ZLIB=bundled
  if test "x$OPENJDK_TARGET_OS" = xmacosx; then
    #
    # On macosx default is system...on others default is
    #
661
    DEFAULT_ZLIB=system
662
  fi
663

664 665 666 667
  if test "x${ZLIB_FOUND}" != "xyes"; then
    #
    # If we don't find any system...set default to bundled
    #
668
    DEFAULT_ZLIB=bundled
669
  fi
670

671 672 673 674
  #
  # If user didn't specify, use DEFAULT_ZLIB
  #
  if test "x${with_zlib}" = "x"; then
675
    with_zlib=${DEFAULT_ZLIB}
676
  fi
677

678
  if test "x${with_zlib}" = "xbundled"; then
679 680
    USE_EXTERNAL_LIBZ=false
    AC_MSG_RESULT([bundled])
681
  elif test "x${with_zlib}" = "xsystem"; then
682
    if test "x${ZLIB_FOUND}" = "xyes"; then
683 684
      USE_EXTERNAL_LIBZ=true
      AC_MSG_RESULT([system])
685
    else
686 687
      AC_MSG_RESULT([system not found])
      AC_MSG_ERROR([--with-zlib=system specified, but no zlib found!])
688
    fi
689 690 691
  else
    AC_MSG_ERROR([Invalid value for --with-zlib: ${with_zlib}, use 'system' or 'bundled'])
  fi
692

693
  AC_SUBST(USE_EXTERNAL_LIBZ)
694

695 696
  ###############################################################################
  LIBZIP_CAN_USE_MMAP=true
697

698
  AC_SUBST(LIBZIP_CAN_USE_MMAP)
699

700 701 702 703
  ###############################################################################
  #
  # Check if altzone exists in time.h
  #
704

705 706 707 708
  AC_LINK_IFELSE([AC_LANG_PROGRAM([#include <time.h>], [return (int)altzone;])],
      [has_altzone=yes],
      [has_altzone=no])
  if test "x$has_altzone" = xyes; then
709
    AC_DEFINE([HAVE_ALTZONE], 1, [Define if you have the external 'altzone' variable in time.h])
710
  fi
711

712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733
  ###############################################################################
  #
  # Check the maths library
  #

  AC_CHECK_LIB(m, cos, [],
      [
        AC_MSG_NOTICE([Maths library was not found])
      ]
  )
  AC_SUBST(LIBM)

  ###############################################################################
  #
  # Check for libdl.so

  save_LIBS="$LIBS"
  LIBS=""
  AC_CHECK_LIB(dl,dlopen)
  LIBDL="$LIBS"
  AC_SUBST(LIBDL)
  LIBS="$save_LIBS"
734 735 736 737
])

AC_DEFUN_ONCE([LIB_SETUP_STATIC_LINK_LIBSTDCPP],
[
738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754
  ###############################################################################
  #
  # statically link libstdc++ before C++ ABI is stablized on Linux unless
  # dynamic build is configured on command line.
  #
  AC_ARG_WITH([stdc++lib], [AS_HELP_STRING([--with-stdc++lib=<static>,<dynamic>,<default>],
      [force linking of the C++ runtime on Linux to either static or dynamic, default is static with dynamic as fallback])],
      [
        if test "x$with_stdc__lib" != xdynamic && test "x$with_stdc__lib" != xstatic \
                && test "x$with_stdc__lib" != xdefault; then
          AC_MSG_ERROR([Bad parameter value --with-stdc++lib=$with_stdc__lib!])
        fi
      ],
      [with_stdc__lib=default]
  )

  if test "x$OPENJDK_TARGET_OS" = xlinux; then
755 756 757 758 759 760
    # Test if -lstdc++ works.
    AC_MSG_CHECKING([if dynamic link of stdc++ is possible])
    AC_LANG_PUSH(C++)
    OLD_CXXFLAGS="$CXXFLAGS"
    CXXFLAGS="$CXXFLAGS -lstdc++"
    AC_LINK_IFELSE([AC_LANG_PROGRAM([], [return 0;])],
761 762
        [has_dynamic_libstdcxx=yes],
        [has_dynamic_libstdcxx=no])
763 764 765 766 767 768 769 770 771 772 773
    CXXFLAGS="$OLD_CXXFLAGS"
    AC_LANG_POP(C++)
    AC_MSG_RESULT([$has_dynamic_libstdcxx])

    # Test if stdc++ can be linked statically.
    AC_MSG_CHECKING([if static link of stdc++ is possible])
    STATIC_STDCXX_FLAGS="-Wl,-Bstatic -lstdc++ -lgcc -Wl,-Bdynamic"
    AC_LANG_PUSH(C++)
    OLD_LIBS="$LIBS"
    OLD_CXX="$CXX"
    LIBS="$STATIC_STDCXX_FLAGS"
774
    CXX="$CC"
775
    AC_LINK_IFELSE([AC_LANG_PROGRAM([], [return 0;])],
776 777
        [has_static_libstdcxx=yes],
        [has_static_libstdcxx=no])
778 779 780 781 782
    LIBS="$OLD_LIBS"
    CXX="$OLD_CXX"
    AC_LANG_POP(C++)
    AC_MSG_RESULT([$has_static_libstdcxx])

783
    if test "x$has_static_libstdcxx" = xno && test "x$has_dynamic_libstdcxx" = xno; then
784
      AC_MSG_ERROR([Cannot link to stdc++, neither dynamically nor statically!])
785 786
    fi

787
    if test "x$with_stdc__lib" = xstatic && test "x$has_static_libstdcxx" = xno; then
788
      AC_MSG_ERROR([Static linking of libstdc++ was not possible!])
789 790
    fi

791
    if test "x$with_stdc__lib" = xdynamic && test "x$has_dynamic_libstdcxx" = xno; then
792
      AC_MSG_ERROR([Dynamic linking of libstdc++ was not possible!])
793 794 795
    fi

    AC_MSG_CHECKING([how to link with libstdc++])
796 797
    # If dynamic was requested, it's available since it would fail above otherwise.
    # If dynamic wasn't requested, go with static unless it isn't available.
798
    if test "x$with_stdc__lib" = xdynamic || test "x$has_static_libstdcxx" = xno || test "x$JVM_VARIANT_ZEROSHARK" = xtrue; then
799 800 801 802
      LIBCXX="$LIBCXX -lstdc++"
      LDCXX="$CXX"
      STATIC_CXX_SETTING="STATIC_CXX=false"
      AC_MSG_RESULT([dynamic])
803
    else
804 805 806 807
      LIBCXX="$LIBCXX $STATIC_STDCXX_FLAGS"
      LDCXX="$CC"
      STATIC_CXX_SETTING="STATIC_CXX=true"
      AC_MSG_RESULT([static])
808
    fi
809 810
  fi
  AC_SUBST(STATIC_CXX_SETTING)
811

812
  if test "x$JVM_VARIANT_ZERO" = xtrue || test "x$JVM_VARIANT_ZEROSHARK" = xtrue; then
813 814 815
    # Figure out LIBFFI_CFLAGS and LIBFFI_LIBS
    PKG_CHECK_MODULES([LIBFFI], [libffi])

816
  fi
817

818
  if test "x$JVM_VARIANT_ZEROSHARK" = xtrue; then
819 820 821
    AC_CHECK_PROG([LLVM_CONFIG], [llvm-config], [llvm-config])

    if test "x$LLVM_CONFIG" != xllvm-config; then
822
      AC_MSG_ERROR([llvm-config not found in $PATH.])
823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862
    fi

    llvm_components="jit mcjit engine nativecodegen native"
    unset LLVM_CFLAGS
    for flag in $("$LLVM_CONFIG" --cxxflags); do
      if echo "${flag}" | grep -q '^-@<:@ID@:>@'; then
        if test "${flag}" != "-D_DEBUG" ; then
          if test "${LLVM_CFLAGS}" != "" ; then
            LLVM_CFLAGS="${LLVM_CFLAGS} "
          fi
          LLVM_CFLAGS="${LLVM_CFLAGS}${flag}"
        fi
      fi
    done
    llvm_version=$("${LLVM_CONFIG}" --version | sed 's/\.//; s/svn.*//')
    LLVM_CFLAGS="${LLVM_CFLAGS} -DSHARK_LLVM_VERSION=${llvm_version}"

    unset LLVM_LDFLAGS
    for flag in $("${LLVM_CONFIG}" --ldflags); do
      if echo "${flag}" | grep -q '^-L'; then
        if test "${LLVM_LDFLAGS}" != ""; then
          LLVM_LDFLAGS="${LLVM_LDFLAGS} "
        fi
        LLVM_LDFLAGS="${LLVM_LDFLAGS}${flag}"
      fi
    done

    unset LLVM_LIBS
    for flag in $("${LLVM_CONFIG}" --libs ${llvm_components}); do
      if echo "${flag}" | grep -q '^-l'; then
        if test "${LLVM_LIBS}" != ""; then
          LLVM_LIBS="${LLVM_LIBS} "
        fi
        LLVM_LIBS="${LLVM_LIBS}${flag}"
      fi
    done

    AC_SUBST(LLVM_CFLAGS)
    AC_SUBST(LLVM_LDFLAGS)
    AC_SUBST(LLVM_LIBS)
863
  fi
864

865
  # libCrun is the c++ runtime-library with SunStudio (roughly the equivalent of gcc's libstdc++.so)
866
  if test "x$TOOLCHAIN_TYPE" = xsolstudio && test "x$LIBCXX" = x; then
867
    LIBCXX="/usr/lib${OPENJDK_TARGET_CPU_ISADIR}/libCrun.so.1"
868
  fi
869

870
  # TODO better (platform agnostic) test
871
  if test "x$OPENJDK_TARGET_OS" = xmacosx && test "x$LIBCXX" = x && test "x$TOOLCHAIN_TYPE" = xgcc; then
872
    LIBCXX="-lstdc++"
873
  fi
874

875
  AC_SUBST(LIBCXX)
876
])
877 878 879 880 881 882 883 884 885 886 887

AC_DEFUN_ONCE([LIB_SETUP_ON_WINDOWS],
[
  if test "x$OPENJDK_TARGET_OS" = "xwindows"; then
    TOOLCHAIN_SETUP_MSVCR_DLL
    BASIC_DEPRECATED_ARG_WITH([dxsdk])
    BASIC_DEPRECATED_ARG_WITH([dxsdk-lib])
    BASIC_DEPRECATED_ARG_WITH([dxsdk-include])
  fi
  AC_SUBST(MSVCR_DLL)
])