# Information
# https://www.libarchive.org/
#
# Downloads
# https://github.com/libarchive/libarchive/archive/refs/tags/v3.5.1.zip

### DEPENDS ###
DKDEPEND(zlib)
DKDEPEND(xz)
DKDEPEND(bzip2)


### VERSION ###
DKSET(ARCHIVE_VERSION 3.5.1)
DKSET(ARCHIVE_NAME libarchive-${ARCHIVE_VERSION})
DKSET(ARCHIVE_DL https://github.com/libarchive/libarchive/archive/refs/tags/v${ARCHIVE_VERSION}.zip)
DKSET(ARCHIVE ${3RDPARTY}/${ARCHIVE_NAME})


### INSTALL ###
DKINSTALL(${ARCHIVE_DL} libarchive ${ARCHIVE})


### DKPLUGINS LINK ###
DKDEFINE(LIBARCHIVE_STATIC)
DKINCLUDE(${ARCHIVE}/libarchive)
DKINCLUDE(${ARCHIVE}/${OS})
ANDROID_INCLUDE(${ARCHIVE}/contrib/android/include)
WIN_DEBUG_LIB(${ARCHIVE}/${OS}/libarchive/${DEBUG_DIR}/archive_static.lib)
WIN_RELEASE_LIB(${ARCHIVE}/${OS}/libarchive/${RELEASE_DIR}/archive_static.lib)
APPLE_DEBUG_LIB(${ARCHIVE}/${OS}/libarchive/${DEBUG_DIR}/libarchive.a)
APPLE_RELEASE_LIB(${ARCHIVE}/${OS}/libarchive/${RELEASE_DIR}/libarchive.a)
LINUX_DEBUG_LIB(${ARCHIVE}/${OS}/${DEBUG_DIR}/libarchive/libarchive.a)
LINUX_RELEASE_LIB(${ARCHIVE}/${OS}/${RELEASE_DIR}/libarchive/libarchive.a)
RASPBERRY_DEBUG_LIB(${ARCHIVE}/${OS}/${DEBUG_DIR}/libarchive/libarchive.a)
RASPBERRY_RELEASE_LIB(${ARCHIVE}/${OS}/${RELEASE_DIR}/libarchive/libarchive.a)
ANDROID_DEBUG_LIB(${ARCHIVE}/${OS}/libarchive/${DEBUG_DIR}/libarchive.a)
ANDROID_RELEASE_LIB(${ARCHIVE}/${OS}/libarchive/${RELEASE_DIR}/libarchive.a)



### COMPILE ###
WIN_PATH(${ARCHIVE}/${OS})
WIN32_COMMAND(${DKCMAKE_WIN32} 
	-DWINDOWS_VERSION=WIN10
	-DENABLE_BZip2=ON 
	-DUSE_BZIP2_STATIC=ON
	-DUSE_BZIP2_DLL=OFF 
	-DBUILD_TESTING=OFF 
	-DENABLE_TEST=OFF 
	-DENABLE_ACL=OFF 
	-DENABLE_CPIO=OFF 
	-DENABLE_CNG=OFF 
	-DENABLE_EXPAT=OFF 
	-DENABLE_ICONV=OFF 
	-DENABLE_LIBXML2=OFF 
	-DENABLE_NETTLE=OFF 
	-DENABLE_OPENSSL=OFF 
	-DENABLE_TAR=ON 
	-DENABLE_XATTR=OFF 
	-DLIBXML2_INCLUDE_DIR=OFF 
	-DLIBXML2_LIBRARIES=OFF 
	-DLIBXML2_XMLLINT_EXECUTABLE=OFF 
	-DEXPAT_INCLUDE_DIR=OFF 
	-DEXPAT_LIBRARY=OFF 
	-DICONV_INCLUDE_DIR=OFF 
	-DENABLE_LibGCC=OFF 
	-DENABLE_LIBB2=OFF 
	-DENABLE_LZ4=OFF 
	-DENABLE_PCREPOSIX=OFF 
	-DENABLE_ZSTD=OFF 
	${XZ_WIN} 
	${BZIP2_WIN}
	${ZLIB_WIN} 
	${ARCHIVE})
WIN64_COMMAND(${DKCMAKE_WIN64}
	-DWINDOWS_VERSION=WIN10
	-DENABLE_BZip2=OFF
	-DUSE_BZIP2_STATIC=ON
	-DUSE_BZIP2_DLL=OFF 
	-DBUILD_TESTING=OFF 
	-DENABLE_TEST=OFF 
	-DENABLE_ACL=OFF 
	-DENABLE_CPIO=OFF 
	-DENABLE_CNG=OFF 
	-DENABLE_EXPAT=OFF 
	-DENABLE_ICONV=OFF 
	-DENABLE_LIBXML2=OFF 
	-DENABLE_NETTLE=OFF 
	-DENABLE_OPENSSL=OFF 
	-DENABLE_TAR=ON 
	-DENABLE_XATTR=OFF 
	-DLIBXML2_INCLUDE_DIR=OFF 
	-DLIBXML2_LIBRARIES=OFF 
	-DLIBXML2_XMLLINT_EXECUTABLE=OFF 
	-DEXPAT_INCLUDE_DIR=OFF 
	-DEXPAT_LIBRARY=OFF 
	-DICONV_INCLUDE_DIR=OFF 
	-DENABLE_LibGCC=OFF 
	-DENABLE_LIBB2=OFF 
	-DENABLE_LZ4=OFF 
	-DENABLE_PCREPOSIX=OFF 
	-DENABLE_ZSTD=OFF 
	${XZ_WIN} 
	${BZIP2_WIN}
	${ZLIB_WIN} 
	${ARCHIVE})
#WIN64_COMMAND(${DKCMAKE_WIN64} "-DCMAKE_C_FLAGS=/DWIN32 /D_WINDOWS /W3 /nologo /DLZMA_API_STATIC /wd4267 /wd4244" -DBUILD_TESTING=OFF -DENABLE_TEST=OFF -DENABLE_ACL=OFF -DENABLE_CPIO=OFF -DENABLE_CNG=OFF -DENABLE_ICONV=OFF -DENABLE_NETTLE=OFF -DENABLE_OPENSSL=OFF -DENABLE_TAR=ON -DENABLE_XATTR=OFF -DLIBXML2_INCLUDE_DIR=OFF -DLIBXML2_LIBRARIES=OFF -DLIBXML2_XMLLINT_EXECUTABLE=OFF -DEXPAT_INCLUDE_DIR=OFF -DEXPAT_LIBRARY=OFF -DICONV_INCLUDE_DIR=OFF ${XZ_WIN} ${BZIP2_WIN} ${ZLIB_WIN} ${ARCHIVE})
WIN_VS(${ARCHIVE_NAME} libarchive.sln archive_static)


MAC_PATH(${ARCHIVE}/${OS})
MAC32_COMMAND(${DKCMAKE_MAC32} -DENABLE_BZip2=OFF -DBUILD_TESTING=OFF -DENABLE_TEST=OFF -DENABLE_ACL=OFF -DENABLE_CPIO=OFF -DENABLE_CNG=OFF -DENABLE_ICONV=OFF -DENABLE_NETTLE=OFF -DENABLE_OPENSSL=OFF -DENABLE_TAR=ON -DENABLE_XATTR=OFF -DLIBXML2_INCLUDE_DIR=OFF -DLIBXML2_LIBRARIES=OFF -DLIBXML2_XMLLINT_EXECUTABLE=OFF -DLZO2_INCLUDE_DIR=OFF -DLZO2_LIBRARY=OFF -DEXPAT_INCLUDE_DIR=OFF -DEXPAT_LIBRARY=OFF -DICONV_INCLUDE_DIR=OFF ${XZ_APPLE} ${BZIP2_APPLE} ${ZLIB_APPLE} ${ARCHIVE})
MAC64_COMMAND(${DKCMAKE_MAC64} -DENABLE_BZip2=OFF -DBUILD_TESTING=OFF -DENABLE_TEST=OFF -DENABLE_ACL=OFF -DENABLE_CPIO=OFF -DENABLE_CNG=OFF -DENABLE_ICONV=OFF -DENABLE_NETTLE=OFF -DENABLE_OPENSSL=OFF -DENABLE_TAR=ON -DENABLE_XATTR=OFF -DLIBXML2_INCLUDE_DIR=OFF -DLIBXML2_LIBRARIES=OFF -DLIBXML2_XMLLINT_EXECUTABLE=OFF -DLZO2_INCLUDE_DIR=OFF -DLZO2_LIBRARY=OFF -DEXPAT_INCLUDE_DIR=OFF -DEXPAT_LIBRARY=OFF -DICONV_INCLUDE_DIR=OFF ${XZ_APPLE} ${BZIP2_APPLE} ${ZLIB_APPLE} ${ARCHIVE})
MAC_XCODE(${ARCHIVE_NAME} archive_static)


IOS_PATH(${ARCHIVE}/${OS})
IOS64_COMMAND(${DKCMAKE_IOS64} -DBUILD_TESTING=OFF -DENABLE_TEST=OFF -DENABLE_ACL=OFF -DENABLE_CAT=OFF -DENABLE_CPIO=OFF -DENABLE_CNG=OFF -DENABLE_ICONV=OFF -DENABLE_NETTLE=OFF -DENABLE_OPENSSL=OFF -DENABLE_TAR=OFF -DENABLE_XATTR=OFF -DLIBXML2_INCLUDE_DIR=OFF -DLIBXML2_LIBRARIES=OFF -DLIBXML2_XMLLINT_EXECUTABLE=OFF -DLZO2_INCLUDE_DIR=OFF -DLZO2_LIBRARY=OFF -DEXPAT_INCLUDE_DIR=OFF -DEXPAT_LIBRARY=OFF -DICONV_INCLUDE_DIR=OFF ${XZ_APPLE} ${BZIP2_APPLE} ${ZLIB_APPLE} ${ARCHIVE})
IOS_XCODE(${ARCHIVE_NAME} archive_static)


IOSSIM_PATH(${ARCHIVE}/${OS})
IOSSIM64_COMMAND(${DKCMAKE_IOSSIM64} -DBUILD_TESTING=OFF -DENABLE_TEST=OFF -DENABLE_ACL=OFF -DENABLE_CAT=OFF -DENABLE_CPIO=OFF -DENABLE_CNG=OFF -DENABLE_ICONV=OFF -DENABLE_NETTLE=OFF -DENABLE_OPENSSL=OFF -DENABLE_TAR=OFF -DENABLE_XATTR=OFF -DLIBXML2_INCLUDE_DIR=OFF -DLIBXML2_LIBRARIES=OFF -DLIBXML2_XMLLINT_EXECUTABLE=OFF -DLZO2_INCLUDE_DIR=OFF -DLZO2_LIBRARY=OFF -DEXPAT_INCLUDE_DIR=OFF -DEXPAT_LIBRARY=OFF -DICONV_INCLUDE_DIR=OFF ${XZ_APPLE} ${BZIP2_APPLE} ${ZLIB_APPLE} ${ARCHIVE})
IOSSIM_XCODE(${ARCHIVE_NAME} archive_static)


LINUX_DEBUG_PATH(${ARCHIVE}/${OS}/${DEBUG_DIR})
LINUX_DEBUG_COMMAND(${DKCMAKE_LINUX_DEBUG} -DENABLE_TEST=OFF -DENABLE_ACL=OFF -DENABLE_CPIO=OFF -DENABLE_CNG=OFF -DENABLE_ICONV=OFF -DENABLE_NETTLE=OFF -DENABLE_OPENSSL=OFF -DENABLE_TAR=ON -DENABLE_XATTR=OFF -DLIBXML2_INCLUDE_DIR=OFF -DLIBXML2_LIBRARIES=OFF -DLIBXML2_XMLLINT_EXECUTABLE=OFF -DEXPAT_INCLUDE_DIR=OFF -DEXPAT_LIBRARY=OFF -DICONV_INCLUDE_DIR=OFF ${XZ_LINUX} ${BZIP2_LINUX} ${ZLIB_LINUX} ${ARCHIVE})
LINUX_DEBUG_COMMAND(make archive_static)
LINUX_RELEASE_PATH(${ARCHIVE}/${OS}/${RELEASE_DIR})
LINUX_RELEASE_COMMAND(${DKCMAKE_LINUX_RELEASE} -DENABLE_TEST=OFF -DENABLE_ACL=OFF -DENABLE_CPIO=OFF -DENABLE_CNG=OFF -DENABLE_ICONV=OFF -DENABLE_NETTLE=OFF -DENABLE_OPENSSL=OFF -DENABLE_TAR=ON -DENABLE_XATTR=OFF -DLIBXML2_INCLUDE_DIR=OFF -DLIBXML2_LIBRARIES=OFF -DLIBXML2_XMLLINT_EXECUTABLE=OFF -DEXPAT_INCLUDE_DIR=OFF -DEXPAT_LIBRARY=OFF -DICONV_INCLUDE_DIR=OFF ${XZ_LINUX} ${BZIP2_LINUX} ${ZLIB_LINUX} ${ARCHIVE})
LINUX_RELEASE_COMMAND(make archive_static)


RASPBERRY32_DEBUG_PATH(${ARCHIVE}/${OS}/${DEBUG_DIR})
RASPBERRY32_DEBUG_COMMAND(${DKCMAKE_RASPBERRY_DEBUG} -DENABLE_TEST=OFF -DENABLE_ACL=OFF -DENABLE_CPIO=OFF -DENABLE_CNG=OFF -DENABLE_ICONV=OFF -DENABLE_NETTLE=OFF -DENABLE_OPENSSL=OFF -DENABLE_TAR=ON -DENABLE_XATTR=OFF -DLIBXML2_INCLUDE_DIR=OFF -DLIBXML2_LIBRARIES=OFF -DLIBXML2_XMLLINT_EXECUTABLE=OFF -DEXPAT_INCLUDE_DIR=OFF -DEXPAT_LIBRARY=OFF -DICONV_INCLUDE_DIR=OFF ${XZ_RASPBERRY} ${BZIP2_RASPBERRY} ${ZLIB_RASPBERRY} ${ARCHIVE})
RASPBERRY32_DEBUG_COMMAND(make archive_static)
RASPBERRY32_RELEASE_PATH(${ARCHIVE}/${OS}/${RELEASE_DIR})
RASPBERRY32_RELEASE_COMMAND(${DKCMAKE_RASPBERRY_RELEASE} -DENABLE_TEST=OFF -DENABLE_ACL=OFF -DENABLE_CPIO=OFF -DENABLE_CNG=OFF -DENABLE_ICONV=OFF -DENABLE_NETTLE=OFF -DENABLE_OPENSSL=OFF -DENABLE_TAR=ON -DENABLE_XATTR=OFF -DLIBXML2_INCLUDE_DIR=OFF -DLIBXML2_LIBRARIES=OFF -DLIBXML2_XMLLINT_EXECUTABLE=OFF -DEXPAT_INCLUDE_DIR=OFF -DEXPAT_LIBRARY=OFF -DICONV_INCLUDE_DIR=OFF ${XZ_RASPBERRY} ${BZIP2_RASPBERRY} ${ZLIB_RASPBERRY} ${ARCHIVE})
RASPBERRY32_RELEASE_COMMAND(make archive_static)


ANDROID_PATH(${ARCHIVE}/${OS})
ANDROID32_COMMAND(${DKCMAKE_ANDROID32} "-DCMAKE_C_FLAGS=-I${ARCHIVE}/${OS} -I${ARCHIVE}/contrib/android/include -I${ZLIB}/${OS}" -DENABLE_BZip2=OFF -DUSE_BZIP2_DLL=OFF -DBUILD_TESTING=OFF -DENABLE_TEST=OFF -DENABLE_ACL=OFF -DENABLE_CPIO=OFF -DENABLE_CNG=OFF -DENABLE_EXPAT=OFF -DENABLE_ICONV=OFF -DENABLE_LIBXML2=OFF -DENABLE_NETTLE=OFF -DENABLE_OPENSSL=OFF -DENABLE_TAR=OFF -DENABLE_XATTR=OFF -DLIBXML2_INCLUDE_DIR=OFF -DLIBXML2_LIBRARIES=OFF -DLIBXML2_XMLLINT_EXECUTABLE=OFF -DEXPAT_INCLUDE_DIR=OFF -DEXPAT_LIBRARY=OFF -DICONV_INCLUDE_DIR=OFF -DENABLE_LibGCC=OFF -DENABLE_LIBB2=OFF -DENABLE_CAT=OFF -DENABLE_LZ4=OFF -DENABLE_PCREPOSIX=OFF -DENABLE_ZSTD=OFF ${XZ_ANDROID} ${BZIP2_ANDROID} ${ZLIB_ANDROID} ${ARCHIVE})
ANDROID64_COMMAND(${DKCMAKE_ANDROID64} "-DCMAKE_C_FLAGS=-I${ARCHIVE}/${OS} -I${ARCHIVE}/contrib/android/include -I${ZLIB}/${OS}" -DENABLE_BZip2=OFF -DUSE_BZIP2_DLL=OFF -DBUILD_TESTING=OFF -DENABLE_TEST=OFF -DENABLE_ACL=OFF -DENABLE_CPIO=OFF -DENABLE_CNG=OFF -DENABLE_EXPAT=OFF -DENABLE_ICONV=OFF -DENABLE_LIBXML2=OFF -DENABLE_NETTLE=OFF -DENABLE_OPENSSL=OFF -DENABLE_TAR=OFF -DENABLE_XATTR=OFF -DLIBXML2_INCLUDE_DIR=OFF -DLIBXML2_LIBRARIES=OFF -DLIBXML2_XMLLINT_EXECUTABLE=OFF -DEXPAT_INCLUDE_DIR=OFF -DEXPAT_LIBRARY=OFF -DICONV_INCLUDE_DIR=OFF -DENABLE_LibGCC=OFF -DENABLE_LIBB2=OFF -DENABLE_CAT=OFF -DENABLE_LZ4=OFF -DENABLE_PCREPOSIX=OFF -DENABLE_ZSTD=OFF ${XZ_ANDROID} ${BZIP2_ANDROID} ${ZLIB_ANDROID} ${ARCHIVE})
ANDROID_VS(${ARCHIVE_NAME} libarchive.sln archive_static)
