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