1dnl Checks for libcsplit required headers and functions 2dnl 3dnl Version: 20190308 4 5dnl Function to detect if libcsplit is available 6dnl ac_libcsplit_dummy is used to prevent AC_CHECK_LIB adding unnecessary -l<library> arguments 7AC_DEFUN([AX_LIBCSPLIT_CHECK_LIB], 8 [AS_IF( 9 [test "x$ac_cv_enable_shared_libs" = xno || test "x$ac_cv_with_libcsplit" = xno], 10 [ac_cv_libcsplit=no], 11 [ac_cv_libcsplit=check 12 dnl Check if the directory provided as parameter exists 13 AS_IF( 14 [test "x$ac_cv_with_libcsplit" != x && test "x$ac_cv_with_libcsplit" != xauto-detect], 15 [AS_IF( 16 [test -d "$ac_cv_with_libcsplit"], 17 [CFLAGS="$CFLAGS -I${ac_cv_with_libcsplit}/include" 18 LDFLAGS="$LDFLAGS -L${ac_cv_with_libcsplit}/lib"], 19 [AC_MSG_FAILURE( 20 [no such directory: $ac_cv_with_libcsplit], 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 [libcsplit], 29 [libcsplit >= 20120701], 30 [ac_cv_libcsplit=yes], 31 [ac_cv_libcsplit=check]) 32 ]) 33 AS_IF( 34 [test "x$ac_cv_libcsplit" = xyes && test "x$ac_cv_enable_wide_character_type" != xno], 35 [AC_CACHE_CHECK( 36 [whether libcsplit/features.h defines LIBCSPLIT_HAVE_WIDE_CHARACTER_TYPE as 1], 37 [ac_cv_header_libcsplit_features_h_have_wide_character_type], 38 [AC_LANG_PUSH(C) 39 AC_COMPILE_IFELSE( 40 [AC_LANG_PROGRAM( 41 [[#include <libcsplit/features.h>]], 42 [[#if !defined( LIBCSPLIT_HAVE_WIDE_CHARACTER_TYPE ) || ( LIBCSPLIT_HAVE_WIDE_CHARACTER_TYPE != 1 ) 43#error LIBCSPLIT_HAVE_WIDE_CHARACTER_TYPE not defined 44#endif]] )], 45 [ac_cv_header_libcsplit_features_h_have_wide_character_type=yes], 46 [ac_cv_header_libcsplit_features_h_have_wide_character_type=no]) 47 AC_LANG_POP(C)], 48 [ac_cv_header_libcsplit_features_h_have_wide_character_type=no]) 49 50 AS_IF( 51 [test "x$ac_cv_header_libcsplit_features_h_have_wide_character_type" = xno], 52 [ac_cv_libcsplit=no]) 53 ]) 54 AS_IF( 55 [test "x$ac_cv_libcsplit" = xyes], 56 [ac_cv_libcsplit_CPPFLAGS="$pkg_cv_libcsplit_CFLAGS" 57 ac_cv_libcsplit_LIBADD="$pkg_cv_libcsplit_LIBS"]) 58 ]) 59 60 AS_IF( 61 [test "x$ac_cv_libcsplit" = xcheck], 62 [dnl Check for headers 63 AC_CHECK_HEADERS([libcsplit.h]) 64 65 AS_IF( 66 [test "x$ac_cv_header_libcsplit_h" = xno], 67 [ac_cv_libcsplit=no], 68 [dnl Check for the individual functions 69 ac_cv_libcsplit=yes 70 71 AC_CHECK_LIB( 72 csplit, 73 libcsplit_get_version, 74 [ac_cv_libcsplit_dummy=yes], 75 [ac_cv_libcsplit=no]) 76 77 dnl Narrow string functions 78 AC_CHECK_LIB( 79 csplit, 80 libcsplit_narrow_string_split, 81 [ac_cv_libcsplit_dummy=yes], 82 [ac_cv_libcsplit=no]) 83 84 dnl Narrow split string functions 85 AC_CHECK_LIB( 86 csplit, 87 libcsplit_narrow_split_string_free, 88 [ac_cv_libcsplit_dummy=yes], 89 [ac_cv_libcsplit=no]) 90 AC_CHECK_LIB( 91 csplit, 92 libcsplit_narrow_split_string_get_string, 93 [ac_cv_libcsplit_dummy=yes], 94 [ac_cv_libcsplit=no]) 95 AC_CHECK_LIB( 96 csplit, 97 libcsplit_narrow_split_string_get_number_of_segments, 98 [ac_cv_libcsplit_dummy=yes], 99 [ac_cv_libcsplit=no]) 100 AC_CHECK_LIB( 101 csplit, 102 libcsplit_narrow_split_string_get_segment_by_index, 103 [ac_cv_libcsplit_dummy=yes], 104 [ac_cv_libcsplit=no]) 105 AC_CHECK_LIB( 106 csplit, 107 libcsplit_narrow_split_string_set_segment_by_index, 108 [ac_cv_libcsplit_dummy=yes], 109 [ac_cv_libcsplit=no]) 110 111 dnl Wide string functions 112 AS_IF( 113 [test "x$ac_cv_enable_wide_character_type" != xno], 114 [AC_CHECK_LIB( 115 csplit, 116 libcsplit_wide_string_split, 117 [ac_cv_libcsplit_dummy=yes], 118 [ac_cv_libcsplit=no]) 119 120 dnl Wide split string functions 121 AC_CHECK_LIB( 122 csplit, 123 libcsplit_wide_split_string_free, 124 [ac_cv_libcsplit_dummy=yes], 125 [ac_cv_libcsplit=no]) 126 AC_CHECK_LIB( 127 csplit, 128 libcsplit_wide_split_string_get_string, 129 [ac_cv_libcsplit_dummy=yes], 130 [ac_cv_libcsplit=no]) 131 AC_CHECK_LIB( 132 csplit, 133 libcsplit_wide_split_string_get_number_of_segments, 134 [ac_cv_libcsplit_dummy=yes], 135 [ac_cv_libcsplit=no]) 136 AC_CHECK_LIB( 137 csplit, 138 libcsplit_wide_split_string_get_segment_by_index, 139 [ac_cv_libcsplit_dummy=yes], 140 [ac_cv_libcsplit=no]) 141 AC_CHECK_LIB( 142 csplit, 143 libcsplit_wide_split_string_set_segment_by_index, 144 [ac_cv_libcsplit_dummy=yes], 145 [ac_cv_libcsplit=no]) 146 ]) 147 148 ac_cv_libcsplit_LIBADD="-lcsplit"]) 149 ]) 150 AS_IF( 151 [test "x$ac_cv_with_libcsplit" != x && test "x$ac_cv_with_libcsplit" != xauto-detect && test "x$ac_cv_libcsplit" != xyes], 152 [AC_MSG_FAILURE( 153 [unable to find supported libcsplit in directory: $ac_cv_with_libcsplit], 154 [1]) 155 ]) 156 ]) 157 158 AS_IF( 159 [test "x$ac_cv_libcsplit" = xyes], 160 [AC_DEFINE( 161 [HAVE_LIBCSPLIT], 162 [1], 163 [Define to 1 if you have the `csplit' library (-lcsplit).]) 164 ]) 165 166 AS_IF( 167 [test "x$ac_cv_libcsplit" = xyes], 168 [AC_SUBST( 169 [HAVE_LIBCSPLIT], 170 [1]) ], 171 [AC_SUBST( 172 [HAVE_LIBCSPLIT], 173 [0]) 174 ]) 175 ]) 176 177dnl Function to detect if libcsplit dependencies are available 178AC_DEFUN([AX_LIBCSPLIT_CHECK_LOCAL], 179 [dnl No additional checks. 180 181 ac_cv_libcsplit_CPPFLAGS="-I../libcsplit"; 182 ac_cv_libcsplit_LIBADD="../libcsplit/libcsplit.la"; 183 184 ac_cv_libcsplit=local 185 ]) 186 187dnl Function to detect how to enable libcsplit 188AC_DEFUN([AX_LIBCSPLIT_CHECK_ENABLE], 189 [AX_COMMON_ARG_WITH( 190 [libcsplit], 191 [libcsplit], 192 [search for libcsplit in includedir and libdir or in the specified DIR, or no if to use local version], 193 [auto-detect], 194 [DIR]) 195 196 dnl Check for a shared library version 197 AX_LIBCSPLIT_CHECK_LIB 198 199 dnl Check if the dependencies for the local library version 200 AS_IF( 201 [test "x$ac_cv_libcsplit" != xyes], 202 [AX_LIBCSPLIT_CHECK_LOCAL 203 204 AC_DEFINE( 205 [HAVE_LOCAL_LIBCSPLIT], 206 [1], 207 [Define to 1 if the local version of libcsplit is used.]) 208 AC_SUBST( 209 [HAVE_LOCAL_LIBCSPLIT], 210 [1]) 211 ]) 212 213 AM_CONDITIONAL( 214 [HAVE_LOCAL_LIBCSPLIT], 215 [test "x$ac_cv_libcsplit" = xlocal]) 216 AS_IF( 217 [test "x$ac_cv_libcsplit_CPPFLAGS" != "x"], 218 [AC_SUBST( 219 [LIBCSPLIT_CPPFLAGS], 220 [$ac_cv_libcsplit_CPPFLAGS]) 221 ]) 222 AS_IF( 223 [test "x$ac_cv_libcsplit_LIBADD" != "x"], 224 [AC_SUBST( 225 [LIBCSPLIT_LIBADD], 226 [$ac_cv_libcsplit_LIBADD]) 227 ]) 228 229 AS_IF( 230 [test "x$ac_cv_libcsplit" = xyes], 231 [AC_SUBST( 232 [ax_libcsplit_pc_libs_private], 233 [-lcsplit]) 234 ]) 235 236 AS_IF( 237 [test "x$ac_cv_libcsplit" = xyes], 238 [AC_SUBST( 239 [ax_libcsplit_spec_requires], 240 [libcsplit]) 241 AC_SUBST( 242 [ax_libcsplit_spec_build_requires], 243 [libcsplit-devel]) 244 ]) 245 ]) 246 247