diff --git a/ports/libmagic/0002-Change-zlib-lib-name-to-match-CMake-output.patch b/ports/libmagic/0002-Change-zlib-lib-name-to-match-CMake-output.patch index 5e070cc07f..e70c202d91 100644 --- a/ports/libmagic/0002-Change-zlib-lib-name-to-match-CMake-output.patch +++ b/ports/libmagic/0002-Change-zlib-lib-name-to-match-CMake-output.patch @@ -16,7 +16,7 @@ index b05c334..dd4063c 100644 dnl Checks for libraries if test "$enable_zlib" != "no"; then - AC_CHECK_LIB(z, gzopen) -+ AC_SEARCH_LIBS(gzopen, [z zlib zlibd], have_zlib = "yes", have_zlib = "no") ++ AC_SEARCH_LIBS(gzopen, [z zlib zlibd], have_zlib="yes", have_zlib="no") fi if test "$enable_bzlib" != "no"; then AC_CHECK_LIB(bz2, BZ2_bzCompressInit) diff --git a/ports/libmagic/0017-Change-bzlib-name-to-match-CMake-output.patch b/ports/libmagic/0017-Change-bzlib-name-to-match-CMake-output.patch new file mode 100644 index 0000000000..ba26f6cbcb --- /dev/null +++ b/ports/libmagic/0017-Change-bzlib-name-to-match-CMake-output.patch @@ -0,0 +1,27 @@ +diff --git a/configure.ac b/configure.ac +index 8b54efda..d043fb06 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -191,7 +191,7 @@ if test "$enable_zlib" != "no"; then + AC_SEARCH_LIBS(gzopen, [z zlib zlibd], have_zlib="yes", have_zlib="no") + fi + if test "$enable_bzlib" != "no"; then +- AC_CHECK_LIB(bz2, BZ2_bzCompressInit) ++ AC_SEARCH_LIBS(BZ2_bzCompressInit, [bz2 bz2d], have_bzlib="yes", have_bzlib="no") + fi + if test "$enable_xzlib" != "no"; then + AC_CHECK_LIB(lzma, lzma_stream_decoder) +@@ -222,11 +222,11 @@ if test "$ac_cv_header_zlib_h$have_zlib" = "yesyes"; then + AC_DEFINE([ZLIBSUPPORT], 1, [Enable zlib compression support]) + fi + if test "$enable_bzlib" = "yes"; then +- if test "$ac_cv_header_bzlib_h$ac_cv_lib_bz2_BZ2_bzCompressInit" != "yesyes"; then ++ if test "$ac_cv_header_bzlib_h$have_bzlib" != "yesyes"; then + AC_MSG_ERROR([bzlib support requested but not found]) + fi + fi +-if test "$ac_cv_header_bzlib_h$ac_cv_lib_bz2_BZ2_bzCompressInit" = "yesyes"; then ++if test "$ac_cv_header_bzlib_h$have_bzlib" = "yesyes"; then + AC_DEFINE([BZLIBSUPPORT], 1, [Enable bzlib compression support]) + fi + if test "$enable_xzlib" = "yes"; then diff --git a/ports/libmagic/portfile.cmake b/ports/libmagic/portfile.cmake index c1afade496..c6d775fda7 100644 --- a/ports/libmagic/portfile.cmake +++ b/ports/libmagic/portfile.cmake @@ -14,6 +14,7 @@ if(VCPKG_TARGET_IS_WINDOWS) "0013-Check-for-backslash-in-argv-0-on-Windows.patch" "0015-MSYS2-Remove-ioctl-call.patch" "0016-Fix-file_famagic-function.patch" + "0017-Change-bzlib-name-to-match-CMake-output.patch" ) endif() @@ -31,9 +32,30 @@ if(VCPKG_TARGET_IS_WINDOWS) set(VCPKG_CXX_FLAGS "${VCPKG_CXX_FLAGS} -D_CRT_SECURE_NO_WARNINGS -D_CRT_NONSTDC_NO_WARNINGS") endif() +set(FEATURE_OPTIONS) + +macro(enable_feature feature switch) + if("${feature}" IN_LIST FEATURES) + list(APPEND FEATURE_OPTIONS "--enable-${switch}") + set(has_${feature} 1) + else() + list(APPEND FEATURE_OPTIONS "--disable-${switch}") + set(has_${feature} 0) + endif() +endmacro() + +enable_feature("bzip2" "bzlib") +enable_feature("zlib" "zlib") +enable_feature("lzma" "xzlib") +enable_feature("zstd" "zstdlib") + vcpkg_configure_make( AUTOCONFIG SOURCE_PATH "${SOURCE_PATH}" + OPTIONS + ${FEATURE_OPTIONS} + "--disable-lzlib" + "--disable-libseccomp" ) if(VCPKG_CROSSCOMPILING) diff --git a/ports/libmagic/unofficial-libmagic-config.cmake.in b/ports/libmagic/unofficial-libmagic-config.cmake.in index 8f22d30f9a..5cda560576 100644 --- a/ports/libmagic/unofficial-libmagic-config.cmake.in +++ b/ports/libmagic/unofficial-libmagic-config.cmake.in @@ -1,8 +1,27 @@ @PACKAGE_INIT@ -if(WIN32 AND "@VCPKG_LIBRARY_LINKAGE@" STREQUAL "static") - include(CMakeFindDependencyMacro) - find_dependency(unofficial-tre) +include(CMakeFindDependencyMacro) + +if("@VCPKG_LIBRARY_LINKAGE@" STREQUAL "static") + if(WIN32) + find_dependency(unofficial-tre) + endif() + + if(@has_zlib@) + find_dependency(ZLIB) + endif() + + if(@has_bzip2@) + find_dependency(BZip2) + endif() + + if(@has_lzma@) + find_dependency(LibLZMA) + endif() + + if(@has_zstd@) + find_dependency(zstd) + endif() endif() # Compute the installation prefix relative to this file. @@ -23,9 +42,14 @@ set_target_properties(unofficial::libmagic::libmagic PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${_IMPORT_PREFIX}/include" ) -if(WIN32 AND "@VCPKG_LIBRARY_LINKAGE@" STREQUAL "static") +if("@VCPKG_LIBRARY_LINKAGE@" STREQUAL "static") set_target_properties(unofficial::libmagic::libmagic PROPERTIES - INTERFACE_LINK_LIBRARIES "\$" + INTERFACE_LINK_LIBRARIES + "\$:unofficial::tre::tre>>" + "\$>" + "\$>" + "\$>" + "\$,zstd::libzstd_shared,zstd::libzstd_static>>>" ) endif() diff --git a/ports/libmagic/vcpkg.json b/ports/libmagic/vcpkg.json index a556d5d34d..6197de48b4 100644 --- a/ports/libmagic/vcpkg.json +++ b/ports/libmagic/vcpkg.json @@ -1,7 +1,7 @@ { "name": "libmagic", "version": "5.45", - "port-version": 1, + "port-version": 2, "description": "This library can be used to classify files according to magic number tests.", "homepage": "https://github.com/file/file", "license": "BSD-2-Clause", @@ -22,5 +22,31 @@ "name": "tre", "platform": "windows | mingw" } - ] + ], + "features": { + "bzip2": { + "description": "Enable bzip2 support", + "dependencies": [ + "bzip2" + ] + }, + "lzma": { + "description": "Enable lzma support", + "dependencies": [ + "liblzma" + ] + }, + "zlib": { + "description": "Enable zlib support", + "dependencies": [ + "zlib" + ] + }, + "zstd": { + "description": "Enable zstd support", + "dependencies": [ + "zstd" + ] + } + } } diff --git a/versions/baseline.json b/versions/baseline.json index 042a25bd35..dd1449a503 100644 --- a/versions/baseline.json +++ b/versions/baseline.json @@ -4590,7 +4590,7 @@ }, "libmagic": { "baseline": "5.45", - "port-version": 1 + "port-version": 2 }, "libmariadb": { "baseline": "3.3.1", diff --git a/versions/l-/libmagic.json b/versions/l-/libmagic.json index a1d52c3b19..10b99fc9bf 100644 --- a/versions/l-/libmagic.json +++ b/versions/l-/libmagic.json @@ -1,5 +1,10 @@ { "versions": [ + { + "git-tree": "c845ff89796041876594f8b6ef8691e8debb1c82", + "version": "5.45", + "port-version": 2 + }, { "git-tree": "65715ba20e3afecd46e0fb81326503257174585f", "version": "5.45",