1 dnl Process this file with autoconf to produce a configure script.
3 dnl First, define all of the version numbers up front.
4 dnl In particular, this allows the version macro to be used in AC_INIT
6 dnl These first two version numbers are updated automatically on each release.
7 m4_define([LIBARCHIVE_VERSION_S],[3.6.2dev])
8 m4_define([LIBARCHIVE_VERSION_N],[3006002])
10 dnl bsdtar and bsdcpio versioning tracks libarchive
11 m4_define([BSDTAR_VERSION_S],LIBARCHIVE_VERSION_S())
12 m4_define([BSDCPIO_VERSION_S],LIBARCHIVE_VERSION_S())
13 m4_define([BSDCAT_VERSION_S],LIBARCHIVE_VERSION_S())
18 # Now starts the "real" configure script.
21 AC_INIT([libarchive],[LIBARCHIVE_VERSION_S()],[libarchive-discuss@googlegroups.com])
22 # Make sure the srcdir contains "libarchive" directory
23 AC_CONFIG_SRCDIR([libarchive])
24 # Use auxiliary subscripts from this subdirectory (cleans up root)
25 AC_CONFIG_AUX_DIR([build/autoconf])
27 AC_CONFIG_MACRO_DIR([build/autoconf])
28 # Must follow AC_CONFIG macros above...
29 AM_INIT_AUTOMAKE([1.11 dist-xz dist-zip])
30 AM_MAINTAINER_MODE([enable])
31 m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
33 # Libtool's "interface version" can be computed from the libarchive version.
35 # Libtool interface version bumps on any API change, so increments
36 # whenever libarchive minor version does.
37 ARCHIVE_MINOR=$(( (LIBARCHIVE_VERSION_N() / 1000) % 1000 ))
38 # Libarchive 2.7 == libtool interface 9 = 2 + 7
39 # Libarchive 2.8 == libtool interface 10 = 2 + 8
40 # Libarchive 2.9 == libtool interface 11 = 2 + 8
41 # Libarchive 3.0 == libtool interface 12
42 # Libarchive 3.1 == libtool interface 13
43 ARCHIVE_INTERFACE=`echo $((13 + ${ARCHIVE_MINOR}))`
44 # Libarchive revision is bumped on any source change === libtool revision
45 ARCHIVE_REVISION=$(( LIBARCHIVE_VERSION_N() % 1000 ))
46 # Libarchive minor is bumped on any interface addition === libtool age
47 ARCHIVE_LIBTOOL_VERSION=$ARCHIVE_INTERFACE:$ARCHIVE_REVISION:$ARCHIVE_MINOR
49 # Stick the version numbers into config.h
50 AC_DEFINE([__LIBARCHIVE_CONFIG_H_INCLUDED], [1],
51 [Internal macro for sanity checks])
52 AC_DEFINE([LIBARCHIVE_VERSION_STRING],"LIBARCHIVE_VERSION_S()",
53 [Version number of libarchive])
54 AC_DEFINE_UNQUOTED([LIBARCHIVE_VERSION_NUMBER],"LIBARCHIVE_VERSION_N()",
55 [Version number of libarchive as a single integer])
56 AC_DEFINE([BSDCPIO_VERSION_STRING],"BSDCPIO_VERSION_S()",
57 [Version number of bsdcpio])
58 AC_DEFINE([BSDTAR_VERSION_STRING],"BSDTAR_VERSION_S()",
59 [Version number of bsdtar])
60 AC_DEFINE([BSDCAT_VERSION_STRING],"BSDTAR_VERSION_S()",
61 [Version number of bsdcat])
63 # The shell variables here must be the same as the AC_SUBST() variables
64 # below, but the shell variable names apparently cannot be the same as
65 # the m4 macro names above. Why? Ask autoconf.
66 BSDCPIO_VERSION_STRING=BSDCPIO_VERSION_S()
67 BSDTAR_VERSION_STRING=BSDTAR_VERSION_S()
68 BSDCAT_VERSION_STRING=BSDCAT_VERSION_S()
69 LIBARCHIVE_VERSION_STRING=LIBARCHIVE_VERSION_S()
70 LIBARCHIVE_VERSION_NUMBER=LIBARCHIVE_VERSION_N()
72 # Substitute the above version numbers into the various files below.
73 # Yes, I believe this is the fourth time we define what are essentially
74 # the same symbols. Why? Ask autoconf.
75 AC_SUBST(ARCHIVE_LIBTOOL_VERSION)
76 AC_SUBST(BSDCPIO_VERSION_STRING)
77 AC_SUBST(BSDTAR_VERSION_STRING)
78 AC_SUBST(BSDCAT_VERSION_STRING)
79 AC_SUBST(LIBARCHIVE_VERSION_STRING)
80 AC_SUBST(LIBARCHIVE_VERSION_NUMBER)
82 AC_CONFIG_HEADERS([config.h])
83 AC_CONFIG_FILES([Makefile])
84 AC_CONFIG_FILES([build/pkgconfig/libarchive.pc])
89 dnl Compilation on mingw and Cygwin needs special Makefile rules
93 *mingw* ) inc_windows_files=yes ;;
94 *cygwin* | *msys*) inc_cygwin_files=yes ;;
96 AM_CONDITIONAL([INC_WINDOWS_FILES], [test $inc_windows_files = yes])
97 AM_CONDITIONAL([INC_CYGWIN_FILES], [test $inc_cygwin_files = yes])
99 dnl Defines that are required for specific platforms (e.g. -D_POSIX_SOURCE, etc)
102 *mingw* ) PLATFORMCPPFLAGS=-D__USE_MINGW_ANSI_STDIO ;;
104 AC_SUBST(PLATFORMCPPFLAGS)
106 # Checks for programs.
111 AC_USE_SYSTEM_EXTENSIONS
114 AC_CHECK_TOOL([STRIP],[strip])
118 # Options for building bsdtar.
120 # Default is to build bsdtar, but allow people to override that.
122 AC_ARG_ENABLE([bsdtar],
123 [AS_HELP_STRING([--enable-bsdtar], [enable build of bsdtar (default)])
124 AS_HELP_STRING([--enable-bsdtar=static], [force static build of bsdtar])
125 AS_HELP_STRING([--enable-bsdtar=shared], [force dynamic build of bsdtar])
126 AS_HELP_STRING([--disable-bsdtar], [disable build of bsdtar])],
127 [], [enable_bsdtar=yes])
129 case "$enable_bsdtar" in
131 if test "$enable_static" = "no"; then
139 if test "$enable_shared" = "no"; then
140 AC_MSG_FAILURE([Shared linking of bsdtar requires shared libarchive])
154 AC_MSG_FAILURE([Unsupported value for --enable-bsdtar])
158 AM_CONDITIONAL([BUILD_BSDTAR], [ test "$build_bsdtar" = yes ])
159 AM_CONDITIONAL([STATIC_BSDTAR], [ test "$static_bsdtar" = yes ])
162 # Options for building bsdcat.
164 # Default is to build bsdcat, but allow people to override that.
166 AC_ARG_ENABLE([bsdcat],
167 [AS_HELP_STRING([--enable-bsdcat], [enable build of bsdcat (default)])
168 AS_HELP_STRING([--enable-bsdcat=static], [force static build of bsdcat])
169 AS_HELP_STRING([--enable-bsdcat=shared], [force dynamic build of bsdcat])
170 AS_HELP_STRING([--disable-bsdcat], [disable build of bsdcat])],
171 [], [enable_bsdcat=yes])
173 case "$enable_bsdcat" in
175 if test "$enable_static" = "no"; then
183 if test "$enable_shared" = "no"; then
184 AC_MSG_FAILURE([Shared linking of bsdcat requires shared libarchive])
198 AC_MSG_FAILURE([Unsupported value for --enable-bsdcat])
202 AM_CONDITIONAL([BUILD_BSDCAT], [ test "$build_bsdcat" = yes ])
203 AM_CONDITIONAL([STATIC_BSDCAT], [ test "$static_bsdcat" = yes ])
206 # Options for building bsdcpio.
208 # Default is not to build bsdcpio, but that can be overridden.
210 AC_ARG_ENABLE([bsdcpio],
211 [AS_HELP_STRING([--enable-bsdcpio], [enable build of bsdcpio (default)])
212 AS_HELP_STRING([--enable-bsdcpio=static], [static build of bsdcpio])
213 AS_HELP_STRING([--enable-bsdcpio=shared], [dynamic build of bsdcpio])
214 AS_HELP_STRING([--disable-bsdcpio], [disable build of bsdcpio])],
215 [], [enable_bsdcpio=yes])
217 case "$enable_bsdcpio" in
219 if test "$enable_static" = "no"; then
227 if test "$enabled_shared" = "no"; then
228 AC_MSG_FAILURE([Shared linking of bsdcpio requires shared libarchive])
241 AC_MSG_FAILURE([Unsupported value for --enable-bsdcpio])
245 AM_CONDITIONAL([BUILD_BSDCPIO], [ test "$build_bsdcpio" = yes ])
246 AM_CONDITIONAL([STATIC_BSDCPIO], [ test "$static_bsdcpio" = yes ])
248 # Set up defines needed before including any headers
250 *mingw* | *cygwin* | *msys* )
251 AC_PREPROC_IFELSE([AC_LANG_PROGRAM(
252 [[#ifdef _WIN32_WINNT
253 # error _WIN32_WINNT already defined
257 AC_DEFINE([_WIN32_WINNT], 0x0502, [Define to '0x0502' for Windows Server 2003 APIs.])
258 AC_DEFINE([NTDDI_VERSION], 0x05020000, [Define to '0x05020000' for Windows Server 2003 APIs.])
260 AC_PREPROC_IFELSE([AC_LANG_PROGRAM(
262 # error WINVER already defined
266 AC_DEFINE([WINVER], 0x0502, [Define to '0x0502' for Windows Server 2003 APIs.])
271 # Checks for header files.
274 AC_CHECK_HEADERS([acl/libacl.h attr/xattr.h])
275 AC_CHECK_HEADERS([copyfile.h ctype.h])
276 AC_CHECK_HEADERS([errno.h ext2fs/ext2_fs.h fcntl.h grp.h])
278 AC_CACHE_CHECK([whether EXT2_IOC_GETFLAGS is usable],
279 [ac_cv_have_decl_EXT2_IOC_GETFLAGS],
280 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([@%:@include <sys/ioctl.h>
281 @%:@include <ext2fs/ext2_fs.h>],
282 [int x = EXT2_IOC_GETFLAGS])],
283 [AS_VAR_SET([ac_cv_have_decl_EXT2_IOC_GETFLAGS], [yes])],
284 [AS_VAR_SET([ac_cv_have_decl_EXT2_IOC_GETFLAGS], [no])])])
286 AS_VAR_IF([ac_cv_have_decl_EXT2_IOC_GETFLAGS], [yes],
287 [AC_DEFINE_UNQUOTED([HAVE_WORKING_EXT2_IOC_GETFLAGS], [1],
288 [Define to 1 if you have a working EXT2_IOC_GETFLAGS])])
290 AC_CHECK_HEADERS([inttypes.h io.h langinfo.h limits.h])
291 AC_CHECK_HEADERS([linux/fiemap.h linux/fs.h linux/magic.h linux/types.h])
293 AC_CACHE_CHECK([whether FS_IOC_GETFLAGS is usable],
294 [ac_cv_have_decl_FS_IOC_GETFLAGS],
295 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([@%:@include <sys/ioctl.h>
296 @%:@include <linux/fs.h>],
297 [int x = FS_IOC_GETFLAGS])],
298 [AS_VAR_SET([ac_cv_have_decl_FS_IOC_GETFLAGS], [yes])],
299 [AS_VAR_SET([ac_cv_have_decl_FS_IOC_GETFLAGS], [no])])])
301 AS_VAR_IF([ac_cv_have_decl_FS_IOC_GETFLAGS], [yes],
302 [AC_DEFINE_UNQUOTED([HAVE_WORKING_FS_IOC_GETFLAGS], [1],
303 [Define to 1 if you have a working FS_IOC_GETFLAGS])])
305 AC_CHECK_HEADERS([locale.h membership.h paths.h poll.h pthread.h pwd.h])
306 AC_CHECK_HEADERS([readpassphrase.h signal.h spawn.h])
307 AC_CHECK_HEADERS([stdarg.h stdint.h stdlib.h string.h])
308 AC_CHECK_HEADERS([sys/acl.h sys/cdefs.h sys/ea.h sys/extattr.h])
309 AC_CHECK_HEADERS([sys/ioctl.h sys/mkdev.h sys/mount.h])
310 AC_CHECK_HEADERS([sys/param.h sys/poll.h sys/richacl.h])
311 AC_CHECK_HEADERS([sys/select.h sys/statfs.h sys/statvfs.h sys/sysmacros.h])
312 AC_CHECK_HEADERS([sys/time.h sys/utime.h sys/utsname.h sys/vfs.h sys/xattr.h])
313 AC_CHECK_HEADERS([time.h unistd.h utime.h wchar.h wctype.h])
314 AC_CHECK_HEADERS([windows.h])
315 # check windows.h first; the other headers require it.
316 AC_CHECK_HEADERS([wincrypt.h winioctl.h],[],[],
317 [[#ifdef HAVE_WINDOWS_H
318 # include <windows.h>
322 # Checks for libraries.
324 AS_HELP_STRING([--without-zlib], [Don't build support for gzip through zlib]))
326 if test "x$with_zlib" != "xno"; then
327 AC_CHECK_HEADERS([zlib.h])
328 AC_CHECK_LIB(z,inflate)
331 AC_ARG_WITH([bz2lib],
332 AS_HELP_STRING([--without-bz2lib], [Don't build support for bzip2 through bz2lib]))
334 if test "x$with_bz2lib" != "xno"; then
335 AC_CHECK_HEADERS([bzlib.h])
337 *mingw* | *cygwin* | *msys*)
338 dnl AC_CHECK_LIB cannot be used on the Windows port of libbz2, therefore
339 dnl use AC_LINK_IFELSE.
340 AC_MSG_CHECKING([for BZ2_bzDecompressInit in -lbz2])
344 [AC_LANG_SOURCE(#include <bzlib.h>
345 int main() { return BZ2_bzDecompressInit(NULL, 0, 0); })],
346 [ac_cv_lib_bz2_BZ2_bzDecompressInit=yes],
347 [ac_cv_lib_bz2_BZ2_bzDecompressInit=no])
349 AC_MSG_RESULT($ac_cv_lib_bz2_BZ2_bzDecompressInit)
350 if test "x$ac_cv_lib_bz2_BZ2_bzDecompressInit" = xyes; then
351 AC_DEFINE([HAVE_LIBBZ2], [1], [Define to 1 if you have the `bz2' library (-lbz2).])
356 AC_CHECK_LIB(bz2,BZ2_bzDecompressInit)
362 AS_HELP_STRING([--without-libb2], [Don't build support for BLAKE2 through libb2]))
364 if test "x$with_libb2" != "xno"; then
365 AC_CHECK_HEADERS([blake2.h])
366 AC_CHECK_LIB(b2,blake2sp_init)
369 AM_CONDITIONAL([INC_BLAKE2], [test "x$ac_cv_lib_b2_blake2sp_init" != "xyes"])
372 AS_HELP_STRING([--without-iconv], [Don't try to link against iconv]))
374 if test "x$with_iconv" != "xno"; then
376 AC_CHECK_HEADERS([iconv.h],[],[],[#include <stdlib.h>])
377 if test "x$am_cv_func_iconv" = "xyes"; then
378 AC_CHECK_HEADERS([localcharset.h])
380 LIBS="${LIBS} ${LIBICONV}"
381 LIBSREQUIRED="$LIBSREQUIRED${LIBSREQUIRED:+ }iconv"
382 AC_CHECK_FUNCS([locale_charset])
383 LIBS="${am_save_LIBS}"
384 if test "x$ac_cv_func_locale_charset" != "xyes"; then
385 # If locale_charset() is not in libiconv, we have to find libcharset.
386 AC_CHECK_LIB(charset,locale_charset)
392 AS_HELP_STRING([--without-lz4], [Don't build support for lz4 through liblz4]))
394 if test "x$with_lz4" != "xno"; then
395 AC_CHECK_HEADERS([lz4.h lz4hc.h])
396 AC_CHECK_LIB(lz4,LZ4_decompress_safe)
400 AS_HELP_STRING([--without-zstd], [Don't build support for zstd through libzstd]))
402 if test "x$with_zstd" != "xno"; then
403 AC_CHECK_HEADERS([zstd.h])
404 AC_CHECK_LIB(zstd,ZSTD_decompressStream)
405 AC_CHECK_LIB(zstd,ZSTD_compressStream,
406 AC_DEFINE([HAVE_LIBZSTD_COMPRESSOR], [1], [Define to 1 if you have the `zstd' library (-lzstd) with compression support.]))
410 AS_HELP_STRING([--without-lzma], [Don't build support for xz through lzma]))
412 if test "x$with_lzma" != "xno"; then
413 AC_CHECK_HEADERS([lzma.h])
414 AC_CHECK_LIB(lzma,lzma_stream_decoder)
415 # Some pre-release (but widely distributed) versions of liblzma
416 # included a disabled version of lzma_stream_encoder_mt that
417 # fools a naive AC_CHECK_LIB or AC_CHECK_FUNC, so we need
418 # to do something more complex here:
420 [whether we have multithread support in lzma],
423 AC_LANG_PROGRAM([[#include <lzma.h>]
424 [#if LZMA_VERSION < 50020000]
427 [[lzma_stream_encoder_mt(0, 0);]])],
428 [ac_cv_lzma_has_mt=yes], [ac_cv_lzma_has_mt=no])])
429 if test "x$ac_cv_lzma_has_mt" != xno; then
430 AC_DEFINE([HAVE_LZMA_STREAM_ENCODER_MT], [1], [Define to 1 if you have the `lzma_stream_encoder_mt' function.])
435 AS_HELP_STRING([--with-lzo2], [Build with LZO support from liblzo2]))
437 if test "x$with_lzo2" = "xyes"; then
438 AC_CHECK_HEADERS([lzo/lzoconf.h lzo/lzo1x.h])
439 AC_CHECK_LIB(lzo2,lzo1x_decompress_safe)
443 AS_HELP_STRING([--without-cng], [Don't build support of CNG(Crypto Next Generation)]))
445 AC_ARG_WITH([mbedtls],
446 AS_HELP_STRING([--with-mbedtls], [Build with crypto support from mbed TLS]))
447 AC_ARG_WITH([nettle],
448 AS_HELP_STRING([--with-nettle], [Build with crypto support from Nettle]))
449 AC_ARG_WITH([openssl],
450 AS_HELP_STRING([--without-openssl], [Don't build support for mtree and xar hashes through openssl]))
452 *darwin* ) with_openssl=no ;;
456 AS_HELP_STRING([--without-xml2], [Don't build support for xar through libxml2]))
458 AS_HELP_STRING([--without-expat], [Don't build support for xar through expat]))
460 if test "x$with_xml2" != "xno"; then
462 PKG_CHECK_MODULES(LIBXML2_PC, [libxml-2.0], [
463 CPPFLAGS="${CPPFLAGS} ${LIBXML2_PC_CFLAGS}"
464 LIBS="${LIBS} ${LIBXML2_PC_LIBS}"
465 AC_CHECK_LIB(xml2,xmlInitParser,[true],AC_MSG_FAILURE(Missing xml2 library))
467 AC_CHECK_LIB(xml2,xmlInitParser)
469 AC_CHECK_HEADERS([libxml/xmlreader.h libxml/xmlwriter.h])
471 if test "x$ac_cv_header_libxml_xmlreader_h" != "xyes"; then
472 if test "x$with_expat" != "xno"; then
473 AC_CHECK_HEADERS([expat.h])
474 AC_CHECK_LIB(expat,XML_ParserCreate)
478 AC_ARG_ENABLE([posix-regex-lib],
479 [AS_HELP_STRING([--enable-posix-regex-lib],
480 [choose what library to use for POSIX regular expression support (default: auto)])
481 AS_HELP_STRING([--enable-posix-regex-lib=libc], [use libc POSIX regular expression support])
482 AS_HELP_STRING([--enable-posix-regex-lib=libregex], [use libregex POSIX regular expression support])
483 AS_HELP_STRING([--enable-posix-regex-lib=libpcreposix], [use libpcreposix POSIX regular expression support])
484 AS_HELP_STRING([--disable-posix-regex-lib], [don't enable POSIX regular expression support])],
485 [], [enable_posix_regex_lib=auto])
487 posix_regex_lib_found=
488 if test "$enable_posix_regex_lib" = "auto" || test "$enable_posix_regex_lib" = "libc" || test "$enable_posix_regex_lib" = "libregex"; then
489 AC_CHECK_HEADERS([regex.h])
490 if test "x$ac_cv_header_regex_h" != "xno"; then
491 AC_CHECK_FUNC(regcomp)
492 if test "x$ac_cv_func_regcomp" = xyes; then
493 posix_regex_lib_found=1
495 AC_CHECK_LIB(regex,regcomp)
496 if test "x$ac_cv_lib_regex_regcomp" = xyes; then
497 posix_regex_lib_found=1
502 if test -z $posix_regex_lib_found && (test "$enable_posix_regex_lib" = "auto" || test "$enable_posix_regex_lib" = "libpcreposix"); then
503 AC_CHECK_HEADERS([pcreposix.h])
504 AC_CHECK_LIB(pcreposix,regcomp)
505 if test "x$ac_cv_lib_pcreposix_regcomp" != xyes; then
506 AC_MSG_NOTICE(trying libpcreposix check again with libpcre)
507 unset ac_cv_lib_pcreposix_regcomp
508 AC_CHECK_LIB(pcre,pcre_exec)
509 AC_CHECK_LIB(pcreposix,regcomp)
510 if test "x$ac_cv_lib_pcre_pcre_exec" = xyes && test "x$ac_cv_lib_pcreposix_regcomp" = xyes; then
511 AC_MSG_CHECKING(if PCRE_STATIC needs to be defined)
513 [AC_LANG_SOURCE(#include <pcreposix.h>
514 int main() { return regcomp(NULL, NULL, 0); })],
515 [without_pcre_static=yes],
516 [without_pcre_static=no])
518 [AC_LANG_SOURCE(#define PCRE_STATIC
519 #include <pcreposix.h>
520 int main() { return regcomp(NULL, NULL, 0); })],
521 [with_pcre_static=yes],
522 [with_pcre_static=no])
523 if test "x$without_pcre_static" != xyes && test "x$with_pcre_static" = xyes; then
525 AC_DEFINE([PCRE_STATIC], [1], [Define to 1 if PCRE_STATIC needs to be defined.])
526 elif test "x$without_pcre_static" = xyes || test "x$with_pcre_static" = xyes; then
529 posix_regex_lib_found=1
532 posix_regex_lib_found=1
536 # TODO: Give the user the option of using a pre-existing system
537 # libarchive. This will define HAVE_LIBARCHIVE which will cause
538 # bsdtar_platform.h to use #include <...> for the libarchive headers.
539 # Need to include Makefile.am magic to link against system
540 # -larchive in that case.
541 #AC_CHECK_LIB(archive,archive_version)
543 # Checks for supported compiler flags
544 AX_APPEND_COMPILE_FLAGS([-Wall -Wformat -Wformat-security])
546 # Place the functions and data into separate sections, allowing the linker
547 # to garbage collect the unused ones.
548 save_LDFLAGS=$LDFLAGS
549 LDFLAGS="$LDFLAGS -Wl,--gc-sections"
550 AC_MSG_CHECKING([whether ld supports --gc-sections])
552 [AC_LANG_SOURCE([static char UnusedFunc() { return 5; } int main() { return 0;}])],
553 [AC_MSG_RESULT([yes])
554 GC_SECTIONS="-Wl,--gc-sections";
555 AX_APPEND_COMPILE_FLAGS([-ffunction-sections -fdata-sections])],
558 LDFLAGS=$save_LDFLAGS
560 AC_SUBST(GC_SECTIONS)
562 # Checks for typedefs, structures, and compiler characteristics.
564 # la_TYPE_UID_T defaults to "int", which is incorrect for MinGW
565 # and MSVC. Use a customized version.
568 # AC_TYPE_OFF_T defaults to "long", which limits us to 4GB files on
569 # most systems... default to "long long" instead.
570 AC_CHECK_TYPE(off_t, [long long])
572 AC_CHECK_TYPE(id_t, [unsigned long])
573 AC_CHECK_TYPE(uintptr_t, [unsigned int])
575 # Check for tm_gmtoff in struct tm
576 AC_CHECK_MEMBERS([struct tm.tm_gmtoff, struct tm.__tm_gmtoff],,,
581 # Check for f_namemax in struct statfs
582 AC_CHECK_MEMBERS([struct statfs.f_namemax],,,
584 #include <sys/param.h>
585 #include <sys/mount.h>
588 # Check for f_iosize in struct statfs
589 AC_CHECK_MEMBERS([struct statfs.f_iosize],,,
591 #include <sys/param.h>
592 #include <sys/mount.h>
595 # Check for f_iosize in struct statvfs
596 AC_CHECK_MEMBERS([struct statvfs.f_iosize],,,
598 #include <sys/statvfs.h>
601 # Check for birthtime in struct stat
602 AC_CHECK_MEMBERS([struct stat.st_birthtime])
604 # Check for high-resolution timestamps in struct stat
605 AC_CHECK_MEMBERS([struct stat.st_birthtimespec.tv_nsec])
606 AC_CHECK_MEMBERS([struct stat.st_mtimespec.tv_nsec])
607 AC_CHECK_MEMBERS([struct stat.st_mtim.tv_nsec])
608 AC_CHECK_MEMBERS([struct stat.st_mtime_n]) # AIX
609 AC_CHECK_MEMBERS([struct stat.st_umtime]) # Tru64
610 AC_CHECK_MEMBERS([struct stat.st_mtime_usec]) # Hurd
611 # Check for block size support in struct stat
612 AC_CHECK_MEMBERS([struct stat.st_blksize])
613 # Check for st_flags in struct stat (BSD fflags)
614 AC_CHECK_MEMBERS([struct stat.st_flags])
616 # If you have uintmax_t, we assume printf supports %ju
617 # If you have unsigned long long, we assume printf supports %llu
618 # TODO: Check for %ju and %llu support directly.
619 AC_CHECK_TYPES([uintmax_t, unsigned long long])
621 # We use C99-style integer types
622 # Declare them if the local platform doesn't already do so.
633 AC_CHECK_DECLS([SIZE_MAX, INT32_MAX, INT32_MIN])
634 AC_CHECK_DECLS([INT64_MAX, INT64_MIN, UINT64_MAX, UINT32_MAX])
635 AC_CHECK_DECLS([INTMAX_MAX, INTMAX_MIN, UINTMAX_MAX])
637 AC_CHECK_DECL([SSIZE_MAX],
638 [AC_DEFINE(HAVE_DECL_SSIZE_MAX, 1, [Define to 1 if you have the declaration of `SSIZE_MAX', and to 0 if you don't.])],
640 [#include <limits.h>])
642 AC_CHECK_DECL([EFTYPE],
643 [AC_DEFINE(HAVE_EFTYPE, 1, [A possible errno value for invalid file format errors])],
645 [#include <errno.h>])
646 AC_CHECK_DECL([EILSEQ],
647 [AC_DEFINE(HAVE_EILSEQ, 1, [A possible errno value for invalid file format errors])],
649 [#include <errno.h>])
650 AC_CHECK_TYPE([wchar_t],
651 [AC_DEFINE_UNQUOTED(AS_TR_CPP(HAVE_[]wchar_t), 1, [Define to 1 if the system has the type `wchar_t'.])dnl
652 AC_CHECK_SIZEOF([wchar_t])],
655 AX_COMPILE_CHECK_SIZEOF(int)
656 AX_COMPILE_CHECK_SIZEOF(long)
660 # Checks for library functions.
661 AC_PROG_GCC_TRADITIONAL
671 # CreateHardLinkA(LPCSTR, LPCSTR, LPSECURITY_ATTRIBUTES)
672 # To avoid necessity for including windows.h or special forward declaration
673 # workarounds, we use 'void *' for 'struct SECURITY_ATTRIBUTES *'
674 AC_CHECK_STDCALL_FUNC([CreateHardLinkA],[const char *, const char *, void *])
675 AC_CHECK_FUNCS([arc4random_buf chflags chown chroot ctime_r])
676 AC_CHECK_FUNCS([fchdir fchflags fchmod fchown fcntl fdopendir fork])
677 AC_CHECK_FUNCS([fstat fstatat fstatfs fstatvfs ftruncate])
678 AC_CHECK_FUNCS([futimens futimes futimesat])
679 AC_CHECK_FUNCS([geteuid getpid getgrgid_r getgrnam_r])
680 AC_CHECK_FUNCS([getpwnam_r getpwuid_r getvfsbyname gmtime_r])
681 AC_CHECK_FUNCS([lchflags lchmod lchown link linkat localtime_r lstat lutimes])
682 AC_CHECK_FUNCS([mbrtowc memmove memset])
683 AC_CHECK_FUNCS([mkdir mkfifo mknod mkstemp])
684 AC_CHECK_FUNCS([nl_langinfo openat pipe poll posix_spawnp readlink readlinkat])
685 AC_CHECK_FUNCS([readpassphrase])
686 AC_CHECK_FUNCS([select setenv setlocale sigaction statfs statvfs])
687 AC_CHECK_FUNCS([strchr strdup strerror strncpy_s strnlen strrchr symlink])
688 AC_CHECK_FUNCS([timegm tzset unlinkat unsetenv utime utimensat utimes vfork])
689 AC_CHECK_FUNCS([wcrtomb wcscmp wcscpy wcslen wctomb wmemcmp wmemcpy wmemmove])
690 AC_CHECK_FUNCS([_ctime64_s _fseeki64])
691 AC_CHECK_FUNCS([_get_timezone _gmtime64_s _localtime64_s _mkgmtime64])
692 # detects cygwin-1.7, as opposed to older versions
693 AC_CHECK_FUNCS([cygwin_conv_path])
695 # DragonFly uses vfsconf, FreeBSD xvfsconf.
696 AC_CHECK_TYPES(struct vfsconf,,,
697 [#if HAVE_SYS_TYPES_H
698 #include <sys/types.h>
700 #include <sys/mount.h>
703 AC_CHECK_TYPES(struct xvfsconf,,,
704 [#if HAVE_SYS_TYPES_H
705 #include <sys/types.h>
707 #include <sys/mount.h>
710 AC_CHECK_TYPES(struct statfs,,,
711 [#if HAVE_SYS_TYPES_H
712 #include <sys/types.h>
714 #include <sys/mount.h>
717 # There are several variants of readdir_r around; we only
718 # accept the POSIX-compliant version.
720 [AC_LANG_PROGRAM([[#include <dirent.h>]],
721 [[DIR *dir; struct dirent e, *r;
722 return(readdir_r(dir, &e, &r));]])],
723 [AC_DEFINE(HAVE_READDIR_R,1,[Define to 1 if you have a POSIX compatible readdir_r])]
725 # dirfd can be either a function or a macro.
727 [AC_LANG_PROGRAM([[#include <dirent.h>
729 [[return(dirfd(dir));]])],
730 [AC_DEFINE(HAVE_DIRFD,1,[Define to 1 if you have a dirfd function or macro])]
733 # FreeBSD's nl_langinfo supports an option to specify whether the
734 # current locale uses month/day or day/month ordering. It makes the
735 # output a little prettier...
736 AC_CHECK_DECL([D_MD_ORDER],
737 [AC_DEFINE(HAVE_D_MD_ORDER, 1, [Define to 1 if nl_langinfo supports D_MD_ORDER])],
740 #include <langinfo.h>
744 # Check for dirent.d_namlen field explicitly
745 # (This is a bit more straightforward than, if not quite as portable as,
746 # the recipe given by the autoconf maintainers.)
747 AC_CHECK_MEMBER(struct dirent.d_namlen,,,
753 # Check for Extended Attributes support
754 AC_ARG_ENABLE([xattr],
755 AS_HELP_STRING([--disable-xattr],
756 [Disable Extended Attributes support (default: check)]))
758 if test "x$enable_xattr" != "xno"; then
759 AC_SEARCH_LIBS([setxattr], [attr gnu])
760 AC_CHECK_DECLS([EXTATTR_NAMESPACE_USER], [], [], [#include <sys/types.h>
761 #include <sys/extattr.h>
763 AC_CHECK_DECLS([XATTR_NOFOLLOW], [], [], [#include <sys/xattr.h>
765 if test "x$ac_cv_header_sys_xattr_h" = "xyes" \
766 -a "x$ac_cv_have_decl_XATTR_NOFOLLOW" = "xyes"; then
767 # Darwin extended attributes support
768 AC_CACHE_VAL([ac_cv_archive_xattr_darwin],
769 [AC_CHECK_FUNCS(fgetxattr \
775 [ac_cv_archive_xattr_darwin=yes],
776 [ac_cv_archive_xattr_darwin=no],
777 [#include <sys/xattr.h>
781 elif test "x$ac_cv_header_sys_extattr_h" = "xyes" \
782 -a "x$ac_cv_have_decl_EXTATTR_NAMESPACE_USER" = "xyes"; then
783 # FreeBSD extended attributes support
784 AC_CACHE_VAL([ac_cv_archive_xattr_freebsd],
785 [AC_CHECK_FUNCS(extattr_get_fd \
793 [ac_cv_archive_xattr_freebsd=yes],
794 [ac_cv_archive_xattr_freebsd=no],
795 [#include <sys/types.h>
796 #include <sys/extattr.h>
800 elif test "x$ac_cv_header_sys_xattr_h" = "xyes" \
801 -o "x$ac_cv_header_attr_xattr_h" = "xyes"; then
802 # Linux extended attributes support
803 AC_CACHE_VAL([ac_cv_archive_xattr_linux],
804 [AC_CHECK_FUNCS(fgetxattr \
812 [ac_cv_archive_xattr_linux=yes],
813 [ac_cv_archive_xattr_linux=no],
814 [#if HAVE_SYS_TYPES_H
815 #include <sys/types.h>
818 #include <sys/xattr.h>
820 #if HAVE_ATTR_XATTR_H
821 #include <attr/xatr.h>
826 elif test "x$ac_cv_header_sys_ea_h" = "xyes"; then
827 # AIX extended attributes support
828 AC_CACHE_VAL([ac_cv_archive_xattr_aix],
829 [AC_CHECK_FUNCS(fgetea \
837 [ac_cv_archive_xattr_aix=yes],
838 [ac_cv_archive_xattr_aix=no],
845 AC_MSG_CHECKING([for extended attributes support])
846 if test "x$ac_cv_archive_xattr_linux" = "xyes"; then
847 AC_DEFINE([ARCHIVE_XATTR_LINUX], [1], [Linux xattr support])
848 AC_MSG_RESULT([Linux])
849 elif test "x$ac_cv_archive_xattr_darwin" = "xyes"; then
850 AC_DEFINE([ARCHIVE_XATTR_DARWIN], [1], [Darwin xattr support])
851 AC_MSG_RESULT([Darwin])
852 elif test "x$ac_cv_archive_xattr_freebsd" = "xyes"; then
853 AC_DEFINE([ARCHIVE_XATTR_FREEBSD], [1], [FreeBSD xattr support])
854 AC_MSG_RESULT([FreeBSD])
855 elif test "x$ac_cv_archive_xattr_aix" = "xyes"; then
856 AC_DEFINE([ARCHIVE_XATTR_AIX], [1], [AIX xattr support])
859 AC_MSG_RESULT([none])
863 # Check for ACL support
865 # The ACL support in libarchive is written against the POSIX1e draft,
866 # which was never officially approved and varies quite a bit across
867 # platforms. Worse, some systems have completely non-POSIX acl functions,
868 # which makes the following checks rather more complex than I would like.
871 AS_HELP_STRING([--disable-acl],
872 [Disable ACL support (default: check)]))
874 if test "x$enable_acl" != "xno"; then
876 AC_CHECK_LIB([acl], [acl_get_file])
878 AC_CHECK_TYPES([acl_t, acl_entry_t, acl_permset_t, acl_tag_t], [], [], [
880 #include <sys/types.h>
887 AC_CHECK_LIB([richacl], [richacl_get_file])
889 AC_CHECK_TYPES([[struct richace], [struct richacl]], [], [], [
890 #if HAVE_SYS_RICHACL_H
891 #include <sys/richacl.h>
895 # Solaris and derivates ACLs
896 AC_CHECK_FUNCS(acl facl)
898 if test "x$ac_cv_lib_richacl_richacl_get_file" = "xyes" \
899 -a "x$ac_cv_type_struct_richace" = "xyes" \
900 -a "x$ac_cv_type_struct_richacl" = "xyes"; then
901 AC_CACHE_VAL([ac_cv_archive_acl_librichacl],
902 [AC_CHECK_FUNCS(richacl_alloc \
909 [ac_cv_archive_acl_librichacl=yes], [ac_cv_archive_acl_librichacl=no], [#include <sys/richacl.h>])])
912 if test "x$ac_cv_func_acl" = "xyes" \
913 -a "x$ac_cv_func_facl" = "xyes"; then
914 AC_CHECK_TYPES([aclent_t], [], [], [[#include <sys/acl.h>]])
915 if test "x$ac_cv_type_aclent_t" = "xyes"; then
916 AC_CACHE_VAL([ac_cv_archive_acl_sunos],
917 [AC_CHECK_DECLS([GETACL, SETACL, GETACLCNT],
918 [ac_cv_archive_acl_sunos=yes], [ac_cv_archive_acl_sunos=no],
919 [#include <sys/acl.h>])])
920 AC_CHECK_TYPES([ace_t], [], [], [[#include <sys/acl.h>]])
921 if test "x$ac_cv_type_ace_t" = "xyes"; then
922 AC_CACHE_VAL([ac_cv_archive_acl_sunos_nfs4],
923 [AC_CHECK_DECLS([ACE_GETACL, ACE_SETACL, ACE_GETACLCNT],
924 [ac_cv_archive_acl_sunos_nfs4=yes],
925 [ac_cv_archive_acl_sonos_nfs4=no],
926 [#include <sys/acl.h>])])
929 elif test "x$ac_cv_type_acl_t" = "xyes" \
930 -a "x$ac_cv_type_acl_entry_t" = "xyes" \
931 -a "x$ac_cv_type_acl_permset_t" = "xyes" \
932 -a "x$ac_cv_type_acl_tag_t" = "xyes"; then
933 # POSIX.1e ACL functions
934 AC_CACHE_VAL([ac_cv_posix_acl_funcs],
935 [AC_CHECK_FUNCS(acl_add_perm \
938 acl_delete_def_file \
951 [ac_cv_posix_acl_funcs=yes], [ac_cv_posix_acl_funcs=no],
952 [#if HAVE_SYS_TYPES_H
953 #include <sys/types.h>
961 AC_CHECK_FUNCS(acl_get_perm)
963 if test "x$ac_cv_posix_acl_funcs" = "xyes" \
964 -a "x$ac_cv_header_acl_libacl_h" = "xyes" \
965 -a "x$ac_cv_lib_acl_acl_get_file" = "xyes" \
966 -a "x$ac_cv_func_acl_get_perm"; then
967 AC_CACHE_VAL([ac_cv_archive_acl_libacl],
968 [ac_cv_archive_acl_libacl=yes])
969 AC_DEFINE([ARCHIVE_ACL_LIBACL], [1],
970 [POSIX.1e ACL support via libacl])
973 AC_CHECK_FUNCS(acl_add_flag_np \
976 acl_get_entry_type_np \
983 acl_set_entry_type_np \
986 [#include <sys/types.h>
987 #include <sys/acl.h>])
989 AC_CHECK_FUNCS(mbr_uid_to_uuid \
992 [#include <membership.h>])
994 AC_CHECK_DECLS([ACL_TYPE_EXTENDED, ACL_TYPE_NFS4, ACL_USER,
995 ACL_SYNCHRONIZE], [], [],
996 [#include <sys/types.h>
997 #include <sys/acl.h>])
998 if test "x$ac_cv_posix_acl_funcs" = "xyes" \
999 -a "x$ac_cv_func_acl_get_fd_np" = "xyes" \
1000 -a "x$ac_cv_func_acl_get_perm" != "xyes" \
1001 -a "x$ac_cv_func_acl_get_perm_np" = "xyes" \
1002 -a "x$ac_cv_func_acl_set_fd_np" = "xyes"; then
1003 if test "x$ac_cv_have_decl_ACL_USER" = "xyes"; then
1004 AC_CACHE_VAL([ac_cv_archive_acl_freebsd],
1005 [ac_cv_archive_acl_freebsd=yes])
1006 if test "x$ac_cv_have_decl_ACL_TYPE_NFS4" = "xyes" \
1007 -a "x$ac_cv_func_acl_add_flag_np" = "xyes" \
1008 -a "x$ac_cv_func_acl_get_brand_np" = "xyes" \
1009 -a "x$ac_cv_func_acl_get_entry_type_np" = "xyes" \
1010 -a "x$ac_cv_func_acl_get_flagset_np" = "xyes" \
1011 -a "x$ac_cv_func_acl_set_entry_type_np" = "xyes"; then
1012 AC_CACHE_VAL([ac_cv_archive_acl_freebsd_nfs4],
1013 [ac_cv_archive_acl_freebsd_nfs4=yes])
1015 elif test "x$ac_cv_have_decl_ACL_TYPE_EXTENDED" = "xyes" \
1016 -a "x$ac_cv_func_acl_add_flag_np" = "xyes" \
1017 -a "x$ac_cv_func_acl_get_flagset_np" = "xyes" \
1018 -a "x$ac_cv_func_acl_get_link_np" = "xyes" \
1019 -a "x$ac_cv_func_acl_set_link_np" = "xyes" \
1020 -a "x$ac_cv_func_mbr_uid_to_uuid" = "xyes" \
1021 -a "x$ac_cv_func_mbr_uuid_to_id" = "xyes" \
1022 -a "x$ac_cv_func_mbr_gid_to_uuid" = "xyes"; then
1023 AC_CACHE_VAL([ac_cv_archive_acl_darwin],
1024 [ac_cv_archive_acl_darwin=yes])
1029 AC_MSG_CHECKING([for ACL support])
1030 if test "x$ac_cv_archive_acl_libacl" = "xyes" \
1031 -a "x$ac_cv_archive_acl_librichacl" = "xyes"; then
1032 AC_MSG_RESULT([libacl (POSIX.1e) + librichacl (NFSv4)])
1033 AC_DEFINE([ARCHIVE_ACL_LIBACL], [1],
1034 [Linux POSIX.1e ACL support via libacl])
1035 AC_DEFINE([ARCHIVE_ACL_LIBRICHACL], [1],
1036 [Linux NFSv4 ACL support via librichacl])
1037 elif test "x$ac_cv_archive_acl_libacl" = "xyes"; then
1038 AC_MSG_RESULT([libacl (POSIX.1e)])
1039 AC_DEFINE([ARCHIVE_ACL_LIBACL], [1],
1040 [Linux POSIX.1e ACL support via libacl])
1041 elif test "x$ac_cv_archive_acl_librichacl" = "xyes"; then
1042 AC_MSG_RESULT([librichacl (NFSv4)])
1043 AC_DEFINE([ARCHIVE_ACL_LIBRICHACL], [1],
1044 [Linux NFSv4 ACL support via librichacl])
1045 elif test "x$ac_cv_archive_acl_darwin" = "xyes"; then
1046 AC_DEFINE([ARCHIVE_ACL_DARWIN], [1], [Darwin ACL support])
1047 AC_MSG_RESULT([Darwin (limited NFSv4)])
1048 elif test "x$ac_cv_archive_acl_sunos" = "xyes"; then
1049 AC_DEFINE([ARCHIVE_ACL_SUNOS], [1], [Solaris ACL support])
1050 if test "x$ac_cv_archive_acl_sunos_nfs4" = "xyes"; then
1051 AC_DEFINE([ARCHIVE_ACL_SUNOS_NFS4], [1],
1052 [Solaris NFSv4 ACL support])
1053 AC_MSG_RESULT([Solaris (POSIX.1e and NFSv4)])
1055 AC_MSG_RESULT([Solaris (POSIX.1e)])
1057 elif test "x$ac_cv_archive_acl_freebsd" = "xyes"; then
1058 AC_DEFINE([ARCHIVE_ACL_FREEBSD], [1], [FreeBSD ACL support])
1059 if test "x$ac_cv_archive_acl_freebsd_nfs4" = "xyes"; then
1060 AC_DEFINE([ARCHIVE_ACL_FREEBSD_NFS4], [1],
1061 [FreeBSD NFSv4 ACL support])
1062 AC_MSG_RESULT([FreeBSD (POSIX.1e and NFSv4)])
1064 AC_MSG_RESULT([FreeBSD (POSIX.1e)])
1067 AC_MSG_RESULT([none])
1072 AM_CONDITIONAL([INC_LINUX_ACL],
1073 [test "x$ac_cv_archive_acl_libacl" = "xyes" \
1074 -o "x$ac_cv_archive_acl_librichacl" = "xyes"])
1075 AM_CONDITIONAL([INC_SUNOS_ACL], [test "x$ac_cv_archive_acl_sunos" = "xyes"])
1076 AM_CONDITIONAL([INC_DARWIN_ACL],
1077 [test "x$ac_cv_archive_acl_darwin" = "xyes"])
1078 AM_CONDITIONAL([INC_FREEBSD_ACL],
1079 [test "x$ac_cv_archive_acl_freebsd" = "xyes"])
1081 # Additional requirements
1084 dnl NOTE: Crypto checks must run last.
1085 AC_DEFUN([CRYPTO_CHECK], [
1086 if test "$found_$1" != yes; then
1087 saved_CPPFLAGS="$CPPFLAGS"
1088 CPPFLAGS="$CPPFLAGS -I. -I$srcdir -I$srcdir/libarchive"
1089 touch "check_crypto_md.h"
1090 AC_MSG_CHECKING([support for ARCHIVE_CRYPTO_$1_$2])
1091 AC_LINK_IFELSE([AC_LANG_SOURCE([
1092 #define ARCHIVE_$1_COMPILE_TEST
1093 #define ARCHIVE_CRYPTO_$1_$2
1094 #define PLATFORM_CONFIG_H "check_crypto_md.h"
1096 $(cat "$srcdir/libarchive/archive_digest.c")
1099 main(int argc, char **argv)
1102 archive_$3_init(&ctx);
1103 archive_$3_update(&ctx, *argv, argc);
1104 archive_$3_final(&ctx, NULL);
1108 [ AC_MSG_RESULT([yes])
1111 AC_DEFINE(ARCHIVE_CRYPTO_$1_$2, 1, [ $1 via ARCHIVE_CRYPTO_$1_$2 supported.])
1113 [ AC_MSG_RESULT([no])])
1114 CPPFLAGS="$saved_CPPFLAGS"
1115 rm "check_crypto_md.h"
1119 AC_DEFUN([CRYPTO_CHECK_WIN], [
1120 if test "$found_$1" != yes; then
1121 AC_MSG_CHECKING([support for ARCHIVE_CRYPTO_$1_WIN])
1122 AC_LINK_IFELSE([AC_LANG_SOURCE([
1123 #define ARCHIVE_$1_COMPILE_TEST
1124 #include <windows.h>
1125 #include <wincrypt.h>
1128 main(int argc, char **argv)
1136 [ AC_MSG_RESULT([yes])
1139 AC_DEFINE(ARCHIVE_CRYPTO_$1_WIN, 1, [ $1 via ARCHIVE_CRYPTO_$1_WIN supported.])
1141 [ AC_MSG_RESULT([no])])
1146 *mingw* | *cygwin* | *msys*)
1149 CRYPTO_CHECK(MD5, LIBC, md5)
1150 CRYPTO_CHECK(MD5, LIBSYSTEM, md5)
1151 CRYPTO_CHECK(RMD160, LIBC, rmd160)
1152 CRYPTO_CHECK(SHA1, LIBC, sha1)
1153 CRYPTO_CHECK(SHA1, LIBSYSTEM, sha1)
1154 CRYPTO_CHECK(SHA256, LIBC, sha256)
1155 CRYPTO_CHECK(SHA256, LIBC2, sha256)
1156 CRYPTO_CHECK(SHA256, LIBC3, sha256)
1157 CRYPTO_CHECK(SHA256, LIBSYSTEM, sha256)
1158 CRYPTO_CHECK(SHA384, LIBC, sha384)
1159 CRYPTO_CHECK(SHA384, LIBC2, sha384)
1160 CRYPTO_CHECK(SHA384, LIBC3, sha384)
1161 CRYPTO_CHECK(SHA384, LIBSYSTEM, sha384)
1162 CRYPTO_CHECK(SHA512, LIBC, sha512)
1163 CRYPTO_CHECK(SHA512, LIBC2, sha512)
1164 CRYPTO_CHECK(SHA512, LIBC3, sha512)
1165 CRYPTO_CHECK(SHA512, LIBSYSTEM, sha512)
1169 if test "x$with_cng" != "xno"; then
1170 AC_CHECK_HEADERS([bcrypt.h],[
1171 LIBS="$LIBS -lbcrypt"
1173 [[#ifdef HAVE_WINDOWS_H
1174 # include <windows.h>
1179 if test "x$with_mbedtls" = "xyes"; then
1180 AC_CHECK_HEADERS([mbedtls/aes.h mbedtls/md.h mbedtls/pkcs5.h])
1182 AC_CHECK_LIB(mbedcrypto,mbedtls_sha1_init)
1183 CRYPTO_CHECK(MD5, MBEDTLS, md5)
1184 CRYPTO_CHECK(RMD160, MBEDTLS, rmd160)
1185 CRYPTO_CHECK(SHA1, MBEDTLS, sha1)
1186 CRYPTO_CHECK(SHA256, MBEDTLS, sha256)
1187 CRYPTO_CHECK(SHA384, MBEDTLS, sha384)
1188 CRYPTO_CHECK(SHA512, MBEDTLS, sha512)
1189 if test "x$found_MBEDTLS" != "xyes"; then
1194 if test "x$with_nettle" = "xyes"; then
1195 AC_CHECK_HEADERS([nettle/md5.h nettle/ripemd160.h nettle/sha.h])
1196 AC_CHECK_HEADERS([nettle/pbkdf2.h nettle/aes.h nettle/hmac.h])
1198 AC_CHECK_LIB(nettle,nettle_sha1_init)
1199 CRYPTO_CHECK(MD5, NETTLE, md5)
1200 CRYPTO_CHECK(RMD160, NETTLE, rmd160)
1201 CRYPTO_CHECK(SHA1, NETTLE, sha1)
1202 CRYPTO_CHECK(SHA256, NETTLE, sha256)
1203 CRYPTO_CHECK(SHA384, NETTLE, sha384)
1204 CRYPTO_CHECK(SHA512, NETTLE, sha512)
1205 if test "x$found_NETTLE" != "xyes"; then
1210 if test "x$with_openssl" != "xno"; then
1211 AC_CHECK_HEADERS([openssl/evp.h])
1213 LIBSREQUIRED="$LIBSREQUIRED${LIBSREQUIRED:+ }libssl libcrypto"
1214 AC_CHECK_LIB(crypto,OPENSSL_config)
1215 CRYPTO_CHECK(MD5, OPENSSL, md5)
1216 CRYPTO_CHECK(RMD160, OPENSSL, rmd160)
1217 CRYPTO_CHECK(SHA1, OPENSSL, sha1)
1218 CRYPTO_CHECK(SHA256, OPENSSL, sha256)
1219 CRYPTO_CHECK(SHA384, OPENSSL, sha384)
1220 CRYPTO_CHECK(SHA512, OPENSSL, sha512)
1221 AC_CHECK_FUNCS([PKCS5_PBKDF2_HMAC_SHA1])
1224 AC_SUBST(LIBSREQUIRED)
1226 # Probe libmd AFTER OpenSSL/libcrypto.
1227 # The two are incompatible and OpenSSL is more complete.
1228 AC_CHECK_HEADERS([md5.h ripemd.h sha.h sha256.h sha512.h])
1230 AC_CHECK_LIB(md,MD5Init)
1231 CRYPTO_CHECK(MD5, LIBMD, md5)
1232 CRYPTO_CHECK(RMD160, LIBMD, rmd160)
1233 CRYPTO_CHECK(SHA1, LIBMD, sha1)
1234 CRYPTO_CHECK(SHA256, LIBMD, sha256)
1235 CRYPTO_CHECK(SHA512, LIBMD, sha512)
1236 if test "x$found_LIBMD" != "xyes"; then
1241 *mingw* | *cygwin* | *msys*)
1242 CRYPTO_CHECK_WIN(MD5, CALG_MD5)
1243 CRYPTO_CHECK_WIN(SHA1, CALG_SHA1)
1244 CRYPTO_CHECK_WIN(SHA256, CALG_SHA_256)
1245 CRYPTO_CHECK_WIN(SHA384, CALG_SHA_384)
1246 CRYPTO_CHECK_WIN(SHA512, CALG_SHA_512)
1250 dnl Visibility annotations...
1251 saved_CFLAGS="$CFLAGS"
1252 CFLAGS="$CFLAGS -fvisibility=hidden -Werror"
1253 AC_MSG_CHECKING(whether compiler supports visibility annotations)
1254 AC_LINK_IFELSE([AC_LANG_PROGRAM([
1255 int foo( void ) __attribute__((visibility("default")));
1257 [CFLAGS="$saved_CFLAGS -fvisibility=hidden -D__LIBARCHIVE_ENABLE_VISIBILITY";
1258 AC_MSG_RESULT(yes)],
1259 [CFLAGS="$saved_CFLAGS"
1262 # Ensure test directories are present if building out-of-tree
1263 AC_CONFIG_COMMANDS([mkdirs],
1264 [mkdir -p libarchive/test tar/test cat/test cpio/test])