| 1 |
dnl Checks for libuna or required headers and functions |
| 2 |
dnl |
| 3 |
dnl Version: 20240513 |
| 4 |
|
| 5 |
dnl Function to detect if libuna is available |
| 6 |
dnl ac_libuna_dummy is used to prevent AC_CHECK_LIB adding unnecessary -l<library> arguments |
| 7 |
AC_DEFUN([AX_LIBUNA_CHECK_LIB], |
| 8 |
[AS_IF( |
| 9 |
[test "x$ac_cv_enable_shared_libs" = xno || test "x$ac_cv_with_libuna" = xno], |
| 10 |
[ac_cv_libuna=no], |
| 11 |
[ac_cv_libuna=check |
| 12 |
dnl Check if the directory provided as parameter exists |
| 13 |
dnl For both --with-libuna which returns "yes" and --with-libuna= which returns "" |
| 14 |
dnl treat them as auto-detection. |
| 15 |
AS_IF( |
| 16 |
[test "x$ac_cv_with_libuna" != x && test "x$ac_cv_with_libuna" != xauto-detect && test "x$ac_cv_with_libuna" != xyes], |
| 17 |
[AX_CHECK_LIB_DIRECTORY_EXISTS([libuna])], |
| 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 |
[libuna], |
| 23 |
[libuna >= 20230702], |
| 24 |
[ac_cv_libuna=yes], |
| 25 |
[ac_cv_libuna=check]) |
| 26 |
]) |
| 27 |
AS_IF( |
| 28 |
[test "x$ac_cv_libuna" = xyes], |
| 29 |
[ac_cv_libuna_CPPFLAGS="$pkg_cv_libuna_CFLAGS" |
| 30 |
ac_cv_libuna_LIBADD="$pkg_cv_libuna_LIBS"]) |
| 31 |
]) |
| 32 |
|
| 33 |
AS_IF( |
| 34 |
[test "x$ac_cv_libuna" = xcheck], |
| 35 |
[dnl Check for headers |
| 36 |
AC_CHECK_HEADERS([libuna.h]) |
| 37 |
|
| 38 |
AS_IF( |
| 39 |
[test "x$ac_cv_header_libuna_h" = xno], |
| 40 |
[ac_cv_libuna=no], |
| 41 |
[ac_cv_libuna=yes |
| 42 |
|
| 43 |
AX_CHECK_LIB_FUNCTIONS( |
| 44 |
[libuna], |
| 45 |
[una], |
| 46 |
[[libuna_get_version], |
| 47 |
[libuna_base16_stream_size_to_byte_stream], |
| 48 |
[libuna_base16_stream_copy_to_byte_stream], |
| 49 |
[libuna_base16_stream_size_from_byte_stream], |
| 50 |
[libuna_base16_stream_copy_from_byte_stream], |
| 51 |
[libuna_base16_stream_with_index_copy_from_byte_stream], |
| 52 |
[libuna_base32_quintuplet_copy_from_base32_stream], |
| 53 |
[libuna_base32_quintuplet_copy_to_base32_stream], |
| 54 |
[libuna_base32_quintuplet_copy_from_byte_stream], |
| 55 |
[libuna_base32_quintuplet_copy_to_byte_stream], |
| 56 |
[libuna_base32_stream_size_to_byte_stream], |
| 57 |
[libuna_base32_stream_copy_to_byte_stream], |
| 58 |
[libuna_base32_stream_size_from_byte_stream], |
| 59 |
[libuna_base32_stream_copy_from_byte_stream], |
| 60 |
[libuna_base32_stream_with_index_copy_from_byte_stream], |
| 61 |
[libuna_base64_triplet_copy_from_base64_stream], |
| 62 |
[libuna_base64_triplet_copy_to_base64_stream], |
| 63 |
[libuna_base64_triplet_copy_from_byte_stream], |
| 64 |
[libuna_base64_triplet_copy_to_byte_stream], |
| 65 |
[libuna_base64_stream_size_to_byte_stream], |
| 66 |
[libuna_base64_stream_copy_to_byte_stream], |
| 67 |
[libuna_base64_stream_size_from_byte_stream], |
| 68 |
[libuna_base64_stream_copy_from_byte_stream], |
| 69 |
[libuna_base64_stream_with_index_copy_from_byte_stream], |
| 70 |
[libuna_byte_stream_size_from_utf8], |
| 71 |
[libuna_byte_stream_copy_from_utf8], |
| 72 |
[libuna_byte_stream_size_from_utf16], |
| 73 |
[libuna_byte_stream_copy_from_utf16], |
| 74 |
[libuna_byte_stream_size_from_utf32], |
| 75 |
[libuna_byte_stream_copy_from_utf32], |
| 76 |
[libuna_unicode_character_size_to_byte_stream], |
| 77 |
[libuna_unicode_character_copy_from_byte_stream], |
| 78 |
[libuna_unicode_character_copy_to_byte_stream], |
| 79 |
[libuna_unicode_character_size_to_ucs2], |
| 80 |
[libuna_unicode_character_copy_from_ucs2], |
| 81 |
[libuna_unicode_character_copy_to_ucs2], |
| 82 |
[libuna_unicode_character_size_to_ucs4], |
| 83 |
[libuna_unicode_character_copy_from_ucs4], |
| 84 |
[libuna_unicode_character_copy_to_ucs4], |
| 85 |
[libuna_unicode_character_copy_from_utf7_stream], |
| 86 |
[libuna_unicode_character_copy_to_utf7_stream], |
| 87 |
[libuna_unicode_character_size_to_utf8], |
| 88 |
[libuna_unicode_character_copy_from_utf8], |
| 89 |
[libuna_unicode_character_copy_to_utf8], |
| 90 |
[libuna_unicode_character_size_to_utf8_rfc2279], |
| 91 |
[libuna_unicode_character_copy_from_utf8_rfc2279], |
| 92 |
[libuna_unicode_character_copy_to_utf8_rfc2279], |
| 93 |
[libuna_unicode_character_size_to_utf16], |
| 94 |
[libuna_unicode_character_copy_from_utf16], |
| 95 |
[libuna_unicode_character_copy_to_utf16], |
| 96 |
[libuna_unicode_character_copy_from_utf16_stream], |
| 97 |
[libuna_unicode_character_copy_to_utf16_stream], |
| 98 |
[libuna_unicode_character_copy_from_utf32], |
| 99 |
[libuna_unicode_character_copy_to_utf32], |
| 100 |
[libuna_unicode_character_copy_from_utf32_stream], |
| 101 |
[libuna_unicode_character_copy_to_utf32_stream], |
| 102 |
[libuna_utf8_stream_size_from_utf8], |
| 103 |
[libuna_utf8_stream_copy_from_utf8], |
| 104 |
[libuna_utf8_stream_size_from_utf16], |
| 105 |
[libuna_utf8_stream_copy_from_utf16], |
| 106 |
[libuna_utf8_stream_size_from_utf32], |
| 107 |
[libuna_utf8_stream_copy_from_utf32], |
| 108 |
[libuna_utf16_stream_size_from_utf8], |
| 109 |
[libuna_utf16_stream_copy_from_utf8], |
| 110 |
[libuna_utf16_stream_size_from_utf16], |
| 111 |
[libuna_utf16_stream_copy_from_utf16], |
| 112 |
[libuna_utf16_stream_size_from_utf32], |
| 113 |
[libuna_utf16_stream_copy_from_utf32], |
| 114 |
[libuna_utf32_stream_size_from_utf8], |
| 115 |
[libuna_utf32_stream_copy_from_utf8], |
| 116 |
[libuna_utf32_stream_size_from_utf16], |
| 117 |
[libuna_utf32_stream_copy_from_utf16], |
| 118 |
[libuna_utf32_stream_size_from_utf32], |
| 119 |
[libuna_utf32_stream_copy_from_utf32], |
| 120 |
[libuna_utf8_string_size_from_byte_stream], |
| 121 |
[libuna_utf8_string_copy_from_byte_stream], |
| 122 |
[libuna_utf8_string_with_index_copy_from_byte_stream], |
| 123 |
[libuna_utf8_string_compare_with_byte_stream], |
| 124 |
[libuna_utf8_string_size_from_utf7_stream], |
| 125 |
[libuna_utf8_string_copy_from_utf7_stream], |
| 126 |
[libuna_utf8_string_with_index_copy_from_utf7_stream], |
| 127 |
[libuna_utf8_string_compare_with_utf7_stream], |
| 128 |
[libuna_utf8_string_size_from_utf8_stream], |
| 129 |
[libuna_utf8_string_copy_from_utf8_stream], |
| 130 |
[libuna_utf8_string_with_index_copy_from_utf8_stream], |
| 131 |
[libuna_utf8_string_compare_with_utf8_stream], |
| 132 |
[libuna_utf8_string_size_from_utf16], |
| 133 |
[libuna_utf8_string_copy_from_utf16], |
| 134 |
[libuna_utf8_string_with_index_copy_from_utf16], |
| 135 |
[libuna_utf8_string_compare_with_utf16], |
| 136 |
[libuna_utf8_string_size_from_utf16_stream], |
| 137 |
[libuna_utf8_string_copy_from_utf16_stream], |
| 138 |
[libuna_utf8_string_with_index_copy_from_utf16_stream], |
| 139 |
[libuna_utf8_string_compare_with_utf16_stream], |
| 140 |
[libuna_utf8_string_size_from_utf32], |
| 141 |
[libuna_utf8_string_copy_from_utf32], |
| 142 |
[libuna_utf8_string_with_index_copy_from_utf32], |
| 143 |
[libuna_utf8_string_compare_with_utf32], |
| 144 |
[libuna_utf8_string_size_from_utf32_stream], |
| 145 |
[libuna_utf8_string_copy_from_utf32_stream], |
| 146 |
[libuna_utf8_string_with_index_copy_from_utf32_stream], |
| 147 |
[libuna_utf8_string_compare_with_utf32_stream], |
| 148 |
[libuna_utf8_string_size_from_scsu_stream], |
| 149 |
[libuna_utf8_string_copy_from_scsu_stream], |
| 150 |
[libuna_utf8_string_with_index_copy_from_scsu_stream], |
| 151 |
[libuna_utf16_string_size_from_byte_stream], |
| 152 |
[libuna_utf16_string_copy_from_byte_stream], |
| 153 |
[libuna_utf16_string_with_index_copy_from_byte_stream], |
| 154 |
[libuna_utf16_string_compare_with_byte_stream], |
| 155 |
[libuna_utf16_string_size_from_utf7_stream], |
| 156 |
[libuna_utf16_string_copy_from_utf7_stream], |
| 157 |
[libuna_utf16_string_with_index_copy_from_utf7_stream], |
| 158 |
[libuna_utf16_string_compare_with_utf7_stream], |
| 159 |
[libuna_utf16_string_size_from_utf8], |
| 160 |
[libuna_utf16_string_copy_from_utf8], |
| 161 |
[libuna_utf16_string_with_index_copy_from_utf8], |
| 162 |
[libuna_utf16_string_size_from_utf8_stream], |
| 163 |
[libuna_utf16_string_copy_from_utf8_stream], |
| 164 |
[libuna_utf16_string_with_index_copy_from_utf8_stream], |
| 165 |
[libuna_utf16_string_compare_with_utf8_stream], |
| 166 |
[libuna_utf16_string_size_from_utf16_stream], |
| 167 |
[libuna_utf16_string_copy_from_utf16_stream], |
| 168 |
[libuna_utf16_string_with_index_copy_from_utf16_stream], |
| 169 |
[libuna_utf16_string_compare_with_utf16_stream], |
| 170 |
[libuna_utf16_string_size_from_utf32], |
| 171 |
[libuna_utf16_string_copy_from_utf32], |
| 172 |
[libuna_utf16_string_with_index_copy_from_utf32], |
| 173 |
[libuna_utf16_string_compare_with_utf32], |
| 174 |
[libuna_utf16_string_size_from_utf32_stream], |
| 175 |
[libuna_utf16_string_copy_from_utf32_stream], |
| 176 |
[libuna_utf16_string_with_index_copy_from_utf32_stream], |
| 177 |
[libuna_utf16_string_compare_with_utf32_stream], |
| 178 |
[libuna_utf16_string_size_from_scsu_stream], |
| 179 |
[libuna_utf16_string_copy_from_scsu_stream], |
| 180 |
[libuna_utf16_string_with_index_copy_from_scsu_stream], |
| 181 |
[libuna_utf32_string_size_from_byte_stream], |
| 182 |
[libuna_utf32_string_copy_from_byte_stream], |
| 183 |
[libuna_utf32_string_with_index_copy_from_byte_stream], |
| 184 |
[libuna_utf32_string_compare_with_byte_stream], |
| 185 |
[libuna_utf32_string_size_from_utf7_stream], |
| 186 |
[libuna_utf32_string_copy_from_utf7_stream], |
| 187 |
[libuna_utf32_string_with_index_copy_from_utf7_stream], |
| 188 |
[libuna_utf32_string_compare_with_utf7_stream], |
| 189 |
[libuna_utf32_string_size_from_utf8_stream], |
| 190 |
[libuna_utf32_string_size_from_utf8], |
| 191 |
[libuna_utf32_string_copy_from_utf8], |
| 192 |
[libuna_utf32_string_copy_from_utf8_stream], |
| 193 |
[libuna_utf32_string_with_index_copy_from_utf8_stream], |
| 194 |
[libuna_utf32_string_compare_with_utf8_stream], |
| 195 |
[libuna_utf32_string_size_from_utf16], |
| 196 |
[libuna_utf32_string_copy_from_utf16], |
| 197 |
[libuna_utf32_string_with_index_copy_from_utf16], |
| 198 |
[libuna_utf32_string_size_from_utf16_stream], |
| 199 |
[libuna_utf32_string_copy_from_utf16_stream], |
| 200 |
[libuna_utf32_string_with_index_copy_from_utf16_stream], |
| 201 |
[libuna_utf32_string_compare_with_utf16_stream], |
| 202 |
[libuna_utf32_string_size_from_utf32_stream], |
| 203 |
[libuna_utf32_string_copy_from_utf32_stream], |
| 204 |
[libuna_utf32_string_with_index_copy_from_utf32_stream], |
| 205 |
[libuna_utf32_string_compare_with_utf32_stream], |
| 206 |
[libuna_utf32_string_size_from_scsu_stream], |
| 207 |
[libuna_utf32_string_copy_from_scsu_stream], |
| 208 |
[libuna_utf32_string_with_index_copy_from_scsu_stream]]) |
| 209 |
|
| 210 |
AX_CHECK_LIB_DEFINITIONS( |
| 211 |
[libuna], |
| 212 |
[[LIBUNA_COMPARE_LESS], |
| 213 |
[LIBUNA_COMPARE_EQUAL], |
| 214 |
[LIBUNA_COMPARE_GREATER], |
| 215 |
[LIBUNA_UTF16_STREAM_ALLOW_UNPAIRED_SURROGATE]]) |
| 216 |
|
| 217 |
ac_cv_libuna_LIBADD="-luna"]) |
| 218 |
]) |
| 219 |
|
| 220 |
AX_CHECK_LIB_DIRECTORY_MSG_ON_FAILURE([libuna]) |
| 221 |
]) |
| 222 |
|
| 223 |
AS_IF( |
| 224 |
[test "x$ac_cv_libuna" = xyes], |
| 225 |
[AC_DEFINE( |
| 226 |
[HAVE_LIBUNA], |
| 227 |
[1], |
| 228 |
[Define to 1 if you have the `una' library (-luna).]) |
| 229 |
]) |
| 230 |
|
| 231 |
AS_IF( |
| 232 |
[test "x$ac_cv_libuna" = xyes], |
| 233 |
[AC_SUBST( |
| 234 |
[HAVE_LIBUNA], |
| 235 |
[1]) ], |
| 236 |
[AC_SUBST( |
| 237 |
[HAVE_LIBUNA], |
| 238 |
[0]) |
| 239 |
]) |
| 240 |
]) |
| 241 |
|
| 242 |
dnl Function to detect if libuna dependencies are available |
| 243 |
AC_DEFUN([AX_LIBUNA_CHECK_LOCAL], |
| 244 |
[dnl No additional checks. |
| 245 |
|
| 246 |
ac_cv_libuna_CPPFLAGS="-I../libuna -I\$(top_srcdir)/libuna"; |
| 247 |
ac_cv_libuna_LIBADD="../libuna/libuna.la"; |
| 248 |
|
| 249 |
ac_cv_libuna=local |
| 250 |
]) |
| 251 |
|
| 252 |
dnl Function to detect how to enable libuna |
| 253 |
AC_DEFUN([AX_LIBUNA_CHECK_ENABLE], |
| 254 |
[AX_COMMON_ARG_WITH( |
| 255 |
[libuna], |
| 256 |
[libuna], |
| 257 |
[search for libuna in includedir and libdir or in the specified DIR, or no if to use local version], |
| 258 |
[auto-detect], |
| 259 |
[DIR]) |
| 260 |
|
| 261 |
dnl Check for a shared library version |
| 262 |
AX_LIBUNA_CHECK_LIB |
| 263 |
|
| 264 |
dnl Check if the dependencies for the local library version |
| 265 |
AS_IF( |
| 266 |
[test "x$ac_cv_libuna" != xyes], |
| 267 |
[AX_LIBUNA_CHECK_LOCAL |
| 268 |
|
| 269 |
AC_DEFINE( |
| 270 |
[HAVE_LOCAL_LIBUNA], |
| 271 |
[1], |
| 272 |
[Define to 1 if the local version of libuna is used.]) |
| 273 |
AC_SUBST( |
| 274 |
[HAVE_LOCAL_LIBUNA], |
| 275 |
[1]) |
| 276 |
]) |
| 277 |
|
| 278 |
AM_CONDITIONAL( |
| 279 |
[HAVE_LOCAL_LIBUNA], |
| 280 |
[test "x$ac_cv_libuna" = xlocal]) |
| 281 |
AS_IF( |
| 282 |
[test "x$ac_cv_libuna_CPPFLAGS" != "x"], |
| 283 |
[AC_SUBST( |
| 284 |
[LIBUNA_CPPFLAGS], |
| 285 |
[$ac_cv_libuna_CPPFLAGS]) |
| 286 |
]) |
| 287 |
AS_IF( |
| 288 |
[test "x$ac_cv_libuna_LIBADD" != "x"], |
| 289 |
[AC_SUBST( |
| 290 |
[LIBUNA_LIBADD], |
| 291 |
[$ac_cv_libuna_LIBADD]) |
| 292 |
]) |
| 293 |
|
| 294 |
AS_IF( |
| 295 |
[test "x$ac_cv_libuna" = xyes], |
| 296 |
[AC_SUBST( |
| 297 |
[ax_libuna_pc_libs_private], |
| 298 |
[-luna]) |
| 299 |
]) |
| 300 |
|
| 301 |
AS_IF( |
| 302 |
[test "x$ac_cv_libuna" = xyes], |
| 303 |
[AC_SUBST( |
| 304 |
[ax_libuna_spec_requires], |
| 305 |
[libuna]) |
| 306 |
AC_SUBST( |
| 307 |
[ax_libuna_spec_build_requires], |
| 308 |
[libuna-devel]) |
| 309 |
]) |
| 310 |
]) |
| 311 |
|