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.1])
8 m4_define([LIBARCHIVE_VERSION_N],[3003001])
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([copyfile.h ctype.h])
257 AC_CHECK_HEADERS([errno.h ext2fs/ext2_fs.h fcntl.h grp.h])
259 AC_CACHE_CHECK([whether EXT2_IOC_GETFLAGS is usable],
260 [ac_cv_have_decl_EXT2_IOC_GETFLAGS],
261 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([@%:@include <sys/ioctl.h>
262 @%:@include <ext2fs/ext2_fs.h>],
263 [int x = EXT2_IOC_GETFLAGS])],
264 [AS_VAR_SET([ac_cv_have_decl_EXT2_IOC_GETFLAGS], [yes])],
265 [AS_VAR_SET([ac_cv_have_decl_EXT2_IOC_GETFLAGS], [no])])])
267 AS_VAR_IF([ac_cv_have_decl_EXT2_IOC_GETFLAGS], [yes],
268 [AC_DEFINE_UNQUOTED([HAVE_WORKING_EXT2_IOC_GETFLAGS], [1],
269 [Define to 1 if you have a working EXT2_IOC_GETFLAGS])])
271 AC_CHECK_HEADERS([inttypes.h io.h langinfo.h limits.h])
272 AC_CHECK_HEADERS([linux/fiemap.h linux/fs.h linux/magic.h linux/types.h])
274 AC_CACHE_CHECK([whether FS_IOC_GETFLAGS is usable],
275 [ac_cv_have_decl_FS_IOC_GETFLAGS],
276 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([@%:@include <sys/ioctl.h>
277 @%:@include <linux/fs.h>],
278 [int x = FS_IOC_GETFLAGS])],
279 [AS_VAR_SET([ac_cv_have_decl_FS_IOC_GETFLAGS], [yes])],
280 [AS_VAR_SET([ac_cv_have_decl_FS_IOC_GETFLAGS], [no])])])
282 AS_VAR_IF([ac_cv_have_decl_FS_IOC_GETFLAGS], [yes],
283 [AC_DEFINE_UNQUOTED([HAVE_WORKING_FS_IOC_GETFLAGS], [1],
284 [Define to 1 if you have a working FS_IOC_GETFLAGS])])
286 AC_CHECK_HEADERS([locale.h paths.h poll.h pthread.h pwd.h])
287 AC_CHECK_HEADERS([readpassphrase.h signal.h spawn.h])
288 AC_CHECK_HEADERS([stdarg.h stdint.h stdlib.h string.h])
289 AC_CHECK_HEADERS([sys/cdefs.h sys/extattr.h])
290 AC_CHECK_HEADERS([sys/ioctl.h sys/mkdev.h sys/mount.h])
291 AC_CHECK_HEADERS([sys/param.h sys/poll.h sys/select.h sys/statfs.h sys/statvfs.h])
292 AC_CHECK_HEADERS([sys/time.h sys/utime.h sys/utsname.h sys/vfs.h])
293 AC_CHECK_HEADERS([time.h unistd.h utime.h wchar.h wctype.h])
294 AC_CHECK_HEADERS([windows.h])
295 AC_CHECK_HEADERS([Bcrypt.h])
296 # check windows.h first; the other headers require it.
297 AC_CHECK_HEADERS([wincrypt.h winioctl.h],[],[],
298 [[#ifdef HAVE_WINDOWS_H
299 # include <windows.h>
303 # Checks for libraries.
305 AS_HELP_STRING([--without-zlib], [Don't build support for gzip through zlib]))
307 if test "x$with_zlib" != "xno"; then
308 AC_CHECK_HEADERS([zlib.h])
309 AC_CHECK_LIB(z,inflate)
312 AC_ARG_WITH([bz2lib],
313 AS_HELP_STRING([--without-bz2lib], [Don't build support for bzip2 through bz2lib]))
315 if test "x$with_bz2lib" != "xno"; then
316 AC_CHECK_HEADERS([bzlib.h])
318 *mingw* | *cygwin* | *msys*)
319 dnl AC_CHECK_LIB cannot be used on the Windows port of libbz2, therefore
320 dnl use AC_LINK_IFELSE.
321 AC_MSG_CHECKING([for BZ2_bzDecompressInit in -lbz2])
325 [AC_LANG_SOURCE(#include <bzlib.h>
326 int main() { return BZ2_bzDecompressInit(NULL, 0, 0); })],
327 [ac_cv_lib_bz2_BZ2_bzDecompressInit=yes],
328 [ac_cv_lib_bz2_BZ2_bzDecompressInit=no])
330 AC_MSG_RESULT($ac_cv_lib_bz2_BZ2_bzDecompressInit)
331 if test "x$ac_cv_lib_bz2_BZ2_bzDecompressInit" = xyes; then
332 AC_DEFINE([HAVE_LIBBZ2], [1], [Define to 1 if you have the `bz2' library (-lbz2).])
337 AC_CHECK_LIB(bz2,BZ2_bzDecompressInit)
343 AS_HELP_STRING([--without-iconv], [Don't try to link against iconv]))
345 if test "x$with_iconv" != "xno"; then
347 AC_CHECK_HEADERS([iconv.h],[],[],[#include <stdlib.h>])
348 if test "x$am_cv_func_iconv" = "xyes"; then
349 AC_CHECK_HEADERS([localcharset.h])
351 LIBS="${LIBS} ${LIBICONV}"
352 AC_CHECK_FUNCS([locale_charset])
353 LIBS="${am_save_LIBS}"
354 if test "x$ac_cv_func_locale_charset" != "xyes"; then
355 # If locale_charset() is not in libiconv, we have to find libcharset.
356 AC_CHECK_LIB(charset,locale_charset)
362 AS_HELP_STRING([--without-lz4], [Don't build support for lz4 through liblz4]))
364 if test "x$with_lz4" != "xno"; then
365 AC_CHECK_HEADERS([lz4.h lz4hc.h])
366 AC_CHECK_LIB(lz4,LZ4_decompress_safe)
370 AS_HELP_STRING([--without-lzma], [Don't build support for xz through lzma]))
372 if test "x$with_lzma" != "xno"; then
373 AC_CHECK_HEADERS([lzma.h])
374 AC_CHECK_LIB(lzma,lzma_stream_decoder)
375 # Some pre-release (but widely distributed) versions of liblzma
376 # included a disabled version of lzma_stream_encoder_mt that
377 # fools a naive AC_CHECK_LIB or AC_CHECK_FUNC, so we need
378 # to do something more complex here:
380 [whether we have multithread support in lzma],
383 AC_LANG_PROGRAM([[#include <lzma.h>]
384 [#if LZMA_VERSION < 50020000]
387 [[lzma_stream_encoder_mt(0, 0);]])],
388 [ac_cv_lzma_has_mt=yes], [ac_cv_lzma_has_mt=no])])
389 if test "x$ac_cv_lzma_has_mt" != xno; then
390 AC_DEFINE([HAVE_LZMA_STREAM_ENCODER_MT], [1], [Define to 1 if you have the `lzma_stream_encoder_mt' function.])
395 AS_HELP_STRING([--with-lzo2], [Build with LZO support from liblzo2]))
397 if test "x$with_lzo2" = "xyes"; then
398 AC_CHECK_HEADERS([lzo/lzoconf.h lzo/lzo1x.h])
399 AC_CHECK_LIB(lzo2,lzo1x_decompress_safe)
402 AC_ARG_WITH([nettle],
403 AS_HELP_STRING([--without-nettle], [Don't build with crypto support from Nettle]))
404 AC_ARG_WITH([openssl],
405 AS_HELP_STRING([--without-openssl], [Don't build support for mtree and xar hashes through openssl]))
407 *darwin* ) with_openssl=no ;;
411 AS_HELP_STRING([--without-xml2], [Don't build support for xar through libxml2]))
413 AS_HELP_STRING([--without-expat], [Don't build support for xar through expat]))
415 if test "x$with_xml2" != "xno"; then
417 PKG_CHECK_MODULES(LIBXML2_PC, [libxml-2.0], [
418 CPPFLAGS="${CPPFLAGS} ${LIBXML2_PC_CFLAGS}"
419 LIBS="${LIBS} ${LIBXML2_PC_LIBS}"
420 AC_CHECK_LIB(xml2,xmlInitParser,[true],AC_MSG_FAILURE(Missing xml2 library))
422 AC_CHECK_LIB(xml2,xmlInitParser)
424 AC_CHECK_HEADERS([libxml/xmlreader.h libxml/xmlwriter.h])
426 if test "x$ac_cv_header_libxml_xmlreader_h" != "xyes"; then
427 if test "x$with_expat" != "xno"; then
428 AC_CHECK_HEADERS([expat.h])
429 AC_CHECK_LIB(expat,XML_ParserCreate)
433 AC_ARG_ENABLE([posix-regex-lib],
434 [AS_HELP_STRING([--enable-posix-regex-lib],
435 [choose what library to use for POSIX regular expression support (default: auto)])
436 AS_HELP_STRING([--enable-posix-regex-lib=libc], [use libc POSIX regular expression support])
437 AS_HELP_STRING([--enable-posix-regex-lib=libregex], [use libregex POSIX regular expression support])
438 AS_HELP_STRING([--enable-posix-regex-lib=libpcreposix], [use libpcreposix POSIX regular expression support])
439 AS_HELP_STRING([--disable-posix-regex-lib], [don't enable POSIX regular expression support])],
440 [], [enable_posix_regex_lib=auto])
442 posix_regex_lib_found=
443 if test "$enable_posix_regex_lib" = "auto" || test "$enable_posix_regex_lib" = "libc" || test "$enable_posix_regex_lib" = "libregex"; then
444 AC_CHECK_HEADERS([regex.h])
445 if test "x$ac_cv_header_regex_h" != "xno"; then
446 AC_CHECK_FUNC(regcomp)
447 if test "x$ac_cv_func_regcomp" = xyes; then
448 posix_regex_lib_found=1
450 AC_CHECK_LIB(regex,regcomp)
451 if test "x$ac_cv_lib_regex_regcomp" = xyes; then
452 posix_regex_lib_found=1
457 if test -z $posix_regex_lib_found && (test "$enable_posix_regex_lib" = "auto" || test "$enable_posix_regex_lib" = "libpcreposix"); then
458 AC_CHECK_HEADERS([pcreposix.h])
459 AC_CHECK_LIB(pcreposix,regcomp)
460 if test "x$ac_cv_lib_pcreposix_regcomp" != xyes; then
461 AC_MSG_NOTICE(trying libpcreposix check again with libpcre)
462 unset ac_cv_lib_pcreposix_regcomp
463 AC_CHECK_LIB(pcre,pcre_exec)
464 AC_CHECK_LIB(pcreposix,regcomp)
465 if test "x$ac_cv_lib_pcre_pcre_exec" = xyes && test "x$ac_cv_lib_pcreposix_regcomp" = xyes; then
466 AC_MSG_CHECKING(if PCRE_STATIC needs to be defined)
468 [AC_LANG_SOURCE(#include <pcreposix.h>
469 int main() { return regcomp(NULL, NULL, 0); })],
470 [without_pcre_static=yes],
471 [without_pcre_static=no])
473 [AC_LANG_SOURCE(#define PCRE_STATIC
474 #include <pcreposix.h>
475 int main() { return regcomp(NULL, NULL, 0); })],
476 [with_pcre_static=yes],
477 [with_pcre_static=no])
478 if test "x$without_pcre_static" != xyes && test "x$with_pcre_static" = xyes; then
480 AC_DEFINE([PCRE_STATIC], [1], [Define to 1 if PCRE_STATIC needs to be defined.])
481 elif test "x$without_pcre_static" = xyes || test "x$with_pcre_static" = xyes; then
484 posix_regex_lib_found=1
487 posix_regex_lib_found=1
491 # TODO: Give the user the option of using a pre-existing system
492 # libarchive. This will define HAVE_LIBARCHIVE which will cause
493 # bsdtar_platform.h to use #include <...> for the libarchive headers.
494 # Need to include Makefile.am magic to link against system
495 # -larchive in that case.
496 #AC_CHECK_LIB(archive,archive_version)
498 # Checks for supported compiler flags
499 AX_APPEND_COMPILE_FLAGS([-Wall -Wformat -Wformat-security])
501 # Checks for typedefs, structures, and compiler characteristics.
503 # la_TYPE_UID_T defaults to "int", which is incorrect for MinGW
504 # and MSVC. Use a customized version.
507 # AC_TYPE_OFF_T defaults to "long", which limits us to 4GB files on
508 # most systems... default to "long long" instead.
509 AC_CHECK_TYPE(off_t, [long long])
511 AC_CHECK_TYPE(id_t, [unsigned long])
512 AC_CHECK_TYPE(uintptr_t, [unsigned int])
514 # Check for tm_gmtoff in struct tm
515 AC_CHECK_MEMBERS([struct tm.tm_gmtoff, struct tm.__tm_gmtoff],,,
520 # Check for f_namemax in struct statfs
521 AC_CHECK_MEMBERS([struct statfs.f_namemax],,,
523 #include <sys/param.h>
524 #include <sys/mount.h>
527 # Check for f_iosize in struct statvfs
528 AC_CHECK_MEMBERS([struct statvfs.f_iosize],,,
530 #include <sys/statvfs.h>
533 # Check for birthtime in struct stat
534 AC_CHECK_MEMBERS([struct stat.st_birthtime])
536 # Check for high-resolution timestamps in struct stat
537 AC_CHECK_MEMBERS([struct stat.st_birthtimespec.tv_nsec])
538 AC_CHECK_MEMBERS([struct stat.st_mtimespec.tv_nsec])
539 AC_CHECK_MEMBERS([struct stat.st_mtim.tv_nsec])
540 AC_CHECK_MEMBERS([struct stat.st_mtime_n]) # AIX
541 AC_CHECK_MEMBERS([struct stat.st_umtime]) # Tru64
542 AC_CHECK_MEMBERS([struct stat.st_mtime_usec]) # Hurd
543 # Check for block size support in struct stat
544 AC_CHECK_MEMBERS([struct stat.st_blksize])
545 # Check for st_flags in struct stat (BSD fflags)
546 AC_CHECK_MEMBERS([struct stat.st_flags])
548 # If you have uintmax_t, we assume printf supports %ju
549 # If you have unsigned long long, we assume printf supports %llu
550 # TODO: Check for %ju and %llu support directly.
551 AC_CHECK_TYPES([uintmax_t, unsigned long long])
553 # We use C99-style integer types
554 # Declare them if the local platform doesn't already do so.
565 AC_CHECK_DECLS([SIZE_MAX, INT32_MAX, INT32_MIN])
566 AC_CHECK_DECLS([INT64_MAX, INT64_MIN, UINT64_MAX, UINT32_MAX])
567 AC_CHECK_DECLS([INTMAX_MAX, INTMAX_MIN, UINTMAX_MAX])
569 AC_CHECK_DECL([SSIZE_MAX],
570 [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.])],
572 [#include <limits.h>])
574 AC_CHECK_DECL([EFTYPE],
575 [AC_DEFINE(HAVE_EFTYPE, 1, [A possible errno value for invalid file format errors])],
577 [#include <errno.h>])
578 AC_CHECK_DECL([EILSEQ],
579 [AC_DEFINE(HAVE_EILSEQ, 1, [A possible errno value for invalid file format errors])],
581 [#include <errno.h>])
582 AC_CHECK_TYPE([wchar_t],
583 [AC_DEFINE_UNQUOTED(AS_TR_CPP(HAVE_[]wchar_t), 1, [Define to 1 if the system has the type `wchar_t'.])dnl
584 AC_CHECK_SIZEOF([wchar_t])],
589 # Checks for library functions.
590 AC_PROG_GCC_TRADITIONAL
600 # CreateHardLinkA(LPCSTR, LPCSTR, LPSECURITY_ATTRIBUTES)
601 # To avoid necessity for including windows.h or special forward declaration
602 # workarounds, we use 'void *' for 'struct SECURITY_ATTRIBUTES *'
603 AC_CHECK_STDCALL_FUNC([CreateHardLinkA],[const char *, const char *, void *])
604 AC_CHECK_FUNCS([arc4random_buf chflags chown chroot ctime_r dirfd])
605 AC_CHECK_FUNCS([fchdir fchflags fchmod fchown fcntl fdopendir fork])
606 AC_CHECK_FUNCS([fstat fstatat fstatfs fstatvfs ftruncate])
607 AC_CHECK_FUNCS([futimens futimes futimesat])
608 AC_CHECK_FUNCS([geteuid getpid getgrgid_r getgrnam_r])
609 AC_CHECK_FUNCS([getpwnam_r getpwuid_r getvfsbyname gmtime_r])
610 AC_CHECK_FUNCS([lchflags lchmod lchown link localtime_r lstat lutimes])
611 AC_CHECK_FUNCS([mbrtowc memmove memset])
612 AC_CHECK_FUNCS([mkdir mkfifo mknod mkstemp])
613 AC_CHECK_FUNCS([nl_langinfo openat pipe poll posix_spawnp readlink readlinkat])
614 AC_CHECK_FUNCS([readpassphrase])
615 AC_CHECK_FUNCS([select setenv setlocale sigaction statfs statvfs])
616 AC_CHECK_FUNCS([strchr strdup strerror strncpy_s strrchr symlink timegm])
617 AC_CHECK_FUNCS([tzset unsetenv utime utimensat utimes vfork])
618 AC_CHECK_FUNCS([wcrtomb wcscmp wcscpy wcslen wctomb wmemcmp wmemcpy wmemmove])
619 AC_CHECK_FUNCS([_ctime64_s _fseeki64])
620 AC_CHECK_FUNCS([_get_timezone _localtime64_s _mkgmtime64])
621 # detects cygwin-1.7, as opposed to older versions
622 AC_CHECK_FUNCS([cygwin_conv_path])
624 # DragonFly uses vfsconf, FreeBSD xvfsconf.
625 AC_CHECK_TYPES(struct vfsconf,,,
626 [#if HAVE_SYS_TYPES_H
627 #include <sys/types.h>
629 #include <sys/mount.h>
632 AC_CHECK_TYPES(struct xvfsconf,,,
633 [#if HAVE_SYS_TYPES_H
634 #include <sys/types.h>
636 #include <sys/mount.h>
639 # There are several variants of readdir_r around; we only
640 # accept the POSIX-compliant version.
642 [AC_LANG_PROGRAM([[#include <dirent.h>]],
643 [[DIR *dir; struct dirent e, *r;
644 return(readdir_r(dir, &e, &r));]])],
645 [AC_DEFINE(HAVE_READDIR_R,1,[Define to 1 if you have a POSIX compatible readdir_r])]
648 # FreeBSD's nl_langinfo supports an option to specify whether the
649 # current locale uses month/day or day/month ordering. It makes the
650 # output a little prettier...
651 AC_CHECK_DECL([D_MD_ORDER],
652 [AC_DEFINE(HAVE_D_MD_ORDER, 1, [Define to 1 if nl_langinfo supports D_MD_ORDER])],
655 #include <langinfo.h>
659 # Check for dirent.d_namlen field explicitly
660 # (This is a bit more straightforward than, if not quite as portable as,
661 # the recipe given by the autoconf maintainers.)
662 AC_CHECK_MEMBER(struct dirent.d_namlen,,,
668 # Check for Extended Attributes support
669 AC_ARG_ENABLE([xattr],
670 AS_HELP_STRING([--disable-xattr],
671 [Disable Extended Attributes support (default: check)]))
673 if test "x$enable_xattr" != "xno"; then
674 AC_CHECK_HEADERS([attr/xattr.h])
675 AC_CHECK_HEADERS([sys/xattr.h sys/ea.h])
676 AC_SEARCH_LIBS([setxattr], [attr])
677 AC_CHECK_FUNCS([extattr_get_file extattr_list_file])
678 AC_CHECK_FUNCS([extattr_set_fd extattr_set_file])
679 AC_CHECK_FUNCS([fgetxattr flistxattr fsetxattr getxattr])
680 AC_CHECK_FUNCS([lgetxattr listxattr llistxattr lsetxattr])
681 AC_CHECK_FUNCS([fgetea flistea fsetea getea])
682 AC_CHECK_FUNCS([lgetea listea llistea lsetea])
683 AC_CHECK_DECLS([EXTATTR_NAMESPACE_USER], [], [], [#include <sys/types.h>
684 #include <sys/extattr.h>
688 # Check for ACL support
690 # The ACL support in libarchive is written against the POSIX1e draft,
691 # which was never officially approved and varies quite a bit across
692 # platforms. Worse, some systems have completely non-POSIX acl functions,
693 # which makes the following checks rather more complex than I would like.
696 AS_HELP_STRING([--disable-acl],
697 [Disable ACL support (default: check)]))
699 if test "x$enable_acl" != "xno"; then
700 AC_CHECK_HEADERS([acl/libacl.h])
701 AC_CHECK_HEADERS([sys/acl.h])
702 AC_CHECK_LIB([acl],[acl_get_file])
703 AC_CHECK_FUNCS([acl_create_entry acl_get_fd_np])
704 AC_CHECK_FUNCS([acl_init acl_set_fd acl_set_fd_np acl_set_file])
706 AC_CHECK_TYPES(acl_permset_t,,,
707 [#if HAVE_SYS_TYPES_H
708 #include <sys/types.h>
715 # The "acl_get_perm()" function was omitted from the POSIX draft.
716 # (It's a pretty obvious oversight; otherwise, there's no way to
717 # test for specific permissions in a permset.) Linux uses the obvious
718 # name, FreeBSD adds _np to mark it as "non-Posix extension."
719 # Test for both as a double-check that we really have POSIX-style ACL
721 AC_CHECK_FUNCS(acl_get_perm_np acl_get_perm acl_get_link acl_get_link_np,,,
722 [#if HAVE_SYS_TYPES_H
723 #include <sys/types.h>
730 # Check for acl_is_trivial_np on FreeBSD
731 AC_CHECK_FUNCS(acl_is_trivial_np,,,
732 [#if HAVE_SYS_TYPES_H
733 #include <sys/types.h>
740 # Check for ACL_TYPE_NFS4
741 AC_CHECK_DECL([ACL_TYPE_NFS4],
742 [AC_DEFINE(HAVE_ACL_TYPE_NFS4, 1, [True for FreeBSD with NFSv4 ACL support])],
744 [#include <sys/acl.h>])
746 # MacOS has an acl.h that isn't POSIX. It can be detected by
747 # checking for ACL_USER
748 AC_CHECK_DECL([ACL_USER],
749 [AC_DEFINE(HAVE_ACL_USER, 1, [True for systems with POSIX ACL support])],
751 [#include <sys/acl.h>])
753 # MacOS has ACL_TYPE_EXTENDED instead
754 AC_CHECK_DECL([ACL_TYPE_EXTENDED],
755 [AC_DEFINE(HAVE_ACL_TYPE_EXTENDED, 1, [True for MacOS ACL support])],
757 [#include <sys/types.h>
758 #include <sys/acl.h>])
760 # Solaris and derivates ACLs
761 AC_CHECK_LIB([sec], [acl_get])
762 AC_CHECK_TYPES([aclent_t], [], [], [[#include <sys/acl.h>]])
763 AC_CHECK_TYPES([ace_t], [], [], [[#include <sys/acl.h>]])
764 AC_CHECK_FUNCS(acl_get facl_get acl_set facl_set)
767 # Additional requirements
770 dnl NOTE: Crypto checks must run last.
771 AC_DEFUN([CRYPTO_CHECK], [
772 if test "$found_$1" != yes; then
773 saved_CPPFLAGS="$CPPFLAGS"
774 CPPFLAGS="$CPPFLAGS -I. -I$srcdir -I$srcdir/libarchive"
775 touch "check_crypto_md.h"
776 AC_MSG_CHECKING([support for ARCHIVE_CRYPTO_$1_$2])
777 AC_LINK_IFELSE([AC_LANG_SOURCE([
778 #define ARCHIVE_$1_COMPILE_TEST
779 #define ARCHIVE_CRYPTO_$1_$2
780 #define PLATFORM_CONFIG_H "check_crypto_md.h"
782 $(cat "$srcdir/libarchive/archive_digest.c")
785 main(int argc, char **argv)
788 archive_$3_init(&ctx);
789 archive_$3_update(&ctx, *argv, argc);
790 archive_$3_final(&ctx, NULL);
794 [ AC_MSG_RESULT([yes])
797 AC_DEFINE(ARCHIVE_CRYPTO_$1_$2, 1, [ $1 via ARCHIVE_CRYPTO_$1_$2 supported.])
799 [ AC_MSG_RESULT([no])])
800 CPPFLAGS="$saved_CPPFLAGS"
801 rm "check_crypto_md.h"
805 AC_DEFUN([CRYPTO_CHECK_WIN], [
806 if test "$found_$1" != yes; then
807 AC_MSG_CHECKING([support for ARCHIVE_CRYPTO_$1_WIN])
808 AC_LINK_IFELSE([AC_LANG_SOURCE([
809 #define ARCHIVE_$1_COMPILE_TEST
811 #include <wincrypt.h>
814 main(int argc, char **argv)
822 [ AC_MSG_RESULT([yes])
825 AC_DEFINE(ARCHIVE_CRYPTO_$1_WIN, 1, [ $1 via ARCHIVE_CRYPTO_$1_WIN supported.])
827 [ AC_MSG_RESULT([no])])
832 *mingw* | *cygwin* | *msys*)
835 CRYPTO_CHECK(MD5, LIBC, md5)
836 CRYPTO_CHECK(MD5, LIBSYSTEM, md5)
837 CRYPTO_CHECK(RMD160, LIBC, rmd160)
838 CRYPTO_CHECK(SHA1, LIBC, sha1)
839 CRYPTO_CHECK(SHA1, LIBSYSTEM, sha1)
840 CRYPTO_CHECK(SHA256, LIBC, sha256)
841 CRYPTO_CHECK(SHA256, LIBC2, sha256)
842 CRYPTO_CHECK(SHA256, LIBC3, sha256)
843 CRYPTO_CHECK(SHA256, LIBSYSTEM, sha256)
844 CRYPTO_CHECK(SHA384, LIBC, sha384)
845 CRYPTO_CHECK(SHA384, LIBC2, sha384)
846 CRYPTO_CHECK(SHA384, LIBC3, sha384)
847 CRYPTO_CHECK(SHA384, LIBSYSTEM, sha384)
848 CRYPTO_CHECK(SHA512, LIBC, sha512)
849 CRYPTO_CHECK(SHA512, LIBC2, sha512)
850 CRYPTO_CHECK(SHA512, LIBC3, sha512)
851 CRYPTO_CHECK(SHA512, LIBSYSTEM, sha512)
855 if test "x$with_nettle" != "xno"; then
856 AC_CHECK_HEADERS([nettle/md5.h nettle/ripemd160.h nettle/sha.h])
857 AC_CHECK_HEADERS([nettle/pbkdf2.h nettle/aes.h nettle/hmac.h])
859 AC_CHECK_LIB(nettle,nettle_sha1_init)
860 CRYPTO_CHECK(MD5, NETTLE, md5)
861 CRYPTO_CHECK(RMD160, NETTLE, rmd160)
862 CRYPTO_CHECK(SHA1, NETTLE, sha1)
863 CRYPTO_CHECK(SHA256, NETTLE, sha256)
864 CRYPTO_CHECK(SHA384, NETTLE, sha384)
865 CRYPTO_CHECK(SHA512, NETTLE, sha512)
866 if test "x$found_NETTLE" != "xyes"; then
871 if test "x$with_openssl" != "xno"; then
872 AC_CHECK_HEADERS([openssl/evp.h])
875 *mingw* | *cygwin* | *msys*)
878 AC_CHECK_LIB(eay64,OPENSSL_config)
879 if test "x$ac_cv_lib_eay64_main" != "xyes"; then
880 AC_CHECK_LIB(eay32,OPENSSL_config)
884 AC_CHECK_LIB(eay32,OPENSSL_config)
889 AC_CHECK_LIB(crypto,OPENSSL_config)
892 CRYPTO_CHECK(MD5, OPENSSL, md5)
893 CRYPTO_CHECK(RMD160, OPENSSL, rmd160)
894 CRYPTO_CHECK(SHA1, OPENSSL, sha1)
895 CRYPTO_CHECK(SHA256, OPENSSL, sha256)
896 CRYPTO_CHECK(SHA384, OPENSSL, sha384)
897 CRYPTO_CHECK(SHA512, OPENSSL, sha512)
898 if test "x$found_OPENSSL" != "xyes"; then
901 AC_CHECK_FUNCS([PKCS5_PBKDF2_HMAC_SHA1])
903 AC_CHECK_LIB(crypto,EVP_CIPHER_CTX_init)
906 # Probe libmd AFTER OpenSSL/libcrypto.
907 # The two are incompatible and OpenSSL is more complete.
908 AC_CHECK_HEADERS([md5.h ripemd.h sha.h sha256.h sha512.h])
910 AC_CHECK_LIB(md,MD5Init)
911 CRYPTO_CHECK(MD5, LIBMD, md5)
912 CRYPTO_CHECK(RMD160, LIBMD, rmd160)
913 CRYPTO_CHECK(SHA1, LIBMD, sha1)
914 CRYPTO_CHECK(SHA256, LIBMD, sha256)
915 CRYPTO_CHECK(SHA512, LIBMD, sha512)
916 if test "x$found_LIBMD" != "xyes"; then
921 *mingw* | *cygwin* | *msys*)
922 CRYPTO_CHECK_WIN(MD5, CALG_MD5)
923 CRYPTO_CHECK_WIN(SHA1, CALG_SHA1)
924 CRYPTO_CHECK_WIN(SHA256, CALG_SHA_256)
925 CRYPTO_CHECK_WIN(SHA384, CALG_SHA_384)
926 CRYPTO_CHECK_WIN(SHA512, CALG_SHA_512)
930 # Ensure test directories are present if building out-of-tree
931 AC_CONFIG_COMMANDS([mkdirs],
932 [mkdir -p libarchive/test tar/test cat/test cpio/test])