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.3.2dev])
8 m4_define([LIBARCHIVE_VERSION_N],[3003002])
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...
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_VERSION_STRING],"LIBARCHIVE_VERSION_S()",
51 [Version number of libarchive])
52 AC_DEFINE_UNQUOTED([LIBARCHIVE_VERSION_NUMBER],"LIBARCHIVE_VERSION_N()",
53 [Version number of libarchive as a single integer])
54 AC_DEFINE([BSDCPIO_VERSION_STRING],"BSDCPIO_VERSION_S()",
55 [Version number of bsdcpio])
56 AC_DEFINE([BSDTAR_VERSION_STRING],"BSDTAR_VERSION_S()",
57 [Version number of bsdtar])
58 AC_DEFINE([BSDCAT_VERSION_STRING],"BSDTAR_VERSION_S()",
59 [Version number of bsdcat])
61 # The shell variables here must be the same as the AC_SUBST() variables
62 # below, but the shell variable names apparently cannot be the same as
63 # the m4 macro names above. Why? Ask autoconf.
64 BSDCPIO_VERSION_STRING=BSDCPIO_VERSION_S()
65 BSDTAR_VERSION_STRING=BSDTAR_VERSION_S()
66 BSDCAT_VERSION_STRING=BSDCAT_VERSION_S()
67 LIBARCHIVE_VERSION_STRING=LIBARCHIVE_VERSION_S()
68 LIBARCHIVE_VERSION_NUMBER=LIBARCHIVE_VERSION_N()
70 # Substitute the above version numbers into the various files below.
71 # Yes, I believe this is the fourth time we define what are essentially
72 # the same symbols. Why? Ask autoconf.
73 AC_SUBST(ARCHIVE_LIBTOOL_VERSION)
74 AC_SUBST(BSDCPIO_VERSION_STRING)
75 AC_SUBST(BSDTAR_VERSION_STRING)
76 AC_SUBST(BSDCAT_VERSION_STRING)
77 AC_SUBST(LIBARCHIVE_VERSION_STRING)
78 AC_SUBST(LIBARCHIVE_VERSION_NUMBER)
80 AC_CONFIG_HEADERS([config.h])
81 AC_CONFIG_FILES([Makefile])
82 AC_CONFIG_FILES([build/pkgconfig/libarchive.pc])
87 dnl Compilation on mingw and Cygwin needs special Makefile rules
91 *mingw* ) inc_windows_files=yes ;;
92 *cygwin* | *msys*) inc_cygwin_files=yes ;;
94 AM_CONDITIONAL([INC_WINDOWS_FILES], [test $inc_windows_files = yes])
95 AM_CONDITIONAL([INC_CYGWIN_FILES], [test $inc_cygwin_files = yes])
97 dnl Defines that are required for specific platforms (e.g. -D_POSIX_SOURCE, etc)
100 *mingw* ) PLATFORMCPPFLAGS=-D__USE_MINGW_ANSI_STDIO ;;
102 AC_SUBST(PLATFORMCPPFLAGS)
104 # Checks for programs.
107 AC_USE_SYSTEM_EXTENSIONS
110 AC_CHECK_TOOL([STRIP],[strip])
114 # Options for building bsdtar.
116 # Default is to build bsdtar, but allow people to override that.
118 AC_ARG_ENABLE([bsdtar],
119 [AS_HELP_STRING([--enable-bsdtar], [enable build of bsdtar (default)])
120 AS_HELP_STRING([--enable-bsdtar=static], [force static build of bsdtar])
121 AS_HELP_STRING([--enable-bsdtar=shared], [force dynamic build of bsdtar])
122 AS_HELP_STRING([--disable-bsdtar], [disable build of bsdtar])],
123 [], [enable_bsdtar=yes])
125 case "$enable_bsdtar" in
127 if test "$enable_static" = "no"; then
135 if test "$enable_shared" = "no"; then
136 AC_MSG_FAILURE([Shared linking of bsdtar requires shared libarchive])
150 AC_MSG_FAILURE([Unsupported value for --enable-bsdtar])
154 AM_CONDITIONAL([BUILD_BSDTAR], [ test "$build_bsdtar" = yes ])
155 AM_CONDITIONAL([STATIC_BSDTAR], [ test "$static_bsdtar" = yes ])
158 # Options for building bsdcat.
160 # Default is to build bsdcat, but allow people to override that.
162 AC_ARG_ENABLE([bsdcat],
163 [AS_HELP_STRING([--enable-bsdcat], [enable build of bsdcat (default)])
164 AS_HELP_STRING([--enable-bsdcat=static], [force static build of bsdcat])
165 AS_HELP_STRING([--enable-bsdcat=shared], [force dynamic build of bsdcat])
166 AS_HELP_STRING([--disable-bsdcat], [disable build of bsdcat])],
167 [], [enable_bsdcat=yes])
169 case "$enable_bsdcat" in
171 if test "$enable_static" = "no"; then
179 if test "$enable_shared" = "no"; then
180 AC_MSG_FAILURE([Shared linking of bsdcat requires shared libarchive])
194 AC_MSG_FAILURE([Unsupported value for --enable-bsdcat])
198 AM_CONDITIONAL([BUILD_BSDCAT], [ test "$build_bsdcat" = yes ])
199 AM_CONDITIONAL([STATIC_BSDCAT], [ test "$static_bsdcat" = yes ])
202 # Options for building bsdcpio.
204 # Default is not to build bsdcpio, but that can be overridden.
206 AC_ARG_ENABLE([bsdcpio],
207 [AS_HELP_STRING([--enable-bsdcpio], [enable build of bsdcpio (default)])
208 AS_HELP_STRING([--enable-bsdcpio=static], [static build of bsdcpio])
209 AS_HELP_STRING([--enable-bsdcpio=shared], [dynamic build of bsdcpio])
210 AS_HELP_STRING([--disable-bsdcpio], [disable build of bsdcpio])],
211 [], [enable_bsdcpio=yes])
213 case "$enable_bsdcpio" in
215 if test "$enable_static" = "no"; then
223 if test "$enabled_shared" = "no"; then
224 AC_MSG_FAILURE([Shared linking of bsdcpio requires shared libarchive])
237 AC_MSG_FAILURE([Unsupported value for --enable-bsdcpio])
241 AM_CONDITIONAL([BUILD_BSDCPIO], [ test "$build_bsdcpio" = yes ])
242 AM_CONDITIONAL([STATIC_BSDCPIO], [ test "$static_bsdcpio" = yes ])
244 # Set up defines needed before including any headers
246 *mingw* | *cygwin* | *msys* )
247 AC_DEFINE([_WIN32_WINNT], 0x0502, [Define to '0x0502' for Windows Server 2003 APIs.])
248 AC_DEFINE([WINVER], 0x0502, [Define to '0x0502' for Windows Server 2003 APIs.])
249 AC_DEFINE([NTDDI_VERSION], 0x05020000, [Define to '0x05020000' for Windows Server 2003 APIs.])
253 # Checks for header files.
256 AC_CHECK_HEADERS([acl/libacl.h attr/xattr.h])
257 AC_CHECK_HEADERS([copyfile.h ctype.h])
258 AC_CHECK_HEADERS([errno.h ext2fs/ext2_fs.h fcntl.h grp.h])
260 AC_CACHE_CHECK([whether EXT2_IOC_GETFLAGS is usable],
261 [ac_cv_have_decl_EXT2_IOC_GETFLAGS],
262 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([@%:@include <sys/ioctl.h>
263 @%:@include <ext2fs/ext2_fs.h>],
264 [int x = EXT2_IOC_GETFLAGS])],
265 [AS_VAR_SET([ac_cv_have_decl_EXT2_IOC_GETFLAGS], [yes])],
266 [AS_VAR_SET([ac_cv_have_decl_EXT2_IOC_GETFLAGS], [no])])])
268 AS_VAR_IF([ac_cv_have_decl_EXT2_IOC_GETFLAGS], [yes],
269 [AC_DEFINE_UNQUOTED([HAVE_WORKING_EXT2_IOC_GETFLAGS], [1],
270 [Define to 1 if you have a working EXT2_IOC_GETFLAGS])])
272 AC_CHECK_HEADERS([inttypes.h io.h langinfo.h limits.h])
273 AC_CHECK_HEADERS([linux/fiemap.h linux/fs.h linux/magic.h linux/types.h])
275 AC_CACHE_CHECK([whether FS_IOC_GETFLAGS is usable],
276 [ac_cv_have_decl_FS_IOC_GETFLAGS],
277 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([@%:@include <sys/ioctl.h>
278 @%:@include <linux/fs.h>],
279 [int x = FS_IOC_GETFLAGS])],
280 [AS_VAR_SET([ac_cv_have_decl_FS_IOC_GETFLAGS], [yes])],
281 [AS_VAR_SET([ac_cv_have_decl_FS_IOC_GETFLAGS], [no])])])
283 AS_VAR_IF([ac_cv_have_decl_FS_IOC_GETFLAGS], [yes],
284 [AC_DEFINE_UNQUOTED([HAVE_WORKING_FS_IOC_GETFLAGS], [1],
285 [Define to 1 if you have a working FS_IOC_GETFLAGS])])
287 AC_CHECK_HEADERS([locale.h membership.h paths.h poll.h pthread.h pwd.h])
288 AC_CHECK_HEADERS([readpassphrase.h signal.h spawn.h])
289 AC_CHECK_HEADERS([stdarg.h stdint.h stdlib.h string.h])
290 AC_CHECK_HEADERS([sys/acl.h sys/cdefs.h sys/ea.h sys/extattr.h])
291 AC_CHECK_HEADERS([sys/ioctl.h sys/mkdev.h sys/mount.h])
292 AC_CHECK_HEADERS([sys/param.h sys/poll.h sys/richacl.h])
293 AC_CHECK_HEADERS([sys/select.h sys/statfs.h sys/statvfs.h])
294 AC_CHECK_HEADERS([sys/time.h sys/utime.h sys/utsname.h sys/vfs.h sys/xattr.h])
295 AC_CHECK_HEADERS([time.h unistd.h utime.h wchar.h wctype.h])
296 AC_CHECK_HEADERS([windows.h])
297 # check windows.h first; the other headers require it.
298 AC_CHECK_HEADERS([wincrypt.h winioctl.h],[],[],
299 [[#ifdef HAVE_WINDOWS_H
300 # include <windows.h>
304 # Checks for libraries.
306 AS_HELP_STRING([--without-zlib], [Don't build support for gzip through zlib]))
308 if test "x$with_zlib" != "xno"; then
309 AC_CHECK_HEADERS([zlib.h])
310 AC_CHECK_LIB(z,inflate)
313 AC_ARG_WITH([bz2lib],
314 AS_HELP_STRING([--without-bz2lib], [Don't build support for bzip2 through bz2lib]))
316 if test "x$with_bz2lib" != "xno"; then
317 AC_CHECK_HEADERS([bzlib.h])
319 *mingw* | *cygwin* | *msys*)
320 dnl AC_CHECK_LIB cannot be used on the Windows port of libbz2, therefore
321 dnl use AC_LINK_IFELSE.
322 AC_MSG_CHECKING([for BZ2_bzDecompressInit in -lbz2])
326 [AC_LANG_SOURCE(#include <bzlib.h>
327 int main() { return BZ2_bzDecompressInit(NULL, 0, 0); })],
328 [ac_cv_lib_bz2_BZ2_bzDecompressInit=yes],
329 [ac_cv_lib_bz2_BZ2_bzDecompressInit=no])
331 AC_MSG_RESULT($ac_cv_lib_bz2_BZ2_bzDecompressInit)
332 if test "x$ac_cv_lib_bz2_BZ2_bzDecompressInit" = xyes; then
333 AC_DEFINE([HAVE_LIBBZ2], [1], [Define to 1 if you have the `bz2' library (-lbz2).])
338 AC_CHECK_LIB(bz2,BZ2_bzDecompressInit)
344 AS_HELP_STRING([--without-iconv], [Don't try to link against iconv]))
346 if test "x$with_iconv" != "xno"; then
348 AC_CHECK_HEADERS([iconv.h],[],[],[#include <stdlib.h>])
349 if test "x$am_cv_func_iconv" = "xyes"; then
350 AC_CHECK_HEADERS([localcharset.h])
352 LIBS="${LIBS} ${LIBICONV}"
353 AC_CHECK_FUNCS([locale_charset])
354 LIBS="${am_save_LIBS}"
355 if test "x$ac_cv_func_locale_charset" != "xyes"; then
356 # If locale_charset() is not in libiconv, we have to find libcharset.
357 AC_CHECK_LIB(charset,locale_charset)
363 AS_HELP_STRING([--without-lz4], [Don't build support for lz4 through liblz4]))
365 if test "x$with_lz4" != "xno"; then
366 AC_CHECK_HEADERS([lz4.h lz4hc.h])
367 AC_CHECK_LIB(lz4,LZ4_decompress_safe)
371 AS_HELP_STRING([--without-lzma], [Don't build support for xz through lzma]))
373 if test "x$with_lzma" != "xno"; then
374 AC_CHECK_HEADERS([lzma.h])
375 AC_CHECK_LIB(lzma,lzma_stream_decoder)
376 # Some pre-release (but widely distributed) versions of liblzma
377 # included a disabled version of lzma_stream_encoder_mt that
378 # fools a naive AC_CHECK_LIB or AC_CHECK_FUNC, so we need
379 # to do something more complex here:
381 [whether we have multithread support in lzma],
384 AC_LANG_PROGRAM([[#include <lzma.h>]
385 [#if LZMA_VERSION < 50020000]
388 [[lzma_stream_encoder_mt(0, 0);]])],
389 [ac_cv_lzma_has_mt=yes], [ac_cv_lzma_has_mt=no])])
390 if test "x$ac_cv_lzma_has_mt" != xno; then
391 AC_DEFINE([HAVE_LZMA_STREAM_ENCODER_MT], [1], [Define to 1 if you have the `lzma_stream_encoder_mt' function.])
396 AS_HELP_STRING([--with-lzo2], [Build with LZO support from liblzo2]))
398 if test "x$with_lzo2" = "xyes"; then
399 AC_CHECK_HEADERS([lzo/lzoconf.h lzo/lzo1x.h])
400 AC_CHECK_LIB(lzo2,lzo1x_decompress_safe)
404 AS_HELP_STRING([--without-cng], [Don't build support of CNG(Crypto Next Generation)]))
406 AC_ARG_WITH([nettle],
407 AS_HELP_STRING([--without-nettle], [Don't build with crypto support from Nettle]))
408 AC_ARG_WITH([openssl],
409 AS_HELP_STRING([--without-openssl], [Don't build support for mtree and xar hashes through openssl]))
411 *darwin* ) with_openssl=no ;;
415 AS_HELP_STRING([--without-xml2], [Don't build support for xar through libxml2]))
417 AS_HELP_STRING([--without-expat], [Don't build support for xar through expat]))
419 if test "x$with_xml2" != "xno"; then
421 PKG_CHECK_MODULES(LIBXML2_PC, [libxml-2.0], [
422 CPPFLAGS="${CPPFLAGS} ${LIBXML2_PC_CFLAGS}"
423 LIBS="${LIBS} ${LIBXML2_PC_LIBS}"
424 AC_CHECK_LIB(xml2,xmlInitParser,[true],AC_MSG_FAILURE(Missing xml2 library))
426 AC_CHECK_LIB(xml2,xmlInitParser)
428 AC_CHECK_HEADERS([libxml/xmlreader.h libxml/xmlwriter.h])
430 if test "x$ac_cv_header_libxml_xmlreader_h" != "xyes"; then
431 if test "x$with_expat" != "xno"; then
432 AC_CHECK_HEADERS([expat.h])
433 AC_CHECK_LIB(expat,XML_ParserCreate)
437 AC_ARG_ENABLE([posix-regex-lib],
438 [AS_HELP_STRING([--enable-posix-regex-lib],
439 [choose what library to use for POSIX regular expression support (default: auto)])
440 AS_HELP_STRING([--enable-posix-regex-lib=libc], [use libc POSIX regular expression support])
441 AS_HELP_STRING([--enable-posix-regex-lib=libregex], [use libregex POSIX regular expression support])
442 AS_HELP_STRING([--enable-posix-regex-lib=libpcreposix], [use libpcreposix POSIX regular expression support])
443 AS_HELP_STRING([--disable-posix-regex-lib], [don't enable POSIX regular expression support])],
444 [], [enable_posix_regex_lib=auto])
446 posix_regex_lib_found=
447 if test "$enable_posix_regex_lib" = "auto" || test "$enable_posix_regex_lib" = "libc" || test "$enable_posix_regex_lib" = "libregex"; then
448 AC_CHECK_HEADERS([regex.h])
449 if test "x$ac_cv_header_regex_h" != "xno"; then
450 AC_CHECK_FUNC(regcomp)
451 if test "x$ac_cv_func_regcomp" = xyes; then
452 posix_regex_lib_found=1
454 AC_CHECK_LIB(regex,regcomp)
455 if test "x$ac_cv_lib_regex_regcomp" = xyes; then
456 posix_regex_lib_found=1
461 if test -z $posix_regex_lib_found && (test "$enable_posix_regex_lib" = "auto" || test "$enable_posix_regex_lib" = "libpcreposix"); then
462 AC_CHECK_HEADERS([pcreposix.h])
463 AC_CHECK_LIB(pcreposix,regcomp)
464 if test "x$ac_cv_lib_pcreposix_regcomp" != xyes; then
465 AC_MSG_NOTICE(trying libpcreposix check again with libpcre)
466 unset ac_cv_lib_pcreposix_regcomp
467 AC_CHECK_LIB(pcre,pcre_exec)
468 AC_CHECK_LIB(pcreposix,regcomp)
469 if test "x$ac_cv_lib_pcre_pcre_exec" = xyes && test "x$ac_cv_lib_pcreposix_regcomp" = xyes; then
470 AC_MSG_CHECKING(if PCRE_STATIC needs to be defined)
472 [AC_LANG_SOURCE(#include <pcreposix.h>
473 int main() { return regcomp(NULL, NULL, 0); })],
474 [without_pcre_static=yes],
475 [without_pcre_static=no])
477 [AC_LANG_SOURCE(#define PCRE_STATIC
478 #include <pcreposix.h>
479 int main() { return regcomp(NULL, NULL, 0); })],
480 [with_pcre_static=yes],
481 [with_pcre_static=no])
482 if test "x$without_pcre_static" != xyes && test "x$with_pcre_static" = xyes; then
484 AC_DEFINE([PCRE_STATIC], [1], [Define to 1 if PCRE_STATIC needs to be defined.])
485 elif test "x$without_pcre_static" = xyes || test "x$with_pcre_static" = xyes; then
488 posix_regex_lib_found=1
491 posix_regex_lib_found=1
495 # TODO: Give the user the option of using a pre-existing system
496 # libarchive. This will define HAVE_LIBARCHIVE which will cause
497 # bsdtar_platform.h to use #include <...> for the libarchive headers.
498 # Need to include Makefile.am magic to link against system
499 # -larchive in that case.
500 #AC_CHECK_LIB(archive,archive_version)
502 # Checks for supported compiler flags
503 AX_APPEND_COMPILE_FLAGS([-Wall -Wformat -Wformat-security])
505 # Checks for typedefs, structures, and compiler characteristics.
507 # la_TYPE_UID_T defaults to "int", which is incorrect for MinGW
508 # and MSVC. Use a customized version.
511 # AC_TYPE_OFF_T defaults to "long", which limits us to 4GB files on
512 # most systems... default to "long long" instead.
513 AC_CHECK_TYPE(off_t, [long long])
515 AC_CHECK_TYPE(id_t, [unsigned long])
516 AC_CHECK_TYPE(uintptr_t, [unsigned int])
518 # Check for tm_gmtoff in struct tm
519 AC_CHECK_MEMBERS([struct tm.tm_gmtoff, struct tm.__tm_gmtoff],,,
524 # Check for f_namemax in struct statfs
525 AC_CHECK_MEMBERS([struct statfs.f_namemax],,,
527 #include <sys/param.h>
528 #include <sys/mount.h>
531 # Check for f_iosize in struct statvfs
532 AC_CHECK_MEMBERS([struct statvfs.f_iosize],,,
534 #include <sys/statvfs.h>
537 # Check for birthtime in struct stat
538 AC_CHECK_MEMBERS([struct stat.st_birthtime])
540 # Check for high-resolution timestamps in struct stat
541 AC_CHECK_MEMBERS([struct stat.st_birthtimespec.tv_nsec])
542 AC_CHECK_MEMBERS([struct stat.st_mtimespec.tv_nsec])
543 AC_CHECK_MEMBERS([struct stat.st_mtim.tv_nsec])
544 AC_CHECK_MEMBERS([struct stat.st_mtime_n]) # AIX
545 AC_CHECK_MEMBERS([struct stat.st_umtime]) # Tru64
546 AC_CHECK_MEMBERS([struct stat.st_mtime_usec]) # Hurd
547 # Check for block size support in struct stat
548 AC_CHECK_MEMBERS([struct stat.st_blksize])
549 # Check for st_flags in struct stat (BSD fflags)
550 AC_CHECK_MEMBERS([struct stat.st_flags])
552 # If you have uintmax_t, we assume printf supports %ju
553 # If you have unsigned long long, we assume printf supports %llu
554 # TODO: Check for %ju and %llu support directly.
555 AC_CHECK_TYPES([uintmax_t, unsigned long long])
557 # We use C99-style integer types
558 # Declare them if the local platform doesn't already do so.
569 AC_CHECK_DECLS([SIZE_MAX, INT32_MAX, INT32_MIN])
570 AC_CHECK_DECLS([INT64_MAX, INT64_MIN, UINT64_MAX, UINT32_MAX])
571 AC_CHECK_DECLS([INTMAX_MAX, INTMAX_MIN, UINTMAX_MAX])
573 AC_CHECK_DECL([SSIZE_MAX],
574 [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.])],
576 [#include <limits.h>])
578 AC_CHECK_DECL([EFTYPE],
579 [AC_DEFINE(HAVE_EFTYPE, 1, [A possible errno value for invalid file format errors])],
581 [#include <errno.h>])
582 AC_CHECK_DECL([EILSEQ],
583 [AC_DEFINE(HAVE_EILSEQ, 1, [A possible errno value for invalid file format errors])],
585 [#include <errno.h>])
586 AC_CHECK_TYPE([wchar_t],
587 [AC_DEFINE_UNQUOTED(AS_TR_CPP(HAVE_[]wchar_t), 1, [Define to 1 if the system has the type `wchar_t'.])dnl
588 AC_CHECK_SIZEOF([wchar_t])],
593 # Checks for library functions.
594 AC_PROG_GCC_TRADITIONAL
604 # CreateHardLinkA(LPCSTR, LPCSTR, LPSECURITY_ATTRIBUTES)
605 # To avoid necessity for including windows.h or special forward declaration
606 # workarounds, we use 'void *' for 'struct SECURITY_ATTRIBUTES *'
607 AC_CHECK_STDCALL_FUNC([CreateHardLinkA],[const char *, const char *, void *])
608 AC_CHECK_FUNCS([arc4random_buf chflags chown chroot ctime_r dirfd])
609 AC_CHECK_FUNCS([fchdir fchflags fchmod fchown fcntl fdopendir fork])
610 AC_CHECK_FUNCS([fstat fstatat fstatfs fstatvfs ftruncate])
611 AC_CHECK_FUNCS([futimens futimes futimesat])
612 AC_CHECK_FUNCS([geteuid getpid getgrgid_r getgrnam_r])
613 AC_CHECK_FUNCS([getpwnam_r getpwuid_r getvfsbyname gmtime_r])
614 AC_CHECK_FUNCS([lchflags lchmod lchown link localtime_r lstat lutimes])
615 AC_CHECK_FUNCS([mbrtowc memmove memset])
616 AC_CHECK_FUNCS([mkdir mkfifo mknod mkstemp])
617 AC_CHECK_FUNCS([nl_langinfo openat pipe poll posix_spawnp readlink readlinkat])
618 AC_CHECK_FUNCS([readpassphrase])
619 AC_CHECK_FUNCS([select setenv setlocale sigaction statfs statvfs])
620 AC_CHECK_FUNCS([strchr strdup strerror strncpy_s strrchr symlink timegm])
621 AC_CHECK_FUNCS([tzset unsetenv utime utimensat utimes vfork])
622 AC_CHECK_FUNCS([wcrtomb wcscmp wcscpy wcslen wctomb wmemcmp wmemcpy wmemmove])
623 AC_CHECK_FUNCS([_ctime64_s _fseeki64])
624 AC_CHECK_FUNCS([_get_timezone _localtime64_s _mkgmtime64])
625 # detects cygwin-1.7, as opposed to older versions
626 AC_CHECK_FUNCS([cygwin_conv_path])
628 # DragonFly uses vfsconf, FreeBSD xvfsconf.
629 AC_CHECK_TYPES(struct vfsconf,,,
630 [#if HAVE_SYS_TYPES_H
631 #include <sys/types.h>
633 #include <sys/mount.h>
636 AC_CHECK_TYPES(struct xvfsconf,,,
637 [#if HAVE_SYS_TYPES_H
638 #include <sys/types.h>
640 #include <sys/mount.h>
643 # There are several variants of readdir_r around; we only
644 # accept the POSIX-compliant version.
646 [AC_LANG_PROGRAM([[#include <dirent.h>]],
647 [[DIR *dir; struct dirent e, *r;
648 return(readdir_r(dir, &e, &r));]])],
649 [AC_DEFINE(HAVE_READDIR_R,1,[Define to 1 if you have a POSIX compatible readdir_r])]
652 # FreeBSD's nl_langinfo supports an option to specify whether the
653 # current locale uses month/day or day/month ordering. It makes the
654 # output a little prettier...
655 AC_CHECK_DECL([D_MD_ORDER],
656 [AC_DEFINE(HAVE_D_MD_ORDER, 1, [Define to 1 if nl_langinfo supports D_MD_ORDER])],
659 #include <langinfo.h>
663 # Check for dirent.d_namlen field explicitly
664 # (This is a bit more straightforward than, if not quite as portable as,
665 # the recipe given by the autoconf maintainers.)
666 AC_CHECK_MEMBER(struct dirent.d_namlen,,,
672 # Check for Extended Attributes support
673 AC_ARG_ENABLE([xattr],
674 AS_HELP_STRING([--disable-xattr],
675 [Disable Extended Attributes support (default: check)]))
677 if test "x$enable_xattr" != "xno"; then
678 AC_SEARCH_LIBS([setxattr], [attr])
679 AC_CHECK_DECLS([EXTATTR_NAMESPACE_USER], [], [], [#include <sys/types.h>
680 #include <sys/extattr.h>
682 AC_CHECK_DECLS([XATTR_NOFOLLOW], [], [], [#include <sys/xattr.h>
684 if test "x$ac_cv_header_sys_xattr_h" = "xyes" \
685 -a "x$ac_cv_have_decl_XATTR_NOFOLLOW" = "xyes"; then
686 # Darwin extended attributes support
687 AC_CACHE_VAL([ac_cv_archive_xattr_darwin],
688 [AC_CHECK_FUNCS(fgetxattr \
694 [ac_cv_archive_xattr_darwin=yes],
695 [ac_cv_archive_xattr_darwin=no],
696 [#include <sys/xattr.h>
700 elif test "x$ac_cv_header_sys_extattr_h" = "xyes" \
701 -a "x$ac_cv_have_decl_EXTATTR_NAMESPACE_USER" = "xyes"; then
702 # FreeBSD extended attributes support
703 AC_CACHE_VAL([ac_cv_archive_xattr_freebsd],
704 [AC_CHECK_FUNCS(extattr_get_fd \
712 [ac_cv_archive_xattr_freebsd=yes],
713 [ac_cv_archive_xattr_freebsd=no],
714 [#include <sys/types.h>
715 #include <sys/extattr.h>
719 elif test "x$ac_cv_header_sys_xattr_h" = "xyes" \
720 -o "x$ac_cv_header_attr_xattr_h" = "xyes"; then
721 # Linux extended attributes support
722 AC_CACHE_VAL([ac_cv_archive_xattr_linux],
723 [AC_CHECK_FUNCS(fgetxattr \
731 [ac_cv_archive_xattr_linux=yes],
732 [ac_cv_archive_xattr_linux=no],
733 [#if HAVE_SYS_TYPES_H
734 #include <sys/types.h>
737 #include <sys/xattr.h>
739 #if HAVE_ATTR_XATTR_H
740 #include <attr/xatr.h>
745 elif test "x$ac_cv_header_sys_ea_h" = "xyes"; then
746 # AIX extended attributes support
747 AC_CACHE_VAL([ac_cv_archive_xattr_aix],
748 [AC_CHECK_FUNCS(fgetea \
756 [ac_cv_archive_xattr_aix=yes],
757 [ac_cv_archive_xattr_aix=no],
764 AC_MSG_CHECKING([for extended attributes support])
765 if test "x$ac_cv_archive_xattr_linux" = "xyes"; then
766 AC_DEFINE([ARCHIVE_XATTR_LINUX], [1], [Linux xattr support])
767 AC_MSG_RESULT([Linux])
768 elif test "x$ac_cv_archive_xattr_darwin" = "xyes"; then
769 AC_DEFINE([ARCHIVE_XATTR_DARWIN], [1], [Darwin xattr support])
770 AC_MSG_RESULT([Darwin])
771 elif test "x$ac_cv_archive_xattr_freebsd" = "xyes"; then
772 AC_DEFINE([ARCHIVE_XATTR_FREEBSD], [1], [FreeBSD xattr support])
773 AC_MSG_RESULT([FreeBSD])
774 elif test "x$ac_cv_archive_xattr_aix" = "xyes"; then
775 AC_DEFINE([ARCHIVE_XATTR_AIX], [1], [AIX xattr support])
778 AC_MSG_RESULT([none])
782 # Check for ACL support
784 # The ACL support in libarchive is written against the POSIX1e draft,
785 # which was never officially approved and varies quite a bit across
786 # platforms. Worse, some systems have completely non-POSIX acl functions,
787 # which makes the following checks rather more complex than I would like.
790 AS_HELP_STRING([--disable-acl],
791 [Disable ACL support (default: check)]))
793 if test "x$enable_acl" != "xno"; then
795 AC_CHECK_LIB([acl], [acl_get_file])
797 AC_CHECK_TYPES([acl_t, acl_entry_t, acl_permset_t, acl_tag_t], [], [], [
799 #include <sys/types.h>
806 AC_CHECK_LIB([richacl], [richacl_get_file])
808 AC_CHECK_TYPES([[struct richace], [struct richacl]], [], [], [
809 #if HAVE_SYS_RICHACL_H
810 #include <sys/richacl.h>
814 # Solaris and derivates ACLs
815 AC_CHECK_FUNCS(acl facl)
817 if test "x$ac_cv_lib_richacl_richacl_get_file" = "xyes" \
818 -a "x$ac_cv_type_struct_richace" = "xyes" \
819 -a "x$ac_cv_type_struct_richacl" = "xyes"; then
820 AC_CACHE_VAL([ac_cv_archive_acl_librichacl],
821 [AC_CHECK_FUNCS(richacl_alloc \
828 [ac_cv_archive_acl_librichacl=yes], [ac_cv_archive_acl_librichacl=no], [#include <sys/richacl.h>])])
831 if test "x$ac_cv_func_acl" = "xyes" \
832 -a "x$ac_cv_func_facl" = "xyes"; then
833 AC_CHECK_TYPES([aclent_t], [], [], [[#include <sys/acl.h>]])
834 if test "x$ac_cv_type_aclent_t" = "xyes"; then
835 AC_CACHE_VAL([ac_cv_archive_acl_sunos],
836 [AC_CHECK_DECLS([GETACL, SETACL, GETACLCNT],
837 [ac_cv_archive_acl_sunos=yes], [ac_cv_archive_acl_sunos=no],
838 [#include <sys/acl.h>])])
839 AC_CHECK_TYPES([ace_t], [], [], [[#include <sys/acl.h>]])
840 if test "x$ac_cv_type_ace_t" = "xyes"; then
841 AC_CACHE_VAL([ac_cv_archive_acl_sunos_nfs4],
842 [AC_CHECK_DECLS([ACE_GETACL, ACE_SETACL, ACE_GETACLCNT],
843 [ac_cv_archive_acl_sunos_nfs4=yes],
844 [ac_cv_archive_acl_sonos_nfs4=no],
845 [#include <sys/acl.h>])])
848 elif test "x$ac_cv_type_acl_t" = "xyes" \
849 -a "x$ac_cv_type_acl_entry_t" = "xyes" \
850 -a "x$ac_cv_type_acl_permset_t" = "xyes" \
851 -a "x$ac_cv_type_acl_tag_t" = "xyes"; then
852 # POSIX.1e ACL functions
853 AC_CACHE_VAL([ac_cv_posix_acl_funcs],
854 [AC_CHECK_FUNCS(acl_add_perm \
857 acl_delete_def_file \
870 [ac_cv_posix_acl_funcs=yes], [ac_cv_posix_acl_funcs=no],
871 [#if HAVE_SYS_TYPES_H
872 #include <sys/types.h>
880 AC_CHECK_FUNCS(acl_get_perm)
882 if test "x$ac_cv_posix_acl_funcs" = "xyes" \
883 -a "x$ac_cv_header_acl_libacl_h" = "xyes" \
884 -a "x$ac_cv_lib_acl_acl_get_file" = "xyes" \
885 -a "x$ac_cv_func_acl_get_perm"; then
886 AC_CACHE_VAL([ac_cv_archive_acl_libacl],
887 [ac_cv_archive_acl_libacl=yes])
888 AC_DEFINE([ARCHIVE_ACL_LIBACL], [1],
889 [POSIX.1e ACL support via libacl])
892 AC_CHECK_FUNCS(acl_add_flag_np \
895 acl_get_entry_type_np \
902 acl_set_entry_type_np \
905 [#include <sys/types.h>
906 #include <sys/acl.h>])
908 AC_CHECK_FUNCS(mbr_uid_to_uuid \
911 [#include <membership.h>])
913 AC_CHECK_DECLS([ACL_TYPE_EXTENDED, ACL_TYPE_NFS4, ACL_USER,
914 ACL_SYNCHRONIZE], [], [],
915 [#include <sys/types.h>
916 #include <sys/acl.h>])
917 if test "x$ac_cv_posix_acl_funcs" = "xyes" \
918 -a "x$ac_cv_func_acl_get_fd_np" = "xyes" \
919 -a "x$ac_cv_func_acl_get_perm" != "xyes" \
920 -a "x$ac_cv_func_acl_get_perm_np" = "xyes" \
921 -a "x$ac_cv_func_acl_set_fd_np" = "xyes"; then
922 if test "x$ac_cv_have_decl_ACL_USER" = "xyes"; then
923 AC_CACHE_VAL([ac_cv_archive_acl_freebsd],
924 [ac_cv_archive_acl_freebsd=yes])
925 if test "x$ac_cv_have_decl_ACL_TYPE_NFS4" = "xyes" \
926 -a "x$ac_cv_func_acl_add_flag_np" = "xyes" \
927 -a "x$ac_cv_func_acl_get_brand_np" = "xyes" \
928 -a "x$ac_cv_func_acl_get_entry_type_np" = "xyes" \
929 -a "x$ac_cv_func_acl_get_flagset_np" = "xyes" \
930 -a "x$ac_cv_func_acl_set_entry_type_np" = "xyes"; then
931 AC_CACHE_VAL([ac_cv_archive_acl_freebsd_nfs4],
932 [ac_cv_archive_acl_freebsd_nfs4=yes])
934 elif test "x$ac_cv_have_decl_ACL_TYPE_EXTENDED" = "xyes" \
935 -a "x$ac_cv_func_acl_add_flag_np" = "xyes" \
936 -a "x$ac_cv_func_acl_get_flagset_np" = "xyes" \
937 -a "x$ac_cv_func_acl_get_link_np" = "xyes" \
938 -a "x$ac_cv_func_acl_set_link_np" = "xyes" \
939 -a "x$ac_cv_func_mbr_uid_to_uuid" = "xyes" \
940 -a "x$ac_cv_func_mbr_uuid_to_id" = "xyes" \
941 -a "x$ac_cv_func_mbr_gid_to_uuid" = "xyes"; then
942 AC_CACHE_VAL([ac_cv_archive_acl_darwin],
943 [ac_cv_archive_acl_darwin=yes])
948 AC_MSG_CHECKING([for ACL support])
949 if test "x$ac_cv_archive_acl_libacl" = "xyes" \
950 -a "x$ac_cv_archive_acl_librichacl" = "xyes"; then
951 AC_MSG_RESULT([libacl (POSIX.1e) + librichacl (NFSv4)])
952 AC_DEFINE([ARCHIVE_ACL_LIBACL], [1],
953 [Linux POSIX.1e ACL support via libacl])
954 AC_DEFINE([ARCHIVE_ACL_LIBRICHACL], [1],
955 [Linux NFSv4 ACL support via librichacl])
956 elif test "x$ac_cv_archive_acl_libacl" = "xyes"; then
957 AC_MSG_RESULT([libacl (POSIX.1e)])
958 AC_DEFINE([ARCHIVE_ACL_LIBACL], [1],
959 [Linux POSIX.1e ACL support via libacl])
960 elif test "x$ac_cv_archive_acl_librichacl" = "xyes"; then
961 AC_MSG_RESULT([librichacl (NFSv4)])
962 AC_DEFINE([ARCHIVE_ACL_LIBRICHACL], [1],
963 [Linux NFSv4 ACL support via librichacl])
964 elif test "x$ac_cv_archive_acl_darwin" = "xyes"; then
965 AC_DEFINE([ARCHIVE_ACL_DARWIN], [1], [Darwin ACL support])
966 AC_MSG_RESULT([Darwin (limited NFSv4)])
967 elif test "x$ac_cv_archive_acl_sunos" = "xyes"; then
968 AC_DEFINE([ARCHIVE_ACL_SUNOS], [1], [Solaris ACL support])
969 if test "x$ac_cv_archive_acl_sunos_nfs4" = "xyes"; then
970 AC_DEFINE([ARCHIVE_ACL_SUNOS_NFS4], [1],
971 [Solaris NFSv4 ACL support])
972 AC_MSG_RESULT([Solaris (POSIX.1e and NFSv4)])
974 AC_MSG_RESULT([Solaris (POSIX.1e)])
976 elif test "x$ac_cv_archive_acl_freebsd" = "xyes"; then
977 AC_DEFINE([ARCHIVE_ACL_FREEBSD], [1], [FreeBSD ACL support])
978 if test "x$ac_cv_archive_acl_freebsd_nfs4" = "xyes"; then
979 AC_DEFINE([ARCHIVE_ACL_FREEBSD_NFS4], [1],
980 [FreeBSD NFSv4 ACL support])
981 AC_MSG_RESULT([FreeBSD (POSIX.1e and NFSv4)])
983 AC_MSG_RESULT([FreeBSD (POSIX.1e)])
986 AC_MSG_RESULT([none])
991 AM_CONDITIONAL([INC_LINUX_ACL],
992 [test "x$ac_cv_archive_acl_libacl" = "xyes" \
993 -o "x$ac_cv_archive_acl_librichacl" = "xyes"])
994 AM_CONDITIONAL([INC_SUNOS_ACL], [test "x$ac_cv_archive_acl_sunos" = "xyes"])
995 AM_CONDITIONAL([INC_DARWIN_ACL],
996 [test "x$ac_cv_archive_acl_darwin" = "xyes"])
997 AM_CONDITIONAL([INC_FREEBSD_ACL],
998 [test "x$ac_cv_archive_acl_freebsd" = "xyes"])
1000 # Additional requirements
1003 dnl NOTE: Crypto checks must run last.
1004 AC_DEFUN([CRYPTO_CHECK], [
1005 if test "$found_$1" != yes; then
1006 saved_CPPFLAGS="$CPPFLAGS"
1007 CPPFLAGS="$CPPFLAGS -I. -I$srcdir -I$srcdir/libarchive"
1008 touch "check_crypto_md.h"
1009 AC_MSG_CHECKING([support for ARCHIVE_CRYPTO_$1_$2])
1010 AC_LINK_IFELSE([AC_LANG_SOURCE([
1011 #define ARCHIVE_$1_COMPILE_TEST
1012 #define ARCHIVE_CRYPTO_$1_$2
1013 #define PLATFORM_CONFIG_H "check_crypto_md.h"
1015 $(cat "$srcdir/libarchive/archive_digest.c")
1018 main(int argc, char **argv)
1021 archive_$3_init(&ctx);
1022 archive_$3_update(&ctx, *argv, argc);
1023 archive_$3_final(&ctx, NULL);
1027 [ AC_MSG_RESULT([yes])
1030 AC_DEFINE(ARCHIVE_CRYPTO_$1_$2, 1, [ $1 via ARCHIVE_CRYPTO_$1_$2 supported.])
1032 [ AC_MSG_RESULT([no])])
1033 CPPFLAGS="$saved_CPPFLAGS"
1034 rm "check_crypto_md.h"
1038 AC_DEFUN([CRYPTO_CHECK_WIN], [
1039 if test "$found_$1" != yes; then
1040 AC_MSG_CHECKING([support for ARCHIVE_CRYPTO_$1_WIN])
1041 AC_LINK_IFELSE([AC_LANG_SOURCE([
1042 #define ARCHIVE_$1_COMPILE_TEST
1043 #include <windows.h>
1044 #include <wincrypt.h>
1047 main(int argc, char **argv)
1055 [ AC_MSG_RESULT([yes])
1058 AC_DEFINE(ARCHIVE_CRYPTO_$1_WIN, 1, [ $1 via ARCHIVE_CRYPTO_$1_WIN supported.])
1060 [ AC_MSG_RESULT([no])])
1065 *mingw* | *cygwin* | *msys*)
1068 CRYPTO_CHECK(MD5, LIBC, md5)
1069 CRYPTO_CHECK(MD5, LIBSYSTEM, md5)
1070 CRYPTO_CHECK(RMD160, LIBC, rmd160)
1071 CRYPTO_CHECK(SHA1, LIBC, sha1)
1072 CRYPTO_CHECK(SHA1, LIBSYSTEM, sha1)
1073 CRYPTO_CHECK(SHA256, LIBC, sha256)
1074 CRYPTO_CHECK(SHA256, LIBC2, sha256)
1075 CRYPTO_CHECK(SHA256, LIBC3, sha256)
1076 CRYPTO_CHECK(SHA256, LIBSYSTEM, sha256)
1077 CRYPTO_CHECK(SHA384, LIBC, sha384)
1078 CRYPTO_CHECK(SHA384, LIBC2, sha384)
1079 CRYPTO_CHECK(SHA384, LIBC3, sha384)
1080 CRYPTO_CHECK(SHA384, LIBSYSTEM, sha384)
1081 CRYPTO_CHECK(SHA512, LIBC, sha512)
1082 CRYPTO_CHECK(SHA512, LIBC2, sha512)
1083 CRYPTO_CHECK(SHA512, LIBC3, sha512)
1084 CRYPTO_CHECK(SHA512, LIBSYSTEM, sha512)
1088 if test "x$with_cng" != "xno"; then
1089 AC_CHECK_HEADERS([bcrypt.h],[
1090 LIBS="$LIBS -lbcrypt"
1092 [[#ifdef HAVE_WINDOWS_H
1093 # include <windows.h>
1098 if test "x$with_nettle" != "xno"; then
1099 AC_CHECK_HEADERS([nettle/md5.h nettle/ripemd160.h nettle/sha.h])
1100 AC_CHECK_HEADERS([nettle/pbkdf2.h nettle/aes.h nettle/hmac.h])
1102 AC_CHECK_LIB(nettle,nettle_sha1_init)
1103 CRYPTO_CHECK(MD5, NETTLE, md5)
1104 CRYPTO_CHECK(RMD160, NETTLE, rmd160)
1105 CRYPTO_CHECK(SHA1, NETTLE, sha1)
1106 CRYPTO_CHECK(SHA256, NETTLE, sha256)
1107 CRYPTO_CHECK(SHA384, NETTLE, sha384)
1108 CRYPTO_CHECK(SHA512, NETTLE, sha512)
1109 if test "x$found_NETTLE" != "xyes"; then
1114 if test "x$with_openssl" != "xno"; then
1115 AC_CHECK_HEADERS([openssl/evp.h])
1118 *mingw* | *cygwin* | *msys*)
1121 AC_CHECK_LIB(eay64,OPENSSL_config)
1122 if test "x$ac_cv_lib_eay64_main" != "xyes"; then
1123 AC_CHECK_LIB(eay32,OPENSSL_config)
1127 AC_CHECK_LIB(eay32,OPENSSL_config)
1132 AC_CHECK_LIB(crypto,OPENSSL_config)
1135 CRYPTO_CHECK(MD5, OPENSSL, md5)
1136 CRYPTO_CHECK(RMD160, OPENSSL, rmd160)
1137 CRYPTO_CHECK(SHA1, OPENSSL, sha1)
1138 CRYPTO_CHECK(SHA256, OPENSSL, sha256)
1139 CRYPTO_CHECK(SHA384, OPENSSL, sha384)
1140 CRYPTO_CHECK(SHA512, OPENSSL, sha512)
1141 if test "x$found_OPENSSL" != "xyes"; then
1144 AC_CHECK_FUNCS([PKCS5_PBKDF2_HMAC_SHA1])
1146 AC_CHECK_LIB(crypto,EVP_CIPHER_CTX_init)
1149 # Probe libmd AFTER OpenSSL/libcrypto.
1150 # The two are incompatible and OpenSSL is more complete.
1151 AC_CHECK_HEADERS([md5.h ripemd.h sha.h sha256.h sha512.h])
1153 AC_CHECK_LIB(md,MD5Init)
1154 CRYPTO_CHECK(MD5, LIBMD, md5)
1155 CRYPTO_CHECK(RMD160, LIBMD, rmd160)
1156 CRYPTO_CHECK(SHA1, LIBMD, sha1)
1157 CRYPTO_CHECK(SHA256, LIBMD, sha256)
1158 CRYPTO_CHECK(SHA512, LIBMD, sha512)
1159 if test "x$found_LIBMD" != "xyes"; then
1164 *mingw* | *cygwin* | *msys*)
1165 CRYPTO_CHECK_WIN(MD5, CALG_MD5)
1166 CRYPTO_CHECK_WIN(SHA1, CALG_SHA1)
1167 CRYPTO_CHECK_WIN(SHA256, CALG_SHA_256)
1168 CRYPTO_CHECK_WIN(SHA384, CALG_SHA_384)
1169 CRYPTO_CHECK_WIN(SHA512, CALG_SHA_512)
1173 # Ensure test directories are present if building out-of-tree
1174 AC_CONFIG_COMMANDS([mkdirs],
1175 [mkdir -p libarchive/test tar/test cat/test cpio/test])