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