annotate make/autoconf/lib-ffi.m4 @ 49578:7c82bb507446

8190333: sun/security/ssl/X509KeyManager/PreferredKey.java failed with "Failed to get the preferable key aliases" Reviewed-by: mullan
author amjiang
date Tue, 10 Apr 2018 18:16:12 -0700
parents 57cde06ae8d6
children
rev   line source
erikj@13133 1 #
ihse@32921 2 # Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
erikj@13133 3 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
erikj@13133 4 #
erikj@13133 5 # This code is free software; you can redistribute it and/or modify it
erikj@13133 6 # under the terms of the GNU General Public License version 2 only, as
erikj@13133 7 # published by the Free Software Foundation. Oracle designates this
erikj@13133 8 # particular file as subject to the "Classpath" exception as provided
erikj@13133 9 # by Oracle in the LICENSE file that accompanied this code.
erikj@13133 10 #
erikj@13133 11 # This code is distributed in the hope that it will be useful, but WITHOUT
erikj@13133 12 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
erikj@13133 13 # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
erikj@13133 14 # version 2 for more details (a copy is included in the LICENSE file that
erikj@13133 15 # accompanied this code).
erikj@13133 16 #
erikj@13133 17 # You should have received a copy of the GNU General Public License version
erikj@13133 18 # 2 along with this work; if not, write to the Free Software Foundation,
erikj@13133 19 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
erikj@13133 20 #
erikj@13133 21 # Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
erikj@13133 22 # or visit www.oracle.com if you need additional information or have any
erikj@13133 23 # questions.
erikj@13133 24 #
erikj@13133 25
ihse@32921 26 ################################################################################
ihse@32921 27 # Setup libffi (Foreign Function Interface)
ihse@32921 28 ################################################################################
ihse@32921 29 AC_DEFUN_ONCE([LIB_SETUP_LIBFFI],
erikj@13133 30 [
ihse@32921 31 AC_ARG_WITH(libffi, [AS_HELP_STRING([--with-libffi],
ihse@32921 32 [specify prefix directory for the libffi package
ihse@32921 33 (expecting the libraries under PATH/lib and the headers under PATH/include)])])
ihse@32921 34 AC_ARG_WITH(libffi-include, [AS_HELP_STRING([--with-libffi-include],
ihse@32921 35 [specify directory for the libffi include files])])
ihse@32921 36 AC_ARG_WITH(libffi-lib, [AS_HELP_STRING([--with-libffi-lib],
ihse@32921 37 [specify directory for the libffi library])])
erikj@42425 38 AC_ARG_ENABLE(libffi-bundling, [AS_HELP_STRING([--enable-libffi-bundling],
erikj@42425 39 [enable bundling of libffi.so to make the built JDK runnable on more systems])])
ihse@20363 40
ihse@32921 41 if test "x$NEEDS_LIB_FFI" = xfalse; then
ihse@33393 42 if (test "x${with_libffi}" != x && test "x${with_libffi}" != xno) || \
ihse@33393 43 (test "x${with_libffi_include}" != x && test "x${with_libffi_include}" != xno) || \
ihse@33393 44 (test "x${with_libffi_lib}" != x && test "x${with_libffi_lib}" != xno); then
ihse@33393 45 AC_MSG_WARN([[libffi not used, so --with-libffi[-*] is ignored]])
ihse@32921 46 fi
ihse@32921 47 LIBFFI_CFLAGS=
ihse@32921 48 LIBFFI_LIBS=
ihse@32921 49 else
ihse@32921 50 LIBFFI_FOUND=no
erikj@13133 51
ihse@32921 52 if test "x${with_libffi}" = xno || test "x${with_libffi_include}" = xno || test "x${with_libffi_lib}" = xno; then
ihse@32921 53 AC_MSG_ERROR([It is not possible to disable the use of libffi. Remove the --without-libffi option.])
ihse@32921 54 fi
erikj@13133 55
ihse@32921 56 if test "x${with_libffi}" != x; then
erikj@42425 57 LIBFFI_LIB_PATH="${with_libffi}/lib"
ihse@32921 58 LIBFFI_LIBS="-L${with_libffi}/lib -lffi"
ihse@32921 59 LIBFFI_CFLAGS="-I${with_libffi}/include"
ihse@32921 60 LIBFFI_FOUND=yes
ihse@27330 61 fi
ihse@32921 62 if test "x${with_libffi_include}" != x; then
ihse@32921 63 LIBFFI_CFLAGS="-I${with_libffi_include}"
ihse@32921 64 LIBFFI_FOUND=yes
ihse@32921 65 fi
ihse@32921 66 if test "x${with_libffi_lib}" != x; then
erikj@42425 67 LIBFFI_LIB_PATH="${with_libffi_lib}"
ihse@32921 68 LIBFFI_LIBS="-L${with_libffi_lib} -lffi"
ihse@32921 69 LIBFFI_FOUND=yes
ihse@32921 70 fi
ihse@32921 71 # Do not try pkg-config if we have a sysroot set.
ihse@32921 72 if test "x$SYSROOT" = x; then
ihse@32921 73 if test "x$LIBFFI_FOUND" = xno; then
ihse@32921 74 # Figure out LIBFFI_CFLAGS and LIBFFI_LIBS
ihse@32921 75 PKG_CHECK_MODULES([LIBFFI], [libffi], [LIBFFI_FOUND=yes], [LIBFFI_FOUND=no])
ihse@20363 76 fi
erikj@13133 77 fi
ihse@32921 78 if test "x$LIBFFI_FOUND" = xno; then
ihse@32921 79 AC_CHECK_HEADERS([ffi.h],
ihse@32921 80 [
ihse@32921 81 LIBFFI_FOUND=yes
ihse@32921 82 LIBFFI_CFLAGS=
ihse@32921 83 LIBFFI_LIBS=-lffi
ihse@32921 84 ],
ihse@32921 85 [LIBFFI_FOUND=no]
ihse@32921 86 )
ihse@32921 87 fi
ihse@32921 88 if test "x$LIBFFI_FOUND" = xno; then
ihse@32921 89 HELP_MSG_MISSING_DEPENDENCY([ffi])
ihse@32921 90 AC_MSG_ERROR([Could not find libffi! $HELP_MSG])
ihse@27330 91 fi
ihse@20363 92
ihse@32921 93 AC_MSG_CHECKING([if libffi works])
ihse@27330 94 AC_LANG_PUSH(C)
ihse@27330 95 OLD_CFLAGS="$CFLAGS"
ihse@32921 96 CFLAGS="$CFLAGS $LIBFFI_CFLAGS"
ihse@32921 97 OLD_LIBS="$LIBS"
ihse@32921 98 LIBS="$LIBS $LIBFFI_LIBS"
ihse@32921 99 AC_LINK_IFELSE([AC_LANG_PROGRAM([#include <ffi.h>],
ihse@32921 100 [
ihse@32921 101 ffi_call(NULL, NULL, NULL, NULL);
ihse@32921 102 return 0;
ihse@32921 103 ])],
ihse@32921 104 [LIBFFI_WORKS=yes],
ihse@32921 105 [LIBFFI_WORKS=no]
ihse@32921 106 )
ihse@32921 107 CFLAGS="$OLD_CFLAGS"
ihse@32921 108 LIBS="$OLD_LIBS"
ihse@32921 109 AC_LANG_POP(C)
ihse@32921 110 AC_MSG_RESULT([$LIBFFI_WORKS])
erikj@13133 111
ihse@32921 112 if test "x$LIBFFI_WORKS" = xno; then
ihse@32921 113 HELP_MSG_MISSING_DEPENDENCY([ffi])
ihse@32921 114 AC_MSG_ERROR([Found libffi but could not link and compile with it. $HELP_MSG])
ihse@20363 115 fi
erikj@42425 116
erikj@42425 117 AC_MSG_CHECKING([if libffi should be bundled])
erikj@42425 118 if test "x$enable_libffi_bundling" = "x"; then
erikj@42425 119 AC_MSG_RESULT([no])
erikj@42425 120 ENABLE_LIBFFI_BUNDLING=false
erikj@42425 121 elif test "x$enable_libffi_bundling" = "xno"; then
erikj@42425 122 AC_MSG_RESULT([no, forced])
erikj@42425 123 ENABLE_LIBFFI_BUNDLING=false
erikj@42425 124 elif test "x$enable_libffi_bundling" = "xyes"; then
erikj@42425 125 AC_MSG_RESULT([yes, forced])
erikj@42425 126 ENABLE_LIBFFI_BUNDLING=true
erikj@42425 127 else
erikj@42425 128 AC_MSG_ERROR([Invalid value for --enable-libffi-bundling])
erikj@42425 129 fi
erikj@42425 130
erikj@42425 131 # Find the libffi.so.X to bundle
erikj@42425 132 if test "x${ENABLE_LIBFFI_BUNDLING}" = "xtrue"; then
erikj@42425 133 AC_MSG_CHECKING([for libffi lib file location])
erikj@42425 134 if test "x${LIBFFI_LIB_PATH}" != x; then
erikj@42425 135 if test -e ${LIBFFI_LIB_PATH}/libffi.so.?; then
erikj@42425 136 LIBFFI_LIB_FILE="${LIBFFI_LIB_PATH}/libffi.so.?"
erikj@42425 137 else
erikj@42425 138 AC_MSG_ERROR([Could not locate libffi.so.? for bundling in ${LIBFFI_LIB_PATH}])
erikj@42425 139 fi
erikj@42425 140 else
erikj@42425 141 # If we don't have an explicit path, look in a few obvious places
erikj@42425 142 if test "x${OPENJDK_TARGET_CPU}" = "xx86"; then
erikj@42425 143 if test -e ${SYSROOT}/usr/lib/libffi.so.? ; then
erikj@42425 144 LIBFFI_LIB_FILE="${SYSROOT}/usr/lib/libffi.so.?"
erikj@42425 145 elif test -e ${SYSROOT}/usr/lib/i386-linux-gnu/libffi.so.? ; then
erikj@42425 146 LIBFFI_LIB_FILE="${SYSROOT}/usr/lib/i386-linux-gnu/libffi.so.?"
erikj@42425 147 else
erikj@42425 148 AC_MSG_ERROR([Could not locate libffi.so.? for bundling])
erikj@42425 149 fi
erikj@42425 150 elif test "x${OPENJDK_TARGET_CPU}" = "xx86_64"; then
erikj@42425 151 if test -e ${SYSROOT}/usr/lib64/libffi.so.? ; then
erikj@42425 152 LIBFFI_LIB_FILE="${SYSROOT}/usr/lib64/libffi.so.?"
erikj@42425 153 elif test -e ${SYSROOT}/usr/lib/x86_64-linux-gnu/libffi.so.? ; then
erikj@42425 154 LIBFFI_LIB_FILE="${SYSROOT}/usr/lib/x86_64-linux-gnu/libffi.so.?"
erikj@42425 155 else
erikj@42425 156 AC_MSG_ERROR([Could not locate libffi.so.? for bundling])
erikj@42425 157 fi
erikj@42425 158 else
erikj@42425 159 # Fallback on the default /usr/lib dir
erikj@42425 160 if test -e ${SYSROOT}/usr/lib/libffi.so.? ; then
erikj@42425 161 LIBFFI_LIB_FILE="${SYSROOT}/usr/lib/libffi.so.?"
erikj@42425 162 else
erikj@42425 163 AC_MSG_ERROR([Could not locate libffi.so.? for bundling])
erikj@42425 164 fi
erikj@42425 165 fi
erikj@42425 166 fi
erikj@42425 167 # Make sure the wildcard is evaluated
erikj@42425 168 LIBFFI_LIB_FILE="$(ls ${LIBFFI_LIB_FILE})"
erikj@42425 169 AC_MSG_RESULT([${LIBFFI_LIB_FILE}])
erikj@42425 170 fi
ihse@20363 171 fi
erikj@13133 172
ihse@32921 173 AC_SUBST(LIBFFI_CFLAGS)
ihse@32921 174 AC_SUBST(LIBFFI_LIBS)
erikj@42425 175 AC_SUBST(ENABLE_LIBFFI_BUNDLING)
erikj@42425 176 AC_SUBST(LIBFFI_LIB_FILE)
erikj@13133 177 ])