1 # |
|
2 # Copyright (c) 2015, 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 # |
|
25 |
|
26 ################################################################################ |
|
27 # Setup libelf (ELF library) |
|
28 ################################################################################ |
|
29 AC_DEFUN_ONCE([LIB_SETUP_LIBELF], |
|
30 [ |
|
31 AC_ARG_WITH(libelf, [AS_HELP_STRING([--with-libelf], |
|
32 [specify prefix directory for the libelf package |
|
33 (expecting the libraries under PATH/lib and the headers under PATH/include)])]) |
|
34 AC_ARG_WITH(libelf-include, [AS_HELP_STRING([--with-libelf-include], |
|
35 [specify directory for the libelf include files])]) |
|
36 AC_ARG_WITH(libelf-lib, [AS_HELP_STRING([--with-libelf-lib], |
|
37 [specify directory for the libelf library])]) |
|
38 |
|
39 if test "x$ENABLE_AOT" = xfalse; then |
|
40 if (test "x${with_libelf}" != x && test "x${with_libelf}" != xno) || \ |
|
41 (test "x${with_libelf_include}" != x && test "x${with_libelf_include}" != xno) || \ |
|
42 (test "x${with_libelf_lib}" != x && test "x${with_libelf_lib}" != xno); then |
|
43 AC_MSG_WARN([[libelf is not used, so --with-libelf[-*] is ignored]]) |
|
44 fi |
|
45 LIBELF_CFLAGS= |
|
46 LIBELF_LIBS= |
|
47 else |
|
48 LIBELF_FOUND=no |
|
49 |
|
50 if test "x${with_libelf}" = xno || test "x${with_libelf_include}" = xno || test "x${with_libelf_lib}" = xno; then |
|
51 ENABLE_AOT="false" |
|
52 if test "x${enable_aot}" = xyes; then |
|
53 AC_MSG_ERROR([libelf is explicitly disabled, cannot build AOT. Enable libelf or remove --enable-aot to disable AOT.]) |
|
54 fi |
|
55 else |
|
56 if test "x${with_libelf}" != x; then |
|
57 ELF_LIBS="-L${with_libelf}/lib -lelf" |
|
58 ELF_CFLAGS="-I${with_libelf}/include" |
|
59 LIBELF_FOUND=yes |
|
60 fi |
|
61 if test "x${with_libelf_include}" != x; then |
|
62 ELF_CFLAGS="-I${with_libelf_include}" |
|
63 LIBELF_FOUND=yes |
|
64 fi |
|
65 if test "x${with_libelf_lib}" != x; then |
|
66 ELF_LIBS="-L${with_libelf_lib} -lelf" |
|
67 LIBELF_FOUND=yes |
|
68 fi |
|
69 # Do not try pkg-config if we have a sysroot set. |
|
70 if test "x$SYSROOT" = x; then |
|
71 if test "x$LIBELF_FOUND" = xno; then |
|
72 # Figure out ELF_CFLAGS and ELF_LIBS |
|
73 PKG_CHECK_MODULES([ELF], [libelf], [LIBELF_FOUND=yes], [LIBELF_FOUND=no]) |
|
74 fi |
|
75 fi |
|
76 if test "x$LIBELF_FOUND" = xno; then |
|
77 AC_CHECK_HEADERS([libelf.h], |
|
78 [ |
|
79 LIBELF_FOUND=yes |
|
80 ELF_CFLAGS= |
|
81 ELF_LIBS=-lelf |
|
82 ], |
|
83 [LIBELF_FOUND=no] |
|
84 ) |
|
85 fi |
|
86 if test "x$LIBELF_FOUND" = xno; then |
|
87 ENABLE_AOT="false" |
|
88 HELP_MSG_MISSING_DEPENDENCY([elf]) |
|
89 if test "x${enable_aot}" = xyes; then |
|
90 AC_MSG_ERROR([libelf not found, cannot build AOT. Remove --enable-aot to disable AOT or: $HELP_MSG]) |
|
91 else |
|
92 AC_MSG_WARN([libelf not found, cannot build AOT. $HELP_MSG]) |
|
93 fi |
|
94 else |
|
95 AC_MSG_CHECKING([if libelf works]) |
|
96 AC_LANG_PUSH(C) |
|
97 OLD_CFLAGS="$CFLAGS" |
|
98 CFLAGS="$CFLAGS $ELF_CFLAGS" |
|
99 OLD_LIBS="$LIBS" |
|
100 LIBS="$LIBS $ELF_LIBS" |
|
101 AC_LINK_IFELSE([AC_LANG_PROGRAM([#include <libelf.h>], |
|
102 [ |
|
103 elf_version(0); |
|
104 return 0; |
|
105 ])], |
|
106 [LIBELF_WORKS=yes], |
|
107 [LIBELF_WORKS=no] |
|
108 ) |
|
109 CFLAGS="$OLD_CFLAGS" |
|
110 LIBS="$OLD_LIBS" |
|
111 AC_LANG_POP(C) |
|
112 AC_MSG_RESULT([$LIBELF_WORKS]) |
|
113 |
|
114 if test "x$LIBELF_WORKS" = xno; then |
|
115 ENABLE_AOT="false" |
|
116 HELP_MSG_MISSING_DEPENDENCY([elf]) |
|
117 if test "x$enable_aot" = "xyes"; then |
|
118 AC_MSG_ERROR([Found libelf but could not link and compile with it. Remove --enable-aot to disable AOT or: $HELP_MSG]) |
|
119 else |
|
120 AC_MSG_WARN([Found libelf but could not link and compile with it. $HELP_MSG]) |
|
121 fi |
|
122 fi |
|
123 fi |
|
124 fi |
|
125 fi |
|
126 |
|
127 AC_SUBST(ELF_CFLAGS) |
|
128 AC_SUBST(ELF_LIBS) |
|
129 ]) |
|