[Cmake-commits] [cmake-commits] hoffman committed CMakeLists.txt NONE 1.1 COPYING NONE 1.1 INSTALL NONE 1.1 Makefile.am NONE 1.1 NEWS NONE 1.1 README NONE 1.1 configure.ac NONE 1.1

cmake-commits at cmake.org cmake-commits at cmake.org
Fri Oct 30 13:09:11 EDT 2009


Update of /cvsroot/CMake/CMake/Utilities/cmlibarchive
In directory public:/mounts/ram/cvs-serv26614/Utilities/cmlibarchive

Added Files:
	CMakeLists.txt COPYING INSTALL Makefile.am NEWS README 
	configure.ac 
Log Message:
Switch to using libarchive from libtar for cpack and cmake -E tar

This allows for a built in bzip and zip capability, so external tools 
will not be needed for these packagers.  The cmake -E tar xf should be
able to handle all compression types now as well.



--- NEW FILE: INSTALL ---
More complete build documentation is available on the libarchive
Wiki:  http://libarchive.googlecode.com/

On most Unix-like systems, you should be able to install libarchive,
bsdtar, and bsdcpio using the following common steps:
    ./configure
    make
    make install

If you need to customize the target directories or otherwise adjust
the build setting, use
    ./configure --help
to list the configure options.

If you are developing libarchive and need to update the
configure script and other build files:
    /bin/sh build/autogen.sh

To create a distribution, please use the 'distcheck' target:
    /bin/sh build/autogen.sh && ./configure && make distcheck

On non-Unix-like systems, use the "cmake" utility (available from
http://cmake.org/) to generate suitable build files for your platform.
Cmake requires the name of the directory containing CmakeLists.txt and
the "generator" to use for your build environment.  For example, to
build with Xcode on Mac OS, you can use the following command:
    cmake -G "Xcode" ~/libarchive-download-dir/
The result will be appropriate makefiles, solution files, or project
files that can be used with the corresponding development tool.
See the libarchive Wiki or the cmake site for further documentation.
--- NEW FILE: configure.ac ---
dnl Process this file with autoconf to produce a configure script.

dnl First, define all of the version numbers up front.
dnl In particular, this allows the version macro to be used in AC_INIT

dnl These first two version numbers are updated automatically on each release.
m4_define([LIBARCHIVE_VERSION_S],[2.7.900a])
m4_define([LIBARCHIVE_VERSION_N],[2007900])

dnl bsdtar and bsdcpio versioning tracks libarchive
m4_define([BSDTAR_VERSION_S],LIBARCHIVE_VERSION_S())
m4_define([BSDCPIO_VERSION_S],LIBARCHIVE_VERSION_S())

#
# Now starts the "real" configure script.
#

AC_INIT([libarchive],LIBARCHIVE_VERSION_S(),[kientzle at freebsd.org])
# Make sure the srcdir contains "libarchive" directory
AC_CONFIG_SRCDIR([libarchive])
# Use auxiliary subscripts from this subdirectory (cleans up root)
AC_CONFIG_AUX_DIR([build/autoconf])
# M4 scripts
AC_CONFIG_MACRO_DIR([build/autoconf])
# Must follow AC_CONFIG macros above...
AM_INIT_AUTOMAKE()

# Libtool versioning uses different conventions on different
# platforms.  At least on FreeBSD, libtool uses an overly complex
# convention that attempts to solve problems that most people just
# don't have and which just causes confusion for most end users.
ARCHIVE_MAJOR=$(( LIBARCHIVE_VERSION_N() / 1000000 ))
ARCHIVE_MINOR=$(( (LIBARCHIVE_VERSION_N() / 1000) % 1000 ))
ARCHIVE_REVISION=$(( LIBARCHIVE_VERSION_N() % 1000 ))
ARCHIVE_LIBTOOL_MAJOR=`echo $((${ARCHIVE_MAJOR} + ${ARCHIVE_MINOR}))`
ARCHIVE_LIBTOOL_VERSION=$ARCHIVE_LIBTOOL_MAJOR:$ARCHIVE_REVISION:$ARCHIVE_MINOR

# Stick the version numbers into config.h
AC_DEFINE([LIBARCHIVE_VERSION_STRING],"LIBARCHIVE_VERSION_S()",
    [Version number of libarchive])
AC_DEFINE_UNQUOTED([LIBARCHIVE_VERSION_NUMBER],"LIBARCHIVE_VERSION_N()",
    [Version number of libarchive as a single integer])
AC_DEFINE([BSDCPIO_VERSION_STRING],"BSDCPIO_VERSION_S()",
    [Version number of bsdcpio])
AC_DEFINE([BSDTAR_VERSION_STRING],"BSDTAR_VERSION_S()",
    [Version number of bsdtar])

# The shell variables here must be the same as the AC_SUBST() variables
# below, but the shell variable names apparently cannot be the same as
# the m4 macro names above.  Why?  Ask autoconf.
BSDCPIO_VERSION_STRING=BSDCPIO_VERSION_S()
BSDTAR_VERSION_STRING=BSDTAR_VERSION_S()
LIBARCHIVE_VERSION_STRING=LIBARCHIVE_VERSION_S()
LIBARCHIVE_VERSION_NUMBER=LIBARCHIVE_VERSION_N()

# Substitute the above version numbers into the various files below.
# Yes, I believe this is the fourth time we define what are essentially
# the same symbols.  Why? Ask autoconf.
AC_SUBST(ARCHIVE_LIBTOOL_VERSION)
AC_SUBST(BSDCPIO_VERSION_STRING)
AC_SUBST(BSDTAR_VERSION_STRING)
AC_SUBST(LIBARCHIVE_VERSION_STRING)
AC_SUBST(LIBARCHIVE_VERSION_NUMBER)

AC_CONFIG_HEADERS([config.h])
AC_CONFIG_FILES([Makefile])

# Check for host type
AC_CANONICAL_HOST

dnl Compilation on mingw and Cygwin needs special Makefile rules
inc_windows_files=no
inc_cygwin_files=no
case "$host_os" in
  *mingw* ) inc_windows_files=yes ;;
  *cygwin*) inc_cygwin_files=yes ;;
esac
AM_CONDITIONAL([INC_WINDOWS_FILES], [test $inc_windows_files = yes])
AM_CONDITIONAL([INC_CYGWIN_FILES], [test $inc_cygwin_files = yes])

dnl Defines that are required for specific platforms (e.g. -D_POSIX_SOURCE, etc)
PLATFORMCPPFLAGS=
case "$host_os" in
  *mingw* ) PLATFORMCPPFLAGS=-D__USE_MINGW_ANSI_STDIO ;;
esac
AC_SUBST(PLATFORMCPPFLAGS)

# Checks for programs.
AC_PROG_CC
AM_PROG_CC_C_O
AC_LIBTOOL_WIN32_DLL
AC_PROG_LIBTOOL
AC_CHECK_TOOL([STRIP],[strip])

#
# Options for building bsdtar.
#
# Default is to build bsdtar, but allow people to override that.
#
AC_ARG_ENABLE([bsdtar],
    [AS_HELP_STRING([--enable-bsdtar], [enable build of bsdtar (default)])
    AS_HELP_STRING([--enable-bsdtar=static], [force static build of bsdtar])
    AS_HELP_STRING([--enable-bsdtar=shared], [force dynamic build of bsdtar])
AS_HELP_STRING([--disable-bsdtar], [disable build of bsdtar])],
    [], [enable_bsdtar=yes])

case "$enable_bsdtar" in
yes)
    if test "$enable_static" = "no"; then
        static_bsdtar=no
    else
        static_bsdtar=yes
    fi
    build_bsdtar=yes
    ;;
dynamic|shared)
    if test "$enable_shared" = "no"; then
        AC_MSG_FAILURE([Shared linking of bsdtar requires shared libarchive])
    fi
    build_bsdtar=yes
    static_bsdtar=no
    ;;
static)
    build_bsdtar=yes
    static_bsdtar=yes
    ;;
no)
    build_bsdtar=no
    static_bsdtar=no
    ;;
*)
    AC_MSG_FAILURE([Unsupported value for --enable-bsdtar])
    ;;
esac

AM_CONDITIONAL([BUILD_BSDTAR], [ test "$build_bsdtar" = yes ])
AM_CONDITIONAL([STATIC_BSDTAR], [ test "$static_bsdtar" = yes ])

#
# Options for building bsdcpio.
#
# Default is not to build bsdcpio, but that can be overridden.
#
AC_ARG_ENABLE([bsdcpio],
    [AS_HELP_STRING([--enable-bsdcpio], [enable build of bsdcpio (default)])
    AS_HELP_STRING([--enable-bsdcpio=static], [static build of bsdcpio])
    AS_HELP_STRING([--enable-bsdcpio=shared], [dynamic build of bsdcpio])
AS_HELP_STRING([--disable-bsdcpio], [disable build of bsdcpio])],
    [], [enable_bsdcpio=yes])

case "$enable_bsdcpio" in
yes)
    if test "$enable_static" = "no"; then
       static_bsdcpio=no
    else
       static_bsdcpio=yes
        fi
    build_bsdcpio=yes
    ;;
dynamic|shared)
    if test "$enabled_shared" = "no"; then
       AC_MSG_FAILURE([Shared linking of bsdcpio requires shared libarchive])
    fi
    build_bsdcpio=yes
    ;;
static)
    build_bsdcpio=yes
    static_bsdcpio=yes
    ;;
no)
    build_bsdcpio=no
    static_bsdcpio=no
    ;;
*)
    AC_MSG_FAILURE([Unsupported value for --enable-bsdcpio])
    ;;
esac

AM_CONDITIONAL([BUILD_BSDCPIO], [ test "$build_bsdcpio" = yes ])
AM_CONDITIONAL([STATIC_BSDCPIO], [ test "$static_bsdcpio" = yes ])

# Set up defines needed before including any headers
case $host in
  *mingw* | *cygwin* )
  AC_DEFINE([_WIN32_WINNT], 0x0500, [Define to '0x0500' for Windows 2000 APIs.])
  AC_DEFINE([WINVER], 0x0500, [Define to '0x0500' for Windows 2000 APIs.])
  ;;
esac

# Checks for header files.
AC_HEADER_STDC
AC_HEADER_DIRENT
AC_HEADER_SYS_WAIT
AC_CHECK_HEADERS([acl/libacl.h attr/xattr.h ctype.h errno.h])
AC_CHECK_HEADERS([ext2fs/ext2_fs.h fcntl.h grp.h])
AC_CHECK_HEADERS([inttypes.h io.h langinfo.h limits.h linux/fs.h])
AC_CHECK_HEADERS([locale.h paths.h poll.h pwd.h regex.h signal.h stdarg.h])
AC_CHECK_HEADERS([stdint.h stdlib.h string.h])
AC_CHECK_HEADERS([sys/acl.h sys/extattr.h sys/ioctl.h sys/mkdev.h])
AC_CHECK_HEADERS([sys/param.h sys/poll.h sys/select.h sys/time.h sys/utime.h])
AC_CHECK_HEADERS([time.h unistd.h utime.h wchar.h wctype.h windows.h])

# Checks for libraries.
AC_ARG_WITH([zlib],
  AS_HELP_STRING([--without-zlib], [Don't build support for gzip through zlib]))

if test "x$with_zlib" != "xno"; then
  AC_CHECK_HEADERS([zlib.h])
  AC_CHECK_LIB(z,inflate)
fi

AC_ARG_WITH([bz2lib],
  AS_HELP_STRING([--without-bz2lib], [Don't build support for bzip2 through bz2lib]))

if test "x$with_bz2lib" != "xno"; then
  AC_CHECK_HEADERS([bzlib.h])
  AC_CHECK_LIB(bz2,BZ2_bzDecompressInit)
fi

AC_ARG_WITH([lzmadec],
  AS_HELP_STRING([--without-lzmadec], [Don't build support for lzma through lzmadec]))

if test "x$with_lzmadec" != "xno"; then
  AC_CHECK_HEADERS([lzmadec.h])
  AC_CHECK_LIB(lzmadec,lzmadec_decode)
fi

AC_ARG_WITH([lzma],
  AS_HELP_STRING([--without-lzma], [Don't build support for xz through lzma]))

if test "x$with_lzma" != "xno"; then
  AC_CHECK_HEADERS([lzma.h])
  AC_CHECK_LIB(lzma,lzma_stream_decoder)
fi

AC_ARG_WITH([openssl],
  AS_HELP_STRING([--without-openssl], [Don't build support for mtree hashes through openssl]))

AC_CHECK_HEADERS([md5.h ripemd.h rmd160.h sha.h sha1.h sha2.h sha256.h])
# Common names for libc implementation on NetBSD and OpenBSD
AC_CHECK_FUNCS(MD5Init RMD160Init SHA1Init)
# SHA2 on NetBSD and older OpenBSD
AC_CHECK_FUNCS(SHA256_Init SHA384_Init SHA512_Init)
# SHA2 on newer OpenBSD
AC_CHECK_FUNCS(SHA256Init SHA384Init SHA512Init)

if test "x$with_openssl" != "xno"; then
  if test "$ac_cv_func_MD5Init" != "yes"; then
    AC_CHECK_HEADERS([openssl/md5.h])
    AC_SEARCH_LIBS([MD5_Init], [crypto])
  fi
  if test "$ac_cv_func_RMD160Init" != "yes"; then
    AC_CHECK_HEADERS([openssl/ripemd.h])
    AC_SEARCH_LIBS([RIMEMD160_Init], [crypto])
  fi
  if test "$ac_cv_func_SHA1Init" != "yes"; then
    AC_CHECK_HEADERS([openssl/sha.h])
    AC_SEARCH_LIBS([SHA1_Init], [crypto])
  fi
  if test "$ac_cv_func_SHA256Init" != "yes" ||
     test "$ac_cv_func_SHA384Init" != "yes" ||
     test "$ac_cv_func_SHA512Init" != "yes"; then
    if test "$ac_cv_func_SHA256_Init" != "yes" ||
       test "$ac_cv_func_SHA384_Init" != "yes" ||
       test "$ac_cv_func_SHA512_Init" != "yes"; then
      AC_CHECK_HEADERS([openssl/sha.h])
      AC_SEARCH_LIBS([SHA256_Init SHA384_Init SHA512_Init], [crypto])
    fi
  fi
fi

# TODO: Give the user the option of using a pre-existing system
# libarchive.  This will define HAVE_LIBARCHIVE which will cause
# bsdtar_platform.h to use #include <...> for the libarchive headers.
# Need to include Makefile.am magic to link against system
# -larchive in that case.
#AC_CHECK_LIB(archive,archive_version)

# Checks for typedefs, structures, and compiler characteristics.
AC_C_CONST
# AC_TYPE_UID_T defaults to "int", which is incorrect for MinGW
# and MSVC. Use a customized version.
la_TYPE_UID_T
AC_TYPE_MODE_T
# AC_TYPE_OFF_T defaults to "long", which limits us to 4GB files on
# most systems... default to "long long" instead.
AC_CHECK_TYPE(off_t, [long long])
AC_TYPE_SIZE_T
AC_CHECK_TYPE(id_t, [unsigned long])
AC_CHECK_TYPE(uintptr_t, [unsigned int])

# Check for birthtime in struct stat
AC_CHECK_MEMBERS([struct stat.st_birthtime])

# Check for high-resolution timestamps in struct stat
AC_CHECK_MEMBERS([struct stat.st_birthtimespec.tv_nsec])
AC_CHECK_MEMBERS([struct stat.st_mtimespec.tv_nsec])
AC_CHECK_MEMBERS([struct stat.st_mtim.tv_nsec])
AC_CHECK_MEMBERS([struct stat.st_mtime_n]) # AIX
AC_CHECK_MEMBERS([struct stat.st_umtime]) # Tru64
AC_CHECK_MEMBERS([struct stat.st_mtime_usec]) # Hurd
# Check for block size support in struct stat
AC_CHECK_MEMBERS([struct stat.st_blksize])
# Check for st_flags in struct stat (BSD fflags)
AC_CHECK_MEMBERS([struct stat.st_flags])

# If you have uintmax_t, we assume printf supports %ju
# If you have unsigned long long, we assume printf supports %llu
# TODO: Check for %ju and %llu support directly.
AC_CHECK_TYPES([uintmax_t, unsigned long long])

# We need int64_t, uint64_t, intmax_t, and uintmax_t
AC_TYPE_INTMAX_T
AC_TYPE_INT64_T
AC_TYPE_UINTMAX_T
AC_TYPE_UINT64_T

# TODO: If any of these are missing, define them right here.
AC_CHECK_DECLS([SIZE_MAX, SSIZE_MAX, INT64_MAX, INT64_MIN, UINT64_MAX, UINT32_MAX])

AC_CHECK_DECL([EFTYPE],
        [AC_DEFINE(HAVE_EFTYPE, 1, [A possible errno value for invalid file format errors])],
        [],
        [#include <errno.h>])
AC_CHECK_DECL([EILSEQ],
        [AC_DEFINE(HAVE_EILSEQ, 1, [A possible errno value for invalid file format errors])],
        [],
        [#include <errno.h>])
AC_CHECK_TYPE([wchar_t],
            [AC_DEFINE_UNQUOTED(AS_TR_CPP(HAVE_[]wchar_t), 1, [Define to 1 if the system has the type `wchar_t'.])dnl
        AC_CHECK_SIZEOF([wchar_t])],
        [])

AC_HEADER_TIME

# Checks for library functions.
AC_PROG_GCC_TRADITIONAL
AC_HEADER_MAJOR
AC_FUNC_FSEEKO
AC_FUNC_MEMCMP
AC_FUNC_LSTAT
AC_FUNC_STAT
AC_FUNC_STRERROR_R
AC_FUNC_STRFTIME
AC_FUNC_VPRINTF
# check for:
#   CreateHardLinkA(LPCSTR, LPCSTR, LPSECURITY_ATTRIBUTES)
# To avoid necessity for including windows.h or special forward declaration
# workarounds, we use 'void *' for 'struct SECURITY_ATTRIBUTES *'
AC_CHECK_STDCALL_FUNC([CreateHardLinkA],[const char *, const char *, void *])
AC_CHECK_FUNCS([chflags chown chroot])
AC_CHECK_FUNCS([fchdir fchflags fchmod fchown fcntl fork])
AC_CHECK_FUNCS([fstat ftruncate futimes geteuid getpid])
AC_CHECK_FUNCS([lchflags lchmod lchown link lstat])
AC_CHECK_FUNCS([lutimes memmove memset mkdir mkfifo mknod])
AC_CHECK_FUNCS([nl_langinfo pipe poll readlink select setenv setlocale])
AC_CHECK_FUNCS([strchr strdup strerror strncpy_s strrchr symlink timegm])
AC_CHECK_FUNCS([tzset unsetenv utime utimes vfork])
AC_CHECK_FUNCS([wcrtomb wcscpy wcslen wctomb wmemcmp wmemcpy])
# detects cygwin-1.7, as opposed to older versions
AC_CHECK_FUNCS([cygwin_conv_path])

# FreeBSD's nl_langinfo supports an option to specify whether the
# current locale uses month/day or day/month ordering.  It makes the
# output a little prettier...
AC_CHECK_DECL([D_MD_ORDER],
[AC_DEFINE(HAVE_D_MD_ORDER, 1, [Define to 1 if nl_langinfo supports D_MD_ORDER])],
[],
[#if HAVE_LANGINFO_H
#include <langinfo.h>
#endif
])

# Check for dirent.d_namlen field explicitly
# (This is a bit more straightforward than, if not quite as portable as,
# the recipe given by the autoconf maintainers.)
AC_CHECK_MEMBER(struct dirent.d_namlen,,,
[#if HAVE_DIRENT_H
#include <dirent.h>
#endif
])

# Check for Extended Attributes support
AC_ARG_ENABLE([xattr],
        AS_HELP_STRING([--disable-xattr],
        [Enable Extended Attributes support (default: check)]))

if test "x$enable_xattr" != "xno"; then
    AC_CHECK_HEADERS([attr/xattr.h])
    AC_CHECK_HEADERS([sys/xattr.h])
    AC_CHECK_LIB(attr,setxattr)
    AC_CHECK_FUNCS([extattr_get_file extattr_list_file])
    AC_CHECK_FUNCS([extattr_set_fd extattr_set_file])
    AC_CHECK_FUNCS([fsetxattr getxattr])
    AC_CHECK_FUNCS([lgetxattr listxattr llistxattr lsetxattr])
fi

# Check for ACL support
#
# The ACL support in libarchive is written against the POSIX1e draft,
# which was never officially approved and varies quite a bit across
# platforms.  Worse, some systems have completely non-POSIX acl functions,
# which makes the following checks rather more complex than I would like.
#
AC_ARG_ENABLE([acl],
        AS_HELP_STRING([--disable-acl],
        [Enable ACL support (default: check)]))

if test "x$enable_acl" != "xno"; then
   AC_CHECK_HEADERS([sys/acl.h])
   AC_CHECK_LIB([acl],[acl_get_file])
   AC_CHECK_FUNCS([acl_create_entry acl_init acl_set_fd acl_set_fd_np acl_set_file])

   AC_CHECK_TYPES(acl_permset_t,,,
    [#if HAVE_SYS_TYPES_H
    #include <sys/types.h>
    #endif
    #if HAVE_SYS_ACL_H
    #include <sys/acl.h>
    #endif
    ])

    # The "acl_get_perm()" function was omitted from the POSIX draft.
    # (It's a pretty obvious oversight; otherwise, there's no way to
    # test for specific permissions in a permset.)  Linux uses the obvious
    # name, FreeBSD adds _np to mark it as "non-Posix extension."
    # Test for both as a double-check that we really have POSIX-style ACL support.
    AC_CHECK_FUNCS(acl_get_perm_np acl_get_perm acl_get_link acl_get_link_np,,,
    [#if HAVE_SYS_TYPES_H
    #include <sys/types.h>
    #endif
    #if HAVE_SYS_ACL_H
    #include <sys/acl.h>
    #endif
    ])

    # MacOS has an acl.h that isn't POSIX.  It can be detected by
    # checking for ACL_USER
    AC_CHECK_DECL([ACL_USER],
        [AC_DEFINE(HAVE_ACL_USER, 1, [True for systems with POSIX ACL support])],
        [],
        [#include <sys/acl.h>])
fi

# Additional requirements
AC_SYS_LARGEFILE

AC_OUTPUT

--- NEW FILE: Makefile.am ---
## Process this file with automake to produce Makefile.in

AUTOMAKE_OPTIONS= foreign subdir-objects
ACLOCAL_AMFLAGS = -I build/autoconf

#
# What to build and install
#
lib_LTLIBRARIES=    libarchive.la
noinst_LTLIBRARIES= libarchive_fe.la
bin_PROGRAMS=   $(bsdtar_programs) $(bsdcpio_programs)
man_MANS= $(libarchive_man_MANS) $(bsdtar_man_MANS) $(bsdcpio_man_MANS)
BUILT_SOURCES= libarchive/test/list.h tar/test/list.h cpio/test/list.h

#
# What to test: We always test libarchive, test bsdtar and bsdcpio only
# if we built them.
#
check_PROGRAMS= libarchive_test $(bsdtar_test_programs) $(bsdcpio_test_programs)
TESTS= libarchive_test $(bsdtar_test_programs) $(bsdcpio_test_programs)
TESTS_ENVIRONMENT= $(libarchive_TESTS_ENVIRONMENT) $(bsdtar_TESTS_ENVIRONMENT) $(bsdcpio_TESTS_ENVIRONMENT)
# Always build and test both bsdtar and bsdcpio as part of 'distcheck'
DISTCHECK_CONFIGURE_FLAGS = --enable-bsdtar --enable-bsdcpio
# Especially for early development, we want to be a little
# aggressive about diagnosing build problems; this can get
# relaxed somewhat in final shipping versions.
AM_CFLAGS=-Wall -Werror
PLATFORMCPPFLAGS = @PLATFORMCPPFLAGS@
AM_CPPFLAGS=$(PLATFORMCPPFLAGS)

#
# What to include in the distribution
#
EXTRA_DIST= \
    CMakeLists.txt          \
    build/autogen.sh        \
    build/release.sh        \
    build/cmake         \
    build/version           \
    build/windows           \
    contrib             \
    doc             \
    examples            \
    $(libarchive_EXTRA_DIST)    \
    $(libarchive_test_EXTRA_DIST)   \
    $(bsdtar_EXTRA_DIST)        \
    $(bsdtar_test_EXTRA_DIST)   \
    $(bsdcpio_EXTRA_DIST)       \
    $(bsdcpio_test_EXTRA_DIST)

# a) Clean out some unneeded files and directories
# b) Collect all documentation and format it for distribution.
dist-hook:
    rm -rf `find $(distdir) -name CVS -type d`
    rm -rf `find $(distdir) -name .svn -type d`
    rm -f `find $(distdir) -name '*~'`
    rm -f `find $(distdir) -name '*.out'`
    rm -f `find $(distdir) -name '*.core'`
    -rm -f $(distdir)/*/Makefile $(distdir)/*/*/Makefile
    cd $(distdir)/doc && /bin/sh update.sh

# Verify cmake builds as part of the acceptance
distcheck-hook:
    mkdir $(distdir)/_build/cmtest
    cd $(distdir)/_build/cmtest && cmake ../.. && make && make test
    rm -rf $(distdir)/_build/cmtest

#
# Extra rules for cleanup
#
DISTCLEANFILES=                 \
    libarchive/test/list.h          \
    tar/test/list.h             \
    cpio/test/list.h

distclean-local:
    -rm -rf .ref
    -rm -rf autom4te.cache/
    -rm -f *~
    -[ -f libarchive/Makefile ] && cd libarchive && make clean
    -[ -f libarchive/test/Makefile ] && cd libarchive/test && make clean
    -[ -f tar/Makefile ] && cd tar && make clean
    -[ -f tar/test/Makefile ] && cd tar/test && make clean
    -[ -f cpio/Makefile ] && cd cpio && make clean
    -[ -f cpio/test/Makefile ] && cd cpio/test && make clean

#
# Libarchive headers, source, etc.
#
#

include_HEADERS= libarchive/archive.h libarchive/archive_entry.h

libarchive_la_SOURCES=                      \
    libarchive/archive_check_magic.c            \
    libarchive/archive_endian.h             \
    libarchive/archive_entry.c              \
    libarchive/archive_entry.h              \
    libarchive/archive_entry_copy_stat.c            \
    libarchive/archive_entry_link_resolver.c        \
    libarchive/archive_entry_private.h          \
    libarchive/archive_entry_stat.c             \
    libarchive/archive_entry_strmode.c          \
    libarchive/archive_entry_xattr.c            \
    libarchive/archive_hash.h               \
    libarchive/archive_platform.h               \
    libarchive/archive_private.h                \
    libarchive/archive_read.c               \
    libarchive/archive_read_data_into_fd.c          \
    libarchive/archive_read_disk.c              \
    libarchive/archive_read_disk_entry_from_file.c      \
    libarchive/archive_read_disk_private.h          \
    libarchive/archive_read_disk_set_standard_lookup.c  \
    libarchive/archive_read_extract.c           \
    libarchive/archive_read_open_fd.c           \
    libarchive/archive_read_open_file.c         \
    libarchive/archive_read_open_filename.c         \
    libarchive/archive_read_open_memory.c           \
    libarchive/archive_read_private.h           \
    libarchive/archive_read_support_compression_all.c   \
    libarchive/archive_read_support_compression_bzip2.c \
    libarchive/archive_read_support_compression_compress.c  \
    libarchive/archive_read_support_compression_gzip.c  \
    libarchive/archive_read_support_compression_none.c  \
    libarchive/archive_read_support_compression_program.c   \
    libarchive/archive_read_support_compression_xz.c    \
    libarchive/archive_read_support_format_all.c        \
    libarchive/archive_read_support_format_ar.c     \
    libarchive/archive_read_support_format_cpio.c       \
    libarchive/archive_read_support_format_empty.c      \
    libarchive/archive_read_support_format_iso9660.c    \
    libarchive/archive_read_support_format_mtree.c      \
    libarchive/archive_read_support_format_raw.c        \
    libarchive/archive_read_support_format_tar.c        \
    libarchive/archive_read_support_format_zip.c        \
    libarchive/archive_string.c             \
    libarchive/archive_string.h             \
    libarchive/archive_string_sprintf.c         \
    libarchive/archive_util.c               \
    libarchive/archive_virtual.c                \
    libarchive/archive_write.c              \
    libarchive/archive_write_disk.c             \
    libarchive/archive_write_disk_private.h         \
    libarchive/archive_write_disk_set_standard_lookup.c \
    libarchive/archive_write_open_fd.c          \
    libarchive/archive_write_open_file.c            \
    libarchive/archive_write_open_filename.c        \
    libarchive/archive_write_open_memory.c          \
    libarchive/archive_write_private.h          \
    libarchive/archive_write_set_compression_bzip2.c    \
    libarchive/archive_write_set_compression_compress.c \
    libarchive/archive_write_set_compression_gzip.c     \
    libarchive/archive_write_set_compression_none.c     \
    libarchive/archive_write_set_compression_program.c  \
    libarchive/archive_write_set_compression_xz.c       \
    libarchive/archive_write_set_format.c           \
    libarchive/archive_write_set_format_ar.c        \
    libarchive/archive_write_set_format_by_name.c       \
    libarchive/archive_write_set_format_cpio.c      \
    libarchive/archive_write_set_format_cpio_newc.c     \
    libarchive/archive_write_set_format_mtree.c     \
    libarchive/archive_write_set_format_pax.c       \
    libarchive/archive_write_set_format_shar.c      \
    libarchive/archive_write_set_format_ustar.c     \
    libarchive/archive_write_set_format_zip.c       \
    libarchive/config_freebsd.h             \
    libarchive/config_windows.h             \
    libarchive/filter_fork.c                \
    libarchive/filter_fork.h

if INC_WINDOWS_FILES
libarchive_la_SOURCES+=                     \
    libarchive/archive_entry_copy_bhfi.c            \
    libarchive/archive_windows.h                \
    libarchive/archive_windows.c                \
    libarchive/filter_fork_windows.c
endif

# -no-undefined marks that libarchive doesn't rely on symbols
# defined in the application.  This is mandatory for cygwin.
libarchive_la_LDFLAGS= -no-undefined -version-info $(ARCHIVE_LIBTOOL_VERSION)

# Manpages to install
libarchive_man_MANS=                        \
    libarchive/archive_entry.3              \
    libarchive/archive_read.3               \
    libarchive/archive_read_disk.3              \
    libarchive/archive_util.3               \
    libarchive/archive_write.3              \
    libarchive/archive_write_disk.3             \
    libarchive/cpio.5                   \
    libarchive/libarchive.3                 \
    libarchive/libarchive_internals.3           \
    libarchive/libarchive-formats.5             \
    libarchive/mtree.5                  \
    libarchive/tar.5

# Additional libarchive files to include in the distribution
libarchive_EXTRA_DIST=          \
    libarchive/test/list.h      \
    libarchive/archive_windows.c    \
    libarchive/archive_windows.h    \
    libarchive/filter_fork_windows.c    \
    libarchive/CMakeLists.txt   \
    $(libarchive_man_MANS)

#
#
# libarchive_test program
#
#
libarchive_test_SOURCES=                    \
    $(libarchive_la_SOURCES)                \
    libarchive/test/main.c                  \
    libarchive/test/read_open_memory.c          \
    libarchive/test/test.h                  \
    libarchive/test/test_acl_basic.c            \
    libarchive/test/test_acl_freebsd.c          \
    libarchive/test/test_acl_pax.c              \
    libarchive/test/test_archive_api_feature.c      \
    libarchive/test/test_bad_fd.c               \
    libarchive/test/test_compat_bzip2.c         \
    libarchive/test/test_compat_gtar.c          \
    libarchive/test/test_compat_gzip.c          \
    libarchive/test/test_compat_solaris_tar_acl.c       \
    libarchive/test/test_compat_tar_hardlink.c      \
    libarchive/test/test_compat_xz.c            \
    libarchive/test/test_compat_zip.c           \
    libarchive/test/test_empty_write.c          \
    libarchive/test/test_entry.c                \
    libarchive/test/test_extattr_freebsd.c          \
    libarchive/test/test_fuzz.c             \
    libarchive/test/test_entry_strmode.c            \
    libarchive/test/test_link_resolver.c            \
    libarchive/test/test_open_fd.c              \
    libarchive/test/test_open_file.c            \
    libarchive/test/test_open_filename.c            \
    libarchive/test/test_pax_filename_encoding.c        \
    libarchive/test/test_read_compress_program.c        \
    libarchive/test/test_read_data_large.c          \
    libarchive/test/test_read_disk.c            \
    libarchive/test/test_read_disk_entry_from_file.c    \
    libarchive/test/test_read_extract.c         \
    libarchive/test/test_read_file_nonexistent.c        \
    libarchive/test/test_read_format_ar.c           \
    libarchive/test/test_read_format_cpio_bin.c     \
    libarchive/test/test_read_format_cpio_bin_Z.c       \
    libarchive/test/test_read_format_cpio_bin_be.c      \
    libarchive/test/test_read_format_cpio_bin_bz2.c     \
    libarchive/test/test_read_format_cpio_bin_gz.c      \
    libarchive/test/test_read_format_cpio_bin_xz.c      \
    libarchive/test/test_read_format_cpio_odc.c     \
    libarchive/test/test_read_format_cpio_svr4_gzip.c   \
    libarchive/test/test_read_format_cpio_svr4c_Z.c     \
    libarchive/test/test_read_format_empty.c        \
    libarchive/test/test_read_format_gtar_gz.c      \
    libarchive/test/test_read_format_gtar_lzma.c        \
    libarchive/test/test_read_format_gtar_sparse.c      \
    libarchive/test/test_read_format_iso_gz.c       \
    libarchive/test/test_read_format_isojoliet_bz2.c    \
    libarchive/test/test_read_format_isojoliet_long.c   \
    libarchive/test/test_read_format_isojoliet_rr.c     \
    libarchive/test/test_read_format_isorr_bz2.c        \
    libarchive/test/test_read_format_isorr_new_bz2.c    \
    libarchive/test/test_read_format_isozisofs_bz2.c    \
    libarchive/test/test_read_format_mtree.c        \
    libarchive/test/test_read_format_pax_bz2.c      \
    libarchive/test/test_read_format_raw.c          \
    libarchive/test/test_read_format_tar.c          \
    libarchive/test/test_read_format_tar_empty_filename.c   \
    libarchive/test/test_read_format_tbz.c          \
    libarchive/test/test_read_format_tgz.c          \
    libarchive/test/test_read_format_txz.c          \
    libarchive/test/test_read_format_tz.c           \
    libarchive/test/test_read_format_zip.c          \
    libarchive/test/test_read_large.c           \
    libarchive/test/test_read_pax_truncated.c       \
    libarchive/test/test_read_position.c            \
    libarchive/test/test_read_truncated.c           \
    libarchive/test/test_tar_filenames.c            \
    libarchive/test/test_tar_large.c            \
    libarchive/test/test_ustar_filenames.c          \
    libarchive/test/test_write_compress.c           \
    libarchive/test/test_write_compress_bzip2.c     \
    libarchive/test/test_write_compress_gzip.c      \
    libarchive/test/test_write_compress_lzma.c      \
    libarchive/test/test_write_compress_program.c       \
    libarchive/test/test_write_compress_xz.c        \
    libarchive/test/test_write_disk.c           \
    libarchive/test/test_write_disk_failures.c      \
    libarchive/test/test_write_disk_hardlink.c      \
    libarchive/test/test_write_disk_perms.c         \
    libarchive/test/test_write_disk_secure.c        \
    libarchive/test/test_write_disk_sparse.c        \
    libarchive/test/test_write_disk_symlink.c       \
    libarchive/test/test_write_disk_times.c         \
    libarchive/test/test_write_format_ar.c          \
    libarchive/test/test_write_format_cpio.c        \
    libarchive/test/test_write_format_cpio_empty.c      \
    libarchive/test/test_write_format_cpio_odc.c        \
    libarchive/test/test_write_format_cpio_newc.c       \
    libarchive/test/test_write_format_mtree.c       \
    libarchive/test/test_write_format_pax.c         \
    libarchive/test/test_write_format_shar_empty.c      \
    libarchive/test/test_write_format_tar.c         \
    libarchive/test/test_write_format_tar_empty.c       \
    libarchive/test/test_write_format_tar_ustar.c       \
    libarchive/test/test_write_format_zip.c         \
    libarchive/test/test_write_format_zip_empty.c       \
    libarchive/test/test_write_format_zip_no_compression.c  \
    libarchive/test/test_write_open_memory.c

libarchive_test_CPPFLAGS= -I$(top_srcdir)/libarchive -I$(top_builddir)/libarchive/test -DLIBARCHIVE_STATIC $(PLATFORMCPPFLAGS)

# The "list.h" file just lists all of the tests defined in all of the sources.
# Building it automatically provides a sanity-check on libarchive_test_SOURCES
# above.
libarchive/test/list.h: Makefile
    cat $(top_srcdir)/libarchive/test/test_*.c | grep DEFINE_TEST > libarchive/test/list.h

libarchive_TESTS_ENVIRONMENT= LIBARCHIVE_TEST_FILES=`cd $(top_srcdir);/bin/pwd`/libarchive/test

libarchive_test_EXTRA_DIST=\
    libarchive/test/test_compat_bzip2_1.tbz.uu          \
    libarchive/test/test_compat_bzip2_2.tbz.uu          \
    libarchive/test/test_compat_gtar_1.tar.uu           \
    libarchive/test/test_compat_gzip_1.tgz.uu           \
    libarchive/test/test_compat_gzip_2.tgz.uu           \
    libarchive/test/test_compat_solaris_tar_acl.tar.uu      \
    libarchive/test/test_compat_tar_hardlink_1.tar.uu       \
    libarchive/test/test_compat_xz_1.txz.uu             \
    libarchive/test/test_compat_zip_1.zip.uu            \
    libarchive/test/test_fuzz_1.iso.uu              \
    libarchive/test/test_pax_filename_encoding.tar.uu       \
    libarchive/test/test_read_format_cpio_bin_be.cpio.uu        \
    libarchive/test/test_read_format_gtar_sparse_1_13.tar.uu    \
    libarchive/test/test_read_format_gtar_sparse_1_17.tar.uu    \
    libarchive/test/test_read_format_gtar_sparse_1_17_posix00.tar.uu \
    libarchive/test/test_read_format_gtar_sparse_1_17_posix01.tar.uu \
    libarchive/test/test_read_format_gtar_sparse_1_17_posix10.tar.uu \
    libarchive/test/test_read_format_gtar_sparse_1_17_posix10_modified.tar.uu \
    libarchive/test/test_read_format_iso_gz.iso.gz.uu       \
    libarchive/test/test_read_format_isojoliet_bz2.iso.bz2.uu   \
    libarchive/test/test_read_format_isojoliet_long.iso.bz2.uu  \
    libarchive/test/test_read_format_isojoliet_rr.iso.bz2.uu    \
    libarchive/test/test_read_format_isorr_bz2.iso.bz2.uu       \
    libarchive/test/test_read_format_isorr_new_bz2.iso.bz2.uu   \
    libarchive/test/test_read_format_isozisofs_bz2.iso.bz2.uu   \
    libarchive/test/test_read_format_raw.data.Z.uu          \
    libarchive/test/test_read_format_raw.data.uu            \
    libarchive/test/test_read_format_iso_gz.iso.gz.uu       \
    libarchive/test/test_read_format_tar_empty_filename.tar.uu  \
    libarchive/test/test_read_format_zip.zip.uu         \
    libarchive/test/CMakeLists.txt                  \
    libarchive/test/README

#
# Common code for libarchive frontends (cpio, tar)
#
libarchive_fe_la_SOURCES=           \
    libarchive_fe/err.c         \
    libarchive_fe/err.h         \
    libarchive_fe/lafe_platform.h       \
    libarchive_fe/line_reader.c     \
    libarchive_fe/line_reader.h     \
    libarchive_fe/matching.c        \
    libarchive_fe/matching.h        \
    libarchive_fe/pathmatch.c       \
    libarchive_fe/pathmatch.h

#
#
# bsdtar source, docs, etc.
#
#

bsdtar_SOURCES=             \
        tar/bsdtar.c        \
        tar/bsdtar.h        \
        tar/bsdtar_platform.h   \
        tar/cmdline.c       \
        tar/getdate.c       \
        tar/read.c      \
        tar/subst.c     \
        tar/tree.c      \
        tar/tree.h      \
        tar/util.c      \
        tar/write.c

if INC_WINDOWS_FILES
bsdtar_SOURCES+=            \
        tar/bsdtar_windows.h    \
        tar/bsdtar_windows.c
endif

bsdtar_DEPENDENCIES= libarchive.la libarchive_fe.la

if STATIC_BSDTAR
bsdtar_ldstatic= -static
bsdtar_ccstatic= -DLIBARCHIVE_STATIC
else
bsdtar_ldstatic=
bsdtar_ccstatic=
endif

bsdtar_LDADD= libarchive.la libarchive_fe.la
bsdtar_CPPFLAGS= -I$(top_srcdir)/libarchive -I$(top_srcdir)/libarchive_fe $(bsdtar_ccstatic) $(PLATFORMCPPFLAGS)
bsdtar_LDFLAGS= $(bsdtar_ldstatic)

bsdtar_EXTRA_DIST=      \
    tar/bsdtar.1        \
    tar/bsdtar_windows.h    \
    tar/bsdtar_windows.c    \
    tar/CMakeLists.txt  \
    tar/config_freebsd.h    \
    tar/test/list.h


if BUILD_BSDTAR
bsdtar_man_MANS= tar/bsdtar.1
bsdtar_programs= bsdtar
else
bsdtar_man_MANS=
bsdtar_programs=
endif

#
# bsdtar_test
#

bsdtar_test_SOURCES=                        \
    tar/getdate.c                       \
    tar/test/main.c                     \
    tar/test/test.h                     \
    tar/test/test_0.c                   \
    tar/test/test_basic.c                   \
    tar/test/test_copy.c                    \
    tar/test/test_getdate.c                 \
    tar/test/test_help.c                    \
    tar/test/test_option_T_upper.c              \
    tar/test/test_option_q.c                \
    tar/test/test_option_r.c                \
    tar/test/test_option_s.c                \
    tar/test/test_patterns.c                \
    tar/test/test_stdio.c                   \
    tar/test/test_strip_components.c            \
    tar/test/test_symlink_dir.c             \
    tar/test/test_version.c                 \
    tar/test/test_windows.c

# For now, bsdtar_test uses Windows shims from tar/bsdtar_windows.*
if INC_WINDOWS_FILES
bsdtar_test_SOURCES+=           \
        tar/bsdtar_windows.h    \
        tar/bsdtar_windows.c
endif

bsdtar_test_CPPFLAGS=\
    -I$(top_srcdir)/libarchive -I$(top_srcdir)/libarchive_fe \
    -I$(top_srcdir)/tar -I$(top_builddir)/tar/test \
    $(PLATFORMCPPFLAGS)

tar/test/list.h: Makefile
    cat $(top_srcdir)/tar/test/test_*.c | grep DEFINE_TEST > tar/test/list.h

if BUILD_BSDTAR
bsdtar_test_programs= bsdtar_test
bsdtar_TESTS_ENVIRONMENT= BSDTAR=`cd $(top_builddir);/bin/pwd`/bsdtar$(EXEEXT) BSDTAR_TEST_FILES=`cd $(top_srcdir);/bin/pwd`/tar/test
else
bsdtar_test_programs=
bsdtar_TESTS_ENVIRONMENT=
endif

bsdtar_test_EXTRA_DIST=         \
    tar/test/test_patterns_2.tar.uu \
    tar/test/test_patterns_3.tar.uu \
    tar/test/test_patterns_4.tar.uu \
    tar/test/CMakeLists.txt


#
#
# bsdcpio source, docs, etc.
#
#

bsdcpio_SOURCES=            \
        cpio/cmdline.c      \
        cpio/cpio.c     \
        cpio/cpio.h     \
        cpio/cpio_platform.h

if INC_WINDOWS_FILES
bsdcpio_SOURCES+=           \
        cpio/cpio_windows.h \
        cpio/cpio_windows.c
endif

bsdcpio_DEPENDENCIES = libarchive.la libarchive_fe.la


if STATIC_BSDCPIO
bsdcpio_ldstatic= -static
bsdcpio_ccstatic= -DLIBARCHIVE_STATIC
else
bsdcpio_ldstatic=
bsdcpio_ccstatic=
endif

bsdcpio_LDADD= libarchive_fe.la libarchive.la
bsdcpio_CPPFLAGS= -I$(top_srcdir)/libarchive -I$(top_srcdir)/libarchive_fe $(bsdcpio_ccstatic) $(PLATFORMCPPFLAGS)
bsdcpio_LDFLAGS= $(bsdcpio_ldstatic)

bsdcpio_EXTRA_DIST=     \
    cpio/test/list.h    \
    cpio/bsdcpio.1      \
    cpio/cpio_windows.h \
    cpio/cpio_windows.c \
    cpio/CMakeLists.txt \
    cpio/config_freebsd.h


if BUILD_BSDCPIO
# Manpages to install
bsdcpio_man_MANS= cpio/bsdcpio.1
bsdcpio_programs= bsdcpio
else
bsdcpio_man_MANS=
bsdcpio_programs=
endif

#
# bsdcpio_test
#

bsdcpio_test_SOURCES=                       \
    cpio/cmdline.c                      \
    cpio/test/main.c                    \
    cpio/test/test.h                    \
    cpio/test/test_0.c                  \
    cpio/test/test_basic.c                  \
    cpio/test/test_cmdline.c                \
    cpio/test/test_format_newc.c                \
    cpio/test/test_gcpio_compat.c               \
    cpio/test/test_option_B_upper.c             \
    cpio/test/test_option_C_upper.c             \
    cpio/test/test_option_J_upper.c             \
    cpio/test/test_option_L_upper.c             \
    cpio/test/test_option_Z_upper.c             \
    cpio/test/test_option_a.c               \
    cpio/test/test_option_c.c               \
    cpio/test/test_option_d.c               \
    cpio/test/test_option_f.c               \
    cpio/test/test_option_help.c                \
    cpio/test/test_option_l.c               \
    cpio/test/test_option_lzma.c                \
    cpio/test/test_option_m.c               \
    cpio/test/test_option_t.c               \
    cpio/test/test_option_u.c               \
    cpio/test/test_option_version.c             \
    cpio/test/test_option_y.c               \
    cpio/test/test_option_z.c               \
    cpio/test/test_owner_parse.c                \
    cpio/test/test_passthrough_dotdot.c         \
    cpio/test/test_passthrough_reverse.c            \
    cpio/test/test_pathmatch.c

bsdcpio_test_CPPFLAGS= \
    -I$(top_srcdir)/libarchive -I$(top_srcdir)/libarchive_fe \
    -I$(top_srcdir)/cpio -I$(top_builddir)/cpio/test \
    $(PLATFORMCPPFLAGS)
bsdcpio_test_LDADD=libarchive_fe.la

cpio/test/list.h: Makefile
    cat $(top_srcdir)/cpio/test/test_*.c | grep DEFINE_TEST > cpio/test/list.h

if BUILD_BSDCPIO
bsdcpio_test_programs= bsdcpio_test
bsdcpio_TESTS_ENVIRONMENT= BSDCPIO=`cd $(top_builddir);/bin/pwd`/bsdcpio$(EXEEXT) BSDCPIO_TEST_FILES=`cd $(top_srcdir);/bin/pwd`/cpio/test
else
bsdcpio_test_programs=
bsdcpio_TESTS_ENVIRONMENT=
endif

bsdcpio_test_EXTRA_DIST=            \
    cpio/test/test_gcpio_compat_ref.bin.uu  \
    cpio/test/test_gcpio_compat_ref.crc.uu  \
    cpio/test/test_gcpio_compat_ref.newc.uu \
    cpio/test/test_gcpio_compat_ref.ustar.uu \
    cpio/test/test_option_f.cpio.uu     \
    cpio/test/test_option_m.cpio.uu     \
    cpio/test/test_option_t.cpio.uu     \
    cpio/test/test_option_t.stdout.uu   \
    cpio/test/test_option_tv.stdout.uu  \
    cpio/test/CMakeLists.txt

--- NEW FILE: CMakeLists.txt ---
#
#
PROJECT(libarchive C)
#
CMAKE_MINIMUM_REQUIRED(VERSION 2.6.1)
SET(CMAKE_MODULE_PATH "${libarchive_SOURCE_DIR}/build/cmake")
#
# Version - read from 'version' file.
#
FILE(STRINGS ${libarchive_SOURCE_DIR}/build/version _version)
STRING(REGEX REPLACE
 "^([0-9])[0-9][0-9][0-9][0-9][0-9][0-9][a-z]?$" "\\1" _major ${_version})
STRING(REGEX REPLACE
 "^[0-9]([0-9][0-9][0-9])[0-9][0-9][0-9][a-z]?$" "\\1" _minor ${_version})
STRING(REGEX REPLACE
 "^[0-9][0-9][0-9][0-9]([0-9][0-9][0-9])[a-z]?$" "\\1" _revision ${_version})
STRING(REGEX REPLACE
 "^[0-9][0-9][0-9][0-9][0-9][0-9][0-9]([a-z]?)$" "\\1" _quality ${_version})
SET(_version_number ${_major}${_minor}${_revision})
STRING(REGEX REPLACE "[0]*([^0][0-9]*)$" "\\1" _minor ${_minor})
STRING(REGEX REPLACE "[0]*([^0][0-9]*)$" "\\1" _revision ${_revision})
#
SET(VERSION                    "${_major}.${_minor}.${_revision}${_quality}")
SET(BSDCPIO_VERSION_STRING     "${VERSION}")
SET(BSDTAR_VERSION_STRING      "${VERSION}")
SET(LIBARCHIVE_VERSION_NUMBER  "${_version_number}")
SET(LIBARCHIVE_VERSION_STRING  "${VERSION}")
# Shared library number
SET(SOVERSION                   8)

OPTION(ENABLE_TAR "Enable tar building" ON)
OPTION(ENABLE_TAR_SHARED "Enable dynamic build of tar" OFF)
OPTION(ENABLE_CPIO "Enable cpio building" ON)
OPTION(ENABLE_CPIO_SHARED "Enable dynamic build of cpio" OFF)
OPTION(ENABLE_XATTR "Enable extended attribute support" ON)
OPTION(ENABLE_ACL "Enable ACL support" ON)
OPTION(ENABLE_TEST "Enable unit and regression tests" ON)

IF(ENABLE_TEST)
    ENABLE_TESTING()
ENDIF(ENABLE_TEST)
IF(WIN32 AND NOT CYGWIN)
  # Currently, dynamic build only.
  SET(ENABLE_TAR_SHARED ON)
  SET(ENABLE_CPIO_SHARED ON)
ENDIF(WIN32 AND NOT CYGWIN)

IF(WIN32)
  SET(_WIN32_WINNT 0x0500 CACHE INTERNAL "Setting _WIN32_WINNT to 0x0500 for Windows 2000 APIs")
  SET(WINVER 0x0500 CACHE INTERNAL "Setting WINVER to 0x0500 for Windows 2000 APIs")
ENDIF(WIN32)

#
INCLUDE(CheckCSourceRuns)
INCLUDE(CheckFileOffsetBits)
INCLUDE(CheckFuncs)
INCLUDE(CheckHeaderDirent)
INCLUDE(CheckHeaderSTDC)
INCLUDE(CheckIncludeFile)
INCLUDE(CheckIncludeFiles)
INCLUDE(CheckLibraryExists)
INCLUDE(CheckStructMember)
INCLUDE(CheckSymbolExists)
INCLUDE(CheckTypeExists)
INCLUDE(CheckTypeSize)

#
# Generate list.h
#
MACRO (GENERATE_LIST_H _listfile _cmlist __list_sources)
  SET(_argv ${ARGV})
  # Remove _listfile and _cmlist from _argv
  LIST(REMOVE_AT _argv 0 1)
  IF (NOT EXISTS "${_listfile}" OR
     ${_cmlist} IS_NEWER_THAN "${_listfile}")

    MESSAGE(STATUS "Generating ${_listfile}")
    FILE(WRITE ${_listfile} "")
    FOREACH (testfile ${_argv})
      IF (testfile MATCHES "^test_[^/]+[.]c$")
        FILE(STRINGS ${testfile} testvar REGEX "^DEFINE_TEST")
        FOREACH (deftest ${testvar})
          FILE(APPEND ${_listfile} "${deftest}\n")
        ENDFOREACH (deftest)
      ENDIF (testfile MATCHES "^test_[^/]+[.]c$")
    ENDFOREACH (testfile)

  ENDIF (NOT EXISTS "${_listfile}" OR
     ${_cmlist} IS_NEWER_THAN "${_listfile}")
ENDMACRO (GENERATE_LIST_H)
#
# Generate installation rules for man pages.
#
MACRO (INSTALL_MAN __mans)
  FOREACH (_man ${ARGV})
    STRING(REGEX REPLACE "^.+[.]([1-9])" "\\1" _mansect ${_man})
    INSTALL(FILES ${_man} DESTINATION "share/man/man${_mansect}")
  ENDFOREACH (_man)
ENDMACRO (INSTALL_MAN __mans)

#
# Check compress/decompress libraries
#
IF(WIN32 AND NOT CMAKE_CL_64 AND NOT CYGWIN)
  # GnuWin32 is only for Win32, not Win64.
  SET(__GNUWIN32PATH "C:/Program Files/GnuWin32")
ENDIF(WIN32 AND NOT CMAKE_CL_64 AND NOT CYGWIN)
IF(DEFINED __GNUWIN32PATH AND EXISTS "${__GNUWIN32PATH}")
  # You have to add a path availabel DLL file into PATH environment variable.
  # Maybe DLL path is "C:/Program Files/GnuWin32/bin".
  # The zlib and the bzip2 Setup program have installed programs and DLLs into
  # "C:/Program Files/GnuWin32" by default.
  # This is convenience setting for Windows.
  SET(CMAKE_PREFIX_PATH ${__GNUWIN32PATH} $(CMAKE_PREFIX_PATH))
  #
  # If you didn't use Setup program or installed into nonstandard path,
  # cmake cannot find out your zlib or bzip2 libraries and include files,
  # you should execute cmake with  -DCMAKE_PREFIX_PATH option.
  #   e.g.
  #     cmake -DCMAKE_PREFIX_PATH=<your-GnuWin32-path> <path-to-source>
  #
  # If compiling error occured in zconf.h, You may need patch to zconf.h.
  #--- zconf.h.orig 2005-07-21 00:40:26.000000000
  #+++ zconf.h  2009-01-19 11:39:10.093750000
  #@@ -286,7 +286,7 @@
  # 
  # #if 1           /* HAVE_UNISTD_H -- this line is updated by ./configure */
  # #  include <sys/types.h> /* for off_t */
  #-#  include <unistd.h>    /* for SEEK_* and off_t */
  #+#  include <stdio.h>    /* for SEEK_* and off_t */
  # #  ifdef VMS
  # #    include <unixio.h>   /* for off_t */
  # #  endif
ENDIF(DEFINED __GNUWIN32PATH AND EXISTS "${__GNUWIN32PATH}")

SET(ADDITIONAL_LIBS "")

#
# Find ZLIB
#
FIND_PACKAGE(ZLIB)
IF(ZLIB_FOUND)
  SET(HAVE_LIBZ 1)
  SET(HAVE_ZLIB_H 1)
  INCLUDE_DIRECTORIES(${ZLIB_INCLUDE_DIR})
  LIST(APPEND ADDITIONAL_LIBS ${ZLIB_LIBRARIES})
ENDIF(ZLIB_FOUND)
MARK_AS_ADVANCED(CLEAR ZLIB_INCLUDE_DIR)
MARK_AS_ADVANCED(CLEAR ZLIB_LIBRARY)
#
# Find BZip2
#
FIND_PACKAGE(BZip2)
IF(BZIP2_FOUND)
  SET(HAVE_LIBBZ2 1)
  SET(HAVE_BZLIB_H 1)
  INCLUDE_DIRECTORIES(${BZIP2_INCLUDE_DIR})
  # if building inside cmake do not add this lib
  # as it will not exist at try compile time
  IF(NOT BUILD_ARCHIVE_WITHIN_CMAKE)
    LIST(APPEND ADDITIONAL_LIBS ${BZIP2_LIBRARIES})
  ENDIF()
ENDIF(BZIP2_FOUND)
MARK_AS_ADVANCED(CLEAR BZIP2_INCLUDE_DIR)
MARK_AS_ADVANCED(CLEAR BZIP2_LIBRARIES)
#
# Find LZMA
#
FIND_PACKAGE(LZMA)
IF(LZMA_FOUND)
  SET(HAVE_LIBLZMA 1)
  SET(HAVE_LZMA_H 1)
  INCLUDE_DIRECTORIES(${LZMA_INCLUDE_DIR})
  LIST(APPEND ADDITIONAL_LIBS ${LZMA_LIBRARIES})
  MARK_AS_ADVANCED(CLEAR LZMA_INCLUDE_DIR)
  MARK_AS_ADVANCED(CLEAR LZMA_LIBRARY)
ELSEIF(LZMADEC_FOUND)
  SET(HAVE_LIBLZMADEC 1)
  SET(HAVE_LZMADEC_H 1)
  INCLUDE_DIRECTORIES(${LZMADEC_INCLUDE_DIR})
  LIST(APPEND ADDITIONAL_LIBS ${LZMADEC_LIBRARIES})
  MARK_AS_ADVANCED(CLEAR LZMADEC_INCLUDE_DIR)
  MARK_AS_ADVANCED(CLEAR LZMADEC_LIBRARY)
ELSE(LZMA_FOUND)
  MARK_AS_ADVANCED(CLEAR LZMA_INCLUDE_DIR)
  MARK_AS_ADVANCED(CLEAR LZMA_LIBRARY)
ENDIF(LZMA_FOUND)

#
# Check headers
#
CHECK_HEADER_STDC()
CHECK_HEADER_DIRENT()

SET(INCLUDES "")
MACRO (LA_CHECK_INCLUDE_FILE header var)
      CHECK_INCLUDE_FILES("${INCLUDES};${header}" ${var})
      IF (${var})
         SET(INCLUDES ${INCLUDES} ${header})
      ENDIF (${var})
ENDMACRO (LA_CHECK_INCLUDE_FILE)

# Few headers that must precede other headers
# Must precede sys/extattr.h on FreeBSD
LA_CHECK_INCLUDE_FILE("sys/types.h" HAVE_SYS_TYPES_H)

# Alphabetize the rest unless there's a compelling reason
LA_CHECK_INCLUDE_FILE("acl/libacl.h" HAVE_ACL_LIBACL_H)
LA_CHECK_INCLUDE_FILE("attr/xattr.h" HAVE_ATTR_XATTR_H)
LA_CHECK_INCLUDE_FILE("ctype.h" HAVE_CTYPE_H)
LA_CHECK_INCLUDE_FILE("direct.h" HAVE_DIRECT_H)
LA_CHECK_INCLUDE_FILE("dlfcn.h" HAVE_DLFCN_H)
LA_CHECK_INCLUDE_FILE("errno.h" HAVE_ERRNO_H)
LA_CHECK_INCLUDE_FILE("ext2fs/ext2_fs.h" HAVE_EXT2FS_EXT2_FS_H)
LA_CHECK_INCLUDE_FILE("fcntl.h" HAVE_FCNTL_H)
LA_CHECK_INCLUDE_FILE("grp.h" HAVE_GRP_H)
LA_CHECK_INCLUDE_FILE("inttypes.h" HAVE_INTTYPES_H)
LA_CHECK_INCLUDE_FILE("io.h" HAVE_IO_H)
LA_CHECK_INCLUDE_FILE("langinfo.h" HAVE_LANGINFO_H)
LA_CHECK_INCLUDE_FILE("limits.h" HAVE_LIMITS_H)
LA_CHECK_INCLUDE_FILE("linux/fs.h" HAVE_LINUX_FS_H)
LA_CHECK_INCLUDE_FILE("locale.h" HAVE_LOCALE_H)
LA_CHECK_INCLUDE_FILE("memory.h" HAVE_MEMORY_H)
LA_CHECK_INCLUDE_FILE("paths.h" HAVE_PATHS_H)
LA_CHECK_INCLUDE_FILE("poll.h" HAVE_POLL_H)
LA_CHECK_INCLUDE_FILE("process.h" HAVE_PROCESS_H)
LA_CHECK_INCLUDE_FILE("pwd.h" HAVE_PWD_H)
LA_CHECK_INCLUDE_FILE("regex.h" HAVE_REGEX_H)
LA_CHECK_INCLUDE_FILE("signal.h" HAVE_SIGNAL_H)
LA_CHECK_INCLUDE_FILE("stdarg.h" HAVE_STDARG_H)
LA_CHECK_INCLUDE_FILE("stdint.h" HAVE_STDINT_H)
LA_CHECK_INCLUDE_FILE("stdlib.h" HAVE_STDLIB_H)
LA_CHECK_INCLUDE_FILE("string.h" HAVE_STRING_H)
LA_CHECK_INCLUDE_FILE("strings.h" HAVE_STRINGS_H)
LA_CHECK_INCLUDE_FILE("sys/acl.h" HAVE_SYS_ACL_H)
LA_CHECK_INCLUDE_FILE("sys/extattr.h" HAVE_SYS_EXTATTR_H)
LA_CHECK_INCLUDE_FILE("sys/ioctl.h" HAVE_SYS_IOCTL_H)
LA_CHECK_INCLUDE_FILE("sys/mkdev.h" HAVE_SYS_MKDEV_H)
LA_CHECK_INCLUDE_FILE("sys/param.h" HAVE_SYS_PARAM_H)
LA_CHECK_INCLUDE_FILE("sys/poll.h" HAVE_SYS_POLL_H)
LA_CHECK_INCLUDE_FILE("sys/select.h" HAVE_SYS_SELECT_H)
LA_CHECK_INCLUDE_FILE("sys/stat.h" HAVE_SYS_STAT_H)
LA_CHECK_INCLUDE_FILE("sys/time.h" HAVE_SYS_TIME_H)
LA_CHECK_INCLUDE_FILE("sys/utime.h" HAVE_SYS_UTIME_H)
LA_CHECK_INCLUDE_FILE("sys/wait.h" HAVE_SYS_WAIT_H)
LA_CHECK_INCLUDE_FILE("time.h" HAVE_TIME_H)
LA_CHECK_INCLUDE_FILE("unistd.h" HAVE_UNISTD_H)
LA_CHECK_INCLUDE_FILE("utime.h" HAVE_UTIME_H)
LA_CHECK_INCLUDE_FILE("wchar.h" HAVE_WCHAR_H)
LA_CHECK_INCLUDE_FILE("wctype.h" HAVE_WCTYPE_H)
LA_CHECK_INCLUDE_FILE("windows.h" HAVE_WINDOWS_H)


#
# Some headers require extra includes when they're available.
#

#
# Find OpenSSL
#
FIND_PACKAGE(OpenSSL)
IF(OPENSSL_FOUND)
  INCLUDE_DIRECTORIES(${OPENSSL_INCLUDE_DIR})
  LIST(APPEND ADDITIONAL_LIBS ${OPENSSL_LIBRARIES})
ENDIF(OPENSSL_FOUND)
#
# Check MD5/RMD160/SHA headers
#
LA_CHECK_INCLUDE_FILE("md5.h" HAVE_MD5_H)
LA_CHECK_INCLUDE_FILE("openssl/md5.h" HAVE_OPENSSL_MD5_H)
LA_CHECK_INCLUDE_FILE("openssl/ripemd.h" HAVE_OPENSSL_RIPEMD_H)
LA_CHECK_INCLUDE_FILE("openssl/sha.h" HAVE_OPENSSL_SHA_H)
LA_CHECK_INCLUDE_FILE("ripemd.h" HAVE_RIPEMD_H)
LA_CHECK_INCLUDE_FILE("rmd160.h" HAVE_RMD160_H)
LA_CHECK_INCLUDE_FILE("sha.h" HAVE_SHA_H)
LA_CHECK_INCLUDE_FILE("sha1.h" HAVE_SHA1_H)
LA_CHECK_INCLUDE_FILE("sha2.h" HAVE_SHA2_H)
LA_CHECK_INCLUDE_FILE("sha256.h" HAVE_SHA256_H)

#
# Find MD5/RMD160/SHA library
#
FIND_LIBRARY(CRYPTO_LIBRARY NAMES crypto)
IF(CRYPTO_LIBRARY)
  LIST(APPEND ADDITIONAL_LIBS ${CRYPTO_LIBRARY})
ELSE(CRYPTO_LIBRARY)
  IF(NOT OPENSSL_FOUND)
    FIND_LIBRARY(MD_LIBRARY NAMES md)
    IF(MD_LIBRARY)
      LIST(APPEND ADDITIONAL_LIBS ${MD_LIBRARY})
    ENDIF(MD_LIBRARY)
  ENDIF(NOT OPENSSL_FOUND)
ENDIF(CRYPTO_LIBRARY)
#
# Check MD5/RMD160/SHA functions
#
SET(CMAKE_REQUIRED_LIBRARIES ${ADDITIONAL_LIBS})
CHECK_FUNCTION_EXISTS(MD5_Init HAVE_MD5_Init)
IF(NOT HAVE_MD5_Init)
  CHECK_FUNCTION_EXISTS(MD5Init HAVE_MD5Init)
  IF(HAVE_MD5Init)
    SET(MD5_Init, "MD5Init")
    SET(MD5_Update, "MD5Update")
    SET(MD5_Final, "MD5Final")
  ENDIF(HAVE_MD5Init)
ENDIF(NOT HAVE_MD5_Init)
IF(HAVE_MD5_Init OR HAVE_MD5Init)
  SET(HAVE_MD5 1)
ENDIF(HAVE_MD5_Init OR HAVE_MD5Init)
#
CHECK_FUNCTION_EXISTS(RIPEMD160_Init HAVE_RIPEMD160_Init)
IF(NOT HAVE_RIPEMD160_Init)
  CHECK_FUNCTION_EXISTS(RMD160Init HAVE_RMD160Init)
  IF(HAVE_RMD160Init)
    SET(RIPEMD160_Init, "RMD160Init")
    SET(RIPEMD160_Update, "RMD160Update")
    SET(RIPEMD160_Final, "RMD160Final")
  ENDIF(HAVE_RMD160Init)
ENDIF(NOT HAVE_RIPEMD160_Init)
IF(HAVE_RIPEMD160_Init OR HAVE_RMD160Init)
  SET(HAVE_RMD160 1)
ENDIF(HAVE_RIPEMD160_Init OR HAVE_RMD160Init)
#
CHECK_FUNCTION_EXISTS(SHA1_Init HAVE_SHA1_Init)
IF(NOT HAVE_SHA1_Init)
  CHECK_FUNCTION_EXISTS(SHA1Init HAVE_SHA1Init)
  IF(HAVE_SHA1Init)
    SET(SHA1_Init, "SHA1Init")
    SET(SHA1_Update, "SHA1Update")
    SET(SHA1_Final, "SHA1Final")
  ENDIF(HAVE_SHA1Init)
ENDIF(NOT HAVE_SHA1_Init)
IF(HAVE_SHA1_Init OR HAVE_SHA1Init)
  SET(HAVE_SHA1 1)
ENDIF(HAVE_SHA1_Init OR HAVE_SHA1Init)
#
CHECK_FUNCTION_EXISTS(SHA256_Init HAVE_SHA256)
CHECK_FUNCTION_EXISTS(SHA384_Init HAVE_SHA384)
CHECK_FUNCTION_EXISTS(SHA512_Init HAVE_SHA512)

#
# Check functions
#
CHECK_SYMBOL_EXISTS(CreateHardLinkA "windows.h" HAVE_CREATEHARDLINKA)
CHECK_SYMBOL_EXISTS(CreateHardLinkW "windows.h" HAVE_CREATEHARDLINKW)
CHECK_FUNCTION_EXISTS_GLIBC(chflags HAVE_CHFLAGS)
CHECK_FUNCTION_EXISTS_GLIBC(chown HAVE_CHOWN)
CHECK_FUNCTION_EXISTS_GLIBC(chroot HAVE_CHROOT)
CHECK_FUNCTION_EXISTS_GLIBC(fchdir HAVE_FCHDIR)
CHECK_FUNCTION_EXISTS_GLIBC(fchflags HAVE_FCHFLAGS)
CHECK_FUNCTION_EXISTS_GLIBC(fchmod HAVE_FCHMOD)
CHECK_FUNCTION_EXISTS_GLIBC(fchown HAVE_FCHOWN)
CHECK_FUNCTION_EXISTS_GLIBC(fcntl HAVE_FCNTL)
CHECK_FUNCTION_EXISTS_GLIBC(fork HAVE_FORK)
CHECK_FUNCTION_EXISTS_GLIBC(fstat HAVE_FSTAT)
CHECK_FUNCTION_EXISTS_GLIBC(ftruncate HAVE_FTRUNCATE)
CHECK_FUNCTION_EXISTS_GLIBC(futimes HAVE_FUTIMES)
CHECK_FUNCTION_EXISTS_GLIBC(geteuid HAVE_GETEUID)
CHECK_FUNCTION_EXISTS_GLIBC(getpid HAVE_GETPID)
CHECK_FUNCTION_EXISTS_GLIBC(lchflags HAVE_LCHFLAGS)
CHECK_FUNCTION_EXISTS_GLIBC(lchmod HAVE_LCHMOD)
CHECK_FUNCTION_EXISTS_GLIBC(lchown HAVE_LCHOWN)
CHECK_FUNCTION_EXISTS_GLIBC(link HAVE_LINK)
CHECK_FUNCTION_EXISTS_GLIBC(lstat HAVE_LSTAT)
CHECK_FUNCTION_EXISTS_GLIBC(lutimes HAVE_LUTIMES)
CHECK_FUNCTION_EXISTS_GLIBC(memmove HAVE_MEMMOVE)
CHECK_FUNCTION_EXISTS_GLIBC(mkdir HAVE_MKDIR)
CHECK_FUNCTION_EXISTS_GLIBC(mkfifo HAVE_MKFIFO)
CHECK_FUNCTION_EXISTS_GLIBC(mknod HAVE_MKNOD)
CHECK_FUNCTION_EXISTS_GLIBC(nl_langinfo HAVE_NL_LANGINFO)
CHECK_FUNCTION_EXISTS_GLIBC(pipe HAVE_PIPE)
CHECK_FUNCTION_EXISTS_GLIBC(poll HAVE_POLL)
CHECK_FUNCTION_EXISTS_GLIBC(readlink HAVE_READLINK)
CHECK_FUNCTION_EXISTS_GLIBC(select HAVE_SELECT)
CHECK_FUNCTION_EXISTS_GLIBC(setenv HAVE_SETENV)
CHECK_FUNCTION_EXISTS_GLIBC(setlocale HAVE_SETLOCALE)
CHECK_FUNCTION_EXISTS_GLIBC(strchr HAVE_STRCHR)
CHECK_FUNCTION_EXISTS_GLIBC(strdup HAVE_STRDUP)
CHECK_FUNCTION_EXISTS_GLIBC(strerror HAVE_STRERROR)
CHECK_FUNCTION_EXISTS_GLIBC(strncpy_s HAVE_STRNCPY_S)
CHECK_FUNCTION_EXISTS_GLIBC(strrchr HAVE_STRRCHR)
CHECK_FUNCTION_EXISTS_GLIBC(symlink HAVE_SYMLINK)
CHECK_FUNCTION_EXISTS_GLIBC(timegm HAVE_TIMEGM)
CHECK_FUNCTION_EXISTS_GLIBC(tzset HAVE_TZSET)
CHECK_FUNCTION_EXISTS_GLIBC(unsetenv HAVE_UNSETENV)
CHECK_FUNCTION_EXISTS_GLIBC(utime HAVE_UTIME)
CHECK_FUNCTION_EXISTS_GLIBC(utimes HAVE_UTIMES)
CHECK_FUNCTION_EXISTS_GLIBC(vfork HAVE_VFORK)
CHECK_FUNCTION_EXISTS_GLIBC(wcrtomb HAVE_WCRTOMB)
CHECK_FUNCTION_EXISTS_GLIBC(wcscpy HAVE_WCSCPY)
CHECK_FUNCTION_EXISTS_GLIBC(wcslen HAVE_WCSLEN)
CHECK_FUNCTION_EXISTS_GLIBC(wctomb HAVE_WCTOMB)
CHECK_SYMBOL_EXISTS(wmemcmp "wchar.h" HAVE_WMEMCMP)
CHECK_SYMBOL_EXISTS(wmemcpy "wchar.h" HAVE_WMEMCPY)

SET(CMAKE_REQUIRED_LIBRARIES "")
CHECK_SYMBOL_EXISTS(fseeko           "stdio.h"    HAVE_FSEEKO)
CHECK_SYMBOL_EXISTS(strerror_r       "string.h"   HAVE_STRERROR_R)
CHECK_SYMBOL_EXISTS(strftime         "time.h"     HAVE_STRFTIME)
CHECK_SYMBOL_EXISTS(vprintf          "stdio.h"    HAVE_VPRINTF)

IF(HAVE_STRERROR_R)
  SET(HAVE_DECL_STRERROR_R 1)
ENDIF(HAVE_STRERROR_R)

#
# Check defines
#
CHECK_SYMBOL_EXISTS(EFTYPE           "errno.h"    HAVE_EFTYPE)
CHECK_SYMBOL_EXISTS(EILSEQ           "errno.h"    HAVE_EILSEQ)
CHECK_SYMBOL_EXISTS(D_MD_ORDER       "langinfo.h" HAVE_D_MD_ORDER)
CHECK_SYMBOL_EXISTS(optarg           "unistd.h"   HAVE_DECL_OPTARG)
CHECK_SYMBOL_EXISTS(optind           "unistd.h"   HAVE_DECL_OPTIND)
IF(HAVE_STDINT_H)
  CHECK_SYMBOL_EXISTS(INT64_MAX      "stdint.h"   HAVE_DECL_INT64_MAX)
  CHECK_SYMBOL_EXISTS(INT64_MIN      "stdint.h"   HAVE_DECL_INT64_MIN)
  CHECK_SYMBOL_EXISTS(UINT32_MAX     "stdint.h"   HAVE_DECL_UINT32_MAX)
  CHECK_SYMBOL_EXISTS(UINT64_MAX     "stdint.h"   HAVE_DECL_UINT64_MAX)
  CHECK_SYMBOL_EXISTS(SIZE_MAX       "stdint.h"   HAVE_DECL_SIZE_MAX)
ELSE(HAVE_STDINT_H)
  CHECK_SYMBOL_EXISTS(INT64_MAX      "limits.h"   HAVE_DECL_INT64_MAX)
  CHECK_SYMBOL_EXISTS(INT64_MIN      "limits.h"   HAVE_DECL_INT64_MIN)
  CHECK_SYMBOL_EXISTS(UINT32_MAX     "limits.h"   HAVE_DECL_UINT32_MAX)
  CHECK_SYMBOL_EXISTS(UINT64_MAX     "limits.h"   HAVE_DECL_UINT64_MAX)
  CHECK_SYMBOL_EXISTS(SIZE_MAX       "limits.h"   HAVE_DECL_SIZE_MAX)
ENDIF(HAVE_STDINT_H)
CHECK_SYMBOL_EXISTS(SSIZE_MAX        "limits.h"   HAVE_DECL_SSIZE_MAX)

#
# Check struct members
#
# Check for birthtime in struct stat
CHECK_STRUCT_MEMBER("struct stat" st_birthtime
    "sys/types.h;sys/stat.h" HAVE_STRUCT_STAT_ST_BIRTHTIME)

# Check for high-resolution timestamps in struct stat
CHECK_STRUCT_MEMBER("struct stat" st_birthtimespec.tv_nsec
    "sys/types.h;sys/stat.h" HAVE_STRUCT_STAT_ST_BIRTHTIMESPEC_TV_NSEC)
CHECK_STRUCT_MEMBER("struct stat" st_mtimespec.tv_nsec
    "sys/types.h;sys/stat.h" HAVE_STRUCT_STAT_ST_MTIMESPEC_TV_NSEC)
CHECK_STRUCT_MEMBER("struct stat" st_mtim.tv_nsec
    "sys/types.h;sys/stat.h" HAVE_STRUCT_STAT_ST_MTIM_TV_NSEC)
CHECK_STRUCT_MEMBER("struct stat" st_mtime_n
    "sys/types.h;sys/stat.h" HAVE_STRUCT_STAT_ST_MTIME_N)
CHECK_STRUCT_MEMBER("struct stat" st_umtime
    "sys/types.h;sys/stat.h" HAVE_STRUCT_STAT_ST_UMTIME)
CHECK_STRUCT_MEMBER("struct stat" st_mtime_usec
    "sys/types.h;sys/stat.h" HAVE_STRUCT_STAT_ST_MTIME_USEC)
# Check for block size support in struct stat
CHECK_STRUCT_MEMBER("struct stat" st_blksize
    "sys/types.h;sys/stat.h" HAVE_STRUCT_STAT_ST_BLKSIZE)
# Check for st_flags in struct stat (BSD fflags)
CHECK_STRUCT_MEMBER("struct stat" st_flags
    "sys/types.h;sys/stat.h" HAVE_STRUCT_STAT_ST_FLAGS)
#
#
CHECK_STRUCT_MEMBER("struct tm" tm_sec
    "sys/types.h;sys/time.h;time.h" TIME_WITH_SYS_TIME)

#
# Check for integer types
#
# XXX There must be a way to make this simpler <sigh> XXXX
#
CHECK_TYPE_SIZE("long long int"            LONG_LONG_INT)
CHECK_TYPE_SIZE("unsigned long long"       UNSIGNED_LONG_LONG)
CHECK_TYPE_SIZE("unsigned long long int"   UNSIGNED_LONG_LONG_INT)

#
CHECK_TYPE_SIZE(dev_t       DEV_T)
IF(NOT HAVE_DEV_T)
  IF(MSVC)
    SET(dev_t "unsigned int")
  ENDIF(MSVC)
ENDIF(NOT HAVE_DEV_T)
#
CHECK_TYPE_SIZE(gid_t       GID_T)
IF(NOT HAVE_GID_T)
  IF(WIN32)
    SET(gid_t "short")
  ELSEIF(WIN32)
    SET(gid_t "unsigned int")
  ENDIF(WIN32)
ENDIF(NOT HAVE_GID_T)
#
CHECK_TYPE_SIZE(id_t        ID_T)
IF(NOT HAVE_ID_T)
  IF(WIN32)
    SET(id_t "short")
  ELSEIF(WIN32)
    SET(id_t "unsigned int")
  ENDIF(WIN32)
ENDIF(NOT HAVE_ID_T)
#
CHECK_TYPE_SIZE(int64_t     INT64_T)
IF(NOT HAVE_INT64_T)
  IF(MSVC)
    SET(int64_t __int64)
  ENDIF(MSVC)
ENDIF(NOT HAVE_INT64_T)
#
CHECK_TYPE_SIZE(intmax_t    INTMAX_T)
IF(NOT HAVE_INTMAX_T)
  IF(MSVC)
    SET(intmax_t "long long")
  ENDIF(MSVC)
ENDIF(NOT HAVE_INTMAX_T)
#
CHECK_TYPE_SIZE(mode_t      MODE_T)
IF(NOT HAVE_MODE_T)
  IF(MSVC)
    SET(mode_t "unsigned short")
  ELSE(MSVC)
    SET(mode_t "int")
  ENDIF(MSVC)
ENDIF(NOT HAVE_MODE_T)
#
CHECK_TYPE_SIZE(off_t       OFF_T)
IF(NOT HAVE_OFF_T)
  SET(off_t "long long")
ENDIF(NOT HAVE_OFF_T)
#
CHECK_TYPE_SIZE(size_t      SIZE_T)
IF(NOT HAVE_SIZE_T)
  SET(size_t "unsigned int")
ENDIF(NOT HAVE_SIZE_T)
#
CHECK_TYPE_SIZE(ssize_t     SSIZE_T)
IF(NOT HAVE_SSIZE_T)
  IF(MSVC)
    IF(CMAKE_CL_64)
      SET(ssize_t "__int64")
    ELSE(CMAKE_CL_64)
      SET(ssize_t   "signed long")
    ENDIF(CMAKE_CL_64)
  ELSE(MSVC)
      SET(ssize_t   "int")
  ENDIF(MSVC)
ENDIF(NOT HAVE_SSIZE_T)
#
CHECK_TYPE_SIZE(uid_t       UID_T)
IF(NOT HAVE_UID_T)
  IF(WIN32)
    SET(uid_t "short")
  ELSEIF(WIN32)
    SET(uid_t "unsigned int")
  ENDIF(WIN32)
ENDIF(NOT HAVE_UID_T)
#
CHECK_TYPE_SIZE(uint16_t    UINT16_T)
IF(NOT HAVE_UINT16_T)
  IF(MSVC)
    SET(uint16_t "unsigned short")
  ENDIF(MSVC)
ENDIF(NOT HAVE_UINT16_T)
#
CHECK_TYPE_SIZE(uint32_t    UINT32_T)
IF(NOT HAVE_UINT32_T)
  IF(MSVC)
    SET(uint32_t "unsigned int")
  ENDIF(MSVC)
ENDIF(NOT HAVE_UINT32_T)
CHECK_TYPE_SIZE(int32_t    INT32_T)
IF(NOT HAVE_INT32_T)
  IF(MSVC)
    SET(int32_t "int")
  ENDIF(MSVC)
ENDIF(NOT HAVE_INT32_T)
#
CHECK_TYPE_SIZE(uint64_t    UINT64_T)
IF(NOT HAVE_UINT64_T)
  IF(MSVC)
    SET(uint64_t "unsigned __int64")
  ENDIF(MSVC)
ENDIF(NOT HAVE_UINT64_T)
#
CHECK_TYPE_SIZE(uintmax_t   UINTMAX_T)
IF(NOT HAVE_UINTMAX_T)
  IF(MSVC)
    SET(uintmax_t "unsigned long long")
  ENDIF(MSVC)
ENDIF(NOT HAVE_UINTMAX_T)
#
CHECK_TYPE_SIZE(wchar_t     SIZEOF_WCHAR_T)
IF(HAVE_SIZEOF_WCHAR_T)
  SET(HAVE_WCHAR_T 1)
ENDIF(HAVE_SIZEOF_WCHAR_T)
#
# Check if _FILE_OFFSET_BITS macro needed for large files
#
CHECK_FILE_OFFSET_BITS()



#
# Check for Extended Attribute libraries, headers, and functions
#
IF(ENABLE_XATTR)
  LA_CHECK_INCLUDE_FILE(attr/xattr.h     HAVE_ATTR_XATTR_H)
  LA_CHECK_INCLUDE_FILE(sys/xattr.h      HAVE_SYS_XATTR_H)
  CHECK_LIBRARY_EXISTS(attr "setxattr" "" HAVE_ATTR_LIB)
  IF(HAVE_ATTR_LIB)
    SET(CMAKE_REQUIRED_LIBRARIES "attr")
  ENDIF(HAVE_ATTR_LIB)
  CHECK_FUNCTION_EXISTS_GLIBC(extattr_get_file HAVE_EXTATTR_GET_FILE)
  CHECK_FUNCTION_EXISTS_GLIBC(extattr_list_file HAVE_EXTATTR_LIST_FILE)
  CHECK_FUNCTION_EXISTS_GLIBC(extattr_set_fd HAVE_EXTATTR_SET_FD)
  CHECK_FUNCTION_EXISTS_GLIBC(extattr_set_file HAVE_EXTATTR_SET_FILE)
  CHECK_FUNCTION_EXISTS_GLIBC(fsetxattr HAVE_FSETXATTR)
  CHECK_FUNCTION_EXISTS_GLIBC(getxattr HAVE_GETXATTR)
  CHECK_FUNCTION_EXISTS_GLIBC(lgetxattr HAVE_LGETXATTR)
  CHECK_FUNCTION_EXISTS_GLIBC(listxattr HAVE_LISTXATTR)
  CHECK_FUNCTION_EXISTS_GLIBC(llistxattr HAVE_LLISTXATTR)
  CHECK_FUNCTION_EXISTS_GLIBC(lsetxattr HAVE_LSETXATTR)
ENDIF(ENABLE_XATTR)

#
# Check for ACL libraries, headers, and functions
#
# The ACL support in libarchive is written against the POSIX1e draft,
# which was never officially approved and varies quite a bit across
# platforms.  Worse, some systems have completely non-POSIX acl functions,
# which makes the following checks rather more complex than I would like.
#
IF(ENABLE_ACL)
  CHECK_LIBRARY_EXISTS(acl "acl_get_file" "" HAVE_ACL_LIB)
  IF(HAVE_ACL_LIB)
    SET(CMAKE_REQUIRED_LIBRARIES "acl")
    FIND_LIBRARY(ACL_LIBRARY NAMES acl)
    LIST(APPEND ADDITIONAL_LIBS ${ACL_LIBRARY})
  ENDIF(HAVE_ACL_LIB)
  #
  CHECK_FUNCTION_EXISTS_GLIBC(acl_create_entry HAVE_ACL_CREATE_ENTRY)
  CHECK_FUNCTION_EXISTS_GLIBC(acl_init HAVE_ACL_INIT)
  CHECK_FUNCTION_EXISTS_GLIBC(acl_set_fd HAVE_ACL_SET_FD)
  CHECK_FUNCTION_EXISTS_GLIBC(acl_set_fd_np HAVE_ACL_SET_FD_NP)
  CHECK_FUNCTION_EXISTS_GLIBC(acl_set_file HAVE_ACL_SET_FILE)
  CHECK_TYPE_EXISTS(acl_permset_t "${INCLUDES}"    HAVE_ACL_PERMSET_T)

  # The "acl_get_perm()" function was omitted from the POSIX draft.
  # (It's a pretty obvious oversight; otherwise, there's no way to
  # test for specific permissions in a permset.)  Linux uses the obvious
  # name, FreeBSD adds _np to mark it as "non-Posix extension."
  # Test for both as a double-check that we really have POSIX-style ACL support.
  CHECK_SYMBOL_EXISTS(acl_get_perm "${INCLUDES}" HAVE_ACL_GET_PERM)
  CHECK_SYMBOL_EXISTS(acl_get_perm_np "${INCLUDES}" HAVE_ACL_GET_PERM_NP)
  CHECK_SYMBOL_EXISTS(acl_get_link "${INCLUDES}" HAVE_ACL_GET_LINK)
  CHECK_SYMBOL_EXISTS(acl_get_link_np "${INCLUDES}" HAVE_ACL_GET_LINK_NP)

  # MacOS has an acl.h that isn't POSIX.  It can be detected by
  # checking for ACL_USER
  CHECK_SYMBOL_EXISTS(ACL_USER "${INCLUDES}" HAVE_ACL_USER)
ENDIF(ENABLE_ACL)

# Check whether printf() supports "%jd"
CHECK_C_SOURCE_RUNS("
   #include <stdint.h>
   #include <stdio.h>
   #include <string.h>
   static char buf[100];
   int main() {
     sprintf(buf, \"%jd\", (intmax_t)7);
     if (strcmp(buf, \"7\")) return 1;
     sprintf(buf, \"%ju\", (uintmax_t)7);
     return (strcmp(buf, \"7\"));
   }" HAVE_PRINTF_JD)

# Check whether printf() supports "%lld"
CHECK_C_SOURCE_RUNS("
   #include <stdint.h>
   #include <stdio.h>
   #include <string.h>
   static char buf[100];
   int main() {
     sprintf(buf, \"%lld\", (long long)7);
     if (strcmp(buf, \"7\")) return 1;
     sprintf(buf, \"%llu\", (long long)7);
     return (strcmp(buf, \"7\"));
   }" HAVE_PRINTF_LLD)

# Generate "config.h" from "build/cmake/config.h.in"
CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/build/cmake/config.h.in
    ${CMAKE_CURRENT_BINARY_DIR}/config.h)
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR})
ADD_DEFINITIONS(-DHAVE_CONFIG_H)

#
# Register installation of PDF documents.
#
IF(WIN32 AND NOT CYGWIN)
  #
  # On Windows platform, It's better that we install PDF documents
  # on one's computer.
  # These PDF documents are available in the release package.
  #
  IF(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/doc/pdf)
    INSTALL(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/doc/pdf
            DESTINATION share/man
            FILES_MATCHING PATTERN "*.pdf"
    )
  ENDIF(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/doc/pdf)
ENDIF(WIN32 AND NOT CYGWIN)
#
#
#
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/libarchive)
#
IF(MSVC)
  ADD_DEFINITIONS(-D_CRT_SECURE_NO_DEPRECATE)
ENDIF(MSVC)
# Especially for early development, we want to be a little
# aggressive about diagnosing build problems; this can get
# relaxed somewhat in final shipping versions.
IF ("CMAKE_C_COMPILER_ID" MATCHES "^GNU$")
  ADD_DEFINITIONS(-Wall -Werror)
ENDIF ("CMAKE_C_COMPILER_ID" MATCHES "^GNU$")

IF(ENABLE_TEST)
ADD_CUSTOM_TARGET(run_all_tests)
ENDIF(ENABLE_TEST)

add_subdirectory(libarchive)
#add_subdirectory(tar)
#add_subdirectory(cpio)

--- NEW FILE: COPYING ---
The libarchive distribution as a whole is Copyright by Tim Kientzle
and is subject to the copyright notice reproduced at the bottom of
this file.

Each individual file in this distribution should have a clear
copyright/licensing statement at the beginning of the file.  If any do
not, please let me know and I will rectify it.  The following is
intended to summarize the copyright status of the individual files;
the actual statements in the files are controlling.

* Except as listed below, all C sources (including .c and .h files)
  and documentation files are subject to the copyright notice reproduced
  at the bottom of this file.

* The following source files are also subject in whole or in part to
  a 3-clause UC Regents copyright; please read the individual source
  files for details:
   libarchive/archive_entry.c
   libarchive/archive_read_support_compression_compress.c
   libarchive/archive_write_set_compression_compress.c
   libarchive/mtree.5
   tar/matching.c

* The following source files are in the public domain:
   tar/getdate.c

* The build files---including Makefiles, configure scripts,
  and auxiliary scripts used as part of the compile process---have
  widely varying licensing terms.  Please check individual files before
  distributing them to see if those restrictions apply to you.

I intend for all new source code to use the license below and hope over
time to replace code with other licenses with new implementations that
do use the license below.  The varying licensing of the build scripts
seems to be an unavoidable mess.


Copyright (c) 2003-2009 <author(s)>
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
   notice, this list of conditions and the following disclaimer
   in this position and unchanged.
2. Redistributions in binary form must reproduce the above copyright
   notice, this list of conditions and the following disclaimer in the
   documentation and/or other materials provided with the distribution.

THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

--- NEW FILE: README ---
README for libarchive bundle.

Questions?  Issues?
   * http://libarchive.googlecode.com/ is the home for ongoing
     libarchive development, including issue tracker, additional
     documentation, and links to the libarchive mailing lists.

This distribution bundle includes the following components:
   * libarchive: a library for reading and writing streaming archives
   * tar: the 'bsdtar' program is a full-featured 'tar'
          replacement built on libarchive
   * cpio: the 'bsdcpio' program is a different interface to
          essentially the same functionality
   * examples: Some small example programs that you may find useful.
   * examples/minitar: a compact sample demonstrating use of libarchive.
          I use this for testing link pollution; it should produce a very
          small executable file on most systems.
   * contrib:  Various items sent to me by third parties;
          please contact the authors with any questions.

The top-level directory contains the following information files:
   * NEWS - highlights of recent changes
   * COPYING - what you can do with this
   * INSTALL - installation instructions
   * README - this file
   * configure - configuration script, see INSTALL for details.
   * CMakeLists.txt - input for "cmake" build tool, see INSTALL

The following files in the top-level directory are used by the
'configure' script:
   * Makefile.am, aclocal.m4, configure.ac
       - used to build this distribution, only needed by maintainers
   * Makefile.in, config.h.in
    - templates used by configure script

Guide to Documentation installed by this system:
 * bsdtar.1 explains the use of the bsdtar program
 * bsdcpio.1 explains the use of the bsdcpio program
 * libarchive.3 gives an overview of the library as a whole
 * archive_read.3, archive_write.3, archive_write_disk.3, and
   archive_read_disk.3 provide detailed calling sequences for the read
   and write APIs
 * archive_entry.3 details the "struct archive_entry" utility class
 * archive_internals.3 provides some insight into libarchive's
   internal structure and operation.
 * libarchive-formats.5 documents the file formats supported by the library
 * cpio.5, mtree.5, and tar.5 provide detailed information about these
   popular archive formats, including hard-to-find details about
   modern cpio and tar variants.
The manual pages above are provided in the 'doc' directory in
a number of different formats.

You should also read the copious comments in "archive.h" and the
source code for the sample programs for more details.  Please let me
know about any errors or omissions you find.

Currently, the library automatically detects and reads the following:
  * gzip compression
  * bzip2 compression
  * compress/LZW compression
  * lzma and xz compression
  * GNU tar format (including GNU long filenames, long link names, and
    sparse files)
  * Solaris 9 extended tar format (including ACLs)
  * Old V7 tar archives
  * POSIX ustar
  * POSIX pax interchange format
  * POSIX octet-oriented cpio
  * SVR4 ASCII cpio
  * POSIX octet-oriented cpio
  * Binary cpio (big-endian or little-endian)
  * ISO9660 CD-ROM images (with optional Rockridge or Joliet extensions)
  * ZIP archives (with uncompressed or "deflate" compressed entries)
  * GNU and BSD 'ar' archives
  * 'mtree' format

The library can write:
  * gzip compression
  * bzip2 compression
  * compress/LZW compression
  * lzma and xz compression
  * POSIX ustar
  * POSIX pax interchange format
  * "restricted" pax format, which will create ustar archives except for
    entries that require pax extensions (for long filenames, ACLs, etc).
  * POSIX octet-oriented cpio
  * SVR4 "newc" cpio
  * shar archives
  * ZIP archives (with uncompressed or "deflate" compressed entries)
  * GNU and BSD 'ar' archives
  * 'mtree' format

Notes about the library architecture:

 * This is a heavily stream-oriented system.  There is no direct
   support for in-place modification or random access.

 * The library is designed to be extended with new compression and
   archive formats.  The only requirement is that the format be
   readable or writable as a stream and that each archive entry be
   independent.  There are articles on the libarchive Wiki explaining
   how to extend libarchive.

 * On read, compression and format are always detected automatically.

 * I've attempted to minimize static link pollution.  If you don't
   explicitly invoke a particular feature (such as support for a
   particular compression or format), it won't get pulled in.
   In particular, if you don't explicitly enable a particular
   compression or decompression support, you won't need to link
   against the corresponding compression or decompression libraries.
   This also reduces the size of statically-linked binaries in
   environments where that matters.

 * On read, the library accepts whatever blocks you hand it.
   Your read callback is free to pass the library a byte at a time
   or mmap the entire archive and give it to the library at once.
   On write, the library always produces correctly-blocked output.

 * The object-style approach allows you to have multiple archive streams
   open at once.  bsdtar uses this in its "@archive" extension.

 * The archive itself is read/written using callback functions.
   You can read an archive directly from an in-memory buffer or
   write it to a socket, if you wish.  There are some utility
   functions to provide easy-to-use "open file," etc, capabilities.

 * The read/write APIs are designed to allow individual entries
   to be read or written to any data source:  You can create
   a block of data in memory and add it to a tar archive without
   first writing a temporary file.  You can also read an entry from
   an archive and write the data directly to a socket.  If you want
   to read/write entries to disk, there are convenience functions to
   make this especially easy.

 * Note: "pax interchange format" is really an extended tar format,
   despite what the name says.

--- NEW FILE: NEWS ---

Apr 01, 2009: libarchive 2.6.990a released
Apr 01, 2009: Use command-line gunzip, bunzip2, unxz, unlzma for
    decompression if the library is built without suitable
    libraries.  The setup functions return ARCHIVE_WARN
    in this case so clients can adapt if necessary.
Apr 01, 2009: Use getpw*_r and getgr*_r functions for thread-safety.
Mar 24, 2009: Add archive_read_next_header2(), which is up to 25%
    more efficient for some clients; from Brian Harring.
Mar 22, 2009: PDF versions of manpages are now included in the distribution.
Mar, 2009: Major work to improve Cygwin build by Charles Wilson.
Feb/Mar, 2009: Major work on cmake build support, mostly by Michihiro NAKAJIMA.
Feb/Mar, 2009: Major work on Visual Studio support by Michihiro NAKAJIMA.
    All tests now pass.
Feb 25, 2009: Fix Debian Bug #516577
Feb 21, 2009: Yacc is no longer needed to build; date parser rewritten in C.
Jan/Feb, 2009: Mtree work by Michihiro.
Feb, 2009: Joliet support by Andreas Henriksson.
Jan/Feb, 2009: New options framework by Michihiro.
Feb, 2009: High-res timestamps on Tru64, AIX, and GNU Hurd, by Björn Jacke.
Jan 18, 2009: Extended attributes work on FreeBSD and Linux now with pax format.
Jan 07, 2009: New archive_read_disk_entry_from_file() knows about ACLs,
    extended attributes, etc so that bsdtar and bsdcpio don't require
    such system-specific knowledge.
Jan 03, 2009: Read filter system extensively refactored.  In particular,
    read filter pipelines are now built out automatically and individual
    filters should be much easier to implement.  Documentation on the
    Googlecode Wiki explains how to implement new filters.
Dec 28, 2008: Many Windows/Visual Studio fixes from Michihiro NAKAJIMA.

Dec 28, 2008: Main libarchive development moved from FreeBSD Perforce
    server to Google Code.  This should make it easier for more
    people to participate in libarchive development.

Dec 28, 2008: libarchive 2.6.0 released
Dec 25, 2008: libarchive 2.5.905a released
Dec 10, 2008: libarchive 2.5.904a released
Dec 04, 2008: libarchive 2.5.903a released
Nov 09, 2008: libarchive 2.5.902a released
Nov 08, 2008: libarchive 2.5.901a released
Nov 08, 2008: Start of pre-release testing for libarchive 2.6

Nov 07, 2008: Read filter refactor: The decompression routines just
    consume and produce arbitrarily-sized blocks.  The reblocking
    from read_support_compression_none() has been pulled into the
    read core.  Also, the decompression bid now makes multiple
    passes and stacks read filters.
Oct 21, 2008: bsdcpio: New command-line parser.
Oct 19, 2008: Internal read_ahead change: short reads are now an error
Oct 06, 2008: bsdtar: option parser no longer uses getopt_long(),
    gives consistent option parsing on all platforms.
Sep 19, 2008: Jaakko Heinonen: shar utility built on libarchive
Sep 17, 2008: Pedro Giffuni: birthtime support
Sep 17, 2008: Miklos Vajna: lzma reader and test.  Note:  I still have
    some concerns about the auto-detection (LZMA file format
    doesn't support auto-detection well), so this is not yet
    enabled under archive_read_support_compression_all().  For
    now, you must call archive_read_support_compression_lzma() if
    you want LZMA read support.
Sep 11, 2008: Ivailo Petrov: Many fixes to Windows build, new solution files
Jul 26, 2008: archive_entry now tracks which values have not been set.
    This helps zip extraction (file size is often "unknown") and
    time restores (tar usually doesn't know atime).
Jul 26, 2008: Joerg Sonnenberger: Performance improvements to shar writer
Jul 25, 2008: Joerg Sonnenberger: mtree write support

Jul 02, 2008: libarchive 2.5.5 released

Jul 02, 2008: libarchive 2.5.5b released
Jul 01, 2008: bsdcpio is being used by enough people, we can call it 1.0.0 now
Jun 20, 2008: bsdcpio: If a -l link fails with EXDEV, copy the file instead
Jun 19, 2008: bsdcpio: additional long options for better GNU cpio compat
Jun 15, 2008: Many small portability and bugfixes since 2.5.4b.

May 25, 2008: libarchive 2.5.4b released
May 21, 2008: Joerg Sonnenberger: fix bsdtar hardlink handling for newc format

May 21, 2008: More progress on Windows building.  Thanks to "Scott"
        for the Windows makefiles, thanks to Kees Zeelenberg for
        code contributions.

May 21, 2008: Fix a number of non-exploitable integer and buffer overflows,
        thanks to David Remahl at Apple for pointing these out.

May 21, 2008: Colin Percival: SIGINFO or SIGUSR1 to bsdtar prints progress info

May 16, 2008: bsdtar's test harness no longer depends on file ordering.
        This was causing spurious test failures on a lot of systems.
        Thanks to Bernhard R. Link for the diagnosis.

May 14, 2008: Joerg Sonnenberger: -s substitution support for bsdtar

May 13, 2008: Joerg Sonnenberger: Many mtree improvements

May 11, 2008: Joerg Sonnenberger: fix hardlink extraction when
    hardlinks have different permissions from original file

April 30, 2008: Primary libarchive work has been moved into the FreeBSD
    project's Perforce repository:  http://perforce.freebsd.org/
    The libarchive project can be browsed at
        //depot/user/kientzle/libarchive-portable
        Direct link: http://preview.tinyurl.com/46mdgr

May 04, 2008: libarchive 2.5.3b released
    * libarchive: Several fixes to link resolver to address bsdcpio crashes
    * bsdcpio: -p hardlink handling fixes
    * tar/pax: Ensure ustar dirnames end in '/'; be more careful about
      measuring filenames when deciding what pathname fields to use
    * libarchive: Mark which entry strings are set; be accurate about
      distinguishing empty strings ("") from unset ones (NULL)
    * tar: Don't crash reading entries with empty filenames
    * libarchive_test, bsdtar_test, bsdcpio_test:  Better detaults:
      run all tests, delete temp dirs, summarize repeated failures
    * -no-undefined to libtool for Cygwin
    * libarchive_test: Skip large file tests on systems with 32-bit off_t
    * iso9660: Don't bother trying to find the body of an empty file;
      this works around strange behavior from some ISO9660 writers
    * tar: allow -r -T to be used together
    * tar: allow --format with -r or -u
    * libarchive: Don't build archive.h

May 04, 2008: Simplified building: archive.h is no longer constructed
    This may require additional #if conditionals on some platforms.

Mar 30, 2008: libarchive 2.5.1b released

Mar 15, 2008: libarchive 2.5.0b released
Mar 15, 2008: bsdcpio now seems to correctly write hardlinks into newc,
    ustar, and old cpio archives.  Just a little more testing before
    bsdcpio 1.0 becomes a reality.
Mar 15, 2008: I think the new linkify() interface is finally handling
    all known hardlink strategies.
Mar 15, 2008: Mtree read fixes from Joerg Sonnenberger.
Mar 15, 2008: Many new bsdtar and bsdcpio options from Joerg Sonnenberger.
Mar 15, 2008: test harnesses no longer require uudecode; they
    now have built-in decoding logic that decodes the reference
    files as they are needed.

Mar 14, 2008: libarchive 2.4.14 released; identical to 2.4.13 except for
    a point fix for gname/uname mixup in pax format that was introduced
    with the UTF-8 fixes.

Feb 26, 2008: libarchive 2.4.13 released
Feb 25, 2008: Handle path, linkname, gname, or uname that can't be converted
    to/from UTF-8.  Implement "hdrcharset" attribute from SUS-2008.
Feb 25, 2008: Fix name clash on NetBSD.
Feb 18, 2008: Fix writing empty 'ar' archives, per Kai Wang
Feb 18, 2008: [bsdtar] Permit appending on block devices.
Feb 09, 2008: New "linkify" resolver to help with newc hardlink writing;
    bsdcpio still needs to be converted to use this.
Feb 02, 2008: Windows compatibility fixes from Ivailo Petrov, Kees Zeelenberg
Jan 30, 2008: Ignore hardlink size for non-POSIX tar archives.

Jan 22, 2008: libarchive 2.4.12 released
Jan 22, 2008: Fix bad padding when writing symlinks to newc cpio archives.
Jan 22, 2008: Verify bsdcpio_test by getting it to work against GNU cpio 2.9.
    bsdcpio_test complains about missing options (-y and -z), format
    of informational messages (--version, --help), and a minor formatting
    issue in odc format output.  After this update, bsdcpio_test uncovered
    several more cosmetic issues in bsdcpio, all now fixed.
Jan 22, 2008: Experimental support for self-extracting Zip archives.
Jan 22, 2008: Extend hardlink restore strategy to work correctly with
    hardlinks extracted from newc cpio files.  (Which store the body
    only with the last occurrence of a link.)

Dec 30, 2007: libarchive 2.4.11 released
Dec 30, 2007: Fixed a compile error in bsdcpio on some systems.

Dec 29, 2007: libarchive 2.4.10 released
Dec 29, 2007: bsdcpio 0.9.0 is ready for wider use.
Dec 29, 2007: Completed initial test harness for bsdcpio.

Dec 22, 2007: libarchive 2.4.9 released
Dec 22, 2007: Implement the remaining options for bsdcpio:  -a, -q, -L, -f,
    pattern selection for -i and -it.

Dec 13, 2007: libarchive 2.4.8 released
Dec 13, 2007: gzip and bzip2 compression now handle zero-byte writes correctly,
    Thanks to Damien Golding for bringing this to my attention.

Dec 12, 2007: libarchive 2.4.7 released

Dec 10, 2007: libarchive 2.4.6 released
Dec 09, 2007: tar/test/test_copy.c verifies "tar -c | tar -x" copy pipeline
Dec 07, 2007: Fix a couple of minor memory leaks.

Dec 04, 2007: libarchive 2.4.5 released
Dec 04, 2007: Fix cpio/test/test_write_odc by setting the umask first.

Dec 03, 2007: libarchive 2.4.4 released
Dec 03, 2007: New configure options --disable-xattr and --disable-acl,
    thanks to Samuli Suominen.

Dec 03, 2007: libarchive 2.4.3 released
Dec 03, 2007: Thanks to Lapo Luchini for sending me a ZIP file that
    libarchive couldn't handle.  Fixed a bug in handling of
    "length at end" flags in ZIP files.
Dec 03, 2007: Fixed bsdcpio -help, bsdtar -help tests.
Dec 02, 2007: First cut at real bsdtar test harness.

Dec 02, 2007: libarchive 2.4.2 released

Dec 02, 2007: libarchive 2.4.1 released
Dec 02, 2007: Minor fixes, rough cut of mdoc-to-man conversion for
    man pages.

Oct 30, 2007: libarchive 2.4.0 released
Oct 30, 2007: Minor compile fix thanks to Joerg Schilling.
Oct 30, 2007: Only run the format auction once at the beginning of the
    archive.  This is simpler and supports better error recovery.
Oct 29, 2007: Test support for very large entries in tar archives:
    libarchive_test now exercises entries from 2GB up to 1TB.

Oct 27, 2007: libarchive 2.3.5 released
Oct 27, 2007: Correct some unnecessary internal data copying in the
    "compression none" reader and writer; this reduces user time
    by up to 2/3 in some tests.  (Thanks to Jan Psota for
    publishing his performance test results to GNU tar's bug-tar
    mailing list; those results pointed me towards this problem.)
Oct 27, 2007: Fix for skipping archive entries that are exactly
    a multiple of 4G on 32-bit platforms.
Oct 25, 2007: Fix for reading very large (>8G) tar archives; this was
    broken when I put in support for new GNU tar sparse formats.
Oct 20, 2007: Initial work on new pattern-matching code for cpio; I
    hope this eventually replaces the code currently in bsdtar.

Oct 08, 2007: libarchive 2.3.4 released
Oct 05, 2007: Continuing work on bsdcpio test suite.
Oct 05, 2007: New cpio.5 manpage, updates to "History" of bsdcpio.1 and
    bsdtar.1 manpages.
Oct 05, 2007: Fix zip reader to immediately return EOF if you try
    to read body of non-regular file.  In particular, this fixes
    bsdtar extraction of zip archives.

Sep 30, 2007: libarchive 2.3.3 released
Sep 26, 2007: Rework Makefile.am so that the enable/disable options
    actually do the right things.
Sep 26, 2007: cpio-odc and cpio-newc archives no longer write bodies
    for non-regular files.
Sep 26, 2007: Test harness for bsdcpio is in place, needs more tests written.
    This is much nicer than the ragtag collection of test scripts
    that bsdtar has.

Sep 20, 2007: libarchive 2.3.2 released
Sep 20, 2007: libarchive 2.3.1 broke bsdtar because the archive_write_data()
    fix was implemented incorrectly.

Sep 16, 2007: libarchive 2.3.1 released
Sep 16, 2007: Many fixes to bsdcpio 0.3:  handle hardlinks with -p, recognize
    block size on writing, fix a couple of segfaults.
Sep 16, 2007: Fixed return value from archive_write_data() when used
    with archive_write_disk() to match the documentation and other
    instances of this same function.
Sep 15, 2007: Add archive_entry_link_resolver, archive_entry_strmode

Sep 11, 2007: libarchive 2.2.8 released
Sep 09, 2007: bsdcpio 0.2 supports most (not yet all) of the old POSIX spec.

Sep 01, 2007: libarchive 2.2.7 released
Aug 31, 2007: Support for reading mtree files, including an mtree.5 manpage
    (A little experimental still.)
Aug 18, 2007: Read gtar 1.17 --posix --sparse entries.
Aug 13, 2007: Refined suid/sgid restore handling; it is no longer
    an error if suid/sgid bits are dropped when you request
    perm restore but don't request owner restore.
Aug 06, 2007: Use --enable-bsdcpio if you want to try bsdcpio

Aug 05, 2007: libarchive 2.2.6 released
Aug 05, 2007: New configure option --disable-bsdtar, thanks to Joerg
    Sonnenberger.
Aug 05, 2007: Several bug fixes from FreeBSD CVS repo.

Jul 13, 2007: libarchive 2.2.5 released

Jul 12, 2007: libarchive 2.2.4 released
Jul 12, 2007: Thanks to Colin Percival's help in diagnosing and
    fixing several critical security bugs.  Details available at
    http://security.freebsd.org/advisories/FreeBSD-SA-07:05.libarchive.asc

May 26, 2007: libarchive 2.2.3 released
May 26, 2007: Fix memory leaks in ZIP reader and shar writer, add some
    missing system headers to archive_entry.h, dead code cleanup
    from Colin Percival, more tests for gzip/bzip2, fix an
    EOF anomaly in bzip2 decompression.

May 12, 2007: libarchive 2.2.2 released
May 12, 2007: Fix archive_write_disk permission restore by cloning
    entry passed into write_header so that permission info is
    still available at finish_entry time.  (archive_read_extract()
    worked okay because it held onto the passed-in entry, but
    direct consumers of archive_write_disk would break).  This
    required fixing archive_entry_clone(), which now works and has
    a reasonably complete test case.
May 10, 2007: Skeletal cpio implementation.

May 06, 2007: libarchive 2.2.1 released
May 06, 2007: Flesh out a lot more of test_entry.c so as to catch
    problems such as the device node breakage before releasing <sigh>.
May 05, 2007: Fix a bad bug introduced in 2.1.9 that broke device
    node entries in tar archives.
May 03, 2007: Move 'struct stat' out of archive_entry core as well.
    This removes some portability headaches and fixes a bunch
    of corner cases that arise when manipulating archives on
    dissimilar systems.

Apr 30, 2007: libarchive 2.1.10 released
Apr 31, 2007: Minor code cleanup.

Apr 24, 2007: libarchive 2.1.9 released
Apr 24, 2007: Fix some recently-introduced problems with libraries
    (Just let automake handle it and it all works much better.)
    Finish isolating major()/minor()/makedev() in archive_entry.c.

Apr 23, 2007: libarchive 2.1.8 released
Apr 23, 2007: Minor fixes found from building on MacOS X

Apr 22, 2007: libarchive 2.1.7 released
Apr 22, 2007: Eliminated all uses of 'struct stat' from the
    format readers/writers.  This should improve portability;
    'struct stat' is now only used in archive_entry and in
    code that actually touches the disk.

Apr 17, 2007: libarchive 2.1.6 released
    Libarchive now compiles and passes all tests on Interix.

Apr 16, 2007: libarchive 2.1.5 released

Apr 15, 2007: libarchive 2.1b2 released
Apr 15, 2007: New libarchive_internals.3 documentation of internal APIs.
    Not complete, but should prove helpful.
Apr 15, 2007: Experimental "read_compress_program" and "write_compress_program"
    for using libarchive with external compression.  Not yet
    well tested, and likely has portability issues.  Feedback
    appreciated.

Apr 14, 2007: libarchive 2.0.31 released
Apr 14, 2007: More fixes for Interix, more 'ar' work

Apr 14, 2007: libarchive 2.0.30 released
Apr 13, 2007: libarchive now enforces trailing '/' on dirs
    written to tar archives

Apr 11, 2007: libarchive 2.0.29 released
Apr 11, 2007: Make it easier to statically configure for different platforms.
Apr 11, 2007: Updated config.guess, config.sub, libtool

Apr 06, 2007: libarchive 2.0.28 released
Apr 06, 2007: 'ar' format read/write support thanks to Kai Wang.

Apr 01, 2007: libarchive 2.0.27 released
Mar 31, 2007: Several minor fixes from Colin Percival and Joerg Sonnenberger.

Mar 12, 2007: libarchive 2.0.25 released
Mar 12, 2007: Fix broken --unlink flag.

Mar 11, 2007: libarchive 2.0.24 released
Mar 10, 2007: Correct an ACL blunder that causes any ACL with an entry
    that refers to a non-existent user or group to not be restored correctly.
    The fix both makes the parser more tolerant (so that archives created
    with the buggy ACLs can be read now) and corrects the ACL formatter.
Mar 10, 2007: More work on test portability to Linux.

Mar 10, 2007: libarchive 2.0.22 released
Mar 10, 2007: Header cleanups; added linux/fs.h, removed
    some unnecessary headers, added #include guards in bsdtar.
    If you see any obvious compile failures from this, let me know.
Mar 10, 2007: Work on bsdtar test scripts: not yet robust enough
    to enable as part of "make check", but getting better.
Mar 10, 2007: libarchive now returns ARCHIVE_FAILED when
    a header write fails in a way that only affects this item.
    Less bad than ARCHIVE_FATAL, but worse than ARCHIVE_WARN.

Mar 07, 2007: libarchive 2.0.21 released
Mar 07, 2007: Add some ACL tests (only for the system-independent
    portion of the ACL support for now).
Mar 07, 2007: tar's ability to read ACLs off disk got
    turned off for FreeBSD; re-enable it.  (ACL restores and
    libarchive support for storing/reading ACLs from pax
    archives was unaffected.)

Mar 02, 2007: libarchive 2.0.20 released
Mar 2, 2007:  It's not perfect, but it's pretty good.
    Libarchive 2.0 is officially out of beta.

Feb 28, 2007: libarchive 2.0b17 released
Feb 27, 2007: Make the GID restore checks more robust by checking
    whether the current user has too few or too many privileges.

Feb 26, 2007: libarchive 2.0b15 released
Feb 26, 2007: Don't lose symlinks when extracting from ISOs.
    Thanks to Diego "Flameeyes" Pettenò for telling me about the
    broken testcase on Gentoo that (finally!) led me to the cause
    of this long-standing bug.

Feb 26, 2007: libarchive 2.0b14 released
Feb 26, 2007: Fix a broken test on platforms that lack lchmod().

Feb 25, 2007: libarchive 2.0b13 released
Feb 25, 2007: Empty archives were being written as empty files,
    without a proper end-of-archive marker.  Fixed.

Feb 23, 2007: libarchive 2.0b12 released
Feb 22, 2007: Basic security checks added: _EXTRACT_SECURE_NODOTDOT
    and _EXTRACT_SECURE_SYMLINK.  These checks used to be in bsdtar,
    but they belong down in libarchive where they can be used by
    other tools and where they can be better optimized.

Feb 11, 2007: libarchive 2.0b11 released
Feb 10, 2007: Fixed a bunch of errors in libarchive's handling
    of EXTRACT_PERM and EXTRACT_OWNER, especially relating
    to SUID and SGID bits.

Jan 31, 2007: libarchive 2.0b9 released
Jan 31, 2007: Added read support for "empty" archives as a
    distinct archive format.  Bsdtar uses this to handle, e.g.,
    "touch foo.tar; tar -rf foo.tar"

Jan 22, 2007: libarchive 2.0b6 released
Jan 22, 2007: archive_write_disk API is now in place.  It provides
    a finer-grained interface than archive_read_extract.  In particular,
    you can use it to create objects on disk without having an archive
    around (just feed it archive_entry objects describing what you
    want to create), you can override the uname/gname-to-uid/gid lookups
    (minitar uses this to avoid getpwXXX() and getgrXXX() bloat).

Jan 09, 2007: libarchive 2.0a3 released
Jan 9, 2007: archive_extract is now much better; it handles the
    most common cases with a minimal number of system calls.
    Some features still need a lot of testing, especially corner
    cases involving objects that already exist on disk.   I expect
    the next round of API overhaul will simplify building test cases.
Jan 9, 2007: a number of fixes thanks to Colin Percival, especially
    corrections to the skip() framework and handling of large files.
Jan 9, 2007: Fixes for large ISOs.  The code should correctly handle
    very large ISOs with entries up to 4G.   Thanks to Robert Sciuk
    for pointing out these issues.

Sep 05, 2006: libarchive 1.3.1 released
Sep 5, 2006: Bump version to 1.3 for new I/O wrappers.
Sep 4, 2006: New memory and FILE read/write wrappers.
Sep 4, 2006: libarchive test harness is now minimally functional;
    it's located a few minor bugs in error-handling logic

Aug 17, 2006: libarchive 1.2.54 released
Aug 17, 2006: Outline ABI changes for libarchive 2.0; these
   are protected behind #ifdef's until I think I've found everything
   that needs to change.
Aug 17, 2006: Fix error-handling in archive_read/write_close()
   They weren't returning any errors before.
Aug 17, 2006: Fix recursive-add logic to not trigger if it's not set
   Fixes a bug adding files when writing archive to pipe or when
   using archive_write_open() directly.
Jul 2006: New "skip" handling improves performance extracting
   single files from large uncompressed archives.

Mar 21, 2006: 1.2.52 released
Mar 21, 2006: Fix -p on platforms that don't have platform-specific
   extended attribute code.
Mar 20, 2006: Add NEWS file; fill in some older history from other
   files.  I'll try to keep this file up-to-date from now on.

OLDER NEWS SUMMARIES

Mar 19, 2006: libarchive 1.2.51 released
Mar 18, 2006: Many fixes to extended attribute support, including a redesign
   of the storage format to simplify debugging.
Mar 12, 2006: Remove 'tp' support; it was a fun idea, but not worth
   spending much time on.
Mar 11, 2006: Incorporated Jaakko Heinonen's still-experimental support
   for extended attributes (Currently Linux-only.).
Mar 11, 2006: Reorganized distribution package: There is now one tar.gz
   file that builds both libarchive and bsdtar.
Feb 13, 2006: Minor bug fixes: correctly read cpio device entries, write
   Pax attribute entry names.
Nov 7, 2005: Experimental 'tp' format support in libarchive.  Feedback
   appreciated; this is not enabled by archive_read_support_format_all()
   yet as I'm not quite content with the format detection heuristics.
Nov 7, 2005: Some more portability improvements thanks to Darin Broady,
   minor bugfixes.
Oct 12, 2005: Use GNU libtool to build shared libraries on many systems.
Aug 9, 2005: Correctly detect that MacOS X does not have POSIX ACLs.
Apr 17, 2005: Kees Zeelenberg has ported libarchive and bsdtar to Windows:
   http://gnuwin32.sourceforge.net/
Apr 11, 2005: Extended Zip/Zip64 support thanks to Dan Nelson.  -L/-h
   fix from Jaakko Heinonen.
Mar 12, 2005: archive_read_extract can now handle very long
   pathnames (I've tested with pathnames up to 1MB).
Mar 12, 2005: Marcus Geiger has written an article about libarchive
   http://xsnil.antbear.org/2005/02/05/archive-mit-libarchive-verarbeiten/
   including examples of using it from Objective-C.  His MoinX
   http://moinx.antbear.org/ desktop Wiki uses
   libarchive for archiving and restoring Wiki pages.
Jan 22, 2005: Preliminary ZIP extraction support,
    new directory-walking code for bsdtar.
Jan 16, 2005: ISO9660 extraction code added; manpage corrections.
May 22, 2004: Many gtar-compatible long options have been added; almost
    all FreeBSD ports extract correctly with bsdtar.
May 18, 2004: bsdtar can read Solaris, HP-UX, Unixware, star, gtar,
    and pdtar archives.



More information about the Cmake-commits mailing list