| 1 |
dnl Checks for libcerror required headers and functions |
| 2 |
dnl |
| 3 |
dnl Version: 20240513 |
| 4 |
|
| 5 |
dnl Function to detect if libcerror is available |
| 6 |
dnl ac_libcerror_dummy is used to prevent AC_CHECK_LIB adding unnecessary -l<library> arguments |
| 7 |
AC_DEFUN([AX_LIBCERROR_CHECK_LIB], |
| 8 |
[AS_IF( |
| 9 |
[test "x$ac_cv_enable_shared_libs" = xno || test "x$ac_cv_with_libcerror" = xno], |
| 10 |
[ac_cv_libcerror=no], |
| 11 |
[ac_cv_libcerror=check |
| 12 |
dnl Check if the directory provided as parameter exists |
| 13 |
dnl For both --with-libcerror which returns "yes" and --with-libcerror= which returns "" |
| 14 |
dnl treat them as auto-detection. |
| 15 |
AS_IF( |
| 16 |
[test "x$ac_cv_with_libcerror" != x && test "x$ac_cv_with_libcerror" != xauto-detect && test "x$ac_cv_with_libcerror" != xyes], |
| 17 |
[AX_CHECK_LIB_DIRECTORY_EXISTS([libcerror])], |
| 18 |
[dnl Check for a pkg-config file |
| 19 |
AS_IF( |
| 20 |
[test "x$cross_compiling" != "xyes" && test "x$PKGCONFIG" != "x"], |
| 21 |
[PKG_CHECK_MODULES( |
| 22 |
[libcerror], |
| 23 |
[libcerror >= 20120425], |
| 24 |
[ac_cv_libcerror=yes], |
| 25 |
[ac_cv_libcerror=check]) |
| 26 |
]) |
| 27 |
AS_IF( |
| 28 |
[test "x$ac_cv_libcerror" = xyes], |
| 29 |
[ac_cv_libcerror_CPPFLAGS="$pkg_cv_libcerror_CFLAGS" |
| 30 |
ac_cv_libcerror_LIBADD="$pkg_cv_libcerror_LIBS"]) |
| 31 |
]) |
| 32 |
|
| 33 |
AS_IF( |
| 34 |
[test "x$ac_cv_libcerror" = xcheck], |
| 35 |
[dnl Check for headers |
| 36 |
AC_CHECK_HEADERS([libcerror.h]) |
| 37 |
|
| 38 |
AS_IF( |
| 39 |
[test "x$ac_cv_header_libcerror_h" = xno], |
| 40 |
[ac_cv_libcerror=no], |
| 41 |
[ac_cv_libcerror=yes |
| 42 |
|
| 43 |
AX_CHECK_LIB_FUNCTIONS( |
| 44 |
[libcerror], |
| 45 |
[cerror], |
| 46 |
[[libcerror_get_version], |
| 47 |
[libcerror_error_free], |
| 48 |
[libcerror_error_set], |
| 49 |
[libcerror_error_matches], |
| 50 |
[libcerror_error_fprint], |
| 51 |
[libcerror_error_sprint], |
| 52 |
[libcerror_error_backtrace_fprint], |
| 53 |
[libcerror_error_backtrace_sprint], |
| 54 |
[libcerror_system_set_error]]) |
| 55 |
|
| 56 |
ac_cv_libcerror_LIBADD="-lcerror"]) |
| 57 |
]) |
| 58 |
|
| 59 |
AX_CHECK_LIB_DIRECTORY_MSG_ON_FAILURE([libcerror]) |
| 60 |
]) |
| 61 |
|
| 62 |
AS_IF( |
| 63 |
[test "x$ac_cv_libcerror" = xyes], |
| 64 |
[AC_DEFINE( |
| 65 |
[HAVE_LIBCERROR], |
| 66 |
[1], |
| 67 |
[Define to 1 if you have the `cerror' library (-lcerror).]) |
| 68 |
]) |
| 69 |
|
| 70 |
AS_IF( |
| 71 |
[test "x$ac_cv_libcerror" = xyes], |
| 72 |
[AC_SUBST( |
| 73 |
[HAVE_LIBCERROR], |
| 74 |
[1]) ], |
| 75 |
[AC_SUBST( |
| 76 |
[HAVE_LIBCERROR], |
| 77 |
[0]) |
| 78 |
]) |
| 79 |
]) |
| 80 |
|
| 81 |
dnl Function to detect if libcerror dependencies are available |
| 82 |
AC_DEFUN([AX_LIBCERROR_CHECK_LOCAL], |
| 83 |
[dnl Headers included in libcerror/libcerror_error.c |
| 84 |
AC_CHECK_HEADERS([stdarg.h varargs.h]) |
| 85 |
|
| 86 |
AS_IF( |
| 87 |
[test "x$ac_cv_header_stdarg_h" != xyes && test "x$ac_cv_header_varargs_h" != xyes], |
| 88 |
[AC_MSG_FAILURE( |
| 89 |
[Missing headers: stdarg.h and varargs.h], |
| 90 |
[1]) |
| 91 |
]) |
| 92 |
|
| 93 |
dnl Wide character string functions used in libcerror/libcerror_error.c |
| 94 |
AS_IF( |
| 95 |
[test "x$ac_cv_enable_wide_character_type" != xno], |
| 96 |
[AC_CHECK_FUNCS([wcstombs]) |
| 97 |
|
| 98 |
AS_IF( |
| 99 |
[test "x$ac_cv_func_wcstombs" != xyes], |
| 100 |
[AC_MSG_FAILURE( |
| 101 |
[Missing function: wcstombs], |
| 102 |
[1]) |
| 103 |
]) |
| 104 |
]) |
| 105 |
|
| 106 |
dnl Check for error string functions used in libcerror/libcerror_system.c |
| 107 |
AC_FUNC_STRERROR_R() |
| 108 |
|
| 109 |
AS_IF( |
| 110 |
[test "x$ac_cv_have_decl_strerror_r" != xyes], |
| 111 |
[AC_CHECK_FUNCS([strerror]) |
| 112 |
|
| 113 |
AS_IF( |
| 114 |
[test "x$ac_cv_func_strerror" != xyes], |
| 115 |
[AC_MSG_FAILURE( |
| 116 |
[Missing functions: strerror_r and strerror], |
| 117 |
[1]) |
| 118 |
]) |
| 119 |
]) |
| 120 |
|
| 121 |
ac_cv_libcerror_CPPFLAGS="-I../libcerror -I\$(top_srcdir)/libcerror"; |
| 122 |
ac_cv_libcerror_LIBADD="../libcerror/libcerror.la"; |
| 123 |
|
| 124 |
ac_cv_libcerror=local |
| 125 |
]) |
| 126 |
|
| 127 |
dnl Function to detect how to enable libcerror |
| 128 |
AC_DEFUN([AX_LIBCERROR_CHECK_ENABLE], |
| 129 |
[AX_COMMON_ARG_WITH( |
| 130 |
[libcerror], |
| 131 |
[libcerror], |
| 132 |
[search for libcerror in includedir and libdir or in the specified DIR, or no if to use local version], |
| 133 |
[auto-detect], |
| 134 |
[DIR]) |
| 135 |
|
| 136 |
dnl Check for a shared library version |
| 137 |
AX_LIBCERROR_CHECK_LIB |
| 138 |
|
| 139 |
dnl Check if the dependencies for the local library version |
| 140 |
AS_IF( |
| 141 |
[test "x$ac_cv_libcerror" != xyes], |
| 142 |
[AX_LIBCERROR_CHECK_LOCAL |
| 143 |
|
| 144 |
AC_DEFINE( |
| 145 |
[HAVE_LOCAL_LIBCERROR], |
| 146 |
[1], |
| 147 |
[Define to 1 if the local version of libcerror is used.]) |
| 148 |
AC_SUBST( |
| 149 |
[HAVE_LOCAL_LIBCERROR], |
| 150 |
[1]) |
| 151 |
]) |
| 152 |
|
| 153 |
AM_CONDITIONAL( |
| 154 |
[HAVE_LOCAL_LIBCERROR], |
| 155 |
[test "x$ac_cv_libcerror" = xlocal]) |
| 156 |
AS_IF( |
| 157 |
[test "x$ac_cv_libcerror_CPPFLAGS" != "x"], |
| 158 |
[AC_SUBST( |
| 159 |
[LIBCERROR_CPPFLAGS], |
| 160 |
[$ac_cv_libcerror_CPPFLAGS]) |
| 161 |
]) |
| 162 |
AS_IF( |
| 163 |
[test "x$ac_cv_libcerror_LIBADD" != "x"], |
| 164 |
[AC_SUBST( |
| 165 |
[LIBCERROR_LIBADD], |
| 166 |
[$ac_cv_libcerror_LIBADD]) |
| 167 |
]) |
| 168 |
|
| 169 |
AS_IF( |
| 170 |
[test "x$ac_cv_libcerror" = xyes], |
| 171 |
[AC_SUBST( |
| 172 |
[ax_libcerror_pc_libs_private], |
| 173 |
[-lcerror]) |
| 174 |
]) |
| 175 |
|
| 176 |
AS_IF( |
| 177 |
[test "x$ac_cv_libcerror" = xyes], |
| 178 |
[AC_SUBST( |
| 179 |
[ax_libcerror_spec_requires], |
| 180 |
[libcerror]) |
| 181 |
AC_SUBST( |
| 182 |
[ax_libcerror_spec_build_requires], |
| 183 |
[libcerror-devel]) |
| 184 |
]) |
| 185 |
]) |
| 186 |
|