common/autoconf/lib-elf.m4
author tschatzl
Mon, 17 Jul 2017 10:32:36 +0200
changeset 46669 05296a16012a
parent 42532 4780f4130eb0
permissions -rw-r--r--
8184452: Add bounds checking for FromCardCache Reviewed-by: shade, rkennke
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
42532
4780f4130eb0 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
     1
#
4780f4130eb0 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
     2
# Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
4780f4130eb0 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
     3
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4780f4130eb0 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
     4
#
4780f4130eb0 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
     5
# This code is free software; you can redistribute it and/or modify it
4780f4130eb0 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
     6
# under the terms of the GNU General Public License version 2 only, as
4780f4130eb0 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
     7
# published by the Free Software Foundation.  Oracle designates this
4780f4130eb0 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
     8
# particular file as subject to the "Classpath" exception as provided
4780f4130eb0 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
     9
# by Oracle in the LICENSE file that accompanied this code.
4780f4130eb0 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    10
#
4780f4130eb0 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    11
# This code is distributed in the hope that it will be useful, but WITHOUT
4780f4130eb0 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    12
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
4780f4130eb0 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    13
# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
4780f4130eb0 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    14
# version 2 for more details (a copy is included in the LICENSE file that
4780f4130eb0 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    15
# accompanied this code).
4780f4130eb0 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    16
#
4780f4130eb0 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    17
# You should have received a copy of the GNU General Public License version
4780f4130eb0 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    18
# 2 along with this work; if not, write to the Free Software Foundation,
4780f4130eb0 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    19
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
4780f4130eb0 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    20
#
4780f4130eb0 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    21
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
4780f4130eb0 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    22
# or visit www.oracle.com if you need additional information or have any
4780f4130eb0 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    23
# questions.
4780f4130eb0 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    24
#
4780f4130eb0 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    25
4780f4130eb0 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    26
################################################################################
4780f4130eb0 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    27
# Setup libelf (ELF library)
4780f4130eb0 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    28
################################################################################
4780f4130eb0 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    29
AC_DEFUN_ONCE([LIB_SETUP_LIBELF],
4780f4130eb0 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    30
[
4780f4130eb0 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    31
  AC_ARG_WITH(libelf, [AS_HELP_STRING([--with-libelf],
4780f4130eb0 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    32
      [specify prefix directory for the libelf package
4780f4130eb0 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    33
      (expecting the libraries under PATH/lib and the headers under PATH/include)])])
4780f4130eb0 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    34
  AC_ARG_WITH(libelf-include, [AS_HELP_STRING([--with-libelf-include],
4780f4130eb0 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    35
      [specify directory for the libelf include files])])
4780f4130eb0 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    36
  AC_ARG_WITH(libelf-lib, [AS_HELP_STRING([--with-libelf-lib],
4780f4130eb0 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    37
      [specify directory for the libelf library])])
4780f4130eb0 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    38
4780f4130eb0 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    39
  if test "x$ENABLE_AOT" = xfalse; then
4780f4130eb0 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    40
    if (test "x${with_libelf}" != x && test "x${with_libelf}" != xno) || \
4780f4130eb0 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    41
        (test "x${with_libelf_include}" != x && test "x${with_libelf_include}" != xno) || \
4780f4130eb0 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    42
        (test "x${with_libelf_lib}" != x && test "x${with_libelf_lib}" != xno); then
4780f4130eb0 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    43
      AC_MSG_WARN([[libelf is not used, so --with-libelf[-*] is ignored]])
4780f4130eb0 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    44
    fi
4780f4130eb0 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    45
    LIBELF_CFLAGS=
4780f4130eb0 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    46
    LIBELF_LIBS=
4780f4130eb0 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    47
  else
4780f4130eb0 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    48
    LIBELF_FOUND=no
4780f4130eb0 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    49
4780f4130eb0 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    50
    if test "x${with_libelf}" = xno || test "x${with_libelf_include}" = xno || test "x${with_libelf_lib}" = xno; then
4780f4130eb0 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    51
      ENABLE_AOT="false"
4780f4130eb0 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    52
      if test "x${enable_aot}" = xyes; then
4780f4130eb0 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    53
        AC_MSG_ERROR([libelf is explicitly disabled, cannot build AOT. Enable libelf or remove --enable-aot to disable AOT.])
4780f4130eb0 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    54
      fi
4780f4130eb0 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    55
    else
4780f4130eb0 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    56
      if test "x${with_libelf}" != x; then
4780f4130eb0 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    57
        ELF_LIBS="-L${with_libelf}/lib -lelf"
4780f4130eb0 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    58
        ELF_CFLAGS="-I${with_libelf}/include"
4780f4130eb0 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    59
        LIBELF_FOUND=yes
4780f4130eb0 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    60
      fi
4780f4130eb0 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    61
      if test "x${with_libelf_include}" != x; then
4780f4130eb0 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    62
        ELF_CFLAGS="-I${with_libelf_include}"
4780f4130eb0 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    63
        LIBELF_FOUND=yes
4780f4130eb0 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    64
      fi
4780f4130eb0 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    65
      if test "x${with_libelf_lib}" != x; then
4780f4130eb0 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    66
        ELF_LIBS="-L${with_libelf_lib} -lelf"
4780f4130eb0 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    67
        LIBELF_FOUND=yes
4780f4130eb0 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    68
      fi
4780f4130eb0 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    69
      # Do not try pkg-config if we have a sysroot set.
4780f4130eb0 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    70
      if test "x$SYSROOT" = x; then
4780f4130eb0 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    71
        if test "x$LIBELF_FOUND" = xno; then
4780f4130eb0 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    72
          # Figure out ELF_CFLAGS and ELF_LIBS
4780f4130eb0 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    73
          PKG_CHECK_MODULES([ELF], [libelf], [LIBELF_FOUND=yes], [LIBELF_FOUND=no])
4780f4130eb0 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    74
        fi
4780f4130eb0 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    75
      fi
4780f4130eb0 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    76
      if test "x$LIBELF_FOUND" = xno; then
4780f4130eb0 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    77
        AC_CHECK_HEADERS([libelf.h],
4780f4130eb0 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    78
            [
4780f4130eb0 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    79
              LIBELF_FOUND=yes
4780f4130eb0 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    80
              ELF_CFLAGS=
4780f4130eb0 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    81
              ELF_LIBS=-lelf
4780f4130eb0 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    82
            ],
4780f4130eb0 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    83
            [LIBELF_FOUND=no]
4780f4130eb0 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    84
        )
4780f4130eb0 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    85
      fi
4780f4130eb0 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    86
      if test "x$LIBELF_FOUND" = xno; then
4780f4130eb0 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    87
        ENABLE_AOT="false"
4780f4130eb0 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    88
        HELP_MSG_MISSING_DEPENDENCY([elf])
4780f4130eb0 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    89
        if test "x${enable_aot}" = xyes; then
4780f4130eb0 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    90
          AC_MSG_ERROR([libelf not found, cannot build AOT. Remove --enable-aot to disable AOT or: $HELP_MSG])
4780f4130eb0 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    91
        else
4780f4130eb0 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    92
          AC_MSG_WARN([libelf not found, cannot build AOT. $HELP_MSG])
4780f4130eb0 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    93
        fi
4780f4130eb0 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    94
      else
4780f4130eb0 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    95
        AC_MSG_CHECKING([if libelf works])
4780f4130eb0 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    96
        AC_LANG_PUSH(C)
4780f4130eb0 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    97
        OLD_CFLAGS="$CFLAGS"
4780f4130eb0 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    98
        CFLAGS="$CFLAGS $ELF_CFLAGS"
4780f4130eb0 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    99
        OLD_LIBS="$LIBS"
4780f4130eb0 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   100
        LIBS="$LIBS $ELF_LIBS"
4780f4130eb0 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   101
        AC_LINK_IFELSE([AC_LANG_PROGRAM([#include <libelf.h>],
4780f4130eb0 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   102
            [
4780f4130eb0 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   103
              elf_version(0);
4780f4130eb0 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   104
              return 0;
4780f4130eb0 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   105
            ])],
4780f4130eb0 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   106
            [LIBELF_WORKS=yes],
4780f4130eb0 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   107
            [LIBELF_WORKS=no]
4780f4130eb0 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   108
        )
4780f4130eb0 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   109
        CFLAGS="$OLD_CFLAGS"
4780f4130eb0 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   110
        LIBS="$OLD_LIBS"
4780f4130eb0 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   111
        AC_LANG_POP(C)
4780f4130eb0 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   112
        AC_MSG_RESULT([$LIBELF_WORKS])
4780f4130eb0 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   113
4780f4130eb0 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   114
        if test "x$LIBELF_WORKS" = xno; then
4780f4130eb0 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   115
          ENABLE_AOT="false"
4780f4130eb0 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   116
          HELP_MSG_MISSING_DEPENDENCY([elf])
4780f4130eb0 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   117
          if test "x$enable_aot" = "xyes"; then
4780f4130eb0 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   118
            AC_MSG_ERROR([Found libelf but could not link and compile with it. Remove --enable-aot to disable AOT or: $HELP_MSG])
4780f4130eb0 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   119
          else
4780f4130eb0 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   120
            AC_MSG_WARN([Found libelf but could not link and compile with it. $HELP_MSG])
4780f4130eb0 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   121
          fi
4780f4130eb0 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   122
        fi
4780f4130eb0 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   123
      fi
4780f4130eb0 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   124
    fi
4780f4130eb0 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   125
  fi
4780f4130eb0 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   126
4780f4130eb0 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   127
  AC_SUBST(ELF_CFLAGS)
4780f4130eb0 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   128
  AC_SUBST(ELF_LIBS)
4780f4130eb0 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   129
])