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],[2.8.5])
8 m4_define([LIBARCHIVE_VERSION_N],[2008005])
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())
15 # Now starts the "real" configure script.
18 AC_INIT([libarchive],LIBARCHIVE_VERSION_S(),[kientzle@freebsd.org])
19 # Make sure the srcdir contains "libarchive" directory
20 AC_CONFIG_SRCDIR([libarchive])
21 # Use auxiliary subscripts from this subdirectory (cleans up root)
22 AC_CONFIG_AUX_DIR([build/autoconf])
24 AC_CONFIG_MACRO_DIR([build/autoconf])
25 # Must follow AC_CONFIG macros above...
28 # Libtool versioning uses different conventions on different
29 # platforms. At least on FreeBSD, libtool uses an overly complex
30 # convention that attempts to solve problems that most people just
31 # don't have and which just causes confusion for most end users.
32 ARCHIVE_MAJOR=$(( LIBARCHIVE_VERSION_N() / 1000000 ))
33 ARCHIVE_MINOR=$(( (LIBARCHIVE_VERSION_N() / 1000) % 1000 ))
34 ARCHIVE_REVISION=$(( LIBARCHIVE_VERSION_N() % 1000 ))
35 ARCHIVE_LIBTOOL_MAJOR=`echo $((${ARCHIVE_MAJOR} + ${ARCHIVE_MINOR}))`
36 ARCHIVE_LIBTOOL_VERSION=$ARCHIVE_LIBTOOL_MAJOR:$ARCHIVE_REVISION:$ARCHIVE_MINOR
38 # Stick the version numbers into config.h
39 AC_DEFINE([LIBARCHIVE_VERSION_STRING],"LIBARCHIVE_VERSION_S()",
40 [Version number of libarchive])
41 AC_DEFINE_UNQUOTED([LIBARCHIVE_VERSION_NUMBER],"LIBARCHIVE_VERSION_N()",
42 [Version number of libarchive as a single integer])
43 AC_DEFINE([BSDCPIO_VERSION_STRING],"BSDCPIO_VERSION_S()",
44 [Version number of bsdcpio])
45 AC_DEFINE([BSDTAR_VERSION_STRING],"BSDTAR_VERSION_S()",
46 [Version number of bsdtar])
48 # The shell variables here must be the same as the AC_SUBST() variables
49 # below, but the shell variable names apparently cannot be the same as
50 # the m4 macro names above. Why? Ask autoconf.
51 BSDCPIO_VERSION_STRING=BSDCPIO_VERSION_S()
52 BSDTAR_VERSION_STRING=BSDTAR_VERSION_S()
53 LIBARCHIVE_VERSION_STRING=LIBARCHIVE_VERSION_S()
54 LIBARCHIVE_VERSION_NUMBER=LIBARCHIVE_VERSION_N()
56 # Substitute the above version numbers into the various files below.
57 # Yes, I believe this is the fourth time we define what are essentially
58 # the same symbols. Why? Ask autoconf.
59 AC_SUBST(ARCHIVE_LIBTOOL_VERSION)
60 AC_SUBST(BSDCPIO_VERSION_STRING)
61 AC_SUBST(BSDTAR_VERSION_STRING)
62 AC_SUBST(LIBARCHIVE_VERSION_STRING)
63 AC_SUBST(LIBARCHIVE_VERSION_NUMBER)
65 AC_CONFIG_HEADERS([config.h])
66 AC_CONFIG_FILES([Makefile])
67 AC_CONFIG_FILES([build/pkgconfig/libarchive.pc])
72 dnl Compilation on mingw and Cygwin needs special Makefile rules
76 *mingw* ) inc_windows_files=yes ;;
77 *cygwin*) inc_cygwin_files=yes ;;
79 AM_CONDITIONAL([INC_WINDOWS_FILES], [test $inc_windows_files = yes])
80 AM_CONDITIONAL([INC_CYGWIN_FILES], [test $inc_cygwin_files = yes])
82 dnl Defines that are required for specific platforms (e.g. -D_POSIX_SOURCE, etc)
85 *mingw* ) PLATFORMCPPFLAGS=-D__USE_MINGW_ANSI_STDIO ;;
87 AC_SUBST(PLATFORMCPPFLAGS)
89 # Checks for programs.
92 AC_USE_SYSTEM_EXTENSIONS
95 AC_CHECK_TOOL([STRIP],[strip])
98 # Options for building bsdtar.
100 # Default is to build bsdtar, but allow people to override that.
102 AC_ARG_ENABLE([bsdtar],
103 [AS_HELP_STRING([--enable-bsdtar], [enable build of bsdtar (default)])
104 AS_HELP_STRING([--enable-bsdtar=static], [force static build of bsdtar])
105 AS_HELP_STRING([--enable-bsdtar=shared], [force dynamic build of bsdtar])
106 AS_HELP_STRING([--disable-bsdtar], [disable build of bsdtar])],
107 [], [enable_bsdtar=yes])
109 case "$enable_bsdtar" in
111 if test "$enable_static" = "no"; then
119 if test "$enable_shared" = "no"; then
120 AC_MSG_FAILURE([Shared linking of bsdtar requires shared libarchive])
134 AC_MSG_FAILURE([Unsupported value for --enable-bsdtar])
138 AM_CONDITIONAL([BUILD_BSDTAR], [ test "$build_bsdtar" = yes ])
139 AM_CONDITIONAL([STATIC_BSDTAR], [ test "$static_bsdtar" = yes ])
142 # Options for building bsdcpio.
144 # Default is not to build bsdcpio, but that can be overridden.
146 AC_ARG_ENABLE([bsdcpio],
147 [AS_HELP_STRING([--enable-bsdcpio], [enable build of bsdcpio (default)])
148 AS_HELP_STRING([--enable-bsdcpio=static], [static build of bsdcpio])
149 AS_HELP_STRING([--enable-bsdcpio=shared], [dynamic build of bsdcpio])
150 AS_HELP_STRING([--disable-bsdcpio], [disable build of bsdcpio])],
151 [], [enable_bsdcpio=yes])
153 case "$enable_bsdcpio" in
155 if test "$enable_static" = "no"; then
163 if test "$enabled_shared" = "no"; then
164 AC_MSG_FAILURE([Shared linking of bsdcpio requires shared libarchive])
177 AC_MSG_FAILURE([Unsupported value for --enable-bsdcpio])
181 AM_CONDITIONAL([BUILD_BSDCPIO], [ test "$build_bsdcpio" = yes ])
182 AM_CONDITIONAL([STATIC_BSDCPIO], [ test "$static_bsdcpio" = yes ])
184 # Set up defines needed before including any headers
187 AC_DEFINE([_WIN32_WINNT], 0x0500, [Define to '0x0500' for Windows 2000 APIs.])
188 AC_DEFINE([WINVER], 0x0500, [Define to '0x0500' for Windows 2000 APIs.])
192 # Checks for header files.
195 AC_CHECK_HEADERS([acl/libacl.h attr/xattr.h ctype.h errno.h])
196 AC_CHECK_HEADERS([ext2fs/ext2_fs.h fcntl.h grp.h])
197 AC_CHECK_HEADERS([inttypes.h io.h langinfo.h limits.h linux/fs.h])
198 AC_CHECK_HEADERS([locale.h paths.h poll.h pwd.h regex.h signal.h stdarg.h])
199 AC_CHECK_HEADERS([stdint.h stdlib.h string.h])
200 AC_CHECK_HEADERS([sys/acl.h sys/cdefs.h sys/extattr.h sys/ioctl.h sys/mkdev.h])
201 AC_CHECK_HEADERS([sys/param.h sys/poll.h sys/select.h sys/time.h sys/utime.h])
202 AC_CHECK_HEADERS([time.h unistd.h utime.h wchar.h wctype.h windows.h])
204 # Checks for libraries.
206 AS_HELP_STRING([--without-zlib], [Don't build support for gzip through zlib]))
208 if test "x$with_zlib" != "xno"; then
209 AC_CHECK_HEADERS([zlib.h])
210 AC_CHECK_LIB(z,inflate)
213 AC_ARG_WITH([bz2lib],
214 AS_HELP_STRING([--without-bz2lib], [Don't build support for bzip2 through bz2lib]))
216 if test "x$with_bz2lib" != "xno"; then
217 AC_CHECK_HEADERS([bzlib.h])
218 AC_CHECK_LIB(bz2,BZ2_bzDecompressInit)
221 AC_ARG_WITH([lzmadec],
222 AS_HELP_STRING([--without-lzmadec], [Don't build support for lzma through lzmadec]))
224 if test "x$with_lzmadec" != "xno"; then
225 AC_CHECK_HEADERS([lzmadec.h])
226 AC_CHECK_LIB(lzmadec,lzmadec_decode)
230 AS_HELP_STRING([--without-lzma], [Don't build support for xz through lzma]))
232 if test "x$with_lzma" != "xno"; then
233 AC_CHECK_HEADERS([lzma.h])
234 AC_CHECK_LIB(lzma,lzma_stream_decoder)
237 AC_ARG_WITH([openssl],
238 AS_HELP_STRING([--without-openssl], [Don't build support for mtree and xar hashes through openssl]))
241 AS_HELP_STRING([--without-xml2], [Don't build support for xar through libxml2]))
243 AS_HELP_STRING([--without-expat], [Don't build support for xar through expat]))
245 if test "x$with_xml2" != "xno"; then
246 AC_PATH_PROG([XML2_CONFIG], [xml2-config],, [${PATH}])
247 if test "x$XML2_CONFIG" != "x"; then
248 CPPFLAGS="${CPPFLAGS} `${XML2_CONFIG} --cflags`"
249 LIBS="${LIBS} `${XML2_CONFIG} --libs`"
251 AC_CHECK_HEADERS([libxml/xmlreader.h])
252 AC_CHECK_LIB(xml2,xmlInitParser)
254 if test "x$ac_cv_header_libxml_xmlreader_h" != "xyes"; then
255 if test "x$with_expat" != "xno"; then
256 AC_CHECK_HEADERS([expat.h])
257 AC_CHECK_LIB(expat,XML_ParserCreate)
261 AC_DEFUN([MD_CHECK], [
262 if test "$found_$1" != yes; then
264 saved_CPPFLAGS="$CPPFLAGS"
265 CPPFLAGS="$CPPFLAGS -I$srcdir/libarchive"
266 if test $ac_cv_header_sys_types_h = yes; then
267 CPPFLAGS="$CPPFLAGS -DHAVE_SYS_TYPES_H=1"
270 AC_MSG_CHECKING([support for ARCHIVE_HASH_$1_$2])
272 #define $1_COMPILE_TEST
273 #define ARCHIVE_HASH_$1_$2
274 #define __LIBARCHIVE_BUILD
275 #include "archive_hash.h"
278 main(int argc, char **argv)
282 archive_$3_init(&ctx);
283 archive_$3_update(&ctx, *argv, argc);
284 archive_$3_final(&ctx, *argv);
288 [ AC_MSG_RESULT([yes])
291 AC_DEFINE(ARCHIVE_HASH_$1_$2, 1, [ $1 via ARCHIVE_HASH_$1_$2 supported.])
293 [ AC_MSG_RESULT([no])])
295 CPPFLAGS="$saved_CPPFLAGS"
299 MD_CHECK(MD5, LIBC, md5)
300 MD_CHECK(MD5, LIBSYSTEM, md5)
301 MD_CHECK(RMD160, LIBC, rmd160)
302 MD_CHECK(SHA1, LIBC, sha1)
303 MD_CHECK(SHA1, LIBSYSTEM, sha1)
304 MD_CHECK(SHA256, LIBC, sha256)
305 MD_CHECK(SHA256, LIBC2, sha256)
306 MD_CHECK(SHA256, LIBC3, sha256)
307 MD_CHECK(SHA256, LIBSYSTEM, sha256)
308 MD_CHECK(SHA384, LIBC, sha384)
309 MD_CHECK(SHA384, LIBC2, sha384)
310 MD_CHECK(SHA384, LIBC3, sha384)
311 MD_CHECK(SHA384, LIBSYSTEM, sha384)
312 MD_CHECK(SHA512, LIBC, sha512)
313 MD_CHECK(SHA512, LIBC2, sha512)
314 MD_CHECK(SHA512, LIBC3, sha512)
315 MD_CHECK(SHA512, LIBSYSTEM, sha512)
317 if test "x$with_openssl" != "xno"; then
318 MD_CHECK(MD5, OPENSSL, md5, -lcrypto)
319 MD_CHECK(RMD160, OPENSSL, rmd160, -lcrypto)
320 MD_CHECK(SHA1, OPENSSL, sha1, -lcrypto)
321 MD_CHECK(SHA256, OPENSSL, sha256, -lcrypto)
322 MD_CHECK(SHA384, OPENSSL, sha384, -lcrypto)
323 MD_CHECK(SHA512, OPENSSL, sha512, -lcrypto)
327 # TODO: Give the user the option of using a pre-existing system
328 # libarchive. This will define HAVE_LIBARCHIVE which will cause
329 # bsdtar_platform.h to use #include <...> for the libarchive headers.
330 # Need to include Makefile.am magic to link against system
331 # -larchive in that case.
332 #AC_CHECK_LIB(archive,archive_version)
334 # Checks for typedefs, structures, and compiler characteristics.
336 # AC_TYPE_UID_T defaults to "int", which is incorrect for MinGW
337 # and MSVC. Use a customized version.
340 # AC_TYPE_OFF_T defaults to "long", which limits us to 4GB files on
341 # most systems... default to "long long" instead.
342 AC_CHECK_TYPE(off_t, [long long])
344 AC_CHECK_TYPE(id_t, [unsigned long])
345 AC_CHECK_TYPE(uintptr_t, [unsigned int])
347 # Check for birthtime in struct stat
348 AC_CHECK_MEMBERS([struct stat.st_birthtime])
350 # Check for high-resolution timestamps in struct stat
351 AC_CHECK_MEMBERS([struct stat.st_birthtimespec.tv_nsec])
352 AC_CHECK_MEMBERS([struct stat.st_mtimespec.tv_nsec])
353 AC_CHECK_MEMBERS([struct stat.st_mtim.tv_nsec])
354 AC_CHECK_MEMBERS([struct stat.st_mtime_n]) # AIX
355 AC_CHECK_MEMBERS([struct stat.st_umtime]) # Tru64
356 AC_CHECK_MEMBERS([struct stat.st_mtime_usec]) # Hurd
357 # Check for block size support in struct stat
358 AC_CHECK_MEMBERS([struct stat.st_blksize])
359 # Check for st_flags in struct stat (BSD fflags)
360 AC_CHECK_MEMBERS([struct stat.st_flags])
362 # If you have uintmax_t, we assume printf supports %ju
363 # If you have unsigned long long, we assume printf supports %llu
364 # TODO: Check for %ju and %llu support directly.
365 AC_CHECK_TYPES([uintmax_t, unsigned long long])
367 # We need int64_t, uint64_t, intmax_t, and uintmax_t
373 # TODO: If any of these are missing, define them right here.
374 AC_CHECK_DECLS([SIZE_MAX, SSIZE_MAX, INT64_MAX, INT64_MIN, UINT64_MAX, UINT32_MAX])
376 AC_CHECK_DECL([EFTYPE],
377 [AC_DEFINE(HAVE_EFTYPE, 1, [A possible errno value for invalid file format errors])],
379 [#include <errno.h>])
380 AC_CHECK_DECL([EILSEQ],
381 [AC_DEFINE(HAVE_EILSEQ, 1, [A possible errno value for invalid file format errors])],
383 [#include <errno.h>])
384 AC_CHECK_TYPE([wchar_t],
385 [AC_DEFINE_UNQUOTED(AS_TR_CPP(HAVE_[]wchar_t), 1, [Define to 1 if the system has the type `wchar_t'.])dnl
386 AC_CHECK_SIZEOF([wchar_t])],
391 # Checks for library functions.
392 AC_PROG_GCC_TRADITIONAL
402 # CreateHardLinkA(LPCSTR, LPCSTR, LPSECURITY_ATTRIBUTES)
403 # To avoid necessity for including windows.h or special forward declaration
404 # workarounds, we use 'void *' for 'struct SECURITY_ATTRIBUTES *'
405 AC_CHECK_STDCALL_FUNC([CreateHardLinkA],[const char *, const char *, void *])
406 AC_CHECK_FUNCS([chflags chown chroot])
407 AC_CHECK_FUNCS([fchdir fchflags fchmod fchown fcntl fork])
408 AC_CHECK_FUNCS([fstat ftruncate futimens futimes geteuid getpid])
409 AC_CHECK_FUNCS([getgrgid_r getgrnam_r getpwnam_r getpwuid_r ])
410 AC_CHECK_FUNCS([lchflags lchmod lchown link lstat])
411 AC_CHECK_FUNCS([lutimes memmove memset mkdir mkfifo mknod])
412 AC_CHECK_FUNCS([nl_langinfo pipe poll readlink])
413 AC_CHECK_FUNCS([select setenv setlocale sigaction])
414 AC_CHECK_FUNCS([strchr strdup strerror strncpy_s strrchr symlink timegm])
415 AC_CHECK_FUNCS([tzset unsetenv utime utimensat utimes vfork])
416 AC_CHECK_FUNCS([wcrtomb wcscmp wcscpy wcslen wctomb wmemcmp wmemcpy])
417 # detects cygwin-1.7, as opposed to older versions
418 AC_CHECK_FUNCS([cygwin_conv_path])
420 # FreeBSD's nl_langinfo supports an option to specify whether the
421 # current locale uses month/day or day/month ordering. It makes the
422 # output a little prettier...
423 AC_CHECK_DECL([D_MD_ORDER],
424 [AC_DEFINE(HAVE_D_MD_ORDER, 1, [Define to 1 if nl_langinfo supports D_MD_ORDER])],
427 #include <langinfo.h>
431 # Check for dirent.d_namlen field explicitly
432 # (This is a bit more straightforward than, if not quite as portable as,
433 # the recipe given by the autoconf maintainers.)
434 AC_CHECK_MEMBER(struct dirent.d_namlen,,,
440 # Check for Extended Attributes support
441 AC_ARG_ENABLE([xattr],
442 AS_HELP_STRING([--disable-xattr],
443 [Enable Extended Attributes support (default: check)]))
445 if test "x$enable_xattr" != "xno"; then
446 AC_CHECK_HEADERS([attr/xattr.h])
447 AC_CHECK_HEADERS([sys/xattr.h])
448 AC_CHECK_LIB(attr,setxattr)
449 AC_CHECK_FUNCS([extattr_get_file extattr_list_file])
450 AC_CHECK_FUNCS([extattr_set_fd extattr_set_file])
451 AC_CHECK_FUNCS([fsetxattr getxattr])
452 AC_CHECK_FUNCS([lgetxattr listxattr llistxattr lsetxattr])
453 AC_CHECK_DECLS([EXTATTR_NAMESPACE_USER], [], [], [#include <sys/types.h>
454 #include <sys/extattr.h>
458 # Check for ACL support
460 # The ACL support in libarchive is written against the POSIX1e draft,
461 # which was never officially approved and varies quite a bit across
462 # platforms. Worse, some systems have completely non-POSIX acl functions,
463 # which makes the following checks rather more complex than I would like.
466 AS_HELP_STRING([--disable-acl],
467 [Enable ACL support (default: check)]))
469 if test "x$enable_acl" != "xno"; then
470 AC_CHECK_HEADERS([sys/acl.h])
471 AC_CHECK_LIB([acl],[acl_get_file])
472 AC_CHECK_FUNCS([acl_create_entry acl_init acl_set_fd acl_set_fd_np acl_set_file])
474 AC_CHECK_TYPES(acl_permset_t,,,
475 [#if HAVE_SYS_TYPES_H
476 #include <sys/types.h>
483 # The "acl_get_perm()" function was omitted from the POSIX draft.
484 # (It's a pretty obvious oversight; otherwise, there's no way to
485 # test for specific permissions in a permset.) Linux uses the obvious
486 # name, FreeBSD adds _np to mark it as "non-Posix extension."
487 # Test for both as a double-check that we really have POSIX-style ACL support.
488 AC_CHECK_FUNCS(acl_get_perm_np acl_get_perm acl_get_link acl_get_link_np,,,
489 [#if HAVE_SYS_TYPES_H
490 #include <sys/types.h>
497 # MacOS has an acl.h that isn't POSIX. It can be detected by
498 # checking for ACL_USER
499 AC_CHECK_DECL([ACL_USER],
500 [AC_DEFINE(HAVE_ACL_USER, 1, [True for systems with POSIX ACL support])],
502 [#include <sys/acl.h>])
505 # Additional requirements