| 1 |
dnl Checks for libbfio required headers and functions |
| 2 |
dnl |
| 3 |
dnl Version: 20240518 |
| 4 |
|
| 5 |
dnl Function to detect if libbfio is available |
| 6 |
dnl ac_libbfio_dummy is used to prevent AC_CHECK_LIB adding unnecessary -l<library> arguments |
| 7 |
AC_DEFUN([AX_LIBBFIO_CHECK_LIB], |
| 8 |
[AS_IF( |
| 9 |
[test "x$ac_cv_enable_shared_libs" = xno || test "x$ac_cv_with_libbfio" = xno], |
| 10 |
[ac_cv_libbfio=no], |
| 11 |
[ac_cv_libbfio=check |
| 12 |
dnl Check if the directory provided as parameter exists |
| 13 |
dnl For both --with-libbfio which returns "yes" and --with-libbfio= which returns "" |
| 14 |
dnl treat them as auto-detection. |
| 15 |
AS_IF( |
| 16 |
[test "x$ac_cv_with_libbfio" != x && test "x$ac_cv_with_libbfio" != xauto-detect && test "x$ac_cv_with_libbfio" != xyes], |
| 17 |
[AX_CHECK_LIB_DIRECTORY_EXISTS([libbfio])], |
| 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 |
[libbfio], |
| 23 |
[libbfio >= 20201125], |
| 24 |
[ac_cv_libbfio=yes], |
| 25 |
[ac_cv_libbfio=check]) |
| 26 |
]) |
| 27 |
AS_IF( |
| 28 |
[test "x$ac_cv_libbfio" = xyes && test "x$ac_cv_enable_wide_character_type" != xno], |
| 29 |
[AC_CACHE_CHECK( |
| 30 |
[whether libbfio/features.h defines LIBBFIO_HAVE_WIDE_CHARACTER_TYPE as 1], |
| 31 |
[ac_cv_header_libbfio_features_h_have_wide_character_type], |
| 32 |
[AC_LANG_PUSH(C) |
| 33 |
AC_COMPILE_IFELSE( |
| 34 |
[AC_LANG_PROGRAM( |
| 35 |
[[#include <libbfio/features.h>]], |
| 36 |
[[#if !defined( LIBBFIO_HAVE_WIDE_CHARACTER_TYPE ) || ( LIBBFIO_HAVE_WIDE_CHARACTER_TYPE != 1 ) |
| 37 |
#error LIBBFIO_HAVE_WIDE_CHARACTER_TYPE not defined |
| 38 |
#endif]] )], |
| 39 |
[ac_cv_header_libbfio_features_h_have_wide_character_type=yes], |
| 40 |
[ac_cv_header_libbfio_features_h_have_wide_character_type=no]) |
| 41 |
AC_LANG_POP(C)], |
| 42 |
[ac_cv_header_libbfio_features_h_have_wide_character_type=no]) |
| 43 |
|
| 44 |
AS_IF( |
| 45 |
[test "x$ac_cv_header_libbfio_features_h_have_wide_character_type" = xno], |
| 46 |
[ac_cv_libbfio=no]) |
| 47 |
]) |
| 48 |
AS_IF( |
| 49 |
[test "x$ac_cv_libbfio" = xyes], |
| 50 |
[ac_cv_libbfio_CPPFLAGS="$pkg_cv_libbfio_CFLAGS" |
| 51 |
ac_cv_libbfio_LIBADD="$pkg_cv_libbfio_LIBS"]) |
| 52 |
]) |
| 53 |
|
| 54 |
AS_IF( |
| 55 |
[test "x$ac_cv_libbfio" = xcheck], |
| 56 |
[dnl Check for headers |
| 57 |
AC_CHECK_HEADERS([libbfio.h]) |
| 58 |
|
| 59 |
AS_IF( |
| 60 |
[test "x$ac_cv_header_libbfio_h" = xno], |
| 61 |
[ac_cv_libbfio=no], |
| 62 |
[ac_cv_libbfio=yes |
| 63 |
|
| 64 |
AX_CHECK_LIB_FUNCTIONS( |
| 65 |
[libbfio], |
| 66 |
[bfio], |
| 67 |
[[libbfio_get_version], |
| 68 |
[libbfio_handle_free], |
| 69 |
[libbfio_handle_open], |
| 70 |
[libbfio_handle_close], |
| 71 |
[libbfio_handle_exists], |
| 72 |
[libbfio_handle_read_buffer], |
| 73 |
[libbfio_handle_read_buffer_at_offset], |
| 74 |
[libbfio_handle_write_buffer], |
| 75 |
[libbfio_handle_write_buffer_at_offset], |
| 76 |
[libbfio_handle_seek_offset], |
| 77 |
[libbfio_handle_is_open], |
| 78 |
[libbfio_handle_get_offset], |
| 79 |
[libbfio_handle_get_size], |
| 80 |
[libbfio_handle_set_track_offsets_read], |
| 81 |
[libbfio_handle_get_number_of_offsets_read], |
| 82 |
[libbfio_handle_get_offset_read], |
| 83 |
[libbfio_file_initialize], |
| 84 |
[libbfio_file_get_name_size], |
| 85 |
[libbfio_file_get_name], |
| 86 |
[libbfio_file_set_name], |
| 87 |
[libbfio_pool_initialize], |
| 88 |
[libbfio_pool_free], |
| 89 |
[libbfio_pool_clone], |
| 90 |
[libbfio_pool_get_number_of_handles], |
| 91 |
[libbfio_pool_get_handle], |
| 92 |
[libbfio_pool_set_handle], |
| 93 |
[libbfio_pool_append_handle], |
| 94 |
[libbfio_pool_remove_handle], |
| 95 |
[libbfio_pool_get_maximum_number_of_open_handles], |
| 96 |
[libbfio_pool_set_maximum_number_of_open_handles], |
| 97 |
[libbfio_pool_open], |
| 98 |
[libbfio_pool_reopen], |
| 99 |
[libbfio_pool_close], |
| 100 |
[libbfio_pool_close_all], |
| 101 |
[libbfio_pool_read_buffer], |
| 102 |
[libbfio_pool_read_buffer_at_offset], |
| 103 |
[libbfio_pool_write_buffer], |
| 104 |
[libbfio_pool_write_buffer_at_offset], |
| 105 |
[libbfio_pool_seek_offset], |
| 106 |
[libbfio_pool_get_offset], |
| 107 |
[libbfio_pool_get_size], |
| 108 |
[libbfio_file_pool_open]]) |
| 109 |
|
| 110 |
AS_IF( |
| 111 |
[test "x$ac_cv_enable_wide_character_type" != xno], |
| 112 |
[AX_CHECK_LIB_FUNCTIONS( |
| 113 |
[libbfio], |
| 114 |
[bfio], |
| 115 |
[[libbfio_file_get_name_size_wide], |
| 116 |
[libbfio_file_get_name_wide], |
| 117 |
[libbfio_file_set_name_wide], |
| 118 |
[libbfio_file_pool_open_wide]]) |
| 119 |
]) |
| 120 |
|
| 121 |
ac_cv_libbfio_LIBADD="-lbfio"]) |
| 122 |
]) |
| 123 |
|
| 124 |
AX_CHECK_LIB_DIRECTORY_MSG_ON_FAILURE([libbfio]) |
| 125 |
]) |
| 126 |
|
| 127 |
AS_IF( |
| 128 |
[test "x$ac_cv_libbfio" = xyes], |
| 129 |
[AC_DEFINE( |
| 130 |
[HAVE_LIBBFIO], |
| 131 |
[1], |
| 132 |
[Define to 1 if you have the `bfio' library (-lbfio).]) |
| 133 |
]) |
| 134 |
|
| 135 |
AS_IF( |
| 136 |
[test "x$ac_cv_libbfio" = xyes], |
| 137 |
[AC_SUBST( |
| 138 |
[HAVE_LIBBFIO], |
| 139 |
[1]) ], |
| 140 |
[AC_SUBST( |
| 141 |
[HAVE_LIBBFIO], |
| 142 |
[0]) |
| 143 |
]) |
| 144 |
]) |
| 145 |
|
| 146 |
dnl Function to detect if libbfio dependencies are available |
| 147 |
AC_DEFUN([AX_LIBBFIO_CHECK_LOCAL], |
| 148 |
[dnl No additional checks. |
| 149 |
|
| 150 |
ac_cv_libbfio_CPPFLAGS="-I../libbfio -I\$(top_srcdir)/libbfio"; |
| 151 |
ac_cv_libbfio_LIBADD="../libbfio/libbfio.la"; |
| 152 |
|
| 153 |
ac_cv_libbfio=local |
| 154 |
]) |
| 155 |
|
| 156 |
dnl Function to detect how to enable libbfio |
| 157 |
AC_DEFUN([AX_LIBBFIO_CHECK_ENABLE], |
| 158 |
[AX_COMMON_ARG_WITH( |
| 159 |
[libbfio], |
| 160 |
[libbfio], |
| 161 |
[search for libbfio in includedir and libdir or in the specified DIR, or no if to use local version], |
| 162 |
[auto-detect], |
| 163 |
[DIR]) |
| 164 |
|
| 165 |
dnl Check for a shared library version |
| 166 |
AX_LIBBFIO_CHECK_LIB |
| 167 |
|
| 168 |
dnl Check if the dependencies for the local library version |
| 169 |
AS_IF( |
| 170 |
[test "x$ac_cv_libbfio" != xyes], |
| 171 |
[AX_LIBBFIO_CHECK_LOCAL |
| 172 |
|
| 173 |
AC_DEFINE( |
| 174 |
[HAVE_LOCAL_LIBBFIO], |
| 175 |
[1], |
| 176 |
[Define to 1 if the local version of libbfio is used.]) |
| 177 |
AC_SUBST( |
| 178 |
[HAVE_LOCAL_LIBBFIO], |
| 179 |
[1]) |
| 180 |
]) |
| 181 |
|
| 182 |
AM_CONDITIONAL( |
| 183 |
[HAVE_LOCAL_LIBBFIO], |
| 184 |
[test "x$ac_cv_libbfio" = xlocal]) |
| 185 |
AS_IF( |
| 186 |
[test "x$ac_cv_libbfio_CPPFLAGS" != "x"], |
| 187 |
[AC_SUBST( |
| 188 |
[LIBBFIO_CPPFLAGS], |
| 189 |
[$ac_cv_libbfio_CPPFLAGS]) |
| 190 |
]) |
| 191 |
AS_IF( |
| 192 |
[test "x$ac_cv_libbfio_LIBADD" != "x"], |
| 193 |
[AC_SUBST( |
| 194 |
[LIBBFIO_LIBADD], |
| 195 |
[$ac_cv_libbfio_LIBADD]) |
| 196 |
]) |
| 197 |
|
| 198 |
AS_IF( |
| 199 |
[test "x$ac_cv_libbfio" = xyes], |
| 200 |
[AC_SUBST( |
| 201 |
[ax_libbfio_pc_libs_private], |
| 202 |
[-lbfio]) |
| 203 |
]) |
| 204 |
|
| 205 |
AS_IF( |
| 206 |
[test "x$ac_cv_libbfio" = xyes], |
| 207 |
[AC_SUBST( |
| 208 |
[ax_libbfio_spec_requires], |
| 209 |
[libbfio]) |
| 210 |
AC_SUBST( |
| 211 |
[ax_libbfio_spec_build_requires], |
| 212 |
[libbfio-devel]) |
| 213 |
]) |
| 214 |
]) |
| 215 |
|