Debian Codegraph @

m4/libfcache.m4

raw
1 dnl Checks for libfcache required headers and functions
2 dnl
3 dnl Version: 20240514
4
5 dnl Function to detect if libfcache is available
6 dnl ac_libfcache_dummy is used to prevent AC_CHECK_LIB adding unnecessary -l<library> arguments
7 AC_DEFUN([AX_LIBFCACHE_CHECK_LIB],
8 [AS_IF(
9 [test "x$ac_cv_enable_shared_libs" = xno || test "x$ac_cv_with_libfcache" = xno],
10 [ac_cv_libfcache=no],
11 [ac_cv_libfcache=check
12 dnl Check if the directory provided as parameter exists
13 dnl For both --with-libfcache which returns "yes" and --with-libfcache= which returns ""
14 dnl treat them as auto-detection.
15 AS_IF(
16 [test "x$ac_cv_with_libfcache" != x && test "x$ac_cv_with_libfcache" != xauto-detect && test "x$ac_cv_with_libfcache" != xyes],
17 [AX_CHECK_LIB_DIRECTORY_EXISTS([libfcache])],
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 [libfcache],
23 [libfcache >= 20191109],
24 [ac_cv_libfcache=yes],
25 [ac_cv_libfcache=check])
26 ])
27 AS_IF(
28 [test "x$ac_cv_libfcache" = xyes],
29 [ac_cv_libfcache_CPPFLAGS="$pkg_cv_libfcache_CFLAGS"
30 ac_cv_libfcache_LIBADD="$pkg_cv_libfcache_LIBS"])
31 ])
32
33 AS_IF(
34 [test "x$ac_cv_libfcache" = xcheck],
35 [dnl Check for headers
36 AC_CHECK_HEADERS([libfcache.h])
37
38 AS_IF(
39 [test "x$ac_cv_header_libfcache_h" = xno],
40 [ac_cv_libfcache=no],
41 [ac_cv_libfcache=yes
42
43 AX_CHECK_LIB_FUNCTIONS(
44 [libfcache],
45 [fcache],
46 [[libfcache_get_version],
47 [libfcache_cache_initialize],
48 [libfcache_cache_free],
49 [libfcache_cache_clone],
50 [libfcache_cache_clear],
51 [libfcache_cache_get_number_of_entries],
52 [libfcache_cache_get_number_of_cache_values],
53 [libfcache_cache_clear_value_by_index],
54 [libfcache_cache_get_value_by_identifier],
55 [libfcache_cache_get_value_by_index],
56 [libfcache_cache_set_value_by_identifier],
57 [libfcache_cache_set_value_by_index],
58 [libfcache_cache_value_free],
59 [libfcache_cache_value_clear],
60 [libfcache_cache_value_get_identifier],
61 [libfcache_cache_value_set_identifier],
62 [libfcache_cache_value_get_value],
63 [libfcache_cache_value_set_value],
64 [libfcache_date_time_get_timestamp]])
65
66 ac_cv_libfcache_LIBADD="-lfcache"])
67 ])
68
69 AX_CHECK_LIB_DIRECTORY_MSG_ON_FAILURE([libfcache])
70 ])
71
72 AS_IF(
73 [test "x$ac_cv_libfcache" = xyes],
74 [AC_DEFINE(
75 [HAVE_LIBFCACHE],
76 [1],
77 [Define to 1 if you have the `fcache' library (-lfcache).])
78 ])
79
80 AS_IF(
81 [test "x$ac_cv_libfcache" = xyes],
82 [AC_SUBST(
83 [HAVE_LIBFCACHE],
84 [1]) ],
85 [AC_SUBST(
86 [HAVE_LIBFCACHE],
87 [0])
88 ])
89 ])
90
91 dnl Function to detect if libfcache dependencies are available
92 AC_DEFUN([AX_LIBFCACHE_CHECK_LOCAL],
93 [dnl Types used in libfcache/libfcache_date_time.h
94 AC_STRUCT_TM
95
96 dnl Headers included in libfcache/libfcache_date_time.h
97 AC_CHECK_HEADERS([sys/time.h])
98
99 dnl Date and time functions used in libfcache/libfcache_date_time.h
100 AC_CHECK_FUNCS([clock_gettime time])
101
102 AS_IF(
103 [test "x$ac_cv_func_time" != xyes],
104 [AC_MSG_FAILURE(
105 [Missing function: time],
106 [1])
107 ])
108
109 ac_cv_libfcache_CPPFLAGS="-I../libfcache -I\$(top_srcdir)/libfcache";
110 ac_cv_libfcache_LIBADD="../libfcache/libfcache.la";
111
112 ac_cv_libfcache=local
113 ])
114
115 dnl Function to detect how to enable libfcache
116 AC_DEFUN([AX_LIBFCACHE_CHECK_ENABLE],
117 [AX_COMMON_ARG_WITH(
118 [libfcache],
119 [libfcache],
120 [search for libfcache in includedir and libdir or in the specified DIR, or no if to use local version],
121 [auto-detect],
122 [DIR])
123
124 dnl Check for a shared library version
125 AX_LIBFCACHE_CHECK_LIB
126
127 dnl Check if the dependencies for the local library version
128 AS_IF(
129 [test "x$ac_cv_libfcache" != xyes],
130 [AX_LIBFCACHE_CHECK_LOCAL
131
132 AC_DEFINE(
133 [HAVE_LOCAL_LIBFCACHE],
134 [1],
135 [Define to 1 if the local version of libfcache is used.])
136 AC_SUBST(
137 [HAVE_LOCAL_LIBFCACHE],
138 [1])
139 ])
140
141 AM_CONDITIONAL(
142 [HAVE_LOCAL_LIBFCACHE],
143 [test "x$ac_cv_libfcache" = xlocal])
144 AS_IF(
145 [test "x$ac_cv_libfcache_CPPFLAGS" != "x"],
146 [AC_SUBST(
147 [LIBFCACHE_CPPFLAGS],
148 [$ac_cv_libfcache_CPPFLAGS])
149 ])
150 AS_IF(
151 [test "x$ac_cv_libfcache_LIBADD" != "x"],
152 [AC_SUBST(
153 [LIBFCACHE_LIBADD],
154 [$ac_cv_libfcache_LIBADD])
155 ])
156
157 AS_IF(
158 [test "x$ac_cv_libfcache" = xyes],
159 [AC_SUBST(
160 [ax_libfcache_pc_libs_private],
161 [-lfcache])
162 ])
163
164 AS_IF(
165 [test "x$ac_cv_libfcache" = xyes],
166 [AC_SUBST(
167 [ax_libfcache_spec_requires],
168 [libfcache])
169 AC_SUBST(
170 [ax_libfcache_spec_build_requires],
171 [libfcache-devel])
172 ])
173 ])