libraries.m4 25.7 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75
#
# Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License version 2 only, as
# published by the Free Software Foundation.  Oracle designates this
# particular file as subject to the "Classpath" exception as provided
# by Oracle in the LICENSE file that accompanied this code.
#
# This code is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
# version 2 for more details (a copy is included in the LICENSE file that
# accompanied this code).
#
# You should have received a copy of the GNU General Public License version
# 2 along with this work; if not, write to the Free Software Foundation,
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
#
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
# or visit www.oracle.com if you need additional information or have any
# questions.
#

AC_DEFUN_ONCE([LIB_SETUP_INIT],
[
        
###############################################################################
#
# OS specific settings that we never will need to probe.
#
if test "x$OPENJDK_TARGET_OS" = xlinux; then
    AC_MSG_CHECKING([what is not needed on Linux?])
    PULSE_NOT_NEEDED=yes
    AC_MSG_RESULT([pulse])
fi

if test "x$OPENJDK_TARGET_OS" = xsolaris; then
    AC_MSG_CHECKING([what is not needed on Solaris?])
    ALSA_NOT_NEEDED=yes
    PULSE_NOT_NEEDED=yes
    AC_MSG_RESULT([alsa pulse])
fi

if test "x$OPENJDK_TARGET_OS" = xwindows; then
    AC_MSG_CHECKING([what is not needed on Windows?])
    CUPS_NOT_NEEDED=yes    
    ALSA_NOT_NEEDED=yes
    PULSE_NOT_NEEDED=yes
    X11_NOT_NEEDED=yes
    AC_MSG_RESULT([alsa cups pulse x11])
fi

if test "x$OPENJDK_TARGET_OS" = xmacosx; then
    AC_MSG_CHECKING([what is not needed on MacOSX?])
    ALSA_NOT_NEEDED=yes
    PULSE_NOT_NEEDED=yes
    X11_NOT_NEEDED=yes
    FREETYPE2_NOT_NEEDED=yes    
    # If the java runtime framework is disabled, then we need X11.
    # This will be adjusted below.
    AC_MSG_RESULT([alsa pulse x11])
fi

if test "x$OPENJDK_TARGET_OS" = xbsd; then
    AC_MSG_CHECKING([what is not needed on bsd?])
    ALSA_NOT_NEEDED=yes
    AC_MSG_RESULT([alsa])    
fi

if test "x$OPENJDK" = "xfalse"; then
    FREETYPE2_NOT_NEEDED=yes
fi

76 77 78 79
if test "x$SUPPORT_HEADFUL" = xno; then
    X11_NOT_NEEDED=yes
fi

80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125
###############################################################################
#
# Check for MacOSX support for OpenJDK. If this exists, try to build a JVM
# that uses this API. 
#
AC_ARG_ENABLE([macosx-runtime-support], [AS_HELP_STRING([--disable-macosx-runtime-support],
	[disable the use of MacOSX Java runtime support framework @<:@enabled@:>@])],
	[MACOSX_RUNTIME_SUPPORT="${enableval}"],[MACOSX_RUNTIME_SUPPORT="no"])

USE_MACOSX_RUNTIME_SUPPORT=no
AC_MSG_CHECKING([for explicit Java runtime support in the OS])
if test -f /System/Library/Frameworks/JavaVM.framework/Frameworks/JavaRuntimeSupport.framework/Headers/JavaRuntimeSupport.h; then
    if test "x$MACOSX_RUNTIME_SUPPORT" != xno; then
        MACOSX_RUNTIME_SUPPORT=yes
        USE_MACOSX_RUNTIME_SUPPORT=yes
        AC_MSG_RESULT([yes, does not need alsa freetype2 pulse and X11])
    else
        AC_MSG_RESULT([yes, but explicitly disabled.])
    fi
else
    AC_MSG_RESULT([no])
fi

if test "x$OPENJDK_TARGET_OS" = xmacosx && test "x$USE_MACOSX_RUNTIME_SUPPORT" = xno; then
    AC_MSG_CHECKING([what is not needed on an X11 build on MacOSX?])
    X11_NOT_NEEDED=
    FREETYPE2_NOT_NEEDED=
    AC_MSG_RESULT([alsa pulse])
fi
])

AC_DEFUN_ONCE([LIB_SETUP_X11],
[

###############################################################################
#
# Check for X Windows
#

# Check if the user has specified sysroot, but not --x-includes or --x-libraries.
# Make a simple check for the libraries at the sysroot, and setup --x-includes and
# --x-libraries for the sysroot, if that seems to be correct.
if test "x$SYS_ROOT" != "x/"; then
  if test "x$x_includes" = xNONE; then
    if test -f "$SYS_ROOT/usr/X11R6/include/X11/Xlib.h"; then
      x_includes="$SYS_ROOT/usr/X11R6/include"
126 127
    elif test -f "$SYS_ROOT/usr/include/X11/Xlib.h"; then
      x_includes="$SYS_ROOT/usr/include"
128 129 130 131 132
    fi
  fi
  if test "x$x_libraries" = xNONE; then
    if test -f "$SYS_ROOT/usr/X11R6/lib/libX11.so"; then
      x_libraries="$SYS_ROOT/usr/X11R6/lib"
133 134 135 136
    elif test "$SYS_ROOT/usr/lib64/libX11.so" && test "x$OPENJDK_TARGET_CPU_BITS" = x64; then
      x_libraries="$SYS_ROOT/usr/lib64"
    elif test -f "$SYS_ROOT/usr/lib/libX11.so"; then
      x_libraries="$SYS_ROOT/usr/lib"
137 138 139 140 141 142 143 144
    fi
  fi
fi

# Now let autoconf do it's magic
AC_PATH_X
AC_PATH_XTRA

145 146 147 148 149 150
# AC_PATH_XTRA creates X_LIBS and sometimes adds -R flags. When cross compiling
# this doesn't make sense so we remove it.
if test "x$COMPILE_TYPE" = xcross; then
  X_LIBS=`$ECHO $X_LIBS | $SED 's/-R \{0,1\}[[^ ]]*//g'`
fi

151 152 153 154 155 156 157 158 159 160 161
if test "x$no_x" = xyes && test "x$X11_NOT_NEEDED" != xyes; then 
    HELP_MSG_MISSING_DEPENDENCY([x11])
    AC_MSG_ERROR([Could not find X11 libraries. $HELP_MSG])
fi

# Some of the old makefiles require a setting of OPENWIN_HOME
# Since the X11R6 directory has disappeared on later Linuxes,
# we need to probe for it.
if test "x$OPENJDK_TARGET_OS" = xlinux; then
    if test -d "$SYS_ROOT/usr/X11R6"; then
        OPENWIN_HOME="$SYS_ROOT/usr/X11R6"
162
    elif test -d "$SYS_ROOT/usr/include/X11"; then
163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185
        OPENWIN_HOME="$SYS_ROOT/usr"
    fi
fi
if test "x$OPENJDK_TARGET_OS" = xsolaris; then
    OPENWIN_HOME="/usr/openwin"
fi
AC_SUBST(OPENWIN_HOME)


#
# Weird Sol10 something check...TODO change to try compile
#
if test "x${OPENJDK_TARGET_OS}" = xsolaris; then
  if test "`uname -r`" = "5.10"; then
     if test "`${EGREP} -c XLinearGradient ${OPENWIN_HOME}/share/include/X11/extensions/Xrender.h`" = "0"; then
     	X_CFLAGS="${X_CFLAGS} -DSOLARIS10_NO_XRENDER_STRUCTS"
     fi
  fi
fi

AC_LANG_PUSH(C)
OLD_CFLAGS="$CFLAGS"
CFLAGS="$CFLAGS $X_CFLAGS"
O
ohair 已提交
186 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],
O
ohair 已提交
189
                 [X11_A_OK=yes],
190
                 [X11_A_OK=no; break],
O
ohair 已提交
191 192 193 194
                 [ # include <X11/Xlib.h>
                   # include <X11/Xutil.h>
                 ])

195 196 197 198 199
CFLAGS="$OLD_CFLAGS"
AC_LANG_POP(C)

if test "x$X11_A_OK" = xno && test "x$X11_NOT_NEEDED" != xyes; then 
    HELP_MSG_MISSING_DEPENDENCY([x11])
200
    AC_MSG_ERROR([Could not find all X11 headers (shape.h Xrender.h XTest.h Intrinsic.h). $HELP_MSG])
201 202 203 204 205 206 207 208 209 210 211 212 213 214 215
fi

AC_SUBST(X_CFLAGS)
AC_SUBST(X_LIBS)
])

AC_DEFUN_ONCE([LIB_SETUP_CUPS],
[

###############################################################################
#
# The common unix printing system cups is used to print from java.
#
AC_ARG_WITH(cups, [AS_HELP_STRING([--with-cups],
    [specify prefix directory for the cups package
O
ohair 已提交
216
	 (expecting the headers under PATH/include)])])
217 218 219 220
AC_ARG_WITH(cups-include, [AS_HELP_STRING([--with-cups-include],
	[specify directory for the cups include files])])

if test "x$CUPS_NOT_NEEDED" = xyes; then
O
ohair 已提交
221
	if test "x${with_cups}" != x || test "x${with_cups_include}" != x; then
222 223 224 225 226 227
		AC_MSG_WARN([cups not used, so --with-cups is ignored])
	fi
	CUPS_CFLAGS=
else
	CUPS_FOUND=no

O
ohair 已提交
228
	if test "x${with_cups}" = xno || test "x${with_cups_include}" = xno; then
229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252
	    AC_MSG_ERROR([It is not possible to disable the use of cups. Remove the --without-cups option.])
	fi

	if test "x${with_cups}" != x; then
	    CUPS_CFLAGS="-I${with_cups}/include"
	    CUPS_FOUND=yes
	fi
	if test "x${with_cups_include}" != x; then
	    CUPS_CFLAGS="-I${with_cups_include}"
	    CUPS_FOUND=yes
	fi
	if test "x$CUPS_FOUND" = xno; then
	    BDEPS_CHECK_MODULE(CUPS, cups, xxx, [CUPS_FOUND=yes])
	fi
	if test "x$CUPS_FOUND" = xno; then
	    # Are the cups headers installed in the default /usr/include location?
	    AC_CHECK_HEADERS([cups/cups.h cups/ppd.h],
	                     [CUPS_FOUND=yes
	                      CUPS_CFLAGS=
	                      DEFAULT_CUPS=yes])
	fi
	if test "x$CUPS_FOUND" = xno; then
	    # Getting nervous now? Lets poke around for standard Solaris third-party
	    # package installation locations.
O
ohair 已提交
253
	    AC_MSG_CHECKING([for cups headers])
254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299
	    if test -s /opt/sfw/cups/include/cups/cups.h; then
	       # An SFW package seems to be installed!
	       CUPS_FOUND=yes
	       CUPS_CFLAGS="-I/opt/sfw/cups/include"
	    elif test -s /opt/csw/include/cups/cups.h; then
	       # A CSW package seems to be installed!
	       CUPS_FOUND=yes
	       CUPS_CFLAGS="-I/opt/csw/include"
	    fi
	    AC_MSG_RESULT([$CUPS_FOUND])
	fi
	if test "x$CUPS_FOUND" = xno; then 
	    HELP_MSG_MISSING_DEPENDENCY([cups])
	    AC_MSG_ERROR([Could not find cups! $HELP_MSG ])
	fi
fi

AC_SUBST(CUPS_CFLAGS)

])

AC_DEFUN_ONCE([LIB_SETUP_FREETYPE],
[

###############################################################################
#
# The ubiquitous freetype2 library is used to render fonts.
#
AC_ARG_WITH(freetype, [AS_HELP_STRING([--with-freetype],
	[specify prefix directory for the freetype2 package
     (expecting the libraries under PATH/lib and the headers under PATH/include)])])

# If we are using the OS installed system lib for freetype, then we do not need to copy it to the build tree
USING_SYSTEM_FT_LIB=false

if test "x$FREETYPE2_NOT_NEEDED" = xyes; then
	if test "x$with_freetype" != x || test "x$with_freetype_include" != x || test "x$with_freetype_lib" != x; then
		AC_MSG_WARN([freetype not used, so --with-freetype is ignored])
	fi
	FREETYPE2_CFLAGS=
	FREETYPE2_LIBS=
        FREETYPE2_LIB_PATH=
else
	FREETYPE2_FOUND=no

	if test "x$with_freetype" != x; then
O
ohair 已提交
300
            BASIC_FIXUP_PATH(with_freetype)
301
	    FREETYPE2_LIBS="-L$with_freetype/lib -lfreetype"
O
ohair 已提交
302 303 304 305 306
            FREETYPE2_LIB_PATH="$with_freetype/lib"
            if test "x$OPENJDK_TARGET_OS" = xsolaris && test "x$OPENJDK_TARGET_CPU" = xx86_64 && test -d "$with_freetype/lib/amd64"; then
                FREETYPE2_LIBS="-L$with_freetype/lib/amd64 -lfreetype"
                FREETYPE2_LIB_PATH="$with_freetype/lib/amd64"
            fi
307 308 309 310 311 312 313
            if test "x$OPENJDK_TARGET_OS" = xwindows; then
                FREETYPE2_LIBS="$with_freetype/lib/freetype.lib"
            fi
	    FREETYPE2_CFLAGS="-I$with_freetype/include"
            if test -s $with_freetype/include/ft2build.h && test -d $with_freetype/include/freetype2/freetype; then
                FREETYPE2_CFLAGS="-I$with_freetype/include/freetype2 -I$with_freetype/include"
            fi
O
ohair 已提交
314
 	    FREETYPE2_FOUND=yes
315 316 317 318 319 320 321 322
   	    if test "x$FREETYPE2_FOUND" = xyes; then
	        # Verify that the directories exist 
                if ! test -d "$with_freetype/lib" || ! test -d "$with_freetype/include"; then
		   AC_MSG_ERROR([Could not find the expected directories $with_freetype/lib and $with_freetype/include])
		fi
	        # List the contents of the lib.
		FREETYPELIB=`ls $with_freetype/lib/libfreetype.so $with_freetype/lib/freetype.dll 2> /dev/null`
                if test "x$FREETYPELIB" = x; then
O
ohair 已提交
323
		   AC_MSG_ERROR([Could not find libfreetype.so nor freetype.dll in $with_freetype/lib])
324 325 326 327 328 329 330 331 332 333 334
		fi
	        # Check one h-file
                if ! test -s "$with_freetype/include/ft2build.h"; then
		   AC_MSG_ERROR([Could not find $with_freetype/include/ft2build.h])
		fi
            fi
        fi
	if test "x$FREETYPE2_FOUND" = xno; then
	    BDEPS_CHECK_MODULE(FREETYPE2, freetype2, xxx, [FREETYPE2_FOUND=yes], [FREETYPE2_FOUND=no])
            USING_SYSTEM_FT_LIB=true
	fi
O
ohair 已提交
335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353
	if test "x$FREETYPE2_FOUND" = xno && test "x$OPENJDK_TARGET_OS" = xwindows; then
            FREETYPELOCATION="$PROGRAMFILES/GnuWin32"
            BASIC_FIXUP_PATH(FREETYPELOCATION)
	    AC_MSG_CHECKING([for freetype in some standard windows locations])
	    if test -s "$FREETYPELOCATION/include/ft2build.h" && test -d "$FREETYPELOCATION/include/freetype2/freetype"; then
	        FREETYPE2_CFLAGS="-I$FREETYPELOCATION/include/freetype2 -I$FREETYPELOCATION/include"
	        FREETYPE2_LIBS="$FREETYPELOCATION/lib/freetype.lib"
 	        FREETYPE2_LIB_PATH="$FREETYPELOCATION/lib"
                if ! test -s "$FREETYPE2_LIBS"; then
		   AC_MSG_ERROR([Could not find $FREETYPE2_LIBS])
		fi
                if ! test -s "$FREETYPE2_LIB_PATH/freetype.dll"; then
		   AC_MSG_ERROR([Could not find $FREETYPE2_LIB_PATH/freetype.dll])
		fi
                USING_SYSTEM_FT_LIB=true
                FREETYPE2_FOUND=yes
	    fi
	    AC_MSG_RESULT([$FREETYPE2_FOUND])         
        fi
354 355
	if test "x$FREETYPE2_FOUND" = xno; then
	    PKG_CHECK_MODULES(FREETYPE2, freetype2, [FREETYPE2_FOUND=yes], [FREETYPE2_FOUND=no])
O
ohair 已提交
356 357
            # On solaris, pkg_check adds -lz to freetype libs, which isn't necessary for us.
            FREETYPE2_LIBS=`$ECHO $FREETYPE2_LIBS | $SED 's/-lz//g'` 
358
            USING_SYSTEM_FT_LIB=true
O
ohair 已提交
359 360 361 362
            # 64-bit libs for Solaris x86 are installed in the amd64 subdirectory, change lib to lib/amd64
            if test "x$FREETYPE2_FOUND" = xyes && test "x$OPENJDK_TARGET_OS" = xsolaris && test "x$OPENJDK_TARGET_CPU" = xx86_64; then
              FREETYPE2_LIBS=`$ECHO $FREETYPE2_LIBS | $SED 's?/lib?/lib/amd64?g'`
            fi
363 364 365 366
	fi
	if test "x$FREETYPE2_FOUND" = xno; then
	    AC_MSG_CHECKING([for freetype in some standard locations])
	
367 368 369
	    if test -s $SYS_ROOT/usr/X11/include/ft2build.h && test -d $SYS_ROOT/usr/X11/include/freetype2/freetype; then
	        DEFAULT_FREETYPE_CFLAGS="-I$SYS_ROOT/usr/X11/include/freetype2 -I$SYS_ROOT/usr/X11/include"
	        DEFAULT_FREETYPE_LIBS="-L$SYS_ROOT/usr/X11/lib -lfreetype"
370
	    fi
371 372
	    if test -s $SYS_ROOT/usr/include/ft2build.h && test -d $SYS_ROOT/usr/include/freetype2/freetype; then
	        DEFAULT_FREETYPE_CFLAGS="-I$SYS_ROOT/usr/include/freetype2"
373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400
	        DEFAULT_FREETYPE_LIBS="-lfreetype"
	    fi
	
	    PREV_CXXCFLAGS="$CXXFLAGS"
	    PREV_LDFLAGS="$LDFLAGS"
	    CXXFLAGS="$CXXFLAGS $DEFAULT_FREETYPE_CFLAGS"
	    LDFLAGS="$LDFLAGS $DEFAULT_FREETYPE_LIBS"
	    AC_LINK_IFELSE([AC_LANG_SOURCE([[#include<ft2build.h>
	                    #include FT_FREETYPE_H 
	                   int main() { return 0; }
	                  ]])],
	                  [
	                      # Yes, the default cflags and libs did the trick.
	                      FREETYPE2_FOUND=yes
	                      FREETYPE2_CFLAGS="$DEFAULT_FREETYPE_CFLAGS"
	                      FREETYPE2_LIBS="$DEFAULT_FREETYPE_LIBS"
	                  ],
	                  [
	                      FREETYPE2_FOUND=no
	                  ])
            CXXCFLAGS="$PREV_CXXFLAGS"
	    LDFLAGS="$PREV_LDFLAGS"
	    AC_MSG_RESULT([$FREETYPE2_FOUND])
            USING_SYSTEM_FT_LIB=true
	fi
	if test "x$FREETYPE2_FOUND" = xno; then
		HELP_MSG_MISSING_DEPENDENCY([freetype2])
		AC_MSG_ERROR([Could not find freetype2! $HELP_MSG ])
O
ohair 已提交
401 402 403 404 405 406
	fi

        if test "x$OPENJDK_TARGET_OS" != xwindows; then
            # AC_CHECK_LIB does not support use of cl.exe
            PREV_LDFLAGS="$LDFLAGS"
            LDFLAGS="$FREETYPE2_LIBS"
407 408 409
            AC_CHECK_LIB(freetype, FT_Init_FreeType, 
                         FREETYPE2_FOUND=true, 
                         AC_MSG_ERROR([Could not find freetype2! $HELP_MSG ]))
O
ohair 已提交
410 411
            LDFLAGS="$PREV_LDFLAGS"
        fi
412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506
fi

AC_SUBST(USING_SYSTEM_FT_LIB)
AC_SUBST(FREETYPE2_LIB_PATH)
AC_SUBST(FREETYPE2_CFLAGS)
AC_SUBST(FREETYPE2_LIBS)

])

AC_DEFUN_ONCE([LIB_SETUP_ALSA],
[

###############################################################################
#
# Check for alsa headers and libraries. Used on Linux/GNU systems.
#
AC_ARG_WITH(alsa, [AS_HELP_STRING([--with-alsa],
	[specify prefix directory for the alsa package
	 (expecting the libraries under PATH/lib and the headers under PATH/include)])])
AC_ARG_WITH(alsa-include, [AS_HELP_STRING([--with-alsa-include],
	[specify directory for the alsa include files])])
AC_ARG_WITH(alsa-lib, [AS_HELP_STRING([--with-alsa-lib],
	[specify directory for the alsa library])])

if test "x$ALSA_NOT_NEEDED" = xyes; then
	if test "x${with_alsa}" != x || test "x${with_alsa_include}" != x || test "x${with_alsa_lib}" != x; then
		AC_MSG_WARN([alsa not used, so --with-alsa is ignored])
	fi
	ALSA_CFLAGS=
	ALSA_LIBS=
else
	ALSA_FOUND=no

	if test "x${with_alsa}" = xno || test "x${with_alsa_include}" = xno || test "x${with_alsa_lib}" = xno; then
	    AC_MSG_ERROR([It is not possible to disable the use of alsa. Remove the --without-alsa option.])
	fi

	if test "x${with_alsa}" != x; then
	    ALSA_LIBS="-L${with_alsa}/lib -lalsa"
	    ALSA_CFLAGS="-I${with_alsa}/include"
	    ALSA_FOUND=yes
	fi
	if test "x${with_alsa_include}" != x; then
	    ALSA_CFLAGS="-I${with_alsa_include}"
	    ALSA_FOUND=yes
	fi
	if test "x${with_alsa_lib}" != x; then
	    ALSA_LIBS="-L${with_alsa_lib} -lalsa"
	    ALSA_FOUND=yes
	fi
	if test "x$ALSA_FOUND" = xno; then
	    BDEPS_CHECK_MODULE(ALSA, alsa, xxx, [ALSA_FOUND=yes], [ALSA_FOUND=no])
	fi
	if test "x$ALSA_FOUND" = xno; then
	    PKG_CHECK_MODULES(ALSA, alsa, [ALSA_FOUND=yes], [ALSA_FOUND=no])
	fi
	if test "x$ALSA_FOUND" = xno; then
	    AC_CHECK_HEADERS([alsa/asoundlib.h],
	                     [ALSA_FOUND=yes
	                      ALSA_CFLAGS=-Iignoreme
	                      ALSA_LIBS=-lasound
	                      DEFAULT_ALSA=yes],
	                     [ALSA_FOUND=no])
	fi
	if test "x$ALSA_FOUND" = xno; then 
	    HELP_MSG_MISSING_DEPENDENCY([alsa])
	    AC_MSG_ERROR([Could not find alsa! $HELP_MSG ])
	fi    
fi

AC_SUBST(ALSA_CFLAGS)
AC_SUBST(ALSA_LIBS)

])

AC_DEFUN_ONCE([LIB_SETUP_MISC_LIBS],
[

###############################################################################
#
# Check for the jpeg library
#

USE_EXTERNAL_LIBJPEG=true
AC_CHECK_LIB(jpeg, main, [],
             [ USE_EXTERNAL_LIBJPEG=false
               AC_MSG_NOTICE([Will use jpeg decoder bundled with the OpenJDK source])
             ])
AC_SUBST(USE_EXTERNAL_LIBJPEG)
        
###############################################################################
#
# Check for the gif library
#

507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536
AC_ARG_WITH(giflib, [AS_HELP_STRING([--with-giflib],
	[use giflib from build system or OpenJDK source (system, bundled) @<:@bundled@:>@])])


AC_MSG_CHECKING([for which giflib to use])

# default is bundled
DEFAULT_GIFLIB=bundled

#
# if user didn't specify, use DEFAULT_GIFLIB
#
if test "x${with_giflib}" = "x"; then
    with_giflib=${DEFAULT_GIFLIB}
fi

AC_MSG_RESULT(${with_giflib})

if test "x${with_giflib}" = "xbundled"; then
    USE_EXTERNAL_LIBGIF=false
elif test "x${with_giflib}" = "xsystem"; then
    AC_CHECK_HEADER(gif_lib.h, [],
             [ AC_MSG_ERROR([--with-giflib=system specified, but gif_lib.h not found!])])
    AC_CHECK_LIB(gif, DGifGetCode, [],
             [ AC_MSG_ERROR([--with-giflib=system specified, but no giflib found!])])

    USE_EXTERNAL_LIBGIF=true
else
    AC_MSG_ERROR([Invalid value of --with-giflib: ${with_giflib}, use 'system' or 'bundled'])
fi
537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593
AC_SUBST(USE_EXTERNAL_LIBGIF)

###############################################################################
#
# Check for the zlib library
#

AC_ARG_WITH(zlib, [AS_HELP_STRING([--with-zlib],
	[use zlib from build system or OpenJDK source (system, bundled) @<:@bundled@:>@])])

AC_CHECK_LIB(z, compress,
             [ ZLIB_FOUND=yes ],
             [ ZLIB_FOUND=no ])

AC_MSG_CHECKING([for which zlib to use])

DEFAULT_ZLIB=bundled
if test "x$OPENJDK_TARGET_OS" = xmacosx; then
#
# On macosx default is system...on others default is 
#
    DEFAULT_ZLIB=system
fi

if test "x${ZLIB_FOUND}" != "xyes"; then
#
# If we don't find any system...set default to bundled
#
    DEFAULT_ZLIB=bundled
fi

#
# If user didn't specify, use DEFAULT_ZLIB
#
if test "x${with_zlib}" = "x"; then
    with_zlib=${DEFAULT_ZLIB}
fi

if test "x${with_zlib}" = "xbundled"; then
    USE_EXTERNAL_LIBZ=false
    AC_MSG_RESULT([bundled])
elif test "x${with_zlib}" = "xsystem"; then
    if test "x${ZLIB_FOUND}" = "xyes"; then
        USE_EXTERNAL_LIBZ=true
        AC_MSG_RESULT([system])
    else
        AC_MSG_RESULT([system not found])
        AC_MSG_ERROR([--with-zlib=system specified, but no zlib found!])  
    fi
else
    AC_MSG_ERROR([Invalid value for --with-zlib: ${with_zlib}, use 'system' or 'bundled'])  
fi

AC_SUBST(USE_EXTERNAL_LIBZ)

###############################################################################
LIBZIP_CAN_USE_MMAP=true
594

595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639
AC_SUBST(LIBZIP_CAN_USE_MMAP)

###############################################################################
#
# Check if altzone exists in time.h
#

AC_LINK_IFELSE([AC_LANG_PROGRAM([#include <time.h>], [return (int)altzone;])],
            [has_altzone=yes],
            [has_altzone=no])
if test "x$has_altzone" = xyes; then
    AC_DEFINE([HAVE_ALTZONE], 1, [Define if you have the external 'altzone' variable in time.h])
fi

###############################################################################
#
# Check the maths library
#

AC_CHECK_LIB(m, cos, [],
             [ 
                  AC_MSG_NOTICE([Maths library was not found])
             ])
AC_SUBST(LIBM)

###############################################################################
#
# Check for libdl.so

save_LIBS="$LIBS"
LIBS=""
AC_CHECK_LIB(dl,dlopen)
LIBDL="$LIBS"
AC_SUBST(LIBDL)
LIBS="$save_LIBS"

])

AC_DEFUN_ONCE([LIB_SETUP_STATIC_LINK_LIBSTDCPP],
[
###############################################################################
#
# statically link libstdc++ before C++ ABI is stablized on Linux unless 
# dynamic build is configured on command line.
#
640 641 642 643 644 645 646 647 648 649
AC_ARG_WITH([stdc++lib], [AS_HELP_STRING([--with-stdc++lib=<static>,<dynamic>,<default>],
  [force linking of the C++ runtime on Linux to either static or dynamic, default is static with dynamic as fallback])],
  [
    if test "x$with_stdc__lib" != xdynamic && test "x$with_stdc__lib" != xstatic \
        && test "x$with_stdc__lib" != xdefault; then
      AC_MSG_ERROR([Bad parameter value --with-stdc++lib=$with_stdc__lib!])
    fi
  ],
  [with_stdc__lib=default]
)
650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679

if test "x$OPENJDK_TARGET_OS" = xlinux; then
    # Test if -lstdc++ works.
    AC_MSG_CHECKING([if dynamic link of stdc++ is possible])
    AC_LANG_PUSH(C++)
    OLD_CXXFLAGS="$CXXFLAGS"
    CXXFLAGS="$CXXFLAGS -lstdc++"
    AC_LINK_IFELSE([AC_LANG_PROGRAM([], [return 0;])],
            [has_dynamic_libstdcxx=yes],
            [has_dynamic_libstdcxx=no])
    CXXFLAGS="$OLD_CXXFLAGS"
    AC_LANG_POP(C++)
    AC_MSG_RESULT([$has_dynamic_libstdcxx])

    # Test if stdc++ can be linked statically.
    AC_MSG_CHECKING([if static link of stdc++ is possible])
    STATIC_STDCXX_FLAGS="-Wl,-Bstatic -lstdc++ -lgcc -Wl,-Bdynamic"
    AC_LANG_PUSH(C++)
    OLD_LIBS="$LIBS"
    OLD_CXX="$CXX"
    LIBS="$STATIC_STDCXX_FLAGS"
    CXX="$CC"                       
    AC_LINK_IFELSE([AC_LANG_PROGRAM([], [return 0;])],
            [has_static_libstdcxx=yes],
            [has_static_libstdcxx=no])
    LIBS="$OLD_LIBS"
    CXX="$OLD_CXX"
    AC_LANG_POP(C++)
    AC_MSG_RESULT([$has_static_libstdcxx])

680 681
    if test "x$has_static_libstdcxx" = xno && test "x$has_dynamic_libstdcxx" = xno; then
        AC_MSG_ERROR([Cannot link to stdc++, neither dynamically nor statically!])
682 683
    fi

684 685
    if test "x$with_stdc__lib" = xstatic && test "x$has_static_libstdcxx" = xno; then
        AC_MSG_ERROR([Static linking of libstdc++ was not possible!])
686 687
    fi

688 689
    if test "x$with_stdc__lib" = xdynamic && test "x$has_dynamic_libstdcxx" = xno; then
        AC_MSG_ERROR([Dynamic linking of libstdc++ was not possible!])
690 691 692
    fi

    AC_MSG_CHECKING([how to link with libstdc++])
693 694
    # If dynamic was requested, it's available since it would fail above otherwise.
    # If dynamic wasn't requested, go with static unless it isn't available.
695
    if test "x$with_stdc__lib" = xdynamic || test "x$has_static_libstdcxx" = xno || test "x$JVM_VARIANT_ZEROSHARK" = xtrue; then
696 697
        LIBCXX="$LIBCXX -lstdc++"
        LDCXX="$CXX"
O
ohair 已提交
698
        STATIC_CXX_SETTING="STATIC_CXX=false"
699
        AC_MSG_RESULT([dynamic])
700 701 702 703 704
    else
        LIBCXX="$LIBCXX $STATIC_STDCXX_FLAGS"
        LDCXX="$CC"
        STATIC_CXX_SETTING="STATIC_CXX=true"
        AC_MSG_RESULT([static])
705 706
    fi
fi
O
ohair 已提交
707
AC_SUBST(STATIC_CXX_SETTING)
708

709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761
if test "x$JVM_VARIANT_ZERO" = xtrue || test "x$JVM_VARIANT_ZEROSHARK" = xtrue; then
    # Figure out LIBFFI_CFLAGS and LIBFFI_LIBS
    PKG_CHECK_MODULES([LIBFFI], [libffi])

fi

if test "x$JVM_VARIANT_ZEROSHARK" = xtrue; then
    AC_CHECK_PROG([LLVM_CONFIG], [llvm-config], [llvm-config])

    if test "x$LLVM_CONFIG" != xllvm-config; then
        AC_MSG_ERROR([llvm-config not found in $PATH.])
    fi

    llvm_components="jit mcjit engine nativecodegen native"
    unset LLVM_CFLAGS
    for flag in $("$LLVM_CONFIG" --cxxflags); do
      if echo "${flag}" | grep -q '^-@<:@ID@:>@'; then
        if test "${flag}" != "-D_DEBUG" ; then
          if test "${LLVM_CFLAGS}" != "" ; then
            LLVM_CFLAGS="${LLVM_CFLAGS} "
          fi
          LLVM_CFLAGS="${LLVM_CFLAGS}${flag}"
        fi
      fi
    done
    llvm_version=$("${LLVM_CONFIG}" --version | sed 's/\.//; s/svn.*//')
    LLVM_CFLAGS="${LLVM_CFLAGS} -DSHARK_LLVM_VERSION=${llvm_version}"

    unset LLVM_LDFLAGS
    for flag in $("${LLVM_CONFIG}" --ldflags); do
      if echo "${flag}" | grep -q '^-L'; then
        if test "${LLVM_LDFLAGS}" != ""; then
          LLVM_LDFLAGS="${LLVM_LDFLAGS} "
        fi
        LLVM_LDFLAGS="${LLVM_LDFLAGS}${flag}"
      fi
    done

    unset LLVM_LIBS
    for flag in $("${LLVM_CONFIG}" --libs ${llvm_components}); do
      if echo "${flag}" | grep -q '^-l'; then
        if test "${LLVM_LIBS}" != ""; then
          LLVM_LIBS="${LLVM_LIBS} "
        fi
        LLVM_LIBS="${LLVM_LIBS}${flag}"
      fi
    done

    AC_SUBST(LLVM_CFLAGS)
    AC_SUBST(LLVM_LDFLAGS)
    AC_SUBST(LLVM_LIBS)
fi

762 763
# libCrun is the c++ runtime-library with SunStudio (roughly the equivalent of gcc's libstdc++.so)
if test "x$OPENJDK_TARGET_OS" = xsolaris && test "x$LIBCXX" = x; then
764
    LIBCXX="/usr/lib${OPENJDK_TARGET_CPU_ISADIR}/libCrun.so.1"
765 766 767 768 769 770 771 772 773 774
fi

# TODO better (platform agnostic) test
if test "x$OPENJDK_TARGET_OS" = xmacosx && test "x$LIBCXX" = x && test "x$GCC" = xyes; then
    LIBCXX="-lstdc++"
fi

AC_SUBST(LIBCXX)

])