common/autoconf/lib-ffi.m4
author lana
Thu, 22 Oct 2015 08:47:53 -0700
changeset 33329 15a50c5e0668
parent 32921 8e0250dfa145
child 33393 0f584e7d6ab6
permissions -rw-r--r--
Added tag jdk9-b88 for changeset b543e47c74b1
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
13133
701e61c32ece 7182051: Update of latest build-infra Makefiles (missing files)
erikj
parents:
diff changeset
     1
#
32921
8e0250dfa145 8138761: Improved handling of libffi, and cleanup of libraries.m4
ihse
parents: 31327
diff changeset
     2
# Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
13133
701e61c32ece 7182051: Update of latest build-infra Makefiles (missing files)
erikj
parents:
diff changeset
     3
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
701e61c32ece 7182051: Update of latest build-infra Makefiles (missing files)
erikj
parents:
diff changeset
     4
#
701e61c32ece 7182051: Update of latest build-infra Makefiles (missing files)
erikj
parents:
diff changeset
     5
# This code is free software; you can redistribute it and/or modify it
701e61c32ece 7182051: Update of latest build-infra Makefiles (missing files)
erikj
parents:
diff changeset
     6
# under the terms of the GNU General Public License version 2 only, as
701e61c32ece 7182051: Update of latest build-infra Makefiles (missing files)
erikj
parents:
diff changeset
     7
# published by the Free Software Foundation.  Oracle designates this
701e61c32ece 7182051: Update of latest build-infra Makefiles (missing files)
erikj
parents:
diff changeset
     8
# particular file as subject to the "Classpath" exception as provided
701e61c32ece 7182051: Update of latest build-infra Makefiles (missing files)
erikj
parents:
diff changeset
     9
# by Oracle in the LICENSE file that accompanied this code.
701e61c32ece 7182051: Update of latest build-infra Makefiles (missing files)
erikj
parents:
diff changeset
    10
#
701e61c32ece 7182051: Update of latest build-infra Makefiles (missing files)
erikj
parents:
diff changeset
    11
# This code is distributed in the hope that it will be useful, but WITHOUT
701e61c32ece 7182051: Update of latest build-infra Makefiles (missing files)
erikj
parents:
diff changeset
    12
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
701e61c32ece 7182051: Update of latest build-infra Makefiles (missing files)
erikj
parents:
diff changeset
    13
# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
701e61c32ece 7182051: Update of latest build-infra Makefiles (missing files)
erikj
parents:
diff changeset
    14
# version 2 for more details (a copy is included in the LICENSE file that
701e61c32ece 7182051: Update of latest build-infra Makefiles (missing files)
erikj
parents:
diff changeset
    15
# accompanied this code).
701e61c32ece 7182051: Update of latest build-infra Makefiles (missing files)
erikj
parents:
diff changeset
    16
#
701e61c32ece 7182051: Update of latest build-infra Makefiles (missing files)
erikj
parents:
diff changeset
    17
# You should have received a copy of the GNU General Public License version
701e61c32ece 7182051: Update of latest build-infra Makefiles (missing files)
erikj
parents:
diff changeset
    18
# 2 along with this work; if not, write to the Free Software Foundation,
701e61c32ece 7182051: Update of latest build-infra Makefiles (missing files)
erikj
parents:
diff changeset
    19
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
701e61c32ece 7182051: Update of latest build-infra Makefiles (missing files)
erikj
parents:
diff changeset
    20
#
701e61c32ece 7182051: Update of latest build-infra Makefiles (missing files)
erikj
parents:
diff changeset
    21
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
701e61c32ece 7182051: Update of latest build-infra Makefiles (missing files)
erikj
parents:
diff changeset
    22
# or visit www.oracle.com if you need additional information or have any
701e61c32ece 7182051: Update of latest build-infra Makefiles (missing files)
erikj
parents:
diff changeset
    23
# questions.
701e61c32ece 7182051: Update of latest build-infra Makefiles (missing files)
erikj
parents:
diff changeset
    24
#
701e61c32ece 7182051: Update of latest build-infra Makefiles (missing files)
erikj
parents:
diff changeset
    25
32921
8e0250dfa145 8138761: Improved handling of libffi, and cleanup of libraries.m4
ihse
parents: 31327
diff changeset
    26
################################################################################
8e0250dfa145 8138761: Improved handling of libffi, and cleanup of libraries.m4
ihse
parents: 31327
diff changeset
    27
# Setup libffi (Foreign Function Interface)
8e0250dfa145 8138761: Improved handling of libffi, and cleanup of libraries.m4
ihse
parents: 31327
diff changeset
    28
################################################################################
8e0250dfa145 8138761: Improved handling of libffi, and cleanup of libraries.m4
ihse
parents: 31327
diff changeset
    29
AC_DEFUN_ONCE([LIB_SETUP_LIBFFI],
13133
701e61c32ece 7182051: Update of latest build-infra Makefiles (missing files)
erikj
parents:
diff changeset
    30
[
32921
8e0250dfa145 8138761: Improved handling of libffi, and cleanup of libraries.m4
ihse
parents: 31327
diff changeset
    31
  AC_ARG_WITH(libffi, [AS_HELP_STRING([--with-libffi],
8e0250dfa145 8138761: Improved handling of libffi, and cleanup of libraries.m4
ihse
parents: 31327
diff changeset
    32
      [specify prefix directory for the libffi package
8e0250dfa145 8138761: Improved handling of libffi, and cleanup of libraries.m4
ihse
parents: 31327
diff changeset
    33
      (expecting the libraries under PATH/lib and the headers under PATH/include)])])
8e0250dfa145 8138761: Improved handling of libffi, and cleanup of libraries.m4
ihse
parents: 31327
diff changeset
    34
  AC_ARG_WITH(libffi-include, [AS_HELP_STRING([--with-libffi-include],
8e0250dfa145 8138761: Improved handling of libffi, and cleanup of libraries.m4
ihse
parents: 31327
diff changeset
    35
      [specify directory for the libffi include files])])
8e0250dfa145 8138761: Improved handling of libffi, and cleanup of libraries.m4
ihse
parents: 31327
diff changeset
    36
  AC_ARG_WITH(libffi-lib, [AS_HELP_STRING([--with-libffi-lib],
8e0250dfa145 8138761: Improved handling of libffi, and cleanup of libraries.m4
ihse
parents: 31327
diff changeset
    37
      [specify directory for the libffi library])])
13133
701e61c32ece 7182051: Update of latest build-infra Makefiles (missing files)
erikj
parents:
diff changeset
    38
32921
8e0250dfa145 8138761: Improved handling of libffi, and cleanup of libraries.m4
ihse
parents: 31327
diff changeset
    39
  if test "x$NEEDS_LIB_FFI" = xfalse; then
8e0250dfa145 8138761: Improved handling of libffi, and cleanup of libraries.m4
ihse
parents: 31327
diff changeset
    40
    if test "x${with_libffi}" != x || test "x${with_libffi_include}" != x || test "x${with_libffi_lib}" != x; then
8e0250dfa145 8138761: Improved handling of libffi, and cleanup of libraries.m4
ihse
parents: 31327
diff changeset
    41
      AC_MSG_WARN([libffi not used, so --with-libffi is ignored])
27330
5e83ad1a521a 8062661: Do not perform X11 checks in configure when X11 is not needed
ihse
parents: 27239
diff changeset
    42
    fi
32921
8e0250dfa145 8138761: Improved handling of libffi, and cleanup of libraries.m4
ihse
parents: 31327
diff changeset
    43
    LIBFFI_CFLAGS=
8e0250dfa145 8138761: Improved handling of libffi, and cleanup of libraries.m4
ihse
parents: 31327
diff changeset
    44
    LIBFFI_LIBS=
27330
5e83ad1a521a 8062661: Do not perform X11 checks in configure when X11 is not needed
ihse
parents: 27239
diff changeset
    45
  else
32921
8e0250dfa145 8138761: Improved handling of libffi, and cleanup of libraries.m4
ihse
parents: 31327
diff changeset
    46
    LIBFFI_FOUND=no
13133
701e61c32ece 7182051: Update of latest build-infra Makefiles (missing files)
erikj
parents:
diff changeset
    47
32921
8e0250dfa145 8138761: Improved handling of libffi, and cleanup of libraries.m4
ihse
parents: 31327
diff changeset
    48
    if test "x${with_libffi}" = xno || test "x${with_libffi_include}" = xno || test "x${with_libffi_lib}" = xno; then
8e0250dfa145 8138761: Improved handling of libffi, and cleanup of libraries.m4
ihse
parents: 31327
diff changeset
    49
      AC_MSG_ERROR([It is not possible to disable the use of libffi. Remove the --without-libffi option.])
27330
5e83ad1a521a 8062661: Do not perform X11 checks in configure when X11 is not needed
ihse
parents: 27239
diff changeset
    50
    fi
27239
12771c65e334 8062159: Fix Xrender check to work with sysroot
erikj
parents: 26400
diff changeset
    51
32921
8e0250dfa145 8138761: Improved handling of libffi, and cleanup of libraries.m4
ihse
parents: 31327
diff changeset
    52
    if test "x${with_libffi}" != x; then
8e0250dfa145 8138761: Improved handling of libffi, and cleanup of libraries.m4
ihse
parents: 31327
diff changeset
    53
      LIBFFI_LIBS="-L${with_libffi}/lib -lffi"
8e0250dfa145 8138761: Improved handling of libffi, and cleanup of libraries.m4
ihse
parents: 31327
diff changeset
    54
      LIBFFI_CFLAGS="-I${with_libffi}/include"
8e0250dfa145 8138761: Improved handling of libffi, and cleanup of libraries.m4
ihse
parents: 31327
diff changeset
    55
      LIBFFI_FOUND=yes
8e0250dfa145 8138761: Improved handling of libffi, and cleanup of libraries.m4
ihse
parents: 31327
diff changeset
    56
    fi
8e0250dfa145 8138761: Improved handling of libffi, and cleanup of libraries.m4
ihse
parents: 31327
diff changeset
    57
    if test "x${with_libffi_include}" != x; then
8e0250dfa145 8138761: Improved handling of libffi, and cleanup of libraries.m4
ihse
parents: 31327
diff changeset
    58
      LIBFFI_CFLAGS="-I${with_libffi_include}"
8e0250dfa145 8138761: Improved handling of libffi, and cleanup of libraries.m4
ihse
parents: 31327
diff changeset
    59
      LIBFFI_FOUND=yes
8e0250dfa145 8138761: Improved handling of libffi, and cleanup of libraries.m4
ihse
parents: 31327
diff changeset
    60
    fi
8e0250dfa145 8138761: Improved handling of libffi, and cleanup of libraries.m4
ihse
parents: 31327
diff changeset
    61
    if test "x${with_libffi_lib}" != x; then
8e0250dfa145 8138761: Improved handling of libffi, and cleanup of libraries.m4
ihse
parents: 31327
diff changeset
    62
      LIBFFI_LIBS="-L${with_libffi_lib} -lffi"
8e0250dfa145 8138761: Improved handling of libffi, and cleanup of libraries.m4
ihse
parents: 31327
diff changeset
    63
      LIBFFI_FOUND=yes
20363
fa7663fc5d50 8001931: The new build system whitespace cleanup
ihse
parents: 19524
diff changeset
    64
    fi
32921
8e0250dfa145 8138761: Improved handling of libffi, and cleanup of libraries.m4
ihse
parents: 31327
diff changeset
    65
    # Do not try pkg-config if we have a sysroot set.
8e0250dfa145 8138761: Improved handling of libffi, and cleanup of libraries.m4
ihse
parents: 31327
diff changeset
    66
    if test "x$SYSROOT" = x; then
8e0250dfa145 8138761: Improved handling of libffi, and cleanup of libraries.m4
ihse
parents: 31327
diff changeset
    67
      if test "x$LIBFFI_FOUND" = xno; then
8e0250dfa145 8138761: Improved handling of libffi, and cleanup of libraries.m4
ihse
parents: 31327
diff changeset
    68
        # Figure out LIBFFI_CFLAGS and LIBFFI_LIBS
8e0250dfa145 8138761: Improved handling of libffi, and cleanup of libraries.m4
ihse
parents: 31327
diff changeset
    69
        PKG_CHECK_MODULES([LIBFFI], [libffi], [LIBFFI_FOUND=yes], [LIBFFI_FOUND=no])
8e0250dfa145 8138761: Improved handling of libffi, and cleanup of libraries.m4
ihse
parents: 31327
diff changeset
    70
      fi
20363
fa7663fc5d50 8001931: The new build system whitespace cleanup
ihse
parents: 19524
diff changeset
    71
    fi
32921
8e0250dfa145 8138761: Improved handling of libffi, and cleanup of libraries.m4
ihse
parents: 31327
diff changeset
    72
    if test "x$LIBFFI_FOUND" = xno; then
8e0250dfa145 8138761: Improved handling of libffi, and cleanup of libraries.m4
ihse
parents: 31327
diff changeset
    73
      AC_CHECK_HEADERS([ffi.h],
20363
fa7663fc5d50 8001931: The new build system whitespace cleanup
ihse
parents: 19524
diff changeset
    74
          [
32921
8e0250dfa145 8138761: Improved handling of libffi, and cleanup of libraries.m4
ihse
parents: 31327
diff changeset
    75
            LIBFFI_FOUND=yes
8e0250dfa145 8138761: Improved handling of libffi, and cleanup of libraries.m4
ihse
parents: 31327
diff changeset
    76
            LIBFFI_CFLAGS=
8e0250dfa145 8138761: Improved handling of libffi, and cleanup of libraries.m4
ihse
parents: 31327
diff changeset
    77
            LIBFFI_LIBS=-lffi
8e0250dfa145 8138761: Improved handling of libffi, and cleanup of libraries.m4
ihse
parents: 31327
diff changeset
    78
          ],
8e0250dfa145 8138761: Improved handling of libffi, and cleanup of libraries.m4
ihse
parents: 31327
diff changeset
    79
          [LIBFFI_FOUND=no]
20363
fa7663fc5d50 8001931: The new build system whitespace cleanup
ihse
parents: 19524
diff changeset
    80
      )
fa7663fc5d50 8001931: The new build system whitespace cleanup
ihse
parents: 19524
diff changeset
    81
    fi
32921
8e0250dfa145 8138761: Improved handling of libffi, and cleanup of libraries.m4
ihse
parents: 31327
diff changeset
    82
    if test "x$LIBFFI_FOUND" = xno; then
8e0250dfa145 8138761: Improved handling of libffi, and cleanup of libraries.m4
ihse
parents: 31327
diff changeset
    83
      HELP_MSG_MISSING_DEPENDENCY([ffi])
8e0250dfa145 8138761: Improved handling of libffi, and cleanup of libraries.m4
ihse
parents: 31327
diff changeset
    84
      AC_MSG_ERROR([Could not find libffi! $HELP_MSG])
26400
4d6c6f2df610 8057538: Build the freetype library during configure on Windows
simonis
parents: 25039
diff changeset
    85
    fi
4d6c6f2df610 8057538: Build the freetype library during configure on Windows
simonis
parents: 25039
diff changeset
    86
32921
8e0250dfa145 8138761: Improved handling of libffi, and cleanup of libraries.m4
ihse
parents: 31327
diff changeset
    87
    AC_MSG_CHECKING([if libffi works])
8e0250dfa145 8138761: Improved handling of libffi, and cleanup of libraries.m4
ihse
parents: 31327
diff changeset
    88
    AC_LANG_PUSH(C)
8e0250dfa145 8138761: Improved handling of libffi, and cleanup of libraries.m4
ihse
parents: 31327
diff changeset
    89
    OLD_CFLAGS="$CFLAGS"
8e0250dfa145 8138761: Improved handling of libffi, and cleanup of libraries.m4
ihse
parents: 31327
diff changeset
    90
    CFLAGS="$CFLAGS $LIBFFI_CFLAGS"
8e0250dfa145 8138761: Improved handling of libffi, and cleanup of libraries.m4
ihse
parents: 31327
diff changeset
    91
    OLD_LIBS="$LIBS"
8e0250dfa145 8138761: Improved handling of libffi, and cleanup of libraries.m4
ihse
parents: 31327
diff changeset
    92
    LIBS="$LIBS $LIBFFI_LIBS"
8e0250dfa145 8138761: Improved handling of libffi, and cleanup of libraries.m4
ihse
parents: 31327
diff changeset
    93
    AC_LINK_IFELSE([AC_LANG_PROGRAM([#include <ffi.h>],
8e0250dfa145 8138761: Improved handling of libffi, and cleanup of libraries.m4
ihse
parents: 31327
diff changeset
    94
        [
8e0250dfa145 8138761: Improved handling of libffi, and cleanup of libraries.m4
ihse
parents: 31327
diff changeset
    95
          ffi_call(NULL, NULL, NULL, NULL);
8e0250dfa145 8138761: Improved handling of libffi, and cleanup of libraries.m4
ihse
parents: 31327
diff changeset
    96
          return 0;
8e0250dfa145 8138761: Improved handling of libffi, and cleanup of libraries.m4
ihse
parents: 31327
diff changeset
    97
        ])],
8e0250dfa145 8138761: Improved handling of libffi, and cleanup of libraries.m4
ihse
parents: 31327
diff changeset
    98
        [LIBFFI_WORKS=yes],
8e0250dfa145 8138761: Improved handling of libffi, and cleanup of libraries.m4
ihse
parents: 31327
diff changeset
    99
        [LIBFFI_WORKS=no]
8e0250dfa145 8138761: Improved handling of libffi, and cleanup of libraries.m4
ihse
parents: 31327
diff changeset
   100
    )
8e0250dfa145 8138761: Improved handling of libffi, and cleanup of libraries.m4
ihse
parents: 31327
diff changeset
   101
    CFLAGS="$OLD_CFLAGS"
8e0250dfa145 8138761: Improved handling of libffi, and cleanup of libraries.m4
ihse
parents: 31327
diff changeset
   102
    LIBS="$OLD_LIBS"
8e0250dfa145 8138761: Improved handling of libffi, and cleanup of libraries.m4
ihse
parents: 31327
diff changeset
   103
    AC_LANG_POP(C)
8e0250dfa145 8138761: Improved handling of libffi, and cleanup of libraries.m4
ihse
parents: 31327
diff changeset
   104
    AC_MSG_RESULT([$LIBFFI_WORKS])
26400
4d6c6f2df610 8057538: Build the freetype library during configure on Windows
simonis
parents: 25039
diff changeset
   105
32921
8e0250dfa145 8138761: Improved handling of libffi, and cleanup of libraries.m4
ihse
parents: 31327
diff changeset
   106
    if test "x$LIBFFI_WORKS" = xno; then
8e0250dfa145 8138761: Improved handling of libffi, and cleanup of libraries.m4
ihse
parents: 31327
diff changeset
   107
      HELP_MSG_MISSING_DEPENDENCY([ffi])
8e0250dfa145 8138761: Improved handling of libffi, and cleanup of libraries.m4
ihse
parents: 31327
diff changeset
   108
      AC_MSG_ERROR([Found libffi but could not link and compile with it. $HELP_MSG])
20654
2c17cbccf2ef 8001922: Improve freetype handling.
ihse
parents: 20649
diff changeset
   109
    fi
2c17cbccf2ef 8001922: Improve freetype handling.
ihse
parents: 20649
diff changeset
   110
  fi
2c17cbccf2ef 8001922: Improve freetype handling.
ihse
parents: 20649
diff changeset
   111
32921
8e0250dfa145 8138761: Improved handling of libffi, and cleanup of libraries.m4
ihse
parents: 31327
diff changeset
   112
  AC_SUBST(LIBFFI_CFLAGS)
8e0250dfa145 8138761: Improved handling of libffi, and cleanup of libraries.m4
ihse
parents: 31327
diff changeset
   113
  AC_SUBST(LIBFFI_LIBS)
13133
701e61c32ece 7182051: Update of latest build-infra Makefiles (missing files)
erikj
parents:
diff changeset
   114
])