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