1dnl Checks for zlib required headers and functions 2dnl 3dnl Version: 20200712 4 5dnl Function to detect if zlib is available 6AC_DEFUN([AX_ZLIB_CHECK_LIB], 7 [AS_IF( 8 [test "x$ac_cv_enable_shared_libs" = xno || test "x$ac_cv_with_zlib" = xno], 9 [ac_cv_zlib=no], 10 [ac_cv_zlib=check 11 dnl Check if the directory provided as parameter exists 12 AS_IF( 13 [test "x$ac_cv_with_zlib" != x && test "x$ac_cv_with_zlib" != xauto-detect], 14 [AS_IF( 15 [test -d "$ac_cv_with_zlib"], 16 [CFLAGS="$CFLAGS -I${ac_cv_with_zlib}/include" 17 LDFLAGS="$LDFLAGS -L${ac_cv_with_zlib}/lib"], 18 [AC_MSG_FAILURE( 19 [no such directory: $ac_cv_with_zlib], 20 [1]) 21 ]) 22 ], 23 [dnl Check for a pkg-config file 24 AS_IF( 25 [test "x$cross_compiling" != "xyes" && test "x$PKGCONFIG" != "x"], 26 [PKG_CHECK_MODULES( 27 [zlib], 28 [zlib >= 1.2.5], 29 [ac_cv_zlib=zlib], 30 [ac_cv_zlib=check]) 31 ]) 32 AS_IF( 33 [test "x$ac_cv_zlib" = xzlib], 34 [ac_cv_zlib_CPPFLAGS="$pkg_cv_zlib_CFLAGS" 35 ac_cv_zlib_LIBADD="$pkg_cv_zlib_LIBS"]) 36 ]) 37 38 AS_IF( 39 [test "x$ac_cv_zlib" = xcheck], 40 [dnl Check for headers 41 AC_CHECK_HEADERS([zlib.h]) 42 43 AS_IF( 44 [test "x$ac_cv_header_zlib_h" = xno], 45 [ac_cv_zlib=no], 46 [dnl Check for the individual functions 47 ac_cv_zlib=zlib 48 49 AC_CHECK_LIB( 50 z, 51 zlibVersion, 52 [], 53 [ac_cv_zlib=no]) 54 55 AS_IF( 56 [test "x$ac_cv_lib_z_zlibVersion" = xno], 57 [AC_MSG_FAILURE( 58 [Missing function: zlibVersion in library: zlib.], 59 [1]) 60 ]) 61 62 ac_cv_zlib_LIBADD="-lz"; 63 ]) 64 ]) 65 ]) 66 67 AS_IF( 68 [test "x$ac_cv_zlib" = xzlib], 69 [AC_DEFINE( 70 [HAVE_ZLIB], 71 [1], 72 [Define to 1 if you have the 'zlib' library (-lz).]) 73 ]) 74 75 AS_IF( 76 [test "x$ac_cv_zlib" != xno], 77 [AC_SUBST( 78 [HAVE_ZLIB], 79 [1]) ], 80 [AC_SUBST( 81 [HAVE_ZLIB], 82 [0]) 83 ]) 84 ]) 85 86dnl Function to detect if the adler32 function is available 87AC_DEFUN([AX_ZLIB_CHECK_ADLER32], 88 [AX_COMMON_ARG_WITH( 89 [adler32], 90 [adler32], 91 [specify which alder32 implementation to use, options: 'auto-detect', 'zlib' or 'local'], 92 [auto-detect], 93 [auto-detect]) 94 95 AS_IF( 96 [test "x$ac_cv_zlib" != xzlib], 97 [ac_cv_adler32=local], 98 [AC_CHECK_LIB( 99 z, 100 adler32, 101 [ac_zlib_dummy=yes]) 102 103 AS_IF( 104 [test "x$ac_cv_lib_z_adler32" = xyes], 105 [AS_IF( 106 [test "x$ac_cv_with_adler32" != xzlib && test "x$ac_cv_with_adler32" != xauto-detect], 107 [ac_cv_adler32=local], 108 [AC_DEFINE( 109 [HAVE_ZLIB_ADLER32], 110 [1], 111 [Define to 1 if adler32 funtion is available in zlib.]) 112 ac_cv_adler32=zlib])], 113 [AS_IF( 114 [test "x$ac_cv_with_adler32" = xzlib], 115 [AC_MSG_FAILURE( 116 [Missing function: adler32 in library: zlib.], 117 [1]) 118 ]) 119 ac_cv_adler32=local]) 120 ]) 121 ]) 122 123dnl Function to detect if the compress2 function is available 124AC_DEFUN([AX_ZLIB_CHECK_COMPRESS2], 125 [AS_IF( 126 [test "x$ac_cv_zlib" = xzlib], 127 [AC_CHECK_LIB( 128 z, 129 compress2, 130 [ac_zlib_dummy=yes]) 131 132 AS_IF( 133 [test "x$ac_cv_lib_z_compress2" = xyes], 134 [AC_DEFINE( 135 [HAVE_ZLIB_COMPRESS2], 136 [1], 137 [Define to 1 if compress2 funtion is available in zlib.]) 138 ]) 139 ]) 140 ]) 141 142dnl Function to detect if the compressBound function is available 143AC_DEFUN([AX_ZLIB_CHECK_COMPRESSBOUND], 144 [AS_IF( 145 [test "x$ac_cv_zlib" = xzlib], 146 [AC_CHECK_LIB( 147 z, 148 compressBound, 149 [ac_zlib_dummy=yes]) 150 151 AS_IF( 152 [test "x$ac_cv_lib_z_compressBound" = xyes], 153 [AC_DEFINE( 154 [HAVE_ZLIB_COMPRESSBOUND], 155 [1], 156 [Define to 1 if compressBound funtion is available in zlib.]) 157 ]) 158 ]) 159 ]) 160 161dnl Function to detect if the inflate functions are available 162AC_DEFUN([AX_ZLIB_CHECK_INFLATE], 163 [AS_IF( 164 [test "x$ac_cv_zlib" != xzlib], 165 [ac_cv_inflate=local], 166 [AC_CHECK_LIB( 167 z, 168 inflate, 169 [ac_cv_inflate=zlib], 170 [ac_cv_inflate=local]) 171 172 AC_CHECK_LIB( 173 z, 174 inflateInit2, 175 [ac_zlib_dummy=yes]) 176 177 dnl Some versions of zlib provide inflateInit2_ instead of inflateInit2 178 AS_IF( 179 [test "x$ac_cv_lib_z_inflateinit2" = xno], 180 [AC_CHECK_LIB( 181 z, 182 inflateInit2_, 183 [ac_zlib_dummy=yes], 184 [ac_cv_inflate=local]) 185 ]) 186 187 AC_CHECK_LIB( 188 z, 189 inflateEnd, 190 [ac_zlib_dummy=yes], 191 [ac_cv_inflate=local]) 192 193 AS_IF( 194 [test "x$ac_cv_inflate" = xzlib], 195 [AC_DEFINE( 196 [HAVE_ZLIB_INFLATE], 197 [1], 198 [Define to 1 if you have the `inflateInit', `inflate', `inflateEnd' functions.]) 199 ]) 200 201 AS_IF( 202 [test "x$ac_cv_lib_z_inflateinit2" != xno], 203 [AC_DEFINE( 204 [HAVE_ZLIB_INFLATE_INIT2], 205 [1], 206 [Define to 1 if you have the `inflateInit2' function.]) 207 ]) 208 ]) 209 ]) 210 211dnl Function to detect if the uncompress function is available 212AC_DEFUN([AX_ZLIB_CHECK_UNCOMPRESS], 213 [AS_IF( 214 [test "x$ac_cv_zlib" != xzlib], 215 [ac_cv_uncompress=local], 216 [AC_CHECK_LIB( 217 z, 218 uncompress, 219 [ac_cv_uncompress=zlib], 220 [ac_cv_uncompress=local]) 221 222 AS_IF( 223 [test "x$ac_cv_uncompress" = xzlib], 224 [AC_DEFINE( 225 [HAVE_ZLIB_UNCOMPRESS], 226 [1], 227 [Define to 1 if you have the `uncompress' function.]) 228 ]) 229 ]) 230 ]) 231 232dnl Function to detect if the uncompress2 function is available 233AC_DEFUN([AX_ZLIB_CHECK_UNCOMPRESS2], 234 [AS_IF( 235 [test "x$ac_cv_zlib" != xzlib], 236 [ac_cv_uncompress2=local], 237 [AC_CHECK_LIB( 238 z, 239 uncompress2, 240 [ac_cv_uncompress2=zlib], 241 [ac_cv_uncompress2=local]) 242 243 AS_IF( 244 [test "x$ac_cv_uncompress2" = xzlib], 245 [AC_DEFINE( 246 [HAVE_ZLIB_UNCOMPRESS2], 247 [1], 248 [Define to 1 if you have the `uncompress2' function.]) 249 ]) 250 ]) 251 ]) 252 253dnl Function to detect how to enable zlib 254AC_DEFUN([AX_ZLIB_CHECK_ENABLE], 255 [AX_COMMON_ARG_WITH( 256 [zlib], 257 [zlib], 258 [search for zlib in includedir and libdir or in the specified DIR, or no if not to use zlib], 259 [auto-detect], 260 [DIR]) 261 262 dnl Check for a shared library version 263 AX_ZLIB_CHECK_LIB 264 265 AS_IF( 266 [test "x$ac_cv_zlib_CPPFLAGS" != "x"], 267 [AC_SUBST( 268 [ZLIB_CPPFLAGS], 269 [$ac_cv_zlib_CPPFLAGS]) 270 ]) 271 AS_IF( 272 [test "x$ac_cv_zlib_LIBADD" != "x"], 273 [AC_SUBST( 274 [ZLIB_LIBADD], 275 [$ac_cv_zlib_LIBADD]) 276 ]) 277 278 AS_IF( 279 [test "x$ac_cv_zlib" = xzlib], 280 [AC_SUBST( 281 [ax_zlib_pc_libs_private], 282 [-lz]) 283 ]) 284 285 AS_IF( 286 [test "x$ac_cv_zlib" = xzlib], 287 [AC_SUBST( 288 [ax_zlib_spec_requires], 289 [zlib]) 290 AC_SUBST( 291 [ax_zlib_spec_build_requires], 292 [zlib-devel]) 293 AC_SUBST( 294 [ax_zlib_static_spec_requires], 295 [zlib-static]) 296 AC_SUBST( 297 [ax_zlib_static_spec_build_requires], 298 [zlib-static]) 299 ]) 300 ]) 301 302