libraries.m4 revision 492:e64f2cb57d05
1#
2# Copyright (c) 2011, 2012, 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#
33if 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])
37fi
38
39if 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])
44fi
45
46if test "x$OPENJDK_TARGET_OS" = xwindows; then
47    AC_MSG_CHECKING([what is not needed on Windows?])
48    CUPS_NOT_NEEDED=yes    
49    ALSA_NOT_NEEDED=yes
50    PULSE_NOT_NEEDED=yes
51    X11_NOT_NEEDED=yes
52    AC_MSG_RESULT([alsa cups pulse x11])
53fi
54
55if test "x$OPENJDK_TARGET_OS" = xmacosx; then
56    AC_MSG_CHECKING([what is not needed on MacOSX?])
57    ALSA_NOT_NEEDED=yes
58    PULSE_NOT_NEEDED=yes
59    X11_NOT_NEEDED=yes
60    FREETYPE2_NOT_NEEDED=yes    
61    # If the java runtime framework is disabled, then we need X11.
62    # This will be adjusted below.
63    AC_MSG_RESULT([alsa pulse x11])
64fi
65
66if test "x$OPENJDK_TARGET_OS" = xbsd; then
67    AC_MSG_CHECKING([what is not needed on bsd?])
68    ALSA_NOT_NEEDED=yes
69    AC_MSG_RESULT([alsa])    
70fi
71
72if test "x$OPENJDK" = "xfalse"; then
73    FREETYPE2_NOT_NEEDED=yes
74fi
75
76if test "x$SUPPORT_HEADFUL" = xno; then
77    X11_NOT_NEEDED=yes
78fi
79
80###############################################################################
81#
82# Check for MacOSX support for OpenJDK. If this exists, try to build a JVM
83# that uses this API. 
84#
85AC_ARG_ENABLE([macosx-runtime-support], [AS_HELP_STRING([--disable-macosx-runtime-support],
86	[disable the use of MacOSX Java runtime support framework @<:@enabled@:>@])],
87	[MACOSX_RUNTIME_SUPPORT="${enableval}"],[MACOSX_RUNTIME_SUPPORT="no"])
88
89USE_MACOSX_RUNTIME_SUPPORT=no
90AC_MSG_CHECKING([for explicit Java runtime support in the OS])
91if test -f /System/Library/Frameworks/JavaVM.framework/Frameworks/JavaRuntimeSupport.framework/Headers/JavaRuntimeSupport.h; then
92    if test "x$MACOSX_RUNTIME_SUPPORT" != xno; then
93        MACOSX_RUNTIME_SUPPORT=yes
94        USE_MACOSX_RUNTIME_SUPPORT=yes
95        AC_MSG_RESULT([yes, does not need alsa freetype2 pulse and X11])
96    else
97        AC_MSG_RESULT([yes, but explicitly disabled.])
98    fi
99else
100    AC_MSG_RESULT([no])
101fi
102
103if test "x$OPENJDK_TARGET_OS" = xmacosx && test "x$USE_MACOSX_RUNTIME_SUPPORT" = xno; then
104    AC_MSG_CHECKING([what is not needed on an X11 build on MacOSX?])
105    X11_NOT_NEEDED=
106    FREETYPE2_NOT_NEEDED=
107    AC_MSG_RESULT([alsa pulse])
108fi
109])
110
111AC_DEFUN_ONCE([LIB_SETUP_X11],
112[
113
114###############################################################################
115#
116# Check for X Windows
117#
118
119# Check if the user has specified sysroot, but not --x-includes or --x-libraries.
120# Make a simple check for the libraries at the sysroot, and setup --x-includes and
121# --x-libraries for the sysroot, if that seems to be correct.
122if test "x$SYS_ROOT" != "x/"; then
123  if test "x$x_includes" = xNONE; then
124    if test -f "$SYS_ROOT/usr/X11R6/include/X11/Xlib.h"; then
125      x_includes="$SYS_ROOT/usr/X11R6/include"
126    fi
127  fi
128  if test "x$x_libraries" = xNONE; then
129    if test -f "$SYS_ROOT/usr/X11R6/lib/libX11.so"; then
130      x_libraries="$SYS_ROOT/usr/X11R6/lib"
131    fi
132  fi
133fi
134
135# Now let autoconf do it's magic
136AC_PATH_X
137AC_PATH_XTRA
138
139if test "x$no_x" = xyes && test "x$X11_NOT_NEEDED" != xyes; then 
140    HELP_MSG_MISSING_DEPENDENCY([x11])
141    AC_MSG_ERROR([Could not find X11 libraries. $HELP_MSG])
142fi
143
144# Some of the old makefiles require a setting of OPENWIN_HOME
145# Since the X11R6 directory has disappeared on later Linuxes,
146# we need to probe for it.
147if test "x$OPENJDK_TARGET_OS" = xlinux; then
148    if test -d "$SYS_ROOT/usr/X11R6"; then
149        OPENWIN_HOME="$SYS_ROOT/usr/X11R6"
150    fi
151    if test -d "$SYS_ROOT/usr/include/X11"; then
152        OPENWIN_HOME="$SYS_ROOT/usr"
153    fi
154fi
155if test "x$OPENJDK_TARGET_OS" = xsolaris; then
156    OPENWIN_HOME="/usr/openwin"
157fi
158AC_SUBST(OPENWIN_HOME)
159
160
161#
162# Weird Sol10 something check...TODO change to try compile
163#
164if test "x${OPENJDK_TARGET_OS}" = xsolaris; then
165  if test "`uname -r`" = "5.10"; then
166     if test "`${EGREP} -c XLinearGradient ${OPENWIN_HOME}/share/include/X11/extensions/Xrender.h`" = "0"; then
167     	X_CFLAGS="${X_CFLAGS} -DSOLARIS10_NO_XRENDER_STRUCTS"
168     fi
169  fi
170fi
171
172AC_LANG_PUSH(C)
173OLD_CFLAGS="$CFLAGS"
174CFLAGS="$CFLAGS $X_CFLAGS"
175
176# Need to include Xlib.h and Xutil.h to avoid "present but cannot be compiled" warnings on Solaris 10
177AC_CHECK_HEADERS([X11/extensions/shape.h X11/extensions/Xrender.h X11/extensions/XTest.h],
178                 [X11_A_OK=yes],
179                 [X11_A_OK=no],
180                 [ # include <X11/Xlib.h>
181                   # include <X11/Xutil.h>
182                 ])
183
184CFLAGS="$OLD_CFLAGS"
185AC_LANG_POP(C)
186
187if test "x$X11_A_OK" = xno && test "x$X11_NOT_NEEDED" != xyes; then 
188    HELP_MSG_MISSING_DEPENDENCY([x11])
189    AC_MSG_ERROR([Could not find all X11 headers (shape.h Xrender.h XTest.h). $HELP_MSG])
190fi
191
192AC_SUBST(X_CFLAGS)
193AC_SUBST(X_LIBS)
194])
195
196AC_DEFUN_ONCE([LIB_SETUP_CUPS],
197[
198
199###############################################################################
200#
201# The common unix printing system cups is used to print from java.
202#
203AC_ARG_WITH(cups, [AS_HELP_STRING([--with-cups],
204    [specify prefix directory for the cups package
205	 (expecting the headers under PATH/include)])])
206AC_ARG_WITH(cups-include, [AS_HELP_STRING([--with-cups-include],
207	[specify directory for the cups include files])])
208
209if test "x$CUPS_NOT_NEEDED" = xyes; then
210	if test "x${with_cups}" != x || test "x${with_cups_include}" != x; then
211		AC_MSG_WARN([cups not used, so --with-cups is ignored])
212	fi
213	CUPS_CFLAGS=
214else
215	CUPS_FOUND=no
216
217	if test "x${with_cups}" = xno || test "x${with_cups_include}" = xno; then
218	    AC_MSG_ERROR([It is not possible to disable the use of cups. Remove the --without-cups option.])
219	fi
220
221	if test "x${with_cups}" != x; then
222	    CUPS_CFLAGS="-I${with_cups}/include"
223	    CUPS_FOUND=yes
224	fi
225	if test "x${with_cups_include}" != x; then
226	    CUPS_CFLAGS="-I${with_cups_include}"
227	    CUPS_FOUND=yes
228	fi
229	if test "x$CUPS_FOUND" = xno; then
230	    BDEPS_CHECK_MODULE(CUPS, cups, xxx, [CUPS_FOUND=yes])
231	fi
232	if test "x$CUPS_FOUND" = xno; then
233	    # Are the cups headers installed in the default /usr/include location?
234	    AC_CHECK_HEADERS([cups/cups.h cups/ppd.h],
235	                     [CUPS_FOUND=yes
236	                      CUPS_CFLAGS=
237	                      DEFAULT_CUPS=yes])
238	fi
239	if test "x$CUPS_FOUND" = xno; then
240	    # Getting nervous now? Lets poke around for standard Solaris third-party
241	    # package installation locations.
242	    AC_MSG_CHECKING([for cups headers])
243	    if test -s /opt/sfw/cups/include/cups/cups.h; then
244	       # An SFW package seems to be installed!
245	       CUPS_FOUND=yes
246	       CUPS_CFLAGS="-I/opt/sfw/cups/include"
247	    elif test -s /opt/csw/include/cups/cups.h; then
248	       # A CSW package seems to be installed!
249	       CUPS_FOUND=yes
250	       CUPS_CFLAGS="-I/opt/csw/include"
251	    fi
252	    AC_MSG_RESULT([$CUPS_FOUND])
253	fi
254	if test "x$CUPS_FOUND" = xno; then 
255	    HELP_MSG_MISSING_DEPENDENCY([cups])
256	    AC_MSG_ERROR([Could not find cups! $HELP_MSG ])
257	fi
258fi
259
260AC_SUBST(CUPS_CFLAGS)
261
262])
263
264AC_DEFUN_ONCE([LIB_SETUP_FREETYPE],
265[
266
267###############################################################################
268#
269# The ubiquitous freetype2 library is used to render fonts.
270#
271AC_ARG_WITH(freetype, [AS_HELP_STRING([--with-freetype],
272	[specify prefix directory for the freetype2 package
273     (expecting the libraries under PATH/lib and the headers under PATH/include)])])
274
275# If we are using the OS installed system lib for freetype, then we do not need to copy it to the build tree
276USING_SYSTEM_FT_LIB=false
277
278if test "x$FREETYPE2_NOT_NEEDED" = xyes; then
279	if test "x$with_freetype" != x || test "x$with_freetype_include" != x || test "x$with_freetype_lib" != x; then
280		AC_MSG_WARN([freetype not used, so --with-freetype is ignored])
281	fi
282	FREETYPE2_CFLAGS=
283	FREETYPE2_LIBS=
284        FREETYPE2_LIB_PATH=
285else
286	FREETYPE2_FOUND=no
287
288	if test "x$with_freetype" != x; then
289            BASIC_FIXUP_PATH(with_freetype)
290	    FREETYPE2_LIBS="-L$with_freetype/lib -lfreetype"
291            FREETYPE2_LIB_PATH="$with_freetype/lib"
292            if test "x$OPENJDK_TARGET_OS" = xsolaris && test "x$OPENJDK_TARGET_CPU" = xx86_64 && test -d "$with_freetype/lib/amd64"; then
293                FREETYPE2_LIBS="-L$with_freetype/lib/amd64 -lfreetype"
294                FREETYPE2_LIB_PATH="$with_freetype/lib/amd64"
295            fi
296            if test "x$OPENJDK_TARGET_OS" = xwindows; then
297                FREETYPE2_LIBS="$with_freetype/lib/freetype.lib"
298            fi
299	    FREETYPE2_CFLAGS="-I$with_freetype/include"
300            if test -s $with_freetype/include/ft2build.h && test -d $with_freetype/include/freetype2/freetype; then
301                FREETYPE2_CFLAGS="-I$with_freetype/include/freetype2 -I$with_freetype/include"
302            fi
303 	    FREETYPE2_FOUND=yes
304   	    if test "x$FREETYPE2_FOUND" = xyes; then
305	        # Verify that the directories exist 
306                if ! test -d "$with_freetype/lib" || ! test -d "$with_freetype/include"; then
307		   AC_MSG_ERROR([Could not find the expected directories $with_freetype/lib and $with_freetype/include])
308		fi
309	        # List the contents of the lib.
310		FREETYPELIB=`ls $with_freetype/lib/libfreetype.so $with_freetype/lib/freetype.dll 2> /dev/null`
311                if test "x$FREETYPELIB" = x; then
312		   AC_MSG_ERROR([Could not find libfreetype.so nor freetype.dll in $with_freetype/lib])
313		fi
314	        # Check one h-file
315                if ! test -s "$with_freetype/include/ft2build.h"; then
316		   AC_MSG_ERROR([Could not find $with_freetype/include/ft2build.h])
317		fi
318            fi
319        fi
320	if test "x$FREETYPE2_FOUND" = xno; then
321	    BDEPS_CHECK_MODULE(FREETYPE2, freetype2, xxx, [FREETYPE2_FOUND=yes], [FREETYPE2_FOUND=no])
322            USING_SYSTEM_FT_LIB=true
323	fi
324	if test "x$FREETYPE2_FOUND" = xno && test "x$OPENJDK_TARGET_OS" = xwindows; then
325            FREETYPELOCATION="$PROGRAMFILES/GnuWin32"
326            BASIC_FIXUP_PATH(FREETYPELOCATION)
327	    AC_MSG_CHECKING([for freetype in some standard windows locations])
328	    if test -s "$FREETYPELOCATION/include/ft2build.h" && test -d "$FREETYPELOCATION/include/freetype2/freetype"; then
329	        FREETYPE2_CFLAGS="-I$FREETYPELOCATION/include/freetype2 -I$FREETYPELOCATION/include"
330	        FREETYPE2_LIBS="$FREETYPELOCATION/lib/freetype.lib"
331 	        FREETYPE2_LIB_PATH="$FREETYPELOCATION/lib"
332                if ! test -s "$FREETYPE2_LIBS"; then
333		   AC_MSG_ERROR([Could not find $FREETYPE2_LIBS])
334		fi
335                if ! test -s "$FREETYPE2_LIB_PATH/freetype.dll"; then
336		   AC_MSG_ERROR([Could not find $FREETYPE2_LIB_PATH/freetype.dll])
337		fi
338                USING_SYSTEM_FT_LIB=true
339                FREETYPE2_FOUND=yes
340	    fi
341	    AC_MSG_RESULT([$FREETYPE2_FOUND])         
342        fi
343	if test "x$FREETYPE2_FOUND" = xno; then
344	    PKG_CHECK_MODULES(FREETYPE2, freetype2, [FREETYPE2_FOUND=yes], [FREETYPE2_FOUND=no])
345            # On solaris, pkg_check adds -lz to freetype libs, which isn't necessary for us.
346            FREETYPE2_LIBS=`$ECHO $FREETYPE2_LIBS | $SED 's/-lz//g'` 
347            USING_SYSTEM_FT_LIB=true
348            # 64-bit libs for Solaris x86 are installed in the amd64 subdirectory, change lib to lib/amd64
349            if test "x$FREETYPE2_FOUND" = xyes && test "x$OPENJDK_TARGET_OS" = xsolaris && test "x$OPENJDK_TARGET_CPU" = xx86_64; then
350              FREETYPE2_LIBS=`$ECHO $FREETYPE2_LIBS | $SED 's?/lib?/lib/amd64?g'`
351            fi
352	fi
353	if test "x$FREETYPE2_FOUND" = xno; then
354	    AC_MSG_CHECKING([for freetype in some standard locations])
355	
356	    if test -s /usr/X11/include/ft2build.h && test -d /usr/X11/include/freetype2/freetype; then
357	        DEFAULT_FREETYPE_CFLAGS="-I/usr/X11/include/freetype2 -I/usr/X11/include"
358	        DEFAULT_FREETYPE_LIBS="-L/usr/X11/lib -lfreetype"
359	    fi
360	    if test -s /usr/include/ft2build.h && test -d /usr/include/freetype2/freetype; then
361	        DEFAULT_FREETYPE_CFLAGS="-I/usr/include/freetype2"
362	        DEFAULT_FREETYPE_LIBS="-lfreetype"
363	    fi
364	
365	    PREV_CXXCFLAGS="$CXXFLAGS"
366	    PREV_LDFLAGS="$LDFLAGS"
367	    CXXFLAGS="$CXXFLAGS $DEFAULT_FREETYPE_CFLAGS"
368	    LDFLAGS="$LDFLAGS $DEFAULT_FREETYPE_LIBS"
369	    AC_LINK_IFELSE([AC_LANG_SOURCE([[#include<ft2build.h>
370	                    #include FT_FREETYPE_H 
371	                   int main() { return 0; }
372	                  ]])],
373	                  [
374	                      # Yes, the default cflags and libs did the trick.
375	                      FREETYPE2_FOUND=yes
376	                      FREETYPE2_CFLAGS="$DEFAULT_FREETYPE_CFLAGS"
377	                      FREETYPE2_LIBS="$DEFAULT_FREETYPE_LIBS"
378	                  ],
379	                  [
380	                      FREETYPE2_FOUND=no
381	                  ])
382            CXXCFLAGS="$PREV_CXXFLAGS"
383	    LDFLAGS="$PREV_LDFLAGS"
384	    AC_MSG_RESULT([$FREETYPE2_FOUND])
385            USING_SYSTEM_FT_LIB=true
386	fi
387	if test "x$FREETYPE2_FOUND" = xno; then
388		HELP_MSG_MISSING_DEPENDENCY([freetype2])
389		AC_MSG_ERROR([Could not find freetype2! $HELP_MSG ])
390	fi
391
392        if test "x$OPENJDK_TARGET_OS" != xwindows; then
393            # AC_CHECK_LIB does not support use of cl.exe
394            PREV_LDFLAGS="$LDFLAGS"
395            LDFLAGS="$FREETYPE2_LIBS"
396            AC_CHECK_LIB(freetype, FT_Init_FreeType, [], AC_MSG_ERROR([Could not find freetype2! $HELP_MSG ]))
397            LDFLAGS="$PREV_LDFLAGS"
398        fi
399fi
400
401AC_SUBST(USING_SYSTEM_FT_LIB)
402AC_SUBST(FREETYPE2_LIB_PATH)
403AC_SUBST(FREETYPE2_CFLAGS)
404AC_SUBST(FREETYPE2_LIBS)
405
406])
407
408AC_DEFUN_ONCE([LIB_SETUP_ALSA],
409[
410
411###############################################################################
412#
413# Check for alsa headers and libraries. Used on Linux/GNU systems.
414#
415AC_ARG_WITH(alsa, [AS_HELP_STRING([--with-alsa],
416	[specify prefix directory for the alsa package
417	 (expecting the libraries under PATH/lib and the headers under PATH/include)])])
418AC_ARG_WITH(alsa-include, [AS_HELP_STRING([--with-alsa-include],
419	[specify directory for the alsa include files])])
420AC_ARG_WITH(alsa-lib, [AS_HELP_STRING([--with-alsa-lib],
421	[specify directory for the alsa library])])
422
423if test "x$ALSA_NOT_NEEDED" = xyes; then
424	if test "x${with_alsa}" != x || test "x${with_alsa_include}" != x || test "x${with_alsa_lib}" != x; then
425		AC_MSG_WARN([alsa not used, so --with-alsa is ignored])
426	fi
427	ALSA_CFLAGS=
428	ALSA_LIBS=
429else
430	ALSA_FOUND=no
431
432	if test "x${with_alsa}" = xno || test "x${with_alsa_include}" = xno || test "x${with_alsa_lib}" = xno; then
433	    AC_MSG_ERROR([It is not possible to disable the use of alsa. Remove the --without-alsa option.])
434	fi
435
436	if test "x${with_alsa}" != x; then
437	    ALSA_LIBS="-L${with_alsa}/lib -lalsa"
438	    ALSA_CFLAGS="-I${with_alsa}/include"
439	    ALSA_FOUND=yes
440	fi
441	if test "x${with_alsa_include}" != x; then
442	    ALSA_CFLAGS="-I${with_alsa_include}"
443	    ALSA_FOUND=yes
444	fi
445	if test "x${with_alsa_lib}" != x; then
446	    ALSA_LIBS="-L${with_alsa_lib} -lalsa"
447	    ALSA_FOUND=yes
448	fi
449	if test "x$ALSA_FOUND" = xno; then
450	    BDEPS_CHECK_MODULE(ALSA, alsa, xxx, [ALSA_FOUND=yes], [ALSA_FOUND=no])
451	fi
452	if test "x$ALSA_FOUND" = xno; then
453	    PKG_CHECK_MODULES(ALSA, alsa, [ALSA_FOUND=yes], [ALSA_FOUND=no])
454	fi
455	if test "x$ALSA_FOUND" = xno; then
456	    AC_CHECK_HEADERS([alsa/asoundlib.h],
457	                     [ALSA_FOUND=yes
458	                      ALSA_CFLAGS=-Iignoreme
459	                      ALSA_LIBS=-lasound
460	                      DEFAULT_ALSA=yes],
461	                     [ALSA_FOUND=no])
462	fi
463	if test "x$ALSA_FOUND" = xno; then 
464	    HELP_MSG_MISSING_DEPENDENCY([alsa])
465	    AC_MSG_ERROR([Could not find alsa! $HELP_MSG ])
466	fi    
467fi
468
469AC_SUBST(ALSA_CFLAGS)
470AC_SUBST(ALSA_LIBS)
471
472])
473
474AC_DEFUN_ONCE([LIB_SETUP_MISC_LIBS],
475[
476
477###############################################################################
478#
479# Check for the jpeg library
480#
481
482USE_EXTERNAL_LIBJPEG=true
483AC_CHECK_LIB(jpeg, main, [],
484             [ USE_EXTERNAL_LIBJPEG=false
485               AC_MSG_NOTICE([Will use jpeg decoder bundled with the OpenJDK source])
486             ])
487AC_SUBST(USE_EXTERNAL_LIBJPEG)
488        
489###############################################################################
490#
491# Check for the gif library
492#
493
494USE_EXTERNAL_LIBJPEG=true
495AC_CHECK_LIB(gif, main, [],
496             [ USE_EXTERNAL_LIBGIF=false
497               AC_MSG_NOTICE([Will use gif decoder bundled with the OpenJDK source])
498             ])
499AC_SUBST(USE_EXTERNAL_LIBGIF)
500
501###############################################################################
502#
503# Check for the zlib library
504#
505
506AC_ARG_WITH(zlib, [AS_HELP_STRING([--with-zlib],
507	[use zlib from build system or OpenJDK source (system, bundled) @<:@bundled@:>@])])
508
509AC_CHECK_LIB(z, compress,
510             [ ZLIB_FOUND=yes ],
511             [ ZLIB_FOUND=no ])
512
513AC_MSG_CHECKING([for which zlib to use])
514
515DEFAULT_ZLIB=bundled
516if test "x$OPENJDK_TARGET_OS" = xmacosx; then
517#
518# On macosx default is system...on others default is 
519#
520    DEFAULT_ZLIB=system
521fi
522
523if test "x${ZLIB_FOUND}" != "xyes"; then
524#
525# If we don't find any system...set default to bundled
526#
527    DEFAULT_ZLIB=bundled
528fi
529
530#
531# If user didn't specify, use DEFAULT_ZLIB
532#
533if test "x${with_zlib}" = "x"; then
534    with_zlib=${DEFAULT_ZLIB}
535fi
536
537if test "x${with_zlib}" = "xbundled"; then
538    USE_EXTERNAL_LIBZ=false
539    AC_MSG_RESULT([bundled])
540elif test "x${with_zlib}" = "xsystem"; then
541    if test "x${ZLIB_FOUND}" = "xyes"; then
542        USE_EXTERNAL_LIBZ=true
543        AC_MSG_RESULT([system])
544    else
545        AC_MSG_RESULT([system not found])
546        AC_MSG_ERROR([--with-zlib=system specified, but no zlib found!])  
547    fi
548else
549    AC_MSG_ERROR([Invalid value for --with-zlib: ${with_zlib}, use 'system' or 'bundled'])  
550fi
551
552AC_SUBST(USE_EXTERNAL_LIBZ)
553
554###############################################################################
555LIBZIP_CAN_USE_MMAP=true
556
557AC_SUBST(LIBZIP_CAN_USE_MMAP)
558
559###############################################################################
560#
561# Check if altzone exists in time.h
562#
563
564AC_LINK_IFELSE([AC_LANG_PROGRAM([#include <time.h>], [return (int)altzone;])],
565            [has_altzone=yes],
566            [has_altzone=no])
567if test "x$has_altzone" = xyes; then
568    AC_DEFINE([HAVE_ALTZONE], 1, [Define if you have the external 'altzone' variable in time.h])
569fi
570
571###############################################################################
572#
573# Check the maths library
574#
575
576AC_CHECK_LIB(m, cos, [],
577             [ 
578                  AC_MSG_NOTICE([Maths library was not found])
579             ])
580AC_SUBST(LIBM)
581
582###############################################################################
583#
584# Check for libdl.so
585
586save_LIBS="$LIBS"
587LIBS=""
588AC_CHECK_LIB(dl,dlopen)
589LIBDL="$LIBS"
590AC_SUBST(LIBDL)
591LIBS="$save_LIBS"
592
593])
594
595AC_DEFUN_ONCE([LIB_SETUP_STATIC_LINK_LIBSTDCPP],
596[
597###############################################################################
598#
599# statically link libstdc++ before C++ ABI is stablized on Linux unless 
600# dynamic build is configured on command line.
601#
602AC_ARG_ENABLE([static-link-stdc++], [AS_HELP_STRING([--disable-static-link-stdc++],
603	[disable static linking of the C++ runtime on Linux @<:@enabled@:>@])],,
604	[
605		enable_static_link_stdc__=yes
606    ])
607
608if test "x$OPENJDK_TARGET_OS" = xlinux; then
609    # Test if -lstdc++ works.
610    AC_MSG_CHECKING([if dynamic link of stdc++ is possible])
611    AC_LANG_PUSH(C++)
612    OLD_CXXFLAGS="$CXXFLAGS"
613    CXXFLAGS="$CXXFLAGS -lstdc++"
614    AC_LINK_IFELSE([AC_LANG_PROGRAM([], [return 0;])],
615            [has_dynamic_libstdcxx=yes],
616            [has_dynamic_libstdcxx=no])
617    CXXFLAGS="$OLD_CXXFLAGS"
618    AC_LANG_POP(C++)
619    AC_MSG_RESULT([$has_dynamic_libstdcxx])
620
621    # Test if stdc++ can be linked statically.
622    AC_MSG_CHECKING([if static link of stdc++ is possible])
623    STATIC_STDCXX_FLAGS="-Wl,-Bstatic -lstdc++ -lgcc -Wl,-Bdynamic"
624    AC_LANG_PUSH(C++)
625    OLD_LIBS="$LIBS"
626    OLD_CXX="$CXX"
627    LIBS="$STATIC_STDCXX_FLAGS"
628    CXX="$CC"                       
629    AC_LINK_IFELSE([AC_LANG_PROGRAM([], [return 0;])],
630            [has_static_libstdcxx=yes],
631            [has_static_libstdcxx=no])
632    LIBS="$OLD_LIBS"
633    CXX="$OLD_CXX"
634    AC_LANG_POP(C++)
635    AC_MSG_RESULT([$has_static_libstdcxx])
636
637    if test "x$has_static_libcxx" = xno && test "x$has_dynamic_libcxx" = xno; then
638        AC_MSG_ERROR([I cannot link to stdc++! Neither dynamically nor statically.])
639    fi
640
641    if test "x$enable_static_link_stdc__" = xyes && test "x$has_static_libstdcxx" = xno; then
642        AC_MSG_NOTICE([Static linking of libstdc++ was not possible reverting to dynamic linking.])
643        enable_static_link_stdc__=no
644    fi
645
646    if test "x$enable_static_link_stdc__" = xno && test "x$has_dynamic_libstdcxx" = xno; then
647        AC_MSG_NOTICE([Dynamic linking of libstdc++ was not possible reverting to static linking.])
648        enable_static_link_stdc__=yes
649    fi
650
651    AC_MSG_CHECKING([how to link with libstdc++])
652    if test "x$enable_static_link_stdc__" = xyes; then
653        LIBCXX="$LIBCXX $STATIC_STDCXX_FLAGS"
654        LDCXX="$CC"
655        STATIC_CXX_SETTING="STATIC_CXX=true"
656        AC_MSG_RESULT([static])
657    else
658        LIBCXX="$LIBCXX -lstdc++"
659        LDCXX="$CXX"
660        STATIC_CXX_SETTING="STATIC_CXX=false"
661        AC_MSG_RESULT([dynamic])
662    fi
663fi
664AC_SUBST(STATIC_CXX_SETTING)
665
666# libCrun is the c++ runtime-library with SunStudio (roughly the equivalent of gcc's libstdc++.so)
667if test "x$OPENJDK_TARGET_OS" = xsolaris && test "x$LIBCXX" = x; then
668    LIBCXX="/usr/lib${OPENJDK_TARGET_CPU_ISADIR}/libCrun.so.1"
669fi
670
671# TODO better (platform agnostic) test
672if test "x$OPENJDK_TARGET_OS" = xmacosx && test "x$LIBCXX" = x && test "x$GCC" = xyes; then
673    LIBCXX="-lstdc++"
674fi
675
676AC_SUBST(LIBCXX)
677
678])
679