Debian Codegraph @

m4/libfguid.m4

raw
1 dnl Checks for libfguid required headers and functions
2 dnl
3 dnl Version: 20240519
4
5 dnl Function to detect if libfguid is available
6 dnl ac_libfguid_dummy is used to prevent AC_CHECK_LIB adding unnecessary -l<library> arguments
7 AC_DEFUN([AX_LIBFGUID_CHECK_LIB],
8 [AS_IF(
9 [test "x$ac_cv_enable_shared_libs" = xno || test "x$ac_cv_with_libfguid" = xno],
10 [ac_cv_libfguid=no],
11 [ac_cv_libfguid=check
12 dnl Check if the directory provided as parameter exists
13 dnl For both --with-libfguid which returns "yes" and --with-libfguid= which returns ""
14 dnl treat them as auto-detection.
15 AS_IF(
16 [test "x$ac_cv_with_libfguid" != x && test "x$ac_cv_with_libfguid" != xauto-detect && test "x$ac_cv_with_libfguid" != xyes],
17 [AX_CHECK_LIB_DIRECTORY_EXISTS([libfguid])],
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 [libfguid],
23 [libfguid >= 20120426],
24 [ac_cv_libfguid=yes],
25 [ac_cv_libfguid=check])
26 ])
27 AS_IF(
28 [test "x$ac_cv_libfguid" = xyes],
29 [ac_cv_libfguid_CPPFLAGS="$pkg_cv_libfguid_CFLAGS"
30 ac_cv_libfguid_LIBADD="$pkg_cv_libfguid_LIBS"])
31 ])
32
33 AS_IF(
34 [test "x$ac_cv_libfguid" = xcheck],
35 [dnl Check for headers
36 AC_CHECK_HEADERS([libfguid.h])
37
38 AS_IF(
39 [test "x$ac_cv_header_libfguid_h" = xno],
40 [ac_cv_libfguid=no],
41 [ac_cv_libfguid=yes
42
43 AX_CHECK_LIB_FUNCTIONS(
44 [libfguid],
45 [fguid],
46 [[libfguid_get_version],
47 [libfguid_identifier_initialize],
48 [libfguid_identifier_free],
49 [libfguid_identifier_copy_from_byte_stream],
50 [libfguid_identifier_get_string_size],
51 [libfguid_identifier_copy_to_utf8_string],
52 [libfguid_identifier_copy_to_utf8_string_with_index],
53 [libfguid_identifier_copy_to_utf16_string],
54 [libfguid_identifier_copy_to_utf16_string_with_index],
55 [libfguid_identifier_copy_to_utf32_string],
56 [libfguid_identifier_copy_to_utf32_string_with_index]])
57
58 ac_cv_libfguid_LIBADD="-lfguid"])
59 ])
60
61 AX_CHECK_LIB_DIRECTORY_MSG_ON_FAILURE([libfguid])
62 ])
63
64 AS_IF(
65 [test "x$ac_cv_libfguid" = xyes],
66 [AC_DEFINE(
67 [HAVE_LIBFGUID],
68 [1],
69 [Define to 1 if you have the `fguid' library (-lfguid).])
70 ])
71
72 AS_IF(
73 [test "x$ac_cv_libfguid" = xyes],
74 [AC_SUBST(
75 [HAVE_LIBFGUID],
76 [1]) ],
77 [AC_SUBST(
78 [HAVE_LIBFGUID],
79 [0])
80 ])
81 ])
82
83 dnl Function to detect if libfguid dependencies are available
84 AC_DEFUN([AX_LIBFGUID_CHECK_LOCAL],
85 [dnl No additional checks.
86
87 ac_cv_libfguid_CPPFLAGS="-I../libfguid -I\$(top_srcdir)/libfguid";
88 ac_cv_libfguid_LIBADD="../libfguid/libfguid.la";
89
90 ac_cv_libfguid=local
91 ])
92
93
94 dnl Function to detect how to enable libfguid
95 AC_DEFUN([AX_LIBFGUID_CHECK_ENABLE],
96 [AX_COMMON_ARG_WITH(
97 [libfguid],
98 [libfguid],
99 [search for libfguid in includedir and libdir or in the specified DIR, or no if to use local version],
100 [auto-detect],
101 [DIR])
102
103 dnl Check for a shared library version
104 AX_LIBFGUID_CHECK_LIB
105
106 dnl Check if the dependencies for the local library version
107 AS_IF(
108 [test "x$ac_cv_libfguid" != xyes],
109 [AX_LIBFGUID_CHECK_LOCAL
110
111 AC_DEFINE(
112 [HAVE_LOCAL_LIBFGUID],
113 [1],
114 [Define to 1 if the local version of libfguid is used.])
115 AC_SUBST(
116 [HAVE_LOCAL_LIBFGUID],
117 [1])
118 ])
119
120 AM_CONDITIONAL(
121 [HAVE_LOCAL_LIBFGUID],
122 [test "x$ac_cv_libfguid" = xlocal])
123 AS_IF(
124 [test "x$ac_cv_libfguid_CPPFLAGS" != "x"],
125 [AC_SUBST(
126 [LIBFGUID_CPPFLAGS],
127 [$ac_cv_libfguid_CPPFLAGS])
128 ])
129 AS_IF(
130 [test "x$ac_cv_libfguid_LIBADD" != "x"],
131 [AC_SUBST(
132 [LIBFGUID_LIBADD],
133 [$ac_cv_libfguid_LIBADD])
134 ])
135
136 AS_IF(
137 [test "x$ac_cv_libfguid" = xyes],
138 [AC_SUBST(
139 [ax_libfguid_pc_libs_private],
140 [-lfguid])
141 ])
142
143 AS_IF(
144 [test "x$ac_cv_libfguid" = xyes],
145 [AC_SUBST(
146 [ax_libfguid_spec_requires],
147 [libfguid])
148 AC_SUBST(
149 [ax_libfguid_spec_build_requires],
150 [libfguid-devel])
151 ])
152 ])
153