Sat, 19 Oct 2013 08:51:39 -0700
Merge
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 #
26 AC_DEFUN_ONCE([LIB_SETUP_INIT],
27 [
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
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
46 if 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])
53 fi
55 if 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])
64 fi
66 if 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])
70 fi
72 if test "x$OPENJDK" = "xfalse"; then
73 FREETYPE2_NOT_NEEDED=yes
74 fi
76 if test "x$SUPPORT_HEADFUL" = xno; then
77 X11_NOT_NEEDED=yes
78 fi
80 ###############################################################################
81 #
82 # Check for MacOSX support for OpenJDK. If this exists, try to build a JVM
83 # that uses this API.
84 #
85 AC_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"])
89 USE_MACOSX_RUNTIME_SUPPORT=no
90 AC_MSG_CHECKING([for explicit Java runtime support in the OS])
91 if 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
99 else
100 AC_MSG_RESULT([no])
101 fi
103 if 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])
108 fi
109 ])
111 AC_DEFUN_ONCE([LIB_SETUP_X11],
112 [
114 ###############################################################################
115 #
116 # Check for X Windows
117 #
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.
122 if 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 elif test -f "$SYS_ROOT/usr/include/X11/Xlib.h"; then
127 x_includes="$SYS_ROOT/usr/include"
128 fi
129 fi
130 if test "x$x_libraries" = xNONE; then
131 if test -f "$SYS_ROOT/usr/X11R6/lib/libX11.so"; then
132 x_libraries="$SYS_ROOT/usr/X11R6/lib"
133 elif test "$SYS_ROOT/usr/lib64/libX11.so" && test "x$OPENJDK_TARGET_CPU_BITS" = x64; then
134 x_libraries="$SYS_ROOT/usr/lib64"
135 elif test -f "$SYS_ROOT/usr/lib/libX11.so"; then
136 x_libraries="$SYS_ROOT/usr/lib"
137 fi
138 fi
139 fi
141 # Now let autoconf do it's magic
142 AC_PATH_X
143 AC_PATH_XTRA
145 # AC_PATH_XTRA creates X_LIBS and sometimes adds -R flags. When cross compiling
146 # this doesn't make sense so we remove it.
147 if test "x$COMPILE_TYPE" = xcross; then
148 X_LIBS=`$ECHO $X_LIBS | $SED 's/-R \{0,1\}[[^ ]]*//g'`
149 fi
151 if test "x$no_x" = xyes && test "x$X11_NOT_NEEDED" != xyes; then
152 HELP_MSG_MISSING_DEPENDENCY([x11])
153 AC_MSG_ERROR([Could not find X11 libraries. $HELP_MSG])
154 fi
156 # Some of the old makefiles require a setting of OPENWIN_HOME
157 # Since the X11R6 directory has disappeared on later Linuxes,
158 # we need to probe for it.
159 if test "x$OPENJDK_TARGET_OS" = xlinux; then
160 if test -d "$SYS_ROOT/usr/X11R6"; then
161 OPENWIN_HOME="$SYS_ROOT/usr/X11R6"
162 elif test -d "$SYS_ROOT/usr/include/X11"; then
163 OPENWIN_HOME="$SYS_ROOT/usr"
164 fi
165 fi
166 if test "x$OPENJDK_TARGET_OS" = xsolaris; then
167 OPENWIN_HOME="/usr/openwin"
168 fi
169 AC_SUBST(OPENWIN_HOME)
172 #
173 # Weird Sol10 something check...TODO change to try compile
174 #
175 if test "x${OPENJDK_TARGET_OS}" = xsolaris; then
176 if test "`uname -r`" = "5.10"; then
177 if test "`${EGREP} -c XLinearGradient ${OPENWIN_HOME}/share/include/X11/extensions/Xrender.h`" = "0"; then
178 X_CFLAGS="${X_CFLAGS} -DSOLARIS10_NO_XRENDER_STRUCTS"
179 fi
180 fi
181 fi
183 AC_LANG_PUSH(C)
184 OLD_CFLAGS="$CFLAGS"
185 CFLAGS="$CFLAGS $X_CFLAGS"
187 # Need to include Xlib.h and Xutil.h to avoid "present but cannot be compiled" warnings on Solaris 10
188 AC_CHECK_HEADERS([X11/extensions/shape.h X11/extensions/Xrender.h X11/extensions/XTest.h X11/Intrinsic.h],
189 [X11_A_OK=yes],
190 [X11_A_OK=no; break],
191 [
192 # include <X11/Xlib.h>
193 # include <X11/Xutil.h>
194 ]
195 )
197 CFLAGS="$OLD_CFLAGS"
198 AC_LANG_POP(C)
200 if test "x$X11_A_OK" = xno && test "x$X11_NOT_NEEDED" != xyes; then
201 HELP_MSG_MISSING_DEPENDENCY([x11])
202 AC_MSG_ERROR([Could not find all X11 headers (shape.h Xrender.h XTest.h Intrinsic.h). $HELP_MSG])
203 fi
205 AC_SUBST(X_CFLAGS)
206 AC_SUBST(X_LIBS)
207 ])
209 AC_DEFUN_ONCE([LIB_SETUP_CUPS],
210 [
212 ###############################################################################
213 #
214 # The common unix printing system cups is used to print from java.
215 #
216 AC_ARG_WITH(cups, [AS_HELP_STRING([--with-cups],
217 [specify prefix directory for the cups package
218 (expecting the headers under PATH/include)])])
219 AC_ARG_WITH(cups-include, [AS_HELP_STRING([--with-cups-include],
220 [specify directory for the cups include files])])
222 if test "x$CUPS_NOT_NEEDED" = xyes; then
223 if test "x${with_cups}" != x || test "x${with_cups_include}" != x; then
224 AC_MSG_WARN([cups not used, so --with-cups is ignored])
225 fi
226 CUPS_CFLAGS=
227 else
228 CUPS_FOUND=no
230 if test "x${with_cups}" = xno || test "x${with_cups_include}" = xno; then
231 AC_MSG_ERROR([It is not possible to disable the use of cups. Remove the --without-cups option.])
232 fi
234 if test "x${with_cups}" != x; then
235 CUPS_CFLAGS="-I${with_cups}/include"
236 CUPS_FOUND=yes
237 fi
238 if test "x${with_cups_include}" != x; then
239 CUPS_CFLAGS="-I${with_cups_include}"
240 CUPS_FOUND=yes
241 fi
242 if test "x$CUPS_FOUND" = xno; then
243 BDEPS_CHECK_MODULE(CUPS, cups, xxx, [CUPS_FOUND=yes])
244 fi
245 if test "x$CUPS_FOUND" = xno; then
246 # Are the cups headers installed in the default /usr/include location?
247 AC_CHECK_HEADERS([cups/cups.h cups/ppd.h],
248 [
249 CUPS_FOUND=yes
250 CUPS_CFLAGS=
251 DEFAULT_CUPS=yes
252 ]
253 )
254 fi
255 if test "x$CUPS_FOUND" = xno; then
256 # Getting nervous now? Lets poke around for standard Solaris third-party
257 # package installation locations.
258 AC_MSG_CHECKING([for cups headers])
259 if test -s /opt/sfw/cups/include/cups/cups.h; then
260 # An SFW package seems to be installed!
261 CUPS_FOUND=yes
262 CUPS_CFLAGS="-I/opt/sfw/cups/include"
263 elif test -s /opt/csw/include/cups/cups.h; then
264 # A CSW package seems to be installed!
265 CUPS_FOUND=yes
266 CUPS_CFLAGS="-I/opt/csw/include"
267 fi
268 AC_MSG_RESULT([$CUPS_FOUND])
269 fi
270 if test "x$CUPS_FOUND" = xno; then
271 HELP_MSG_MISSING_DEPENDENCY([cups])
272 AC_MSG_ERROR([Could not find cups! $HELP_MSG ])
273 fi
274 fi
276 AC_SUBST(CUPS_CFLAGS)
278 ])
280 AC_DEFUN_ONCE([LIB_SETUP_FREETYPE],
281 [
283 ###############################################################################
284 #
285 # The ubiquitous freetype2 library is used to render fonts.
286 #
287 AC_ARG_WITH(freetype, [AS_HELP_STRING([--with-freetype],
288 [specify prefix directory for the freetype2 package
289 (expecting the libraries under PATH/lib and the headers under PATH/include)])])
291 # If we are using the OS installed system lib for freetype, then we do not need to copy it to the build tree
292 USING_SYSTEM_FT_LIB=false
294 if test "x$FREETYPE2_NOT_NEEDED" = xyes; then
295 if test "x$with_freetype" != x || test "x$with_freetype_include" != x || test "x$with_freetype_lib" != x; then
296 AC_MSG_WARN([freetype not used, so --with-freetype is ignored])
297 fi
298 FREETYPE2_CFLAGS=
299 FREETYPE2_LIBS=
300 FREETYPE2_LIB_PATH=
301 else
302 FREETYPE2_FOUND=no
304 if test "x$with_freetype" != x; then
305 BASIC_FIXUP_PATH(with_freetype)
306 FREETYPE2_LIBS="-L$with_freetype/lib -lfreetype"
307 FREETYPE2_LIB_PATH="$with_freetype/lib"
308 if test "x$OPENJDK_TARGET_OS" = xsolaris && test "x$OPENJDK_TARGET_CPU" = xx86_64 && test -d "$with_freetype/lib/amd64"; then
309 FREETYPE2_LIBS="-L$with_freetype/lib/amd64 -lfreetype"
310 FREETYPE2_LIB_PATH="$with_freetype/lib/amd64"
311 fi
312 if test "x$OPENJDK_TARGET_OS" = xwindows; then
313 FREETYPE2_LIBS="$with_freetype/lib/freetype.lib"
314 fi
315 FREETYPE2_CFLAGS="-I$with_freetype/include"
316 if test -s $with_freetype/include/ft2build.h && test -d $with_freetype/include/freetype2/freetype; then
317 FREETYPE2_CFLAGS="-I$with_freetype/include/freetype2 -I$with_freetype/include"
318 fi
319 FREETYPE2_FOUND=yes
320 if test "x$FREETYPE2_FOUND" = xyes; then
321 # Verify that the directories exist
322 if ! test -d "$with_freetype/lib" || ! test -d "$with_freetype/include"; then
323 AC_MSG_ERROR([Could not find the expected directories $with_freetype/lib and $with_freetype/include])
324 fi
325 # List the contents of the lib.
326 FREETYPELIB=`ls $with_freetype/lib/libfreetype.so $with_freetype/lib/freetype.dll 2> /dev/null`
327 if test "x$FREETYPELIB" = x; then
328 AC_MSG_ERROR([Could not find libfreetype.so nor freetype.dll in $with_freetype/lib])
329 fi
330 # Check one h-file
331 if ! test -s "$with_freetype/include/ft2build.h"; then
332 AC_MSG_ERROR([Could not find $with_freetype/include/ft2build.h])
333 fi
334 fi
335 fi
336 if test "x$FREETYPE2_FOUND" = xno; then
337 BDEPS_CHECK_MODULE(FREETYPE2, freetype2, xxx, [FREETYPE2_FOUND=yes], [FREETYPE2_FOUND=no])
338 USING_SYSTEM_FT_LIB=true
339 fi
340 if test "x$FREETYPE2_FOUND" = xno && test "x$OPENJDK_TARGET_OS" = xwindows; then
341 FREETYPELOCATION="$PROGRAMFILES/GnuWin32"
342 BASIC_FIXUP_PATH(FREETYPELOCATION)
343 AC_MSG_CHECKING([for freetype in some standard windows locations])
344 if test -s "$FREETYPELOCATION/include/ft2build.h" && test -d "$FREETYPELOCATION/include/freetype2/freetype"; then
345 FREETYPE2_CFLAGS="-I$FREETYPELOCATION/include/freetype2 -I$FREETYPELOCATION/include"
346 FREETYPE2_LIBS="$FREETYPELOCATION/lib/freetype.lib"
347 FREETYPE2_LIB_PATH="$FREETYPELOCATION/lib"
348 if ! test -s "$FREETYPE2_LIBS"; then
349 AC_MSG_ERROR([Could not find $FREETYPE2_LIBS])
350 fi
351 if ! test -s "$FREETYPE2_LIB_PATH/freetype.dll"; then
352 AC_MSG_ERROR([Could not find $FREETYPE2_LIB_PATH/freetype.dll])
353 fi
354 USING_SYSTEM_FT_LIB=true
355 FREETYPE2_FOUND=yes
356 fi
357 AC_MSG_RESULT([$FREETYPE2_FOUND])
358 fi
359 if test "x$FREETYPE2_FOUND" = xno; then
360 PKG_CHECK_MODULES(FREETYPE2, freetype2, [FREETYPE2_FOUND=yes], [FREETYPE2_FOUND=no])
361 # On solaris, pkg_check adds -lz to freetype libs, which isn't necessary for us.
362 FREETYPE2_LIBS=`$ECHO $FREETYPE2_LIBS | $SED 's/-lz//g'`
363 USING_SYSTEM_FT_LIB=true
364 # 64-bit libs for Solaris x86 are installed in the amd64 subdirectory, change lib to lib/amd64
365 if test "x$FREETYPE2_FOUND" = xyes && test "x$OPENJDK_TARGET_OS" = xsolaris && test "x$OPENJDK_TARGET_CPU" = xx86_64; then
366 FREETYPE2_LIBS=`$ECHO $FREETYPE2_LIBS | $SED 's?/lib?/lib/amd64?g'`
367 fi
368 fi
369 if test "x$FREETYPE2_FOUND" = xno; then
370 AC_MSG_CHECKING([for freetype in some standard locations])
372 if test -s $SYS_ROOT/usr/X11/include/ft2build.h && test -d $SYS_ROOT/usr/X11/include/freetype2/freetype; then
373 DEFAULT_FREETYPE_CFLAGS="-I$SYS_ROOT/usr/X11/include/freetype2 -I$SYS_ROOT/usr/X11/include"
374 DEFAULT_FREETYPE_LIBS="-L$SYS_ROOT/usr/X11/lib -lfreetype"
375 fi
376 if test -s $SYS_ROOT/usr/include/ft2build.h && test -d $SYS_ROOT/usr/include/freetype2/freetype; then
377 DEFAULT_FREETYPE_CFLAGS="-I$SYS_ROOT/usr/include/freetype2"
378 DEFAULT_FREETYPE_LIBS="-lfreetype"
379 fi
381 PREV_CXXCFLAGS="$CXXFLAGS"
382 PREV_LDFLAGS="$LDFLAGS"
383 CXXFLAGS="$CXXFLAGS $DEFAULT_FREETYPE_CFLAGS"
384 LDFLAGS="$LDFLAGS $DEFAULT_FREETYPE_LIBS"
385 AC_LINK_IFELSE([AC_LANG_SOURCE([[
386 #include<ft2build.h>
387 #include FT_FREETYPE_H
388 int main() { return 0; }
389 ]])],
390 [
391 # Yes, the default cflags and libs did the trick.
392 FREETYPE2_FOUND=yes
393 FREETYPE2_CFLAGS="$DEFAULT_FREETYPE_CFLAGS"
394 FREETYPE2_LIBS="$DEFAULT_FREETYPE_LIBS"
395 ],
396 [
397 FREETYPE2_FOUND=no
398 ]
399 )
400 CXXCFLAGS="$PREV_CXXFLAGS"
401 LDFLAGS="$PREV_LDFLAGS"
402 AC_MSG_RESULT([$FREETYPE2_FOUND])
403 USING_SYSTEM_FT_LIB=true
404 fi
405 if test "x$FREETYPE2_FOUND" = xno; then
406 HELP_MSG_MISSING_DEPENDENCY([freetype2])
407 AC_MSG_ERROR([Could not find freetype2! $HELP_MSG ])
408 fi
410 if test "x$OPENJDK_TARGET_OS" != xwindows; then
411 # AC_CHECK_LIB does not support use of cl.exe
412 PREV_LDFLAGS="$LDFLAGS"
413 LDFLAGS="$FREETYPE2_LIBS"
414 AC_CHECK_LIB(freetype, FT_Init_FreeType,
415 FREETYPE2_FOUND=true,
416 AC_MSG_ERROR([Could not find freetype2! $HELP_MSG ]))
417 LDFLAGS="$PREV_LDFLAGS"
418 fi
419 fi
421 AC_SUBST(USING_SYSTEM_FT_LIB)
422 AC_SUBST(FREETYPE2_LIB_PATH)
423 AC_SUBST(FREETYPE2_CFLAGS)
424 AC_SUBST(FREETYPE2_LIBS)
425 ])
427 AC_DEFUN_ONCE([LIB_SETUP_ALSA],
428 [
430 ###############################################################################
431 #
432 # Check for alsa headers and libraries. Used on Linux/GNU systems.
433 #
434 AC_ARG_WITH(alsa, [AS_HELP_STRING([--with-alsa],
435 [specify prefix directory for the alsa package
436 (expecting the libraries under PATH/lib and the headers under PATH/include)])])
437 AC_ARG_WITH(alsa-include, [AS_HELP_STRING([--with-alsa-include],
438 [specify directory for the alsa include files])])
439 AC_ARG_WITH(alsa-lib, [AS_HELP_STRING([--with-alsa-lib],
440 [specify directory for the alsa library])])
442 if test "x$ALSA_NOT_NEEDED" = xyes; then
443 if test "x${with_alsa}" != x || test "x${with_alsa_include}" != x || test "x${with_alsa_lib}" != x; then
444 AC_MSG_WARN([alsa not used, so --with-alsa is ignored])
445 fi
446 ALSA_CFLAGS=
447 ALSA_LIBS=
448 else
449 ALSA_FOUND=no
451 if test "x${with_alsa}" = xno || test "x${with_alsa_include}" = xno || test "x${with_alsa_lib}" = xno; then
452 AC_MSG_ERROR([It is not possible to disable the use of alsa. Remove the --without-alsa option.])
453 fi
455 if test "x${with_alsa}" != x; then
456 ALSA_LIBS="-L${with_alsa}/lib -lalsa"
457 ALSA_CFLAGS="-I${with_alsa}/include"
458 ALSA_FOUND=yes
459 fi
460 if test "x${with_alsa_include}" != x; then
461 ALSA_CFLAGS="-I${with_alsa_include}"
462 ALSA_FOUND=yes
463 fi
464 if test "x${with_alsa_lib}" != x; then
465 ALSA_LIBS="-L${with_alsa_lib} -lalsa"
466 ALSA_FOUND=yes
467 fi
468 if test "x$ALSA_FOUND" = xno; then
469 BDEPS_CHECK_MODULE(ALSA, alsa, xxx, [ALSA_FOUND=yes], [ALSA_FOUND=no])
470 fi
471 if test "x$ALSA_FOUND" = xno; then
472 PKG_CHECK_MODULES(ALSA, alsa, [ALSA_FOUND=yes], [ALSA_FOUND=no])
473 fi
474 if test "x$ALSA_FOUND" = xno; then
475 AC_CHECK_HEADERS([alsa/asoundlib.h],
476 [
477 ALSA_FOUND=yes
478 ALSA_CFLAGS=-Iignoreme
479 ALSA_LIBS=-lasound
480 DEFAULT_ALSA=yes
481 ],
482 [ALSA_FOUND=no])
483 fi
484 if test "x$ALSA_FOUND" = xno; then
485 HELP_MSG_MISSING_DEPENDENCY([alsa])
486 AC_MSG_ERROR([Could not find alsa! $HELP_MSG ])
487 fi
488 fi
490 AC_SUBST(ALSA_CFLAGS)
491 AC_SUBST(ALSA_LIBS)
492 ])
494 AC_DEFUN_ONCE([LIB_SETUP_MISC_LIBS],
495 [
497 ###############################################################################
498 #
499 # Check for the jpeg library
500 #
502 USE_EXTERNAL_LIBJPEG=true
503 AC_CHECK_LIB(jpeg, main, [],
504 [ USE_EXTERNAL_LIBJPEG=false
505 AC_MSG_NOTICE([Will use jpeg decoder bundled with the OpenJDK source])
506 ])
507 AC_SUBST(USE_EXTERNAL_LIBJPEG)
509 ###############################################################################
510 #
511 # Check for the gif library
512 #
514 AC_ARG_WITH(giflib, [AS_HELP_STRING([--with-giflib],
515 [use giflib from build system or OpenJDK source (system, bundled) @<:@bundled@:>@])])
518 AC_MSG_CHECKING([for which giflib to use])
520 # default is bundled
521 DEFAULT_GIFLIB=bundled
523 #
524 # if user didn't specify, use DEFAULT_GIFLIB
525 #
526 if test "x${with_giflib}" = "x"; then
527 with_giflib=${DEFAULT_GIFLIB}
528 fi
530 AC_MSG_RESULT(${with_giflib})
532 if test "x${with_giflib}" = "xbundled"; then
533 USE_EXTERNAL_LIBGIF=false
534 elif test "x${with_giflib}" = "xsystem"; then
535 AC_CHECK_HEADER(gif_lib.h, [],
536 [ AC_MSG_ERROR([--with-giflib=system specified, but gif_lib.h not found!])])
537 AC_CHECK_LIB(gif, DGifGetCode, [],
538 [ AC_MSG_ERROR([--with-giflib=system specified, but no giflib found!])])
540 USE_EXTERNAL_LIBGIF=true
541 else
542 AC_MSG_ERROR([Invalid value of --with-giflib: ${with_giflib}, use 'system' or 'bundled'])
543 fi
544 AC_SUBST(USE_EXTERNAL_LIBGIF)
546 ###############################################################################
547 #
548 # Check for the zlib library
549 #
551 AC_ARG_WITH(zlib, [AS_HELP_STRING([--with-zlib],
552 [use zlib from build system or OpenJDK source (system, bundled) @<:@bundled@:>@])])
554 AC_CHECK_LIB(z, compress,
555 [ ZLIB_FOUND=yes ],
556 [ ZLIB_FOUND=no ])
558 AC_MSG_CHECKING([for which zlib to use])
560 DEFAULT_ZLIB=bundled
561 if test "x$OPENJDK_TARGET_OS" = xmacosx; then
562 #
563 # On macosx default is system...on others default is
564 #
565 DEFAULT_ZLIB=system
566 fi
568 if test "x${ZLIB_FOUND}" != "xyes"; then
569 #
570 # If we don't find any system...set default to bundled
571 #
572 DEFAULT_ZLIB=bundled
573 fi
575 #
576 # If user didn't specify, use DEFAULT_ZLIB
577 #
578 if test "x${with_zlib}" = "x"; then
579 with_zlib=${DEFAULT_ZLIB}
580 fi
582 if test "x${with_zlib}" = "xbundled"; then
583 USE_EXTERNAL_LIBZ=false
584 AC_MSG_RESULT([bundled])
585 elif test "x${with_zlib}" = "xsystem"; then
586 if test "x${ZLIB_FOUND}" = "xyes"; then
587 USE_EXTERNAL_LIBZ=true
588 AC_MSG_RESULT([system])
589 else
590 AC_MSG_RESULT([system not found])
591 AC_MSG_ERROR([--with-zlib=system specified, but no zlib found!])
592 fi
593 else
594 AC_MSG_ERROR([Invalid value for --with-zlib: ${with_zlib}, use 'system' or 'bundled'])
595 fi
597 AC_SUBST(USE_EXTERNAL_LIBZ)
599 ###############################################################################
600 LIBZIP_CAN_USE_MMAP=true
602 AC_SUBST(LIBZIP_CAN_USE_MMAP)
604 ###############################################################################
605 #
606 # Check if altzone exists in time.h
607 #
609 AC_LINK_IFELSE([AC_LANG_PROGRAM([#include <time.h>], [return (int)altzone;])],
610 [has_altzone=yes],
611 [has_altzone=no])
612 if test "x$has_altzone" = xyes; then
613 AC_DEFINE([HAVE_ALTZONE], 1, [Define if you have the external 'altzone' variable in time.h])
614 fi
616 ###############################################################################
617 #
618 # Check the maths library
619 #
621 AC_CHECK_LIB(m, cos, [],
622 [
623 AC_MSG_NOTICE([Maths library was not found])
624 ]
625 )
626 AC_SUBST(LIBM)
628 ###############################################################################
629 #
630 # Check for libdl.so
632 save_LIBS="$LIBS"
633 LIBS=""
634 AC_CHECK_LIB(dl,dlopen)
635 LIBDL="$LIBS"
636 AC_SUBST(LIBDL)
637 LIBS="$save_LIBS"
638 ])
640 AC_DEFUN_ONCE([LIB_SETUP_STATIC_LINK_LIBSTDCPP],
641 [
642 ###############################################################################
643 #
644 # statically link libstdc++ before C++ ABI is stablized on Linux unless
645 # dynamic build is configured on command line.
646 #
647 AC_ARG_WITH([stdc++lib], [AS_HELP_STRING([--with-stdc++lib=<static>,<dynamic>,<default>],
648 [force linking of the C++ runtime on Linux to either static or dynamic, default is static with dynamic as fallback])],
649 [
650 if test "x$with_stdc__lib" != xdynamic && test "x$with_stdc__lib" != xstatic \
651 && test "x$with_stdc__lib" != xdefault; then
652 AC_MSG_ERROR([Bad parameter value --with-stdc++lib=$with_stdc__lib!])
653 fi
654 ],
655 [with_stdc__lib=default]
656 )
658 if test "x$OPENJDK_TARGET_OS" = xlinux; then
659 # Test if -lstdc++ works.
660 AC_MSG_CHECKING([if dynamic link of stdc++ is possible])
661 AC_LANG_PUSH(C++)
662 OLD_CXXFLAGS="$CXXFLAGS"
663 CXXFLAGS="$CXXFLAGS -lstdc++"
664 AC_LINK_IFELSE([AC_LANG_PROGRAM([], [return 0;])],
665 [has_dynamic_libstdcxx=yes],
666 [has_dynamic_libstdcxx=no])
667 CXXFLAGS="$OLD_CXXFLAGS"
668 AC_LANG_POP(C++)
669 AC_MSG_RESULT([$has_dynamic_libstdcxx])
671 # Test if stdc++ can be linked statically.
672 AC_MSG_CHECKING([if static link of stdc++ is possible])
673 STATIC_STDCXX_FLAGS="-Wl,-Bstatic -lstdc++ -lgcc -Wl,-Bdynamic"
674 AC_LANG_PUSH(C++)
675 OLD_LIBS="$LIBS"
676 OLD_CXX="$CXX"
677 LIBS="$STATIC_STDCXX_FLAGS"
678 CXX="$CC"
679 AC_LINK_IFELSE([AC_LANG_PROGRAM([], [return 0;])],
680 [has_static_libstdcxx=yes],
681 [has_static_libstdcxx=no])
682 LIBS="$OLD_LIBS"
683 CXX="$OLD_CXX"
684 AC_LANG_POP(C++)
685 AC_MSG_RESULT([$has_static_libstdcxx])
687 if test "x$has_static_libstdcxx" = xno && test "x$has_dynamic_libstdcxx" = xno; then
688 AC_MSG_ERROR([Cannot link to stdc++, neither dynamically nor statically!])
689 fi
691 if test "x$with_stdc__lib" = xstatic && test "x$has_static_libstdcxx" = xno; then
692 AC_MSG_ERROR([Static linking of libstdc++ was not possible!])
693 fi
695 if test "x$with_stdc__lib" = xdynamic && test "x$has_dynamic_libstdcxx" = xno; then
696 AC_MSG_ERROR([Dynamic linking of libstdc++ was not possible!])
697 fi
699 AC_MSG_CHECKING([how to link with libstdc++])
700 # If dynamic was requested, it's available since it would fail above otherwise.
701 # If dynamic wasn't requested, go with static unless it isn't available.
702 if test "x$with_stdc__lib" = xdynamic || test "x$has_static_libstdcxx" = xno || test "x$JVM_VARIANT_ZEROSHARK" = xtrue; then
703 LIBCXX="$LIBCXX -lstdc++"
704 LDCXX="$CXX"
705 STATIC_CXX_SETTING="STATIC_CXX=false"
706 AC_MSG_RESULT([dynamic])
707 else
708 LIBCXX="$LIBCXX $STATIC_STDCXX_FLAGS"
709 LDCXX="$CC"
710 STATIC_CXX_SETTING="STATIC_CXX=true"
711 AC_MSG_RESULT([static])
712 fi
713 fi
714 AC_SUBST(STATIC_CXX_SETTING)
716 if test "x$JVM_VARIANT_ZERO" = xtrue || test "x$JVM_VARIANT_ZEROSHARK" = xtrue; then
717 # Figure out LIBFFI_CFLAGS and LIBFFI_LIBS
718 PKG_CHECK_MODULES([LIBFFI], [libffi])
720 fi
722 if test "x$JVM_VARIANT_ZEROSHARK" = xtrue; then
723 AC_CHECK_PROG([LLVM_CONFIG], [llvm-config], [llvm-config])
725 if test "x$LLVM_CONFIG" != xllvm-config; then
726 AC_MSG_ERROR([llvm-config not found in $PATH.])
727 fi
729 llvm_components="jit mcjit engine nativecodegen native"
730 unset LLVM_CFLAGS
731 for flag in $("$LLVM_CONFIG" --cxxflags); do
732 if echo "${flag}" | grep -q '^-@<:@ID@:>@'; then
733 if test "${flag}" != "-D_DEBUG" ; then
734 if test "${LLVM_CFLAGS}" != "" ; then
735 LLVM_CFLAGS="${LLVM_CFLAGS} "
736 fi
737 LLVM_CFLAGS="${LLVM_CFLAGS}${flag}"
738 fi
739 fi
740 done
741 llvm_version=$("${LLVM_CONFIG}" --version | sed 's/\.//; s/svn.*//')
742 LLVM_CFLAGS="${LLVM_CFLAGS} -DSHARK_LLVM_VERSION=${llvm_version}"
744 unset LLVM_LDFLAGS
745 for flag in $("${LLVM_CONFIG}" --ldflags); do
746 if echo "${flag}" | grep -q '^-L'; then
747 if test "${LLVM_LDFLAGS}" != ""; then
748 LLVM_LDFLAGS="${LLVM_LDFLAGS} "
749 fi
750 LLVM_LDFLAGS="${LLVM_LDFLAGS}${flag}"
751 fi
752 done
754 unset LLVM_LIBS
755 for flag in $("${LLVM_CONFIG}" --libs ${llvm_components}); do
756 if echo "${flag}" | grep -q '^-l'; then
757 if test "${LLVM_LIBS}" != ""; then
758 LLVM_LIBS="${LLVM_LIBS} "
759 fi
760 LLVM_LIBS="${LLVM_LIBS}${flag}"
761 fi
762 done
764 AC_SUBST(LLVM_CFLAGS)
765 AC_SUBST(LLVM_LDFLAGS)
766 AC_SUBST(LLVM_LIBS)
767 fi
769 # libCrun is the c++ runtime-library with SunStudio (roughly the equivalent of gcc's libstdc++.so)
770 if test "x$OPENJDK_TARGET_OS" = xsolaris && test "x$LIBCXX" = x; then
771 LIBCXX="/usr/lib${OPENJDK_TARGET_CPU_ISADIR}/libCrun.so.1"
772 fi
774 # TODO better (platform agnostic) test
775 if test "x$OPENJDK_TARGET_OS" = xmacosx && test "x$LIBCXX" = x && test "x$GCC" = xyes; then
776 LIBCXX="-lstdc++"
777 fi
779 AC_SUBST(LIBCXX)
780 ])