1dnl Checks for libcdata required headers and functions 2dnl 3dnl Version: 20191221 4 5dnl Function to detect if libcdata is available 6dnl ac_libcdata_dummy is used to prevent AC_CHECK_LIB adding unnecessary -l<library> arguments 7AC_DEFUN([AX_LIBCDATA_CHECK_LIB], 8 [AS_IF( 9 [test "x$ac_cv_enable_shared_libs" = xno || test "x$ac_cv_with_libcdata" = xno], 10 [ac_cv_libcdata=no], 11 [ac_cv_libcdata=check 12 dnl Check if the directory provided as parameter exists 13 AS_IF( 14 [test "x$ac_cv_with_libcdata" != x && test "x$ac_cv_with_libcdata" != xauto-detect], 15 [AS_IF( 16 [test -d "$ac_cv_with_libcdata"], 17 [CFLAGS="$CFLAGS -I${ac_cv_with_libcdata}/include" 18 LDFLAGS="$LDFLAGS -L${ac_cv_with_libcdata}/lib"], 19 [AC_MSG_FAILURE( 20 [no such directory: $ac_cv_with_libcdata], 21 [1]) 22 ]) 23 ], 24 [dnl Check for a pkg-config file 25 AS_IF( 26 [test "x$cross_compiling" != "xyes" && test "x$PKGCONFIG" != "x"], 27 [PKG_CHECK_MODULES( 28 [libcdata], 29 [libcdata >= 20190112], 30 [ac_cv_libcdata=yes], 31 [ac_cv_libcdata=check]) 32 ]) 33 AS_IF( 34 [test "x$ac_cv_libcdata" = xyes], 35 [ac_cv_libcdata_CPPFLAGS="$pkg_cv_libcdata_CFLAGS" 36 ac_cv_libcdata_LIBADD="$pkg_cv_libcdata_LIBS"]) 37 ]) 38 39 AS_IF( 40 [test "x$ac_cv_libcdata" = xcheck], 41 [dnl Check for headers 42 AC_CHECK_HEADERS([libcdata.h]) 43 44 AS_IF( 45 [test "x$ac_cv_header_libcdata_h" = xno], 46 [ac_cv_libcdata=no], 47 [dnl Check for the individual functions 48 ac_cv_libcdata=yes 49 50 AC_CHECK_LIB( 51 cdata, 52 libcdata_get_version, 53 [ac_cv_libcdata_dummy=yes], 54 [ac_cv_libcdata=no]) 55 56 dnl Array functions 57 AC_CHECK_LIB( 58 cdata, 59 libcdata_array_initialize, 60 [ac_cv_libcdata_dummy=yes], 61 [ac_cv_libcdata=no]) 62 AC_CHECK_LIB( 63 cdata, 64 libcdata_array_free, 65 [ac_cv_libcdata_dummy=yes], 66 [ac_cv_libcdata=no]) 67 AC_CHECK_LIB( 68 cdata, 69 libcdata_array_empty, 70 [ac_cv_libcdata_dummy=yes], 71 [ac_cv_libcdata=no]) 72 AC_CHECK_LIB( 73 cdata, 74 libcdata_array_clone, 75 [ac_cv_libcdata_dummy=yes], 76 [ac_cv_libcdata=no]) 77 AC_CHECK_LIB( 78 cdata, 79 libcdata_array_resize, 80 [ac_cv_libcdata_dummy=yes], 81 [ac_cv_libcdata=no]) 82 AC_CHECK_LIB( 83 cdata, 84 libcdata_array_reverse, 85 [ac_cv_libcdata_dummy=yes], 86 [ac_cv_libcdata=no]) 87 AC_CHECK_LIB( 88 cdata, 89 libcdata_array_get_number_of_entries, 90 [ac_cv_libcdata_dummy=yes], 91 [ac_cv_libcdata=no]) 92 AC_CHECK_LIB( 93 cdata, 94 libcdata_array_get_entry_by_index, 95 [ac_cv_libcdata_dummy=yes], 96 [ac_cv_libcdata=no]) 97 AC_CHECK_LIB( 98 cdata, 99 libcdata_array_get_entry_by_value, 100 [ac_cv_libcdata_dummy=yes], 101 [ac_cv_libcdata=no]) 102 AC_CHECK_LIB( 103 cdata, 104 libcdata_array_set_entry_by_index, 105 [ac_cv_libcdata_dummy=yes], 106 [ac_cv_libcdata=no]) 107 AC_CHECK_LIB( 108 cdata, 109 libcdata_array_prepend_entry, 110 [ac_cv_libcdata_dummy=yes], 111 [ac_cv_libcdata=no]) 112 AC_CHECK_LIB( 113 cdata, 114 libcdata_array_append_entry, 115 [ac_cv_libcdata_dummy=yes], 116 [ac_cv_libcdata=no]) 117 AC_CHECK_LIB( 118 cdata, 119 libcdata_array_insert_entry, 120 [ac_cv_libcdata_dummy=yes], 121 [ac_cv_libcdata=no]) 122 AC_CHECK_LIB( 123 cdata, 124 libcdata_array_remove_entry, 125 [ac_cv_libcdata_dummy=yes], 126 [ac_cv_libcdata=no]) 127 128 dnl Balanced tree functions 129 AC_CHECK_LIB( 130 cdata, 131 libfdata_btree_initialize, 132 [ac_cv_libcdata_dummy=yes], 133 [ac_cv_libcdata=no]) 134 AC_CHECK_LIB( 135 cdata, 136 libcdata_btree_free, 137 [ac_cv_libcdata_dummy=yes], 138 [ac_cv_libcdata=no]) 139 AC_CHECK_LIB( 140 cdata, 141 libcdata_btree_get_number_of_values, 142 [ac_cv_libcdata_dummy=yes], 143 [ac_cv_libcdata=no]) 144 AC_CHECK_LIB( 145 cdata, 146 libcdata_btree_get_value_by_index, 147 [ac_cv_libcdata_dummy=yes], 148 [ac_cv_libcdata=no]) 149 AC_CHECK_LIB( 150 cdata, 151 libcdata_btree_get_value_by_value, 152 [ac_cv_libcdata_dummy=yes], 153 [ac_cv_libcdata=no]) 154 AC_CHECK_LIB( 155 cdata, 156 libcdata_btree_insert_value, 157 [ac_cv_libcdata_dummy=yes], 158 [ac_cv_libcdata=no]) 159 AC_CHECK_LIB( 160 cdata, 161 libcdata_btree_replace_value, 162 [ac_cv_libcdata_dummy=yes], 163 [ac_cv_libcdata=no]) 164 AC_CHECK_LIB( 165 cdata, 166 libcdata_btree_remove_value, 167 [ac_cv_libcdata_dummy=yes], 168 [ac_cv_libcdata=no]) 169 170 dnl List functions 171 AC_CHECK_LIB( 172 cdata, 173 libcdata_list_initialize, 174 [ac_cv_libcdata_dummy=yes], 175 [ac_cv_libcdata=no]) 176 AC_CHECK_LIB( 177 cdata, 178 libcdata_list_free, 179 [ac_cv_libcdata_dummy=yes], 180 [ac_cv_libcdata=no]) 181 AC_CHECK_LIB( 182 cdata, 183 libcdata_list_empty, 184 [ac_cv_libcdata_dummy=yes], 185 [ac_cv_libcdata=no]) 186 AC_CHECK_LIB( 187 cdata, 188 libcdata_list_clone, 189 [ac_cv_libcdata_dummy=yes], 190 [ac_cv_libcdata=no]) 191 AC_CHECK_LIB( 192 cdata, 193 libcdata_list_get_number_of_elements, 194 [ac_cv_libcdata_dummy=yes], 195 [ac_cv_libcdata=no]) 196 AC_CHECK_LIB( 197 cdata, 198 libcdata_list_get_first_element, 199 [ac_cv_libcdata_dummy=yes], 200 [ac_cv_libcdata=no]) 201 AC_CHECK_LIB( 202 cdata, 203 libcdata_list_get_last_element, 204 [ac_cv_libcdata_dummy=yes], 205 [ac_cv_libcdata=no]) 206 AC_CHECK_LIB( 207 cdata, 208 libcdata_list_get_element_by_index, 209 [ac_cv_libcdata_dummy=yes], 210 [ac_cv_libcdata=no]) 211 AC_CHECK_LIB( 212 cdata, 213 libcdata_list_get_value_by_index, 214 [ac_cv_libcdata_dummy=yes], 215 [ac_cv_libcdata=no]) 216 AC_CHECK_LIB( 217 cdata, 218 libcdata_list_prepend_element, 219 [ac_cv_libcdata_dummy=yes], 220 [ac_cv_libcdata=no]) 221 AC_CHECK_LIB( 222 cdata, 223 libcdata_list_prepend_value, 224 [ac_cv_libcdata_dummy=yes], 225 [ac_cv_libcdata=no]) 226 AC_CHECK_LIB( 227 cdata, 228 libcdata_list_append_element, 229 [ac_cv_libcdata_dummy=yes], 230 [ac_cv_libcdata=no]) 231 AC_CHECK_LIB( 232 cdata, 233 libcdata_list_append_value, 234 [ac_cv_libcdata_dummy=yes], 235 [ac_cv_libcdata=no]) 236 AC_CHECK_LIB( 237 cdata, 238 libcdata_list_insert_element, 239 [ac_cv_libcdata_dummy=yes], 240 [ac_cv_libcdata=no]) 241 AC_CHECK_LIB( 242 cdata, 243 libcdata_list_insert_value, 244 [ac_cv_libcdata_dummy=yes], 245 [ac_cv_libcdata=no]) 246 AC_CHECK_LIB( 247 cdata, 248 libcdata_list_remove_element, 249 [ac_cv_libcdata_dummy=yes], 250 [ac_cv_libcdata=no]) 251 252 dnl List element functions 253 AC_CHECK_LIB( 254 cdata, 255 libcdata_list_element_initialize, 256 [ac_cv_libcdata_dummy=yes], 257 [ac_cv_libcdata=no]) 258 AC_CHECK_LIB( 259 cdata, 260 libcdata_list_element_free, 261 [ac_cv_libcdata_dummy=yes], 262 [ac_cv_libcdata=no]) 263 AC_CHECK_LIB( 264 cdata, 265 libcdata_list_element_get_value, 266 [ac_cv_libcdata_dummy=yes], 267 [ac_cv_libcdata=no]) 268 AC_CHECK_LIB( 269 cdata, 270 libcdata_list_element_set_value, 271 [ac_cv_libcdata_dummy=yes], 272 [ac_cv_libcdata=no]) 273 AC_CHECK_LIB( 274 cdata, 275 libcdata_list_element_get_previous_element, 276 [ac_cv_libcdata_dummy=yes], 277 [ac_cv_libcdata=no]) 278 AC_CHECK_LIB( 279 cdata, 280 libcdata_list_element_set_previous_element, 281 [ac_cv_libcdata_dummy=yes], 282 [ac_cv_libcdata=no]) 283 AC_CHECK_LIB( 284 cdata, 285 libcdata_list_element_get_next_element, 286 [ac_cv_libcdata_dummy=yes], 287 AC_CHECK_LIB( 288 cdata, 289 libcdata_list_element_set_next_element, 290 [ac_cv_libcdata_dummy=yes], 291 [ac_cv_libcdata=no]) 292 AC_CHECK_LIB( 293 cdata, 294 libcdata_list_element_get_elements, 295 [ac_cv_libcdata_dummy=yes], 296 [ac_cv_libcdata=no]) 297 AC_CHECK_LIB( 298 cdata, 299 libcdata_list_element_set_elements, 300 [ac_cv_libcdata_dummy=yes], 301 [ac_cv_libcdata=no]) 302 [ac_cv_libcdata=no]) 303 304 dnl Range list functions 305 AC_CHECK_LIB( 306 cdata, 307 libcdata_range_list_initialize, 308 [ac_cv_libcdata_dummy=yes], 309 [ac_cv_libcdata=no]) 310 AC_CHECK_LIB( 311 cdata, 312 libcdata_range_list_free, 313 [ac_cv_libcdata_dummy=yes], 314 [ac_cv_libcdata=no]) 315 AC_CHECK_LIB( 316 cdata, 317 libcdata_range_list_empty, 318 [ac_cv_libcdata_dummy=yes], 319 [ac_cv_libcdata=no]) 320 AC_CHECK_LIB( 321 cdata, 322 libcdata_range_list_clone, 323 [ac_cv_libcdata_dummy=yes], 324 [ac_cv_libcdata=no]) 325 AC_CHECK_LIB( 326 cdata, 327 libcdata_range_list_get_number_of_elements, 328 [ac_cv_libcdata_dummy=yes], 329 [ac_cv_libcdata=no]) 330 AC_CHECK_LIB( 331 cdata, 332 libcdata_range_list_insert_range, 333 [ac_cv_libcdata_dummy=yes], 334 [ac_cv_libcdata=no]) 335 AC_CHECK_LIB( 336 cdata, 337 libcdata_range_list_insert_range_list, 338 [ac_cv_libcdata_dummy=yes], 339 [ac_cv_libcdata=no]) 340 AC_CHECK_LIB( 341 cdata, 342 libcdata_range_list_remove_range, 343 [ac_cv_libcdata_dummy=yes], 344 [ac_cv_libcdata=no]) 345 AC_CHECK_LIB( 346 cdata, 347 libcdata_range_list_get_range_by_index, 348 [ac_cv_libcdata_dummy=yes], 349 [ac_cv_libcdata=no]) 350 AC_CHECK_LIB( 351 cdata, 352 libcdata_range_list_get_range_at_offset, 353 [ac_cv_libcdata_dummy=yes], 354 [ac_cv_libcdata=no]) 355 AC_CHECK_LIB( 356 cdata, 357 libcdata_range_list_range_is_present, 358 [ac_cv_libcdata_dummy=yes], 359 [ac_cv_libcdata=no]) 360 AC_CHECK_LIB( 361 cdata, 362 libcdata_range_list_get_spanning_range, 363 [ac_cv_libcdata_dummy=yes], 364 [ac_cv_libcdata=no]) 365 366 dnl Tree node functions 367 AC_CHECK_LIB( 368 cdata, 369 libcdata_tree_node_initialize, 370 [ac_cv_libcdata_dummy=yes], 371 [ac_cv_libcdata=no]) 372 AC_CHECK_LIB( 373 cdata, 374 libcdata_tree_node_free, 375 [ac_cv_libcdata_dummy=yes], 376 [ac_cv_libcdata=no]) 377 AC_CHECK_LIB( 378 cdata, 379 libcdata_tree_node_empty, 380 [ac_cv_libcdata_dummy=yes], 381 [ac_cv_libcdata=no]) 382 AC_CHECK_LIB( 383 cdata, 384 libcdata_tree_node_clone, 385 [ac_cv_libcdata_dummy=yes], 386 [ac_cv_libcdata=no]) 387 AC_CHECK_LIB( 388 cdata, 389 libcdata_tree_node_get_value, 390 [ac_cv_libcdata_dummy=yes], 391 [ac_cv_libcdata=no]) 392 AC_CHECK_LIB( 393 cdata, 394 libcdata_tree_node_set_value, 395 [ac_cv_libcdata_dummy=yes], 396 [ac_cv_libcdata=no]) 397 AC_CHECK_LIB( 398 cdata, 399 libcdata_tree_node_get_parent_node, 400 [ac_cv_libcdata_dummy=yes], 401 [ac_cv_libcdata=no]) 402 AC_CHECK_LIB( 403 cdata, 404 libcdata_tree_node_set_parent_node, 405 [ac_cv_libcdata_dummy=yes], 406 [ac_cv_libcdata=no]) 407 AC_CHECK_LIB( 408 cdata, 409 libcdata_tree_node_get_previous_node, 410 [ac_cv_libcdata_dummy=yes], 411 [ac_cv_libcdata=no]) 412 AC_CHECK_LIB( 413 cdata, 414 libcdata_tree_node_set_previous_node, 415 [ac_cv_libcdata_dummy=yes], 416 [ac_cv_libcdata=no]) 417 AC_CHECK_LIB( 418 cdata, 419 libcdata_tree_node_get_next_node, 420 [ac_cv_libcdata_dummy=yes], 421 [ac_cv_libcdata=no]) 422 AC_CHECK_LIB( 423 cdata, 424 libcdata_tree_node_set_next_node, 425 [ac_cv_libcdata_dummy=yes], 426 [ac_cv_libcdata=no]) 427 AC_CHECK_LIB( 428 cdata, 429 libcdata_tree_node_get_nodes, 430 [ac_cv_libcdata_dummy=yes], 431 [ac_cv_libcdata=no]) 432 AC_CHECK_LIB( 433 cdata, 434 libcdata_tree_node_set_nodes, 435 [ac_cv_libcdata_dummy=yes], 436 [ac_cv_libcdata=no]) 437 AC_CHECK_LIB( 438 cdata, 439 libcdata_tree_node_append_node, 440 [ac_cv_libcdata_dummy=yes], 441 [ac_cv_libcdata=no]) 442 AC_CHECK_LIB( 443 cdata, 444 libcdata_tree_node_append_value, 445 [ac_cv_libcdata_dummy=yes], 446 [ac_cv_libcdata=no]) 447 AC_CHECK_LIB( 448 cdata, 449 libcdata_tree_node_insert_node, 450 [ac_cv_libcdata_dummy=yes], 451 [ac_cv_libcdata=no]) 452 AC_CHECK_LIB( 453 cdata, 454 libcdata_tree_node_insert_value, 455 [ac_cv_libcdata_dummy=yes], 456 [ac_cv_libcdata=no]) 457 AC_CHECK_LIB( 458 cdata, 459 libcdata_tree_node_replace_node, 460 [ac_cv_libcdata_dummy=yes], 461 [ac_cv_libcdata=no]) 462 AC_CHECK_LIB( 463 cdata, 464 libcdata_tree_node_remove_node, 465 [ac_cv_libcdata_dummy=yes], 466 [ac_cv_libcdata=no]) 467 AC_CHECK_LIB( 468 cdata, 469 libcdata_tree_node_get_number_of_sub_nodes, 470 [ac_cv_libcdata_dummy=yes], 471 [ac_cv_libcdata=no]) 472 AC_CHECK_LIB( 473 cdata, 474 libcdata_tree_node_get_sub_node_by_index, 475 [ac_cv_libcdata_dummy=yes], 476 [ac_cv_libcdata=no]) 477 AC_CHECK_LIB( 478 cdata, 479 libcdata_tree_node_get_leaf_node_list, 480 [ac_cv_libcdata_dummy=yes], 481 [ac_cv_libcdata=no]) 482 483 ac_cv_libcdata_LIBADD="-lcdata"]) 484 ]) 485 AS_IF( 486 [test "x$ac_cv_with_libcdata" != x && test "x$ac_cv_with_libcdata" != xauto-detect && test "x$ac_cv_libcdata" != xyes], 487 [AC_MSG_FAILURE( 488 [unable to find supported libcdata in directory: $ac_cv_with_libcdata], 489 [1]) 490 ]) 491 ]) 492 493 AS_IF( 494 [test "x$ac_cv_libcdata" = xyes], 495 [AC_DEFINE( 496 [HAVE_LIBCDATA], 497 [1], 498 [Define to 1 if you have the `cdata' library (-lcdata).]) 499 ]) 500 501 AS_IF( 502 [test "x$ac_cv_libcdata" = xyes], 503 [AC_SUBST( 504 [HAVE_LIBCDATA], 505 [1]) ], 506 [AC_SUBST( 507 [HAVE_LIBCDATA], 508 [0]) 509 ]) 510 ]) 511 512dnl Function to detect if libcdata dependencies are available 513AC_DEFUN([AX_LIBCDATA_CHECK_LOCAL], 514 [dnl No additional checks. 515 516 ac_cv_libcdata_CPPFLAGS="-I../libcdata"; 517 ac_cv_libcdata_LIBADD="../libcdata/libcdata.la"; 518 519 ac_cv_libcdata=local 520 ]) 521 522dnl Function to detect how to enable libcdata 523AC_DEFUN([AX_LIBCDATA_CHECK_ENABLE], 524 [AX_COMMON_ARG_WITH( 525 [libcdata], 526 [libcdata], 527 [search for libcdata in includedir and libdir or in the specified DIR, or no if to use local version], 528 [auto-detect], 529 [DIR]) 530 531 dnl Check for a shared library version 532 AX_LIBCDATA_CHECK_LIB 533 534 dnl Check if the dependencies for the local library version 535 AS_IF( 536 [test "x$ac_cv_libcdata" != xyes], 537 [AX_LIBCDATA_CHECK_LOCAL 538 539 AC_DEFINE( 540 [HAVE_LOCAL_LIBCDATA], 541 [1], 542 [Define to 1 if the local version of libcdata is used.]) 543 AC_SUBST( 544 [HAVE_LOCAL_LIBCDATA], 545 [1]) 546 ]) 547 548 AM_CONDITIONAL( 549 [HAVE_LOCAL_LIBCDATA], 550 [test "x$ac_cv_libcdata" = xlocal]) 551 AS_IF( 552 [test "x$ac_cv_libcdata_CPPFLAGS" != "x"], 553 [AC_SUBST( 554 [LIBCDATA_CPPFLAGS], 555 [$ac_cv_libcdata_CPPFLAGS]) 556 ]) 557 AS_IF( 558 [test "x$ac_cv_libcdata_LIBADD" != "x"], 559 [AC_SUBST( 560 [LIBCDATA_LIBADD], 561 [$ac_cv_libcdata_LIBADD]) 562 ]) 563 564 AS_IF( 565 [test "x$ac_cv_libcdata" = xyes], 566 [AC_SUBST( 567 [ax_libcdata_pc_libs_private], 568 [-lcdata]) 569 ]) 570 571 AS_IF( 572 [test "x$ac_cv_libcdata" = xyes], 573 [AC_SUBST( 574 [ax_libcdata_spec_requires], 575 [libcdata]) 576 AC_SUBST( 577 [ax_libcdata_spec_build_requires], 578 [libcdata-devel]) 579 ]) 580 ]) 581 582