libraries.m4 revision 1215:515fa19188af
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
26AC_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    AC_MSG_RESULT([alsa pulse x11])
69  fi
70
71  if test "x$OPENJDK_TARGET_OS" = xbsd; then
72    AC_MSG_CHECKING([what is not needed on bsd?])
73    ALSA_NOT_NEEDED=yes
74    AC_MSG_RESULT([alsa])
75  fi
76
77  if test "x$OPENJDK" = "xfalse"; then
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
86AC_DEFUN_ONCE([LIB_SETUP_X11],
87[
88
89  ###############################################################################
90  #
91  # Check for X Windows
92  #
93
94  if test "x$X11_NOT_NEEDED" = xyes; then
95    if test "x${with_x}" != x; then
96      AC_MSG_WARN([X11 is not used, so --with-x is ignored])
97    fi
98    X_CFLAGS=
99    X_LIBS=
100  else
101    # Check if the user has specified sysroot, but not --x-includes or --x-libraries.
102    # Make a simple check for the libraries at the sysroot, and setup --x-includes and
103    # --x-libraries for the sysroot, if that seems to be correct.
104    if test "x$OPENJDK_TARGET_OS" = "xlinux"; then
105      if test "x$SYSROOT" != "x"; then
106        if test "x$x_includes" = xNONE; then
107          if test -f "$SYSROOT/usr/X11R6/include/X11/Xlib.h"; then
108            x_includes="$SYSROOT/usr/X11R6/include"
109          elif test -f "$SYSROOT/usr/include/X11/Xlib.h"; then
110            x_includes="$SYSROOT/usr/include"
111          fi
112        fi
113        if test "x$x_libraries" = xNONE; then
114          if test -f "$SYSROOT/usr/X11R6/lib/libX11.so"; then
115            x_libraries="$SYSROOT/usr/X11R6/lib"
116          elif test "$SYSROOT/usr/lib64/libX11.so" && test "x$OPENJDK_TARGET_CPU_BITS" = x64; then
117            x_libraries="$SYSROOT/usr/lib64"
118          elif test -f "$SYSROOT/usr/lib/libX11.so"; then
119            x_libraries="$SYSROOT/usr/lib"
120          fi
121        fi
122      fi
123    fi
124
125    # Now let autoconf do it's magic
126    AC_PATH_X
127    AC_PATH_XTRA
128
129    # AC_PATH_XTRA creates X_LIBS and sometimes adds -R flags. When cross compiling
130    # this doesn't make sense so we remove it.
131    if test "x$COMPILE_TYPE" = xcross; then
132      X_LIBS=`$ECHO $X_LIBS | $SED 's/-R \{0,1\}[[^ ]]*//g'`
133    fi
134
135    if test "x$no_x" = xyes; then
136      HELP_MSG_MISSING_DEPENDENCY([x11])
137      AC_MSG_ERROR([Could not find X11 libraries. $HELP_MSG])
138    fi
139
140    if test "x$OPENJDK_TARGET_OS" = xsolaris; then
141      OPENWIN_HOME="/usr/openwin"
142      X_CFLAGS="-I$SYSROOT$OPENWIN_HOME/include -I$SYSROOT$OPENWIN_HOME/include/X11/extensions"
143      X_LIBS="-L$SYSROOT$OPENWIN_HOME/sfw/lib$OPENJDK_TARGET_CPU_ISADIR \
144          -L$SYSROOT$OPENWIN_HOME/lib$OPENJDK_TARGET_CPU_ISADIR \
145          -R$OPENWIN_HOME/sfw/lib$OPENJDK_TARGET_CPU_ISADIR \
146          -R$OPENWIN_HOME/lib$OPENJDK_TARGET_CPU_ISADIR"
147    fi
148
149    AC_LANG_PUSH(C)
150    OLD_CFLAGS="$CFLAGS"
151    CFLAGS="$CFLAGS $SYSROOT_CFLAGS $X_CFLAGS"
152
153    # Need to include Xlib.h and Xutil.h to avoid "present but cannot be compiled" warnings on Solaris 10
154    AC_CHECK_HEADERS([X11/extensions/shape.h X11/extensions/Xrender.h X11/extensions/XTest.h X11/Intrinsic.h],
155        [X11_HEADERS_OK=yes],
156        [X11_HEADERS_OK=no; break],
157        [
158          # include <X11/Xlib.h>
159          # include <X11/Xutil.h>
160        ]
161    )
162
163    if test "x$X11_HEADERS_OK" = xno; then
164      HELP_MSG_MISSING_DEPENDENCY([x11])
165      AC_MSG_ERROR([Could not find all X11 headers (shape.h Xrender.h XTest.h Intrinsic.h). $HELP_MSG])
166    fi
167
168    # If XLinearGradient isn't available in Xrender.h, signal that it needs to be
169    # defined in libawt_xawt.
170    AC_MSG_CHECKING([if XlinearGradient is defined in Xrender.h])
171    AC_COMPILE_IFELSE(
172        [AC_LANG_PROGRAM([[#include <X11/extensions/Xrender.h>]],
173            [[XLinearGradient x;]])],
174        [AC_MSG_RESULT([yes])],
175        [AC_MSG_RESULT([no])
176         X_CFLAGS="$X_CFLAGS -DSOLARIS10_NO_XRENDER_STRUCTS"])
177
178    CFLAGS="$OLD_CFLAGS"
179    AC_LANG_POP(C)
180  fi # X11_NOT_NEEDED
181
182  AC_SUBST(X_CFLAGS)
183  AC_SUBST(X_LIBS)
184])
185
186AC_DEFUN_ONCE([LIB_SETUP_CUPS],
187[
188
189  ###############################################################################
190  #
191  # The common unix printing system cups is used to print from java.
192  #
193  AC_ARG_WITH(cups, [AS_HELP_STRING([--with-cups],
194      [specify prefix directory for the cups package
195      (expecting the headers under PATH/include)])])
196  AC_ARG_WITH(cups-include, [AS_HELP_STRING([--with-cups-include],
197      [specify directory for the cups include files])])
198
199  if test "x$CUPS_NOT_NEEDED" = xyes; then
200    if test "x${with_cups}" != x || test "x${with_cups_include}" != x; then
201      AC_MSG_WARN([cups not used, so --with-cups is ignored])
202    fi
203    CUPS_CFLAGS=
204  else
205    CUPS_FOUND=no
206
207    if test "x${with_cups}" = xno || test "x${with_cups_include}" = xno; then
208      AC_MSG_ERROR([It is not possible to disable the use of cups. Remove the --without-cups option.])
209    fi
210
211    if test "x${with_cups}" != x; then
212      CUPS_CFLAGS="-I${with_cups}/include"
213      CUPS_FOUND=yes
214    fi
215    if test "x${with_cups_include}" != x; then
216      CUPS_CFLAGS="-I${with_cups_include}"
217      CUPS_FOUND=yes
218    fi
219    if test "x$CUPS_FOUND" = xno; then
220      BDEPS_CHECK_MODULE(CUPS, cups, xxx, [CUPS_FOUND=yes])
221    fi
222    if test "x$CUPS_FOUND" = xno; then
223      # Are the cups headers installed in the default /usr/include location?
224      AC_CHECK_HEADERS([cups/cups.h cups/ppd.h],
225          [
226            CUPS_FOUND=yes
227            CUPS_CFLAGS=
228            DEFAULT_CUPS=yes
229          ]
230      )
231    fi
232    if test "x$CUPS_FOUND" = xno; then
233      # Getting nervous now? Lets poke around for standard Solaris third-party
234      # package installation locations.
235      AC_MSG_CHECKING([for cups headers])
236      if test -s $SYSROOT/opt/sfw/cups/include/cups/cups.h; then
237        # An SFW package seems to be installed!
238        CUPS_FOUND=yes
239        CUPS_CFLAGS="-I$SYSROOT/opt/sfw/cups/include"
240      elif test -s $SYSROOT/opt/csw/include/cups/cups.h; then
241        # A CSW package seems to be installed!
242        CUPS_FOUND=yes
243        CUPS_CFLAGS="-I$SYSROOT/opt/csw/include"
244      fi
245      AC_MSG_RESULT([$CUPS_FOUND])
246    fi
247    if test "x$CUPS_FOUND" = xno; then
248      HELP_MSG_MISSING_DEPENDENCY([cups])
249      AC_MSG_ERROR([Could not find cups! $HELP_MSG ])
250    fi
251  fi
252
253  AC_SUBST(CUPS_CFLAGS)
254
255])
256
257AC_DEFUN([LIB_BUILD_FREETYPE],
258[
259  FREETYPE_SRC_PATH="$1"
260  BUILD_FREETYPE=yes
261
262  # Check if the freetype sources are acessible..
263  if ! test -d $FREETYPE_SRC_PATH; then
264    AC_MSG_WARN([--with-freetype-src specified, but can't find path "$FREETYPE_SRC_PATH" - ignoring --with-freetype-src])
265    BUILD_FREETYPE=no
266  fi
267  # ..and contain a vc2010 project file
268  vcxproj_path="$FREETYPE_SRC_PATH/builds/windows/vc2010/freetype.vcxproj"
269  if test "x$BUILD_FREETYPE" = xyes && ! test -s $vcxproj_path; then
270    AC_MSG_WARN([Can't find project file $vcxproj_path (you may try a newer freetype version) - ignoring --with-freetype-src])
271    BUILD_FREETYPE=no
272  fi
273  # Now check if configure found a version of 'msbuild.exe'
274  if test "x$BUILD_FREETYPE" = xyes && test "x$MSBUILD" == x ; then
275    AC_MSG_WARN([Can't find an msbuild.exe executable (you may try to install .NET 4.0) - ignoring --with-freetype-src])
276    BUILD_FREETYPE=no
277  fi
278
279  # Ready to go..
280  if test "x$BUILD_FREETYPE" = xyes; then
281
282    # msbuild requires trailing slashes for output directories
283    freetype_lib_path="$FREETYPE_SRC_PATH/lib$OPENJDK_TARGET_CPU_BITS/"
284    freetype_lib_path_unix="$freetype_lib_path"
285    freetype_obj_path="$FREETYPE_SRC_PATH/obj$OPENJDK_TARGET_CPU_BITS/"
286    BASIC_WINDOWS_REWRITE_AS_WINDOWS_MIXED_PATH(vcxproj_path)
287    BASIC_WINDOWS_REWRITE_AS_WINDOWS_MIXED_PATH(freetype_lib_path)
288    BASIC_WINDOWS_REWRITE_AS_WINDOWS_MIXED_PATH(freetype_obj_path)
289    if test "x$OPENJDK_TARGET_CPU_BITS" = x64; then
290      freetype_platform=x64
291    else
292      freetype_platform=win32
293    fi
294
295    # The original freetype project file is for VS 2010 (i.e. 'v100'),
296    # so we have to adapt the toolset if building with any other toolsed (i.e. SDK).
297    # Currently 'PLATFORM_TOOLSET' is set in 'TOOLCHAIN_CHECK_POSSIBLE_VISUAL_STUDIO_ROOT'/
298    # 'TOOLCHAIN_CHECK_POSSIBLE_WIN_SDK_ROOT' in toolchain_windows.m4
299    AC_MSG_NOTICE([Trying to compile freetype sources with PlatformToolset=$PLATFORM_TOOLSET to $freetype_lib_path_unix ...])
300
301    # First we try to build the freetype.dll
302    $ECHO -e "@echo off\n"\
303	     "$MSBUILD $vcxproj_path "\
304		       "/p:PlatformToolset=$PLATFORM_TOOLSET "\
305		       "/p:Configuration=\"Release Multithreaded\" "\
306		       "/p:Platform=$freetype_platform "\
307		       "/p:ConfigurationType=DynamicLibrary "\
308		       "/p:TargetName=freetype "\
309		       "/p:OutDir=\"$freetype_lib_path\" "\
310		       "/p:IntDir=\"$freetype_obj_path\" > freetype.log" > freetype.bat
311    cmd /c freetype.bat
312
313    if test -s "$freetype_lib_path_unix/freetype.dll"; then
314      # If that succeeds we also build freetype.lib
315      $ECHO -e "@echo off\n"\
316	       "$MSBUILD $vcxproj_path "\
317			 "/p:PlatformToolset=$PLATFORM_TOOLSET "\
318			 "/p:Configuration=\"Release Multithreaded\" "\
319			 "/p:Platform=$freetype_platform "\
320			 "/p:ConfigurationType=StaticLibrary "\
321			 "/p:TargetName=freetype "\
322			 "/p:OutDir=\"$freetype_lib_path\" "\
323			 "/p:IntDir=\"$freetype_obj_path\" >> freetype.log" > freetype.bat
324      cmd /c freetype.bat
325
326      if test -s "$freetype_lib_path_unix/freetype.lib"; then
327	# Once we build both, lib and dll, set freetype lib and include path appropriately
328	POTENTIAL_FREETYPE_INCLUDE_PATH="$FREETYPE_SRC_PATH/include"
329	POTENTIAL_FREETYPE_LIB_PATH="$freetype_lib_path_unix"
330	AC_MSG_NOTICE([Compiling freetype sources succeeded! (see freetype.log for build results)])
331      else
332	BUILD_FREETYPE=no
333      fi
334    else
335      BUILD_FREETYPE=no
336    fi
337  fi
338])
339
340AC_DEFUN([LIB_CHECK_POTENTIAL_FREETYPE],
341[
342  POTENTIAL_FREETYPE_INCLUDE_PATH="$1"
343  POTENTIAL_FREETYPE_LIB_PATH="$2"
344  METHOD="$3"
345
346  # First check if the files exists.
347  if test -s "$POTENTIAL_FREETYPE_INCLUDE_PATH/ft2build.h"; then
348    # We found an arbitrary include file. That's a good sign.
349    AC_MSG_NOTICE([Found freetype include files at $POTENTIAL_FREETYPE_INCLUDE_PATH using $METHOD])
350    FOUND_FREETYPE=yes
351
352    FREETYPE_LIB_NAME="${LIBRARY_PREFIX}freetype${SHARED_LIBRARY_SUFFIX}"
353    if ! test -s "$POTENTIAL_FREETYPE_LIB_PATH/$FREETYPE_LIB_NAME"; then
354      AC_MSG_NOTICE([Could not find $POTENTIAL_FREETYPE_LIB_PATH/$FREETYPE_LIB_NAME. Ignoring location.])
355      FOUND_FREETYPE=no
356    else
357      if test "x$OPENJDK_TARGET_OS" = xwindows; then
358        # On Windows, we will need both .lib and .dll file.
359        if ! test -s "$POTENTIAL_FREETYPE_LIB_PATH/freetype.lib"; then
360          AC_MSG_NOTICE([Could not find $POTENTIAL_FREETYPE_LIB_PATH/freetype.lib. Ignoring location.])
361          FOUND_FREETYPE=no
362        fi
363      elif test "x$OPENJDK_TARGET_OS" = xsolaris \
364          && test -s "$POTENTIAL_FREETYPE_LIB_PATH$OPENJDK_TARGET_CPU_ISADIR/$FREETYPE_LIB_NAME"; then
365        # Found lib in isa dir, use that instead.
366        POTENTIAL_FREETYPE_LIB_PATH="$POTENTIAL_FREETYPE_LIB_PATH$OPENJDK_TARGET_CPU_ISADIR"
367      fi
368    fi
369  fi
370
371  if test "x$FOUND_FREETYPE" = xyes; then
372    BASIC_FIXUP_PATH(POTENTIAL_FREETYPE_INCLUDE_PATH)
373    BASIC_FIXUP_PATH(POTENTIAL_FREETYPE_LIB_PATH)
374
375    FREETYPE_INCLUDE_PATH="$POTENTIAL_FREETYPE_INCLUDE_PATH"
376    AC_MSG_CHECKING([for freetype includes])
377    AC_MSG_RESULT([$FREETYPE_INCLUDE_PATH])
378    FREETYPE_LIB_PATH="$POTENTIAL_FREETYPE_LIB_PATH"
379    AC_MSG_CHECKING([for freetype libraries])
380    AC_MSG_RESULT([$FREETYPE_LIB_PATH])
381  fi
382])
383
384AC_DEFUN_ONCE([LIB_SETUP_FREETYPE],
385[
386
387  ###############################################################################
388  #
389  # The ubiquitous freetype library is used to render fonts.
390  #
391  AC_ARG_WITH(freetype, [AS_HELP_STRING([--with-freetype],
392      [specify prefix directory for the freetype package
393      (expecting the libraries under PATH/lib and the headers under PATH/include)])])
394  AC_ARG_WITH(freetype-include, [AS_HELP_STRING([--with-freetype-include],
395      [specify directory for the freetype include files])])
396  AC_ARG_WITH(freetype-lib, [AS_HELP_STRING([--with-freetype-lib],
397      [specify directory for the freetype library])])
398  AC_ARG_WITH(freetype-src, [AS_HELP_STRING([--with-freetype-src],
399      [specify directory with freetype sources to automatically build the library (experimental, Windows-only)])])
400  AC_ARG_ENABLE(freetype-bundling, [AS_HELP_STRING([--disable-freetype-bundling],
401      [disable bundling of the freetype library with the build result @<:@enabled on Windows or when using --with-freetype, disabled otherwise@:>@])])
402
403  FREETYPE_CFLAGS=
404  FREETYPE_LIBS=
405  FREETYPE_BUNDLE_LIB_PATH=
406
407  if test "x$FREETYPE_NOT_NEEDED" = xyes; then
408    if test "x$with_freetype" != x || test "x$with_freetype_include" != x || test "x$with_freetype_lib" != x || test "x$with_freetype_src" != x; then
409      AC_MSG_WARN([freetype not used, so --with-freetype is ignored])
410    fi
411    if test "x$enable_freetype_bundling" != x; then
412      AC_MSG_WARN([freetype not used, so --enable-freetype-bundling is ignored])
413    fi
414  else
415    # freetype is needed to build; go get it!
416
417    BUNDLE_FREETYPE="$enable_freetype_bundling"
418
419    if  test "x$with_freetype_src" != x; then
420      if test "x$OPENJDK_TARGET_OS" = xwindows; then
421        # Try to build freetype if --with-freetype-src was given on Windows
422        LIB_BUILD_FREETYPE([$with_freetype_src])
423        if test "x$BUILD_FREETYPE" = xyes; then
424          # Okay, we built it. Check that it works.
425          LIB_CHECK_POTENTIAL_FREETYPE($POTENTIAL_FREETYPE_INCLUDE_PATH, $POTENTIAL_FREETYPE_LIB_PATH, [--with-freetype-src])
426          if test "x$FOUND_FREETYPE" != xyes; then
427            AC_MSG_ERROR([Can not use the built freetype at location given by --with-freetype-src])
428          fi
429        else
430          AC_MSG_NOTICE([User specified --with-freetype-src but building freetype failed. (see freetype.log for build results)])
431          AC_MSG_ERROR([Consider building freetype manually and using --with-freetype instead.])
432        fi
433      else
434        AC_MSG_WARN([--with-freetype-src is currently only supported on Windows - ignoring])
435      fi
436    fi
437
438    if test "x$with_freetype" != x || test "x$with_freetype_include" != x || test "x$with_freetype_lib" != x; then
439      # User has specified settings
440
441      if test "x$BUNDLE_FREETYPE" = x; then
442        # If not specified, default is to bundle freetype
443        BUNDLE_FREETYPE=yes
444      fi
445
446      if test "x$with_freetype" != x; then
447        POTENTIAL_FREETYPE_INCLUDE_PATH="$with_freetype/include"
448        POTENTIAL_FREETYPE_LIB_PATH="$with_freetype/lib"
449      fi
450
451      # Allow --with-freetype-lib and --with-freetype-include to override
452      if test "x$with_freetype_include" != x; then
453        POTENTIAL_FREETYPE_INCLUDE_PATH="$with_freetype_include"
454      fi
455      if test "x$with_freetype_lib" != x; then
456        POTENTIAL_FREETYPE_LIB_PATH="$with_freetype_lib"
457      fi
458
459      if test "x$POTENTIAL_FREETYPE_INCLUDE_PATH" != x && test "x$POTENTIAL_FREETYPE_LIB_PATH" != x; then
460        # Okay, we got it. Check that it works.
461        LIB_CHECK_POTENTIAL_FREETYPE($POTENTIAL_FREETYPE_INCLUDE_PATH, $POTENTIAL_FREETYPE_LIB_PATH, [--with-freetype])
462        if test "x$FOUND_FREETYPE" != xyes; then
463          AC_MSG_ERROR([Can not find or use freetype at location given by --with-freetype])
464        fi
465      else
466        # User specified only one of lib or include. This is an error.
467        if test "x$POTENTIAL_FREETYPE_INCLUDE_PATH" = x ; then
468          AC_MSG_NOTICE([User specified --with-freetype-lib but not --with-freetype-include])
469          AC_MSG_ERROR([Need both freetype lib and include paths. Consider using --with-freetype instead.])
470        else
471          AC_MSG_NOTICE([User specified --with-freetype-include but not --with-freetype-lib])
472          AC_MSG_ERROR([Need both freetype lib and include paths. Consider using --with-freetype instead.])
473        fi
474      fi
475    else
476      # User did not specify settings, but we need freetype. Try to locate it.
477
478      if test "x$BUNDLE_FREETYPE" = x; then
479        # If not specified, default is to bundle freetype only on windows
480        if test "x$OPENJDK_TARGET_OS" = xwindows; then
481          BUNDLE_FREETYPE=yes
482        else
483          BUNDLE_FREETYPE=no
484        fi
485      fi
486
487      if test "x$FOUND_FREETYPE" != xyes; then
488        # Check builddeps
489        BDEPS_CHECK_MODULE(FREETYPE, freetype2, xxx, [FOUND_FREETYPE=yes], [FOUND_FREETYPE=no])
490        # BDEPS_CHECK_MODULE will set FREETYPE_CFLAGS and _LIBS, but we don't get a lib path for bundling.
491        if test "x$FOUND_FREETYPE" = xyes; then
492          if test "x$BUNDLE_FREETYPE" = xyes; then
493            AC_MSG_NOTICE([Found freetype using builddeps, but ignoring since we can not bundle that])
494            FOUND_FREETYPE=no
495          else
496            AC_MSG_CHECKING([for freetype])
497            AC_MSG_RESULT([yes (using builddeps)])
498          fi
499        fi
500      fi
501
502      # If we have a sysroot, assume that's where we are supposed to look and skip pkg-config.
503      if test "x$SYSROOT" = x; then
504        if test "x$FOUND_FREETYPE" != xyes; then
505          # Check modules using pkg-config, but only if we have it (ugly output results otherwise)
506          if test "x$PKG_CONFIG" != x; then
507            PKG_CHECK_MODULES(FREETYPE, freetype2, [FOUND_FREETYPE=yes], [FOUND_FREETYPE=no])
508            if test "x$FOUND_FREETYPE" = xyes; then
509              # On solaris, pkg_check adds -lz to freetype libs, which isn't necessary for us.
510              FREETYPE_LIBS=`$ECHO $FREETYPE_LIBS | $SED 's/-lz//g'`
511              # 64-bit libs for Solaris x86 are installed in the amd64 subdirectory, change lib to lib/amd64
512              if test "x$OPENJDK_TARGET_OS" = xsolaris && test "x$OPENJDK_TARGET_CPU" = xx86_64; then
513                FREETYPE_LIBS=`$ECHO $FREETYPE_LIBS | $SED 's?/lib?/lib/amd64?g'`
514              fi
515              # BDEPS_CHECK_MODULE will set FREETYPE_CFLAGS and _LIBS, but we don't get a lib path for bundling.
516              if test "x$BUNDLE_FREETYPE" = xyes; then
517                AC_MSG_NOTICE([Found freetype using pkg-config, but ignoring since we can not bundle that])
518                FOUND_FREETYPE=no
519              else
520                AC_MSG_CHECKING([for freetype])
521                AC_MSG_RESULT([yes (using pkg-config)])
522              fi
523            fi
524          fi
525        fi
526      fi
527
528      if test "x$FOUND_FREETYPE" != xyes; then
529        # Check in well-known locations
530        if test "x$OPENJDK_TARGET_OS" = xwindows; then
531          FREETYPE_BASE_DIR="$PROGRAMFILES/GnuWin32"
532          BASIC_WINDOWS_REWRITE_AS_UNIX_PATH(FREETYPE_BASE_DIR)
533          LIB_CHECK_POTENTIAL_FREETYPE([$FREETYPE_BASE_DIR/include], [$FREETYPE_BASE_DIR/lib], [well-known location])
534          if test "x$FOUND_FREETYPE" != xyes; then
535            FREETYPE_BASE_DIR="$ProgramW6432/GnuWin32"
536            BASIC_WINDOWS_REWRITE_AS_UNIX_PATH(FREETYPE_BASE_DIR)
537            LIB_CHECK_POTENTIAL_FREETYPE([$FREETYPE_BASE_DIR/include], [$FREETYPE_BASE_DIR/lib], [well-known location])
538          fi
539        else
540          FREETYPE_BASE_DIR="$SYSROOT/usr"
541          LIB_CHECK_POTENTIAL_FREETYPE([$FREETYPE_BASE_DIR/include], [$FREETYPE_BASE_DIR/lib], [well-known location])
542
543          if test "x$FOUND_FREETYPE" != xyes; then
544            FREETYPE_BASE_DIR="$SYSROOT/usr/X11"
545            LIB_CHECK_POTENTIAL_FREETYPE([$FREETYPE_BASE_DIR/include], [$FREETYPE_BASE_DIR/lib], [well-known location])
546          fi
547
548          if test "x$FOUND_FREETYPE" != xyes; then
549            FREETYPE_BASE_DIR="$SYSROOT/usr/sfw"
550            LIB_CHECK_POTENTIAL_FREETYPE([$FREETYPE_BASE_DIR/include], [$FREETYPE_BASE_DIR/lib], [well-known location])
551          fi
552
553          if test "x$FOUND_FREETYPE" != xyes; then
554            FREETYPE_BASE_DIR="$SYSROOT/usr"
555            if test "x$OPENJDK_TARGET_CPU_BITS" = x64; then
556              LIB_CHECK_POTENTIAL_FREETYPE([$FREETYPE_BASE_DIR/include], [$FREETYPE_BASE_DIR/lib/x86_64-linux-gnu], [well-known location])
557            else
558              LIB_CHECK_POTENTIAL_FREETYPE([$FREETYPE_BASE_DIR/include], [$FREETYPE_BASE_DIR/lib/i386-linux-gnu], [well-known location])
559              if test "x$FOUND_FREETYPE" != xyes; then
560                LIB_CHECK_POTENTIAL_FREETYPE([$FREETYPE_BASE_DIR/include], [$FREETYPE_BASE_DIR/lib32], [well-known location])
561              fi
562            fi
563          fi
564        fi
565      fi # end check in well-known locations
566
567      if test "x$FOUND_FREETYPE" != xyes; then
568        HELP_MSG_MISSING_DEPENDENCY([freetype])
569        AC_MSG_ERROR([Could not find freetype! $HELP_MSG ])
570      fi
571    fi # end user specified settings
572
573    # Set FREETYPE_CFLAGS, _LIBS and _LIB_PATH from include and lib dir.
574    if test "x$FREETYPE_CFLAGS" = x; then
575      BASIC_FIXUP_PATH(FREETYPE_INCLUDE_PATH)
576      if test -d $FREETYPE_INCLUDE_PATH/freetype2/freetype; then
577        FREETYPE_CFLAGS="-I$FREETYPE_INCLUDE_PATH/freetype2 -I$FREETYPE_INCLUDE_PATH"
578      else
579        FREETYPE_CFLAGS="-I$FREETYPE_INCLUDE_PATH"
580      fi
581    fi
582
583    if test "x$FREETYPE_LIBS" = x; then
584      BASIC_FIXUP_PATH(FREETYPE_LIB_PATH)
585      if test "x$OPENJDK_TARGET_OS" = xwindows; then
586        FREETYPE_LIBS="$FREETYPE_LIB_PATH/freetype.lib"
587      else
588        FREETYPE_LIBS="-L$FREETYPE_LIB_PATH -lfreetype"
589      fi
590    fi
591
592    # Try to compile it
593    AC_MSG_CHECKING([if we can compile and link with freetype])
594    AC_LANG_PUSH(C++)
595    PREV_CXXCFLAGS="$CXXFLAGS"
596    PREV_LIBS="$LIBS"
597    PREV_CXX="$CXX"
598    CXXFLAGS="$CXXFLAGS $FREETYPE_CFLAGS"
599    LIBS="$LIBS $FREETYPE_LIBS"
600    CXX="$FIXPATH $CXX"
601    AC_LINK_IFELSE([AC_LANG_SOURCE([[
602          #include<ft2build.h>
603          #include FT_FREETYPE_H
604          int main () {
605            FT_Init_FreeType(NULL);
606            return 0;
607          }
608        ]])],
609        [
610          AC_MSG_RESULT([yes])
611        ],
612        [
613          AC_MSG_RESULT([no])
614          AC_MSG_NOTICE([Could not compile and link with freetype. This might be a 32/64-bit mismatch.])
615          AC_MSG_NOTICE([Using FREETYPE_CFLAGS=$FREETYPE_CFLAGS and FREETYPE_LIBS=$FREETYPE_LIBS])
616
617          HELP_MSG_MISSING_DEPENDENCY([freetype])
618
619          AC_MSG_ERROR([Can not continue without freetype. $HELP_MSG])
620        ]
621    )
622    CXXCFLAGS="$PREV_CXXFLAGS"
623    LIBS="$PREV_LIBS"
624    CXX="$PREV_CXX"
625    AC_LANG_POP(C++)
626
627    AC_MSG_CHECKING([if we should bundle freetype])
628    if test "x$BUNDLE_FREETYPE" = xyes; then
629      FREETYPE_BUNDLE_LIB_PATH="$FREETYPE_LIB_PATH"
630    fi
631    AC_MSG_RESULT([$BUNDLE_FREETYPE])
632
633  fi # end freetype needed
634
635  AC_SUBST(FREETYPE_BUNDLE_LIB_PATH)
636  AC_SUBST(FREETYPE_CFLAGS)
637  AC_SUBST(FREETYPE_LIBS)
638])
639
640AC_DEFUN_ONCE([LIB_SETUP_ALSA],
641[
642
643  ###############################################################################
644  #
645  # Check for alsa headers and libraries. Used on Linux/GNU systems.
646  #
647  AC_ARG_WITH(alsa, [AS_HELP_STRING([--with-alsa],
648      [specify prefix directory for the alsa package
649      (expecting the libraries under PATH/lib and the headers under PATH/include)])])
650  AC_ARG_WITH(alsa-include, [AS_HELP_STRING([--with-alsa-include],
651      [specify directory for the alsa include files])])
652  AC_ARG_WITH(alsa-lib, [AS_HELP_STRING([--with-alsa-lib],
653      [specify directory for the alsa library])])
654
655  if test "x$ALSA_NOT_NEEDED" = xyes; then
656    if test "x${with_alsa}" != x || test "x${with_alsa_include}" != x || test "x${with_alsa_lib}" != x; then
657      AC_MSG_WARN([alsa not used, so --with-alsa is ignored])
658    fi
659    ALSA_CFLAGS=
660    ALSA_LIBS=
661  else
662    ALSA_FOUND=no
663
664    if test "x${with_alsa}" = xno || test "x${with_alsa_include}" = xno || test "x${with_alsa_lib}" = xno; then
665      AC_MSG_ERROR([It is not possible to disable the use of alsa. Remove the --without-alsa option.])
666    fi
667
668    if test "x${with_alsa}" != x; then
669      ALSA_LIBS="-L${with_alsa}/lib -lasound"
670      ALSA_CFLAGS="-I${with_alsa}/include"
671      ALSA_FOUND=yes
672    fi
673    if test "x${with_alsa_include}" != x; then
674      ALSA_CFLAGS="-I${with_alsa_include}"
675      ALSA_FOUND=yes
676    fi
677    if test "x${with_alsa_lib}" != x; then
678      ALSA_LIBS="-L${with_alsa_lib} -lasound"
679      ALSA_FOUND=yes
680    fi
681    if test "x$ALSA_FOUND" = xno; then
682      BDEPS_CHECK_MODULE(ALSA, alsa, xxx, [ALSA_FOUND=yes], [ALSA_FOUND=no])
683    fi
684    # Do not try pkg-config if we have a sysroot set.
685    if test "x$SYSROOT" = x; then
686      if test "x$ALSA_FOUND" = xno; then
687        PKG_CHECK_MODULES(ALSA, alsa, [ALSA_FOUND=yes], [ALSA_FOUND=no])
688      fi
689    fi
690    if test "x$ALSA_FOUND" = xno; then
691      AC_CHECK_HEADERS([alsa/asoundlib.h],
692          [
693            ALSA_FOUND=yes
694            ALSA_CFLAGS=-Iignoreme
695            ALSA_LIBS=-lasound
696            DEFAULT_ALSA=yes
697          ],
698          [ALSA_FOUND=no])
699    fi
700    if test "x$ALSA_FOUND" = xno; then
701      HELP_MSG_MISSING_DEPENDENCY([alsa])
702      AC_MSG_ERROR([Could not find alsa! $HELP_MSG ])
703    fi
704  fi
705
706  AC_SUBST(ALSA_CFLAGS)
707  AC_SUBST(ALSA_LIBS)
708])
709
710AC_DEFUN_ONCE([LIB_SETUP_MISC_LIBS],
711[
712
713  ###############################################################################
714  #
715  # Check for the jpeg library
716  #
717
718  AC_ARG_WITH(libjpeg, [AS_HELP_STRING([--with-libjpeg],
719      [use libjpeg from build system or OpenJDK source (system, bundled) @<:@bundled@:>@])])
720
721  AC_MSG_CHECKING([for which libjpeg to use])
722
723  # default is bundled
724  DEFAULT_LIBJPEG=bundled
725
726  #
727  # if user didn't specify, use DEFAULT_LIBJPEG
728  #
729  if test "x${with_libjpeg}" = "x"; then
730    with_libjpeg=${DEFAULT_LIBJPEG}
731  fi
732
733  AC_MSG_RESULT(${with_libjpeg})
734
735  if test "x${with_libjpeg}" = "xbundled"; then
736    USE_EXTERNAL_LIBJPEG=false
737  elif test "x${with_libjpeg}" = "xsystem"; then
738    AC_CHECK_HEADER(jpeglib.h, [],
739        [ AC_MSG_ERROR([--with-libjpeg=system specified, but jpeglib.h not found!])])
740    AC_CHECK_LIB(jpeg, jpeg_CreateDecompress, [],
741        [ AC_MSG_ERROR([--with-libjpeg=system specified, but no libjpeg found])])
742
743    USE_EXTERNAL_LIBJPEG=true
744  else
745    AC_MSG_ERROR([Invalid use of --with-libjpeg: ${with_libjpeg}, use 'system' or 'bundled'])
746  fi
747
748  AC_SUBST(USE_EXTERNAL_LIBJPEG)
749
750  ###############################################################################
751  #
752  # Check for the gif library
753  #
754
755  AC_ARG_WITH(giflib, [AS_HELP_STRING([--with-giflib],
756      [use giflib from build system or OpenJDK source (system, bundled) @<:@bundled@:>@])])
757
758
759  AC_MSG_CHECKING([for which giflib to use])
760
761  # default is bundled
762  DEFAULT_GIFLIB=bundled
763
764  #
765  # if user didn't specify, use DEFAULT_GIFLIB
766  #
767  if test "x${with_giflib}" = "x"; then
768    with_giflib=${DEFAULT_GIFLIB}
769  fi
770
771  AC_MSG_RESULT(${with_giflib})
772
773  if test "x${with_giflib}" = "xbundled"; then
774    USE_EXTERNAL_LIBGIF=false
775  elif test "x${with_giflib}" = "xsystem"; then
776    AC_CHECK_HEADER(gif_lib.h, [],
777        [ AC_MSG_ERROR([--with-giflib=system specified, but gif_lib.h not found!])])
778    AC_CHECK_LIB(gif, DGifGetCode, [],
779        [ AC_MSG_ERROR([--with-giflib=system specified, but no giflib found!])])
780
781    USE_EXTERNAL_LIBGIF=true
782  else
783    AC_MSG_ERROR([Invalid value of --with-giflib: ${with_giflib}, use 'system' or 'bundled'])
784  fi
785  AC_SUBST(USE_EXTERNAL_LIBGIF)
786
787  ###############################################################################
788  #
789  # Check for the lcms2 library
790  #
791
792  AC_ARG_WITH(lcms, [AS_HELP_STRING([--with-lcms],
793  	[use lcms2 from build system or OpenJDK source (system, bundled) @<:@bundled@:>@])])
794
795  AC_MSG_CHECKING([for which lcms to use])
796
797  DEFAULT_LCMS=bundled
798
799  #
800  # If user didn't specify, use DEFAULT_LCMS
801  #
802  if test "x${with_lcms}" = "x"; then
803      with_lcms=${DEFAULT_LCMS}
804  fi
805
806  if test "x${with_lcms}" = "xbundled"; then
807    USE_EXTERNAL_LCMS=false
808    AC_MSG_RESULT([bundled])
809  elif test "x${with_lcms}" = "xsystem"; then
810    AC_MSG_RESULT([system])
811    PKG_CHECK_MODULES([LCMS], [lcms2], [LCMS_FOUND=yes], [LCMS_FOUND=no])
812    if test "x${LCMS_FOUND}" = "xyes"; then
813      USE_EXTERNAL_LCMS=true
814    else
815      AC_MSG_ERROR([--with-lcms=system specified, but no lcms found!])
816    fi
817  else
818    AC_MSG_ERROR([Invalid value for --with-lcms: ${with_lcms}, use 'system' or 'bundled'])
819  fi
820
821  AC_SUBST(USE_EXTERNAL_LCMS)
822
823  ###############################################################################
824  #
825  # Check for the png library
826  #
827
828  AC_ARG_WITH(libpng, [AS_HELP_STRING([--with-libpng],
829     [use libpng from build system or OpenJDK source (system, bundled) @<:@bundled@:>@])])
830
831
832  AC_MSG_CHECKING([for which libpng to use])
833
834  # default is bundled
835  DEFAULT_LIBPNG=bundled
836
837  #
838  # if user didn't specify, use DEFAULT_LIBPNG
839  #
840  if test "x${with_libpng}" = "x"; then
841      with_libpng=${DEFAULT_LIBPNG}
842  fi
843
844  if test "x${with_libpng}" = "xbundled"; then
845      USE_EXTERNAL_LIBPNG=false
846      AC_MSG_RESULT([bundled])
847  elif test "x${with_libpng}" = "xsystem"; then
848      PKG_CHECK_MODULES(PNG, libpng,
849                   [ LIBPNG_FOUND=yes ],
850                   [ LIBPNG_FOUND=no ])
851      if test "x${LIBPNG_FOUND}" = "xyes"; then
852          USE_EXTERNAL_LIBPNG=true
853          AC_MSG_RESULT([system])
854      else
855          AC_MSG_RESULT([system not found])
856          AC_MSG_ERROR([--with-libpng=system specified, but no libpng found!])
857      fi
858  else
859      AC_MSG_ERROR([Invalid value of --with-libpng: ${with_libpng}, use 'system' or 'bundled'])
860  fi
861  AC_SUBST(USE_EXTERNAL_LIBPNG)
862
863  ###############################################################################
864  #
865  # Check for the zlib library
866  #
867
868  AC_ARG_WITH(zlib, [AS_HELP_STRING([--with-zlib],
869      [use zlib from build system or OpenJDK source (system, bundled) @<:@bundled@:>@])])
870
871  AC_CHECK_LIB(z, compress,
872      [ ZLIB_FOUND=yes ],
873      [ ZLIB_FOUND=no ])
874
875  AC_MSG_CHECKING([for which zlib to use])
876
877  DEFAULT_ZLIB=bundled
878  if test "x$OPENJDK_TARGET_OS" = xmacosx; then
879    #
880    # On macosx default is system...on others default is
881    #
882    DEFAULT_ZLIB=system
883  fi
884
885  if test "x${ZLIB_FOUND}" != "xyes"; then
886    #
887    # If we don't find any system...set default to bundled
888    #
889    DEFAULT_ZLIB=bundled
890  fi
891
892  #
893  # If user didn't specify, use DEFAULT_ZLIB
894  #
895  if test "x${with_zlib}" = "x"; then
896    with_zlib=${DEFAULT_ZLIB}
897  fi
898
899  if test "x${with_zlib}" = "xbundled"; then
900    USE_EXTERNAL_LIBZ=false
901    AC_MSG_RESULT([bundled])
902  elif test "x${with_zlib}" = "xsystem"; then
903    if test "x${ZLIB_FOUND}" = "xyes"; then
904      USE_EXTERNAL_LIBZ=true
905      AC_MSG_RESULT([system])
906    else
907      AC_MSG_RESULT([system not found])
908      AC_MSG_ERROR([--with-zlib=system specified, but no zlib found!])
909    fi
910  else
911    AC_MSG_ERROR([Invalid value for --with-zlib: ${with_zlib}, use 'system' or 'bundled'])
912  fi
913
914  AC_SUBST(USE_EXTERNAL_LIBZ)
915
916  ###############################################################################
917  LIBZIP_CAN_USE_MMAP=true
918
919  AC_SUBST(LIBZIP_CAN_USE_MMAP)
920
921  ###############################################################################
922  #
923  # Check if altzone exists in time.h
924  #
925
926  AC_LINK_IFELSE([AC_LANG_PROGRAM([#include <time.h>], [return (int)altzone;])],
927      [has_altzone=yes],
928      [has_altzone=no])
929  if test "x$has_altzone" = xyes; then
930    AC_DEFINE([HAVE_ALTZONE], 1, [Define if you have the external 'altzone' variable in time.h])
931  fi
932
933  ###############################################################################
934  #
935  # Check the maths library
936  #
937
938  AC_CHECK_LIB(m, cos, [],
939      [
940        AC_MSG_NOTICE([Maths library was not found])
941      ]
942  )
943  AC_SUBST(LIBM)
944
945  ###############################################################################
946  #
947  # Check for libdl.so
948
949  save_LIBS="$LIBS"
950  LIBS=""
951  AC_CHECK_LIB(dl,dlopen)
952  LIBDL="$LIBS"
953  AC_SUBST(LIBDL)
954  LIBS="$save_LIBS"
955])
956
957AC_DEFUN_ONCE([LIB_SETUP_STATIC_LINK_LIBSTDCPP],
958[
959  ###############################################################################
960  #
961  # statically link libstdc++ before C++ ABI is stablized on Linux unless
962  # dynamic build is configured on command line.
963  #
964  AC_ARG_WITH([stdc++lib], [AS_HELP_STRING([--with-stdc++lib=<static>,<dynamic>,<default>],
965      [force linking of the C++ runtime on Linux to either static or dynamic, default is static with dynamic as fallback])],
966      [
967        if test "x$with_stdc__lib" != xdynamic && test "x$with_stdc__lib" != xstatic \
968                && test "x$with_stdc__lib" != xdefault; then
969          AC_MSG_ERROR([Bad parameter value --with-stdc++lib=$with_stdc__lib!])
970        fi
971      ],
972      [with_stdc__lib=default]
973  )
974
975  if test "x$OPENJDK_TARGET_OS" = xlinux; then
976    # Test if -lstdc++ works.
977    AC_MSG_CHECKING([if dynamic link of stdc++ is possible])
978    AC_LANG_PUSH(C++)
979    OLD_CXXFLAGS="$CXXFLAGS"
980    CXXFLAGS="$CXXFLAGS -lstdc++"
981    AC_LINK_IFELSE([AC_LANG_PROGRAM([], [return 0;])],
982        [has_dynamic_libstdcxx=yes],
983        [has_dynamic_libstdcxx=no])
984    CXXFLAGS="$OLD_CXXFLAGS"
985    AC_LANG_POP(C++)
986    AC_MSG_RESULT([$has_dynamic_libstdcxx])
987
988    # Test if stdc++ can be linked statically.
989    AC_MSG_CHECKING([if static link of stdc++ is possible])
990    STATIC_STDCXX_FLAGS="-Wl,-Bstatic -lstdc++ -lgcc -Wl,-Bdynamic"
991    AC_LANG_PUSH(C++)
992    OLD_LIBS="$LIBS"
993    OLD_CXX="$CXX"
994    LIBS="$STATIC_STDCXX_FLAGS"
995    CXX="$CC"
996    AC_LINK_IFELSE([AC_LANG_PROGRAM([], [return 0;])],
997        [has_static_libstdcxx=yes],
998        [has_static_libstdcxx=no])
999    LIBS="$OLD_LIBS"
1000    CXX="$OLD_CXX"
1001    AC_LANG_POP(C++)
1002    AC_MSG_RESULT([$has_static_libstdcxx])
1003
1004    if test "x$has_static_libstdcxx" = xno && test "x$has_dynamic_libstdcxx" = xno; then
1005      AC_MSG_ERROR([Cannot link to stdc++, neither dynamically nor statically!])
1006    fi
1007
1008    if test "x$with_stdc__lib" = xstatic && test "x$has_static_libstdcxx" = xno; then
1009      AC_MSG_ERROR([Static linking of libstdc++ was not possible!])
1010    fi
1011
1012    if test "x$with_stdc__lib" = xdynamic && test "x$has_dynamic_libstdcxx" = xno; then
1013      AC_MSG_ERROR([Dynamic linking of libstdc++ was not possible!])
1014    fi
1015
1016    AC_MSG_CHECKING([how to link with libstdc++])
1017    # If dynamic was requested, it's available since it would fail above otherwise.
1018    # If dynamic wasn't requested, go with static unless it isn't available.
1019    if test "x$with_stdc__lib" = xdynamic || test "x$has_static_libstdcxx" = xno || test "x$JVM_VARIANT_ZEROSHARK" = xtrue; then
1020      LIBCXX="$LIBCXX -lstdc++"
1021      LDCXX="$CXX"
1022      STATIC_CXX_SETTING="STATIC_CXX=false"
1023      AC_MSG_RESULT([dynamic])
1024    else
1025      LIBCXX="$LIBCXX $STATIC_STDCXX_FLAGS"
1026      LDCXX="$CC"
1027      STATIC_CXX_SETTING="STATIC_CXX=true"
1028      AC_MSG_RESULT([static])
1029    fi
1030  fi
1031  AC_SUBST(STATIC_CXX_SETTING)
1032
1033  if test "x$JVM_VARIANT_ZERO" = xtrue || test "x$JVM_VARIANT_ZEROSHARK" = xtrue; then
1034    # Figure out LIBFFI_CFLAGS and LIBFFI_LIBS
1035    PKG_CHECK_MODULES([LIBFFI], [libffi])
1036
1037  fi
1038
1039  if test "x$JVM_VARIANT_ZEROSHARK" = xtrue; then
1040    AC_CHECK_PROG([LLVM_CONFIG], [llvm-config], [llvm-config])
1041
1042    if test "x$LLVM_CONFIG" != xllvm-config; then
1043      AC_MSG_ERROR([llvm-config not found in $PATH.])
1044    fi
1045
1046    llvm_components="jit mcjit engine nativecodegen native"
1047    unset LLVM_CFLAGS
1048    for flag in $("$LLVM_CONFIG" --cxxflags); do
1049      if echo "${flag}" | grep -q '^-@<:@ID@:>@'; then
1050        if test "${flag}" != "-D_DEBUG" ; then
1051          if test "${LLVM_CFLAGS}" != "" ; then
1052            LLVM_CFLAGS="${LLVM_CFLAGS} "
1053          fi
1054          LLVM_CFLAGS="${LLVM_CFLAGS}${flag}"
1055        fi
1056      fi
1057    done
1058    llvm_version=$("${LLVM_CONFIG}" --version | sed 's/\.//; s/svn.*//')
1059    LLVM_CFLAGS="${LLVM_CFLAGS} -DSHARK_LLVM_VERSION=${llvm_version}"
1060
1061    unset LLVM_LDFLAGS
1062    for flag in $("${LLVM_CONFIG}" --ldflags); do
1063      if echo "${flag}" | grep -q '^-L'; then
1064        if test "${LLVM_LDFLAGS}" != ""; then
1065          LLVM_LDFLAGS="${LLVM_LDFLAGS} "
1066        fi
1067        LLVM_LDFLAGS="${LLVM_LDFLAGS}${flag}"
1068      fi
1069    done
1070
1071    unset LLVM_LIBS
1072    for flag in $("${LLVM_CONFIG}" --libs ${llvm_components}); do
1073      if echo "${flag}" | grep -q '^-l'; then
1074        if test "${LLVM_LIBS}" != ""; then
1075          LLVM_LIBS="${LLVM_LIBS} "
1076        fi
1077        LLVM_LIBS="${LLVM_LIBS}${flag}"
1078      fi
1079    done
1080
1081    AC_SUBST(LLVM_CFLAGS)
1082    AC_SUBST(LLVM_LDFLAGS)
1083    AC_SUBST(LLVM_LIBS)
1084  fi
1085
1086  # libCrun is the c++ runtime-library with SunStudio (roughly the equivalent of gcc's libstdc++.so)
1087  if test "x$TOOLCHAIN_TYPE" = xsolstudio && test "x$LIBCXX" = x; then
1088    LIBCXX="${SYSROOT}/usr/lib${OPENJDK_TARGET_CPU_ISADIR}/libCrun.so.1"
1089  fi
1090
1091  # TODO better (platform agnostic) test
1092  if test "x$OPENJDK_TARGET_OS" = xmacosx && test "x$LIBCXX" = x && test "x$TOOLCHAIN_TYPE" = xgcc; then
1093    LIBCXX="-lstdc++"
1094  fi
1095
1096  AC_SUBST(LIBCXX)
1097])
1098
1099AC_DEFUN_ONCE([LIB_SETUP_ON_WINDOWS],
1100[
1101  if test "x$OPENJDK_TARGET_OS" = "xwindows"; then
1102    TOOLCHAIN_SETUP_MSVCR_DLL
1103    BASIC_DEPRECATED_ARG_WITH([dxsdk])
1104    BASIC_DEPRECATED_ARG_WITH([dxsdk-lib])
1105    BASIC_DEPRECATED_ARG_WITH([dxsdk-include])
1106  fi
1107  AC_SUBST(MSVCR_DLL)
1108])
1109