diff --git a/.readthedocs.yml b/.readthedocs.yml index 459b768ef7f..0c2c9b0fa84 100644 --- a/.readthedocs.yml +++ b/.readthedocs.yml @@ -12,6 +12,17 @@ build: os: "ubuntu-22.04" tools: python: "3.8" + apt_packages: + - autoconf + - autoconf-archive + - automake + - curl + - git + - libtool + - make + - pkg-config + - unzip + - zip python: install: diff --git a/doc/dev/BUILD.md b/doc/dev/BUILD.md index 1717cb0fa90..d0c8140d145 100644 --- a/doc/dev/BUILD.md +++ b/doc/dev/BUILD.md @@ -12,6 +12,7 @@ title: Building TileDB from source * Apple Clang 14 * Git (required by vcpkg) * curl (required by vcpkg on non-Windows) +* autoconf (required by building libmagic on non-Windows) ## Downloading the source code diff --git a/ports/README.md b/ports/README.md index 7faf08053d3..09981c7650f 100644 --- a/ports/README.md +++ b/ports/README.md @@ -30,7 +30,6 @@ After copying the port, add an entry to the table below. You should also contrib |Port|Reason| |----|------| -|`libmagic`|Updating to the upstream port deferred due to failures.| |`openssl`|Pinning to OpenSSL 1.1 until we can move to 3.0 in January 2024.| -|`pcre2`|To be removed alongside libmagic.| |`azure-storage-common-cpp`|Patching to disable default features on libxml2 (https://github.com/Azure/azure-sdk-for-cpp/pull/5221).| +|`libmagic`|Patching to add features explicitly enabling compression support.| diff --git a/ports/libmagic/0001-Use-pcre2.patch b/ports/libmagic/0001-Use-libtre.patch similarity index 98% rename from ports/libmagic/0001-Use-pcre2.patch rename to ports/libmagic/0001-Use-libtre.patch index 2bcf73cd2bc..a1080d5a070 100644 --- a/ports/libmagic/0001-Use-pcre2.patch +++ b/ports/libmagic/0001-Use-libtre.patch @@ -44,7 +44,7 @@ index c548e97..299ac0c 100644 #include #include /* For open and flags */ -#include -+#include ++#include #include #include #ifndef WIN32 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 new file mode 100644 index 00000000000..5e070cc07fe --- /dev/null +++ b/ports/libmagic/0002-Change-zlib-lib-name-to-match-CMake-output.patch @@ -0,0 +1,39 @@ +From 2fa43ece9ec7564e1fbb9867bb5852b834643aa4 Mon Sep 17 00:00:00 2001 +From: Long Nguyen +Date: Sat, 8 May 2021 19:36:11 +0700 +Subject: [PATCH 02/14] Change zlib lib name to match CMake output + +--- + configure.ac | 6 +++--- + 1 file changed, 3 insertions(+), 3 deletions(-) + +diff --git a/configure.ac b/configure.ac +index b05c334..dd4063c 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -173,7 +173,7 @@ AC_REPLACE_FUNCS(getopt_long asprintf vasprintf strlcpy strlcat getline ctime_r + + 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") + fi + if test "$enable_bzlib" != "no"; then + AC_CHECK_LIB(bz2, BZ2_bzCompressInit) +@@ -193,11 +193,11 @@ AM_CONDITIONAL(IS_CROSS_COMPILE, test "$cross_compiling" = yes) + + dnl Final sanity checks + if test "$enable_zlib" = "yes"; then +- if test "$ac_cv_header_zlib_h$ac_cv_lib_z_gzopen" != "yesyes"; then ++ if test "$ac_cv_header_zlib_h$have_zlib" != "yesyes"; then + AC_MSG_ERROR([zlib support requested but not found]) + fi + fi +-if test "$ac_cv_header_zlib_h$ac_cv_lib_z_gzopen" = "yesyes"; then ++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 +-- +2.29.2.windows.2 + diff --git a/ports/libmagic/0003-Fix-WIN32-macro-checks.patch b/ports/libmagic/0003-Fix-WIN32-macro-checks.patch index 44ab2ddea2a..e90beb4d409 100644 --- a/ports/libmagic/0003-Fix-WIN32-macro-checks.patch +++ b/ports/libmagic/0003-Fix-WIN32-macro-checks.patch @@ -12,7 +12,7 @@ index 299ac0c..2c365a6 100644 --- a/src/file.h +++ b/src/file.h @@ -82,7 +82,7 @@ - #include + #include #include #include -#ifndef WIN32 @@ -31,13 +31,13 @@ index 299ac0c..2c365a6 100644 #define PATHSEP ':' @@ -103,7 +103,7 @@ - #define private static + #define file_private static -#if HAVE_VISIBILITY && !defined(WIN32) +#if HAVE_VISIBILITY && !defined(_WIN32) - #define public __attribute__ ((__visibility__("default"))) - #ifndef protected - #define protected __attribute__ ((__visibility__("hidden"))) + #define file_public __attribute__ ((__visibility__("default"))) + #ifndef file_protected + #define file_protected __attribute__ ((__visibility__("hidden"))) -- 2.29.2.windows.2 diff --git a/ports/libmagic/0005-Include-dirent.h-for-S_ISREG-and-S_ISDIR.patch b/ports/libmagic/0005-Include-dirent.h-for-S_ISREG-and-S_ISDIR.patch index 76cbc1222c8..afcb658d889 100644 --- a/ports/libmagic/0005-Include-dirent.h-for-S_ISREG-and-S_ISDIR.patch +++ b/ports/libmagic/0005-Include-dirent.h-for-S_ISREG-and-S_ISDIR.patch @@ -11,14 +11,15 @@ diff --git a/src/file.h b/src/file.h index 0332506..4aa9f60 100644 --- a/src/file.h +++ b/src/file.h -@@ -88,6 +88,7 @@ +@@ -88,7 +88,8 @@ /* Do this here and now, because struct stat gets re-defined on solaris */ #include #include +#include - - #define ENABLE_CONDITIONALS - + #include + #if defined(HAVE_XLOCALE_H) + #include + #endif -- 2.29.2.windows.2 diff --git a/ports/libmagic/0006-Remove-Wrap-POSIX-headers.patch b/ports/libmagic/0006-Remove-Wrap-POSIX-headers.patch index 56efac24815..169561d2437 100644 --- a/ports/libmagic/0006-Remove-Wrap-POSIX-headers.patch +++ b/ports/libmagic/0006-Remove-Wrap-POSIX-headers.patch @@ -161,7 +161,7 @@ index 3ab52d1..fc48d84 100644 --- a/src/pread.c +++ b/src/pread.c @@ -3,7 +3,9 @@ - FILE_RCSID("@(#)$File: pread.c,v 1.2 2013/04/02 16:23:07 christos Exp $") + FILE_RCSID("@(#)$File: pread.c,v 1.5 2022/09/24 20:30:13 christos Exp $") #endif /* lint */ #include +#ifdef HAVE_UNISTD_H diff --git a/ports/libmagic/0009-No-fcntl-in-magic.c.patch b/ports/libmagic/0009-No-fcntl-in-magic.c.patch deleted file mode 100644 index 47bf16165ef..00000000000 --- a/ports/libmagic/0009-No-fcntl-in-magic.c.patch +++ /dev/null @@ -1,25 +0,0 @@ -From 6d10bef865b69764f6e0ddd2b0f6a84e484cdb37 Mon Sep 17 00:00:00 2001 -From: Long Nguyen -Date: Sun, 9 May 2021 13:25:14 +0700 -Subject: [PATCH 09/14] No fcntl in magic.c - ---- - src/magic.c | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/src/magic.c b/src/magic.c -index e9aeafa..382bd96 100644 ---- a/src/magic.c -+++ b/src/magic.c -@@ -462,7 +462,7 @@ file_or_fd(struct magic_set *ms, const char *inname, int fd) - rv = 0; - goto done; - } --#if O_CLOEXEC == 0 -+#if O_CLOEXEC == 0 && !defined(_WIN32) - (void)fcntl(fd, F_SETFD, FD_CLOEXEC); - #endif - } --- -2.29.2.windows.2 - diff --git a/ports/libmagic/0010-Properly-check-for-the-presence-of-bitmasks.patch b/ports/libmagic/0010-Properly-check-for-the-presence-of-bitmasks.patch index f0d8738e465..e241f5e49c0 100644 --- a/ports/libmagic/0010-Properly-check-for-the-presence-of-bitmasks.patch +++ b/ports/libmagic/0010-Properly-check-for-the-presence-of-bitmasks.patch @@ -17,7 +17,7 @@ index 5204f20..7244841 100644 #undef HAVE_MAJOR -#ifdef S_IFLNK +#if S_IFLNK != 0 - private int + file_private int bad_link(struct magic_set *ms, int err, char *buf) { @@ -108,7 +108,7 @@ file_fsmagic(struct magic_set *ms, const char *fn, struct stat *sb) diff --git a/ports/libmagic/0011-Remove-pipe-related-functions-in-funcs.c.patch b/ports/libmagic/0011-Remove-pipe-related-functions-in-funcs.c.patch index ae2720ca361..13c24faaca0 100644 --- a/ports/libmagic/0011-Remove-pipe-related-functions-in-funcs.c.patch +++ b/ports/libmagic/0011-Remove-pipe-related-functions-in-funcs.c.patch @@ -11,21 +11,19 @@ diff --git a/src/funcs.c b/src/funcs.c index b926625..b585486 100644 --- a/src/funcs.c +++ b/src/funcs.c -@@ -809,6 +809,7 @@ file_print_guid(char *str, size_t len, const uint64_t *guid) - g->data4[6], g->data4[7]); +@@ -888,5 +888,6 @@ } +#ifndef _WIN32 - protected int + file_protected int file_pipe_closexec(int *fds) { -@@ -827,6 +828,7 @@ protected int - file_clear_closexec(int fd) { - return fcntl(fd, F_SETFD, 0); +@@ -914,5 +915,6 @@ + #endif } +#endif - protected char * + file_protected char * file_strtrim(char *str) -- 2.29.2.windows.2 diff --git a/ports/libmagic/0012-Convert-MSYS2-paths-to-Windows-paths.patch b/ports/libmagic/0012-Convert-MSYS2-paths-to-Windows-paths.patch new file mode 100644 index 00000000000..728fe77539f --- /dev/null +++ b/ports/libmagic/0012-Convert-MSYS2-paths-to-Windows-paths.patch @@ -0,0 +1,24 @@ +From f0139ced57c1579450f3d09b6e3ae0159aae031b Mon Sep 17 00:00:00 2001 +From: Long Nguyen +Date: Mon, 10 May 2021 08:43:28 +0700 +Subject: [PATCH 12/14] Convert MSYS2 paths to Windows paths + +--- + src/Makefile.am | 3 +++ + 1 file changed, 3 insertions(+) + +diff --git a/src/Makefile.am b/src/Makefile.am +index 34781b9..26f853f 100644 +--- a/src/Makefile.am ++++ b/src/Makefile.am +@@ -1,4 +1,7 @@ + MAGIC = $(pkgdatadir)/magic ++if MINGW ++MAGIC != cygpath -m -a -l '$(MAGIC)' ++endif + lib_LTLIBRARIES = libmagic.la + nodist_include_HEADERS = magic.h + +-- +2.29.2.windows.2 + diff --git a/ports/libmagic/0013-Check-for-backslash-in-argv-0-on-Windows.patch b/ports/libmagic/0013-Check-for-backslash-in-argv-0-on-Windows.patch new file mode 100644 index 00000000000..77777fc61e8 --- /dev/null +++ b/ports/libmagic/0013-Check-for-backslash-in-argv-0-on-Windows.patch @@ -0,0 +1,42 @@ +From 3f10c7d31627b64b068b84ba72e706991f672560 Mon Sep 17 00:00:00 2001 +From: Long Nguyen +Date: Fri, 14 May 2021 08:14:05 +0700 +Subject: [PATCH 13/14] Check for backslash in argv[0] on Windows + +--- + magic/Makefile.am | 2 +- + src/file.c | 5 +++++ + 2 files changed, 6 insertions(+), 1 deletion(-) + +diff --git a/magic/Makefile.am b/magic/Makefile.am +index 0eb5865..170bbab 100644 +--- a/magic/Makefile.am ++++ b/magic/Makefile.am +@@ -353,7 +353,7 @@ ${MAGIC}: $(EXTRA_DIST) $(FILE_COMPILE_DEP) + @(if expr "${FILE_COMPILE}" : '.*/.*' > /dev/null; then \ + echo "Using ${FILE_COMPILE} to generate ${MAGIC}" > /dev/null; \ + else \ +- v=$$(${FILE_COMPILE} --version | sed -e s/file-// -e q); \ ++ v=$$(${FILE_COMPILE} --version | sed -e s/file${EXEEXT}-// -e q); \ + if [ "$$v" != "${PACKAGE_VERSION}" ]; then \ + echo "Cannot use the installed version of file ($$v) to"; \ + echo "cross-compile file ${PACKAGE_VERSION}"; \ +diff --git a/src/file.c b/src/file.c +index 2889f8a..12a604b 100644 +--- a/src/file.c ++++ b/src/file.c +@@ -200,6 +200,11 @@ main(int argc, char *argv[]) + _wildcard(&argc, &argv); + #endif + ++#ifdef _WIN32 ++ if ((progname = strrchr(argv[0], '\\')) != NULL) ++ progname++; ++ else ++#endif + if ((progname = strrchr(argv[0], '/')) != NULL) + progname++; + else +-- +2.29.2.windows.2 + diff --git a/ports/libmagic/0014-Define-POSIX-macros-if-missing.patch b/ports/libmagic/0014-Define-POSIX-macros-if-missing.patch deleted file mode 100644 index 09ac7a11926..00000000000 --- a/ports/libmagic/0014-Define-POSIX-macros-if-missing.patch +++ /dev/null @@ -1,38 +0,0 @@ -From fa0e11f36bb0e322250e1e488ced9f2bf166874f Mon Sep 17 00:00:00 2001 -From: Long Nguyen -Date: Fri, 14 May 2021 18:11:39 +0700 -Subject: [PATCH 14/14] Define POSIX macros if missing - ---- - src/file.h | 15 +++++++++++++++ - 1 file changed, 15 insertions(+) - -diff --git a/src/file.h b/src/file.h -index ccfe0da..98cd37b 100644 ---- a/src/file.h -+++ b/src/file.h -@@ -100,6 +100,21 @@ - #include - #include - -+#if !defined(S_IFBLK) -+#define S_IFBLK 0 -+#define S_ISBLK(mode) (((mode) & S_IFMT) == S_IFBLK) -+#endif -+ -+#if !defined(S_IFLNK) -+#define S_IFLNK 0 -+#define S_ISLNK(mode) (((mode) & S_IFMT) == S_IFLNK) -+#endif -+ -+#if !defined(S_IFSOCK) -+#define S_IFSOCK 0 -+#define S_ISSOCK(mode) (((mode) & S_IFMT) == S_IFSOCK) -+#endif -+ - #define ENABLE_CONDITIONALS - - #ifndef MAGIC --- -2.29.2.windows.2 - diff --git a/ports/libmagic/0015-MSYS2-Remove-ioctl-call.patch b/ports/libmagic/0015-MSYS2-Remove-ioctl-call.patch index da8ef79df29..13fe3cf0c55 100644 --- a/ports/libmagic/0015-MSYS2-Remove-ioctl-call.patch +++ b/ports/libmagic/0015-MSYS2-Remove-ioctl-call.patch @@ -7,20 +7,20 @@ diff --git a/src/compress.c b/src/compress.c index 33ce2bc..f172eda 100644 --- a/src/compress.c +++ b/src/compress.c -@@ -378,7 +378,7 @@ +@@ -407,7 +407,7 @@ sread(int fd, void *buf, size_t n, int canbepipe __attribute__((__unused__))) { ssize_t rv; --#ifdef FIONREAD +-#if defined(FIONREAD) && !defined(__MINGW32__) +#if defined(FIONREAD) && !defined(__MINGW32__) && !defined(WIN32) int t = 0; #endif size_t rn = n; -@@ -386,7 +386,7 @@ +@@ -418,7 +418,7 @@ if (fd == STDIN_FILENO) goto nocheck; --#ifdef FIONREAD +-#if defined(FIONREAD) && !defined(__MINGW32__) +#if defined(FIONREAD) && !defined(__MINGW32__) && !defined(WIN32) if (canbepipe && (ioctl(fd, FIONREAD, &t) == -1 || t == 0)) { #ifdef FD_ZERO diff --git a/ports/libmagic/0016-Fix-file_famagic-function.patch b/ports/libmagic/0016-Fix-file_famagic-function.patch new file mode 100644 index 00000000000..5eaba925a58 --- /dev/null +++ b/ports/libmagic/0016-Fix-file_famagic-function.patch @@ -0,0 +1,40 @@ +diff --git a/src/fsmagic.c b/src/fsmagic.c +index 7244841..2c553c1 100644 +--- a/src/fsmagic.c ++++ b/src/fsmagic.c +@@ -66,7 +66,7 @@ # define major(dev) (((dev) >> 8) & 0xff) + # define minor(dev) ((dev) & 0xff) + #endif + #undef HAVE_MAJOR +-#if S_IFLNK != 0 ++#if S_IFLNK != 0 && ! defined(_WIN32) + file_private int + bad_link(struct magic_set *ms, int err, char *buf) + { +@@ -108,7 +108,7 @@ file_fsmagic(struct magic_set *ms, const char *fn, struct stat *sb) + int ret, did = 0; + int mime = ms->flags & MAGIC_MIME; + int silent = ms->flags & (MAGIC_APPLE|MAGIC_EXTENSION); +-#if S_IFLNK != 0 ++#if S_IFLNK != 0 && ! defined(_WIN32) + char buf[BUFSIZ+4]; + ssize_t nch; + struct stat tstatbuf; +@@ -122,7 +122,7 @@ file_fsmagic(struct magic_set *ms, const char *fn, struct stat *sb) + * Fstat is cheaper but fails for files you don't have read perms on. + * On 4.2BSD and similar systems, use lstat() to identify symlinks. + */ +-#if S_IFLNK != 0 ++#if S_IFLNK != 0 && ! defined(_WIN32) + if ((ms->flags & MAGIC_SYMLINK) == 0) + ret = lstat(fn, sb); + else +@@ -290,7 +290,7 @@ file_fsmagic(struct magic_set *ms, const char *fn, struct stat *sb) + return -1; + break; + #endif +-#if S_IFLNK != 0 ++#if S_IFLNK != 0 && ! defined(_WIN32) + case S_IFLNK: + if ((nch = readlink(fn, buf, BUFSIZ-1)) <= 0) { + if (ms->flags & MAGIC_ERROR) { diff --git a/ports/libmagic/CMakeLists.txt b/ports/libmagic/CMakeLists.txt deleted file mode 100644 index a6248bdf871..00000000000 --- a/ports/libmagic/CMakeLists.txt +++ /dev/null @@ -1,170 +0,0 @@ -cmake_minimum_required(VERSION 3.12) - -file(READ ${CMAKE_CURRENT_SOURCE_DIR}/configure.ac CONFIGURE_AC_CONTENT) -string(REGEX MATCH "AC_INIT\\(\\[file\\],\\[([0-9]+\\.[0-9]+)\\]" _ ${CONFIGURE_AC_CONTENT}) -unset(CONFIGURE_AC_CONTENT) - -project(file VERSION ${CMAKE_MATCH_1}) - -option(FILE_TESTS "Enable file tests" OFF) - -# Get library directory for multiarch linux distros -include(GNUInstallDirs) - -list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules") -set(targets) -find_package(PCRE2 CONFIG REQUIRED COMPONENTS 8BIT) -if(WIN32 AND NOT MINGW) - find_package(unofficial-getopt-win32 CONFIG REQUIRED) -endif() - -set(LIBMAGIC_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/src") -set(LIBMAGIC_TEST_DIR "${CMAKE_CURRENT_SOURCE_DIR}/tests") - -set(WIN_COMPAT_SOURCES - ${LIBMAGIC_SOURCE_DIR}/asctime_r.c - ${LIBMAGIC_SOURCE_DIR}/asprintf.c - ${LIBMAGIC_SOURCE_DIR}/ctime_r.c - ${LIBMAGIC_SOURCE_DIR}/dprintf.c - ${LIBMAGIC_SOURCE_DIR}/getline.c - ${LIBMAGIC_SOURCE_DIR}/gmtime_r.c - ${LIBMAGIC_SOURCE_DIR}/localtime_r.c - ${LIBMAGIC_SOURCE_DIR}/pread.c - ${LIBMAGIC_SOURCE_DIR}/strcasestr.c - # ${LIBMAGIC_SOURCE_DIR}/strlcat.c - # ${LIBMAGIC_SOURCE_DIR}/strlcpy.c - ${LIBMAGIC_SOURCE_DIR}/vasprintf.c - ${LIBMAGIC_SOURCE_DIR}/fmtcheck.c - ${LIBMAGIC_SOURCE_DIR}/magic.def -) - -if(WIN32) - set(LIBMAGIC_SOURCE_FILES ${WIN_COMPAT_SOURCES}) -else() - set(LIBMAGIC_SOURCE_FILES) -endif() - -list(APPEND LIBMAGIC_SOURCE_FILES - ${LIBMAGIC_SOURCE_DIR}/apprentice.c - ${LIBMAGIC_SOURCE_DIR}/apptype.c - ${LIBMAGIC_SOURCE_DIR}/ascmagic.c - ${LIBMAGIC_SOURCE_DIR}/buffer.c - ${LIBMAGIC_SOURCE_DIR}/cdf.c - ${LIBMAGIC_SOURCE_DIR}/cdf_time.c - ${LIBMAGIC_SOURCE_DIR}/compress.c - ${LIBMAGIC_SOURCE_DIR}/der.c - ${LIBMAGIC_SOURCE_DIR}/encoding.c - ${LIBMAGIC_SOURCE_DIR}/fmtcheck.c - ${LIBMAGIC_SOURCE_DIR}/fsmagic.c - ${LIBMAGIC_SOURCE_DIR}/funcs.c - ${LIBMAGIC_SOURCE_DIR}/is_json.c - ${LIBMAGIC_SOURCE_DIR}/is_tar.c - ${LIBMAGIC_SOURCE_DIR}/magic.c - ${LIBMAGIC_SOURCE_DIR}/print.c - ${LIBMAGIC_SOURCE_DIR}/readcdf.c - ${LIBMAGIC_SOURCE_DIR}/readelf.c - ${LIBMAGIC_SOURCE_DIR}/softmagic.c - # ${LIBMAGIC_SOURCE_DIR}/strlcat.c - # ${LIBMAGIC_SOURCE_DIR}/strlcpy.c - ${LIBMAGIC_SOURCE_DIR}/is_csv.c -) -if(NOT APPLE) -list(APPEND LIBMAGIC_SOURCE_FILES - ${LIBMAGIC_SOURCE_DIR}/strlcat.c - ${LIBMAGIC_SOURCE_DIR}/strlcpy.c -) -endif() - -# replace the version in the magic.h.in and write it to magic.h -FILE(READ ${LIBMAGIC_SOURCE_DIR}/magic.h.in MAGIC_H_CONTENT) -STRING(REPLACE "." "" FILE_VERSION_WITHOUT_DOT "${CMAKE_PROJECT_VERSION}") -STRING(REPLACE "X.YY" ${FILE_VERSION_WITHOUT_DOT} MAGIC_H_CONTENT_NEW "${MAGIC_H_CONTENT}") -FILE(WRITE ${LIBMAGIC_SOURCE_DIR}/magic.h "${MAGIC_H_CONTENT_NEW}") - -add_compile_definitions(HAVE_CONFIG_H VERSION="${CMAKE_PROJECT_VERSION}") -if(WIN32) - add_compile_definitions(WIN32_LEAN_AND_MEAN WIN32) -endif() - -add_library(libmagic ${LIBMAGIC_SOURCE_FILES}) -set(targets ${targets} libmagic) - -target_link_libraries(libmagic PRIVATE PCRE2::POSIX) - -target_include_directories(libmagic - PUBLIC - "$" - "$" -) - -# 'file' CLI -add_executable(file ${LIBMAGIC_SOURCE_DIR}/file.c) -set(targets ${targets} file) -target_link_libraries(file PRIVATE PCRE2::POSIX libmagic) -if (WIN32) - if (NOT MINGW) - target_link_libraries(file PRIVATE unofficial::getopt-win32::getopt) - endif() - target_link_libraries(file PRIVATE shlwapi) -endif() - -if(MSVC) - target_include_directories(file PRIVATE getopt) -endif() - -# Following is the compilation of the magic file -file(GLOB MAGIC_FRAGMENTS magic/Magdir/*) - -# Prepare a temporary file to combine the magic fragments: -set(MAGIC_FRAGMENTS_FILE ${CMAKE_CURRENT_BINARY_DIR}/magic) -file(WRITE ${MAGIC_FRAGMENTS_FILE} "") - -# Call the "cat" function for each input file -foreach(MAGIC_FRAGMENT ${MAGIC_FRAGMENTS}) - file(APPEND ${MAGIC_FRAGMENTS_FILE} "############## ${MAGIC_FRAGMENT} ##############\n") - file(READ ${MAGIC_FRAGMENT} MAGIC_FRAGMENT_CONTENTS) - file(APPEND ${MAGIC_FRAGMENTS_FILE} "${MAGIC_FRAGMENT_CONTENTS}\n") - unset(MAGIC_FRAGMENT_CONTENTS) -endforeach() - -add_custom_command(OUTPUT magic.mgc - COMMAND file -C -m magic - COMMENT "Compiling magic file" -) - -add_custom_target(magic_mgc ALL DEPENDS magic.mgc) - -# Include module with function 'configure_package_config_file' -include(CMakePackageConfigHelpers) - -set(PORT_NAME unofficial-libmagic) -set(TARGETS_EXPORT_NAME ${PORT_NAME}-targets) - -install(FILES ${CMAKE_CURRENT_BINARY_DIR}/magic.mgc DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/${PORT_NAME}) - -install(FILES ${LIBMAGIC_SOURCE_DIR}/magic.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) - -install(TARGETS ${targets} - EXPORT ${TARGETS_EXPORT_NAME} - RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} - LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} - ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} - INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} -) -install(EXPORT ${TARGETS_EXPORT_NAME} - FILE ${TARGETS_EXPORT_NAME}.cmake - DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${PORT_NAME} - NAMESPACE unofficial::libmagic:: - ) -configure_package_config_file( - ${PORT_NAME}-config.cmake.in - ${PORT_NAME}-config.cmake - INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${PORT_NAME}) -write_basic_package_version_file( - ${PORT_NAME}-config-version.cmake - VERSION ${CMAKE_PROJECT_VERSION} - COMPATIBILITY SameMajorVersion) -install(FILES - ${CMAKE_BINARY_DIR}/${PORT_NAME}-config.cmake - ${CMAKE_BINARY_DIR}/${PORT_NAME}-config-version.cmake - DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${PORT_NAME}) diff --git a/ports/libmagic/config.h b/ports/libmagic/config.h deleted file mode 100644 index 3a6e492f7c2..00000000000 --- a/ports/libmagic/config.h +++ /dev/null @@ -1,401 +0,0 @@ -/* Define in built-in ELF support is used */ -#define BUILTIN_ELF 1 - -/* Define for ELF core file support */ -#define ELFCORE 1 - -/* Define to 1 if you have the `asctime_r' function. */ -#undef HAVE_ASCTIME_R - -/* Define to 1 if you have the `asprintf' function. */ -#undef HAVE_ASPRINTF - -/* Define to 1 if you have the `ctime_r' function. */ -#undef HAVE_CTIME_R - -/* HAVE_DAYLIGHT */ -#define HAVE_DAYLIGHT 1 - -/* Define to 1 if you have the declaration of `daylight', and to 0 if you - don't. */ -#undef HAVE_DECL_DAYLIGHT - -/* Define to 1 if you have the declaration of `tzname', and to 0 if you don't. - */ -#undef HAVE_DECL_TZNAME - -/* Define to 1 if you have the header file. */ -#undef HAVE_DLFCN_H - -/* Define to 1 if you have the `dprintf' function. */ -#undef HAVE_DPRINTF - -/* Define to 1 if you have the header file. */ -#undef HAVE_ERR_H - -/* Define to 1 if you have the header file. */ -#ifdef WIN32 -#undef HAVE_DIRENT_H -#else -// TBD: will all non-win32 xplatforms we want have this? -#define HAVE_DIRENT_H 1 -#endif - -/* Define to 1 if you have the header file. */ -#define HAVE_FCNTL_H 1 - -/* Define to 1 if you have the `fmtcheck' function. */ -/*#undef HAVE_FMTCHECK*/ - -/* Define to 1 if you have the `fork' function. */ -#undef HAVE_FORK - -/* Define to 1 if fseeko (and presumably ftello) exists and is declared. */ -#undef HAVE_FSEEKO - -/* Define to 1 if you have the `getline' function. */ -#undef HAVE_GETLINE - -/* Define to 1 if you have the header file. */ -#ifdef _WIN32 -#define HAVE_GETOPT_H 1 -#endif - -/* Define to 1 if you have the `getopt_long' function. */ -#undef HAVE_GETOPT_LONG - -/* Define to 1 if you have the `getpagesize' function. */ -#undef HAVE_GETPAGESIZE - -/* Define to 1 if you have the header file. */ -#define HAVE_INTTYPES_H 1 - -/* Define to 1 if you have the `gnurx' library (-lgnurx). */ -#undef HAVE_LIBGNURX - -/* Define to 1 if you have the `z' library (-lz). */ -/* #undef HAVE_LIBZ */ - -/* Define to 1 if you have the header file. */ -#define HAVE_LIMITS_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_LOCALE_H 1 - -/* Define to 1 if mbrtowc and mbstate_t are properly declared. */ -#define HAVE_MBRTOWC 1 - -/* Define to 1 if declares mbstate_t. */ -#define HAVE_MBSTATE_T 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_MEMORY_H 1 - -/* Define to 1 if you have the `mkostemp' function. */ -#undef HAVE_MKOSTEMP - -/* Define to 1 if you have the `mkstemp' function. */ -#ifdef _WIN32 -#undef HAVE_MKSTEMP -#else -#define HAVE_MKSTEMP 1 -#endif - -/* Define to 1 if you have a working `mmap' system call. */ -#undef HAVE_MMAP - -/* Define to 1 if you have the `pread' function. */ -#undef HAVE_PREAD - -/* Define to 1 if you have the header file. */ -#define HAVE_STDDEF_H 1 - -/* Define to 1 if the system has the type `pid_t'. */ -#undef HAVE_PID_T - -/* Define to 1 if you have the header file. */ -#define HAVE_STDINT_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_STDLIB_H 1 - -/* Define to 1 if you have the `strcasestr' function. */ -#if defined(_WIN32) && !defined(__MINGW32__) -#define HAVE_STRCASESTR 1 -#else -#undef HAVE_STRCASESTR -#endif - -/* Define to 1 if you have the `strerror' function. */ -#define HAVE_STRERROR 1 - -/* Define to 1 if you have the header file. */ -#undef HAVE_STRINGS_H - -/* Define to 1 if you have the header file. */ -#define HAVE_STRING_H 1 - -/* Define to 1 if you have the `strlcat' function. */ -#undef HAVE_STRLCAT - -/* Define to 1 if you have the `strlcpy' function. */ -#undef HAVE_STRLCPY - -/* Define to 1 if you have the `strndup' function. */ -#undef HAVE_STRNDUP - -/* Define to 1 if you have the `strtof' function. */ -#undef HAVE_STRTOF - -/* Define to 1 if you have the `strtoul' function. */ -#define HAVE_STRTOUL 1 - -/* HAVE_STRUCT_OPTION */ -#define HAVE_STRUCT_OPTION 1 - -/* Define to 1 if `st_rdev' is a member of `struct stat'. */ -#undef HAVE_STRUCT_STAT_ST_RDEV - -/* Define to 1 if `tm_gmtoff' is a member of `struct tm'. */ -#undef HAVE_STRUCT_TM_TM_GMTOFF - -/* Define to 1 if `tm_zone' is a member of `struct tm'. */ -#undef HAVE_STRUCT_TM_TM_ZONE - -/* Define to 1 if you have the header file. */ -#undef HAVE_SYS_MMAN_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_SYS_PARAM_H - -/* Define to 1 if you have the header file. */ -#define HAVE_SYS_STAT_H 1 - -/* Define to 1 if you have the header file. */ -#undef HAVE_SYS_TIME_H - -/* Define to 1 if you have the header file. */ -#define HAVE_SYS_TYPES_H 1 - -/* Define to 1 if you have the header file. */ -#undef HAVE_SYS_UTIME_H - -/* Define to 1 if you have that is POSIX.1 compatible. */ -#undef HAVE_SYS_WAIT_H - -/* HAVE_TM_ISDST */ -#undef HAVE_TM_ISDST - -/* HAVE_TM_ZONE */ -#undef HAVE_TM_ZONE - -/* HAVE_TZNAME */ -#undef HAVE_TZNAME - -/* Define to 1 if the system has the type `int32_t'. */ -#define HAVE_INT32_T 1 - -/* Define to 1 if the system has the type `int64_t'. */ -#define HAVE_INT64_T 1 - -/* Define to 1 if the system has the type `uint16_t'. */ -#define HAVE_UINT16_T 1 - -/* Define to 1 if the system has the type `uint32_t'. */ -#define HAVE_UINT32_T 1 - -/* Define to 1 if the system has the type `uint64_t'. */ -#define HAVE_UINT64_T 1 - -/* Define to 1 if the system has the type `uint8_t'. */ -#define HAVE_UINT8_T 1 - -/* Define to 1 if you have the header file. */ -/* turns out, v5.39 file/src/buffer.c does -not- subject inclusion to this define */ -#ifndef _WIN32 -#define HAVE_UNISTD_H 1 -#endif - -/* Define to 1 if you have the `utime' function. */ -#undef HAVE_UTIME - -/* Define to 1 if you have the `utimes' function. */ -#undef HAVE_UTIMES - -/* Define to 1 if you have the header file. */ -#undef HAVE_UTIME_H - -/* Define to 1 if you have the `vasprintf' function. */ -#undef HAVE_VASPRINTF - -/* Define to 1 if you have the `vfork' function. */ -#undef HAVE_VFORK - -/* Define to 1 if you have the header file. */ -/* #undef HAVE_VFORK_H */ - -/* Define to 1 or 0, depending whether the compiler supports simple visibility - declarations. */ -#undef HAVE_VISIBILITY - -/* Define to 1 if you have the header file. */ -#define HAVE_WCHAR_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_WCTYPE_H 1 - -/* Define to 1 if you have the `wcwidth' function. */ -#undef HAVE_WCWIDTH - -/* Define to 1 if `fork' works. */ -#undef HAVE_WORKING_FORK - -/* Define to 1 if `vfork' works. */ -#undef HAVE_WORKING_VFORK - -/* Define to 1 if you have the header file. */ -/* #undef HAVE_ZLIB_H */ - -/* Define to the sub-directory in which libtool stores uninstalled libraries. - */ -#undef LT_OBJDIR - -/* Define to 1 if `major', `minor', and `makedev' are declared in . - */ -#undef MAJOR_IN_MKDEV - -/* Define to 1 if `major', `minor', and `makedev' are declared in - . */ -#undef MAJOR_IN_SYSMACROS - -/* Name of package */ -#undef PACKAGE - -/* Define to the address where bug reports for this package should be sent. */ -#undef PACKAGE_BUGREPORT - -/* Define to the full name of this package. */ -#undef PACKAGE_NAME - -/* Define to the full name and version of this package. */ -#undef PACKAGE_STRING - -/* Define to the one symbol short name of this package. */ -#undef PACKAGE_TARNAME - -/* Define to the home page for this package. */ -#undef PACKAGE_URL - -/* Define to the version of this package. */ -#undef PACKAGE_VERSION - -/* The size of `long long', as computed by sizeof. */ -#undef SIZEOF_LONG_LONG - -/* Define to 1 if you have the ANSI C header files. */ -#undef STDC_HEADERS - -/* Define to 1 if your declares `struct tm'. */ -#undef TM_IN_SYS_TIME - -/* Enable extensions on AIX 3, Interix. */ -#ifndef _ALL_SOURCE -# undef _ALL_SOURCE -#endif -/* Enable GNU extensions on systems that have them. */ -#ifndef _GNU_SOURCE -# undef _GNU_SOURCE -#endif -/* Enable threading extensions on Solaris. */ -#ifndef _POSIX_PTHREAD_SEMANTICS -# undef _POSIX_PTHREAD_SEMANTICS -#endif -/* Enable extensions on HP NonStop. */ -#ifndef _TANDEM_SOURCE -# undef _TANDEM_SOURCE -#endif -/* Enable general extensions on Solaris. */ -#ifndef __EXTENSIONS__ -# undef __EXTENSIONS__ -#endif - - -/* Number of bits in a file offset, on hosts where this is settable. */ -#undef _FILE_OFFSET_BITS - -/* Define to 1 to make fseeko visible on some hosts (e.g. glibc 2.2). */ -#undef _LARGEFILE_SOURCE - -/* Define for large files, on AIX-style hosts. */ -#undef _LARGE_FILES - -/* Define to 1 if on MINIX. */ -#undef _MINIX - -/* Define to 2 if the system does not provide POSIX.1 features except with - this defined. */ -#undef _POSIX_1_SOURCE - -/* Define to 1 if you need to in order for `stat' and other things to work. */ -#undef _POSIX_SOURCE - -/* Define to empty if `const' does not conform to ANSI C. */ -//#define const - -/* Define to a type if does not define. */ -//#undef mbstate_t - -/* Define to `long int' if does not define. */ -//#undef off_t - -/* Define to `unsigned int' if does not define. */ -//#undef size_t - - -#ifndef HAVE_UINT8_T -typedef unsigned char uint8_t; -#endif -#ifndef HAVE_UINT16_T -typedef unsigned short uint16_t; -#endif -#ifndef HAVE_UINT32_T -typedef unsigned int uint32_t; -#endif -#ifndef HAVE_INT32_T -typedef int int32_t; -#endif -#ifndef HAVE_UINT64_T -#if SIZEOF_LONG_LONG == 8 -typedef unsigned long long uint64_t; -#else -typedef unsigned long uint64_t; -#endif -#endif -#ifndef HAVE_INT64_T -#if SIZEOF_LONG_LONG == 8 -typedef long long int64_t; -#else -typedef long int64_t; -#endif -#endif - -#ifndef _SSIZE_T_DEFINED -#ifdef _WIN32 -#if defined(__MINGW32__) && !defined(__MINGW64__) -typedef int ssize_t; -#else -#include -typedef int64_t ssize_t; -#endif -#endif -#define _SSIZE_T_DEFINED -#endif - -#ifdef _WIN32 -#include - -#include -#endif - -/* Define as `fork' if `vfork' does not work. */ -/* #undef vfork */ diff --git a/ports/libmagic/magic.def b/ports/libmagic/magic.def deleted file mode 100644 index f286a62ae48..00000000000 --- a/ports/libmagic/magic.def +++ /dev/null @@ -1,20 +0,0 @@ -LIBRARY libmagic -EXPORTS - magic_open - magic_close - magic_getpath - magic_file - magic_descriptor - magic_buffer - magic_error - magic_setflags - magic_version - magic_load - magic_load_buffers - magic_compile - magic_check - magic_list - magic_errno - magic_setparam - magic_getparam - getline diff --git a/ports/libmagic/portfile.cmake b/ports/libmagic/portfile.cmake index c40c3e2bac6..34ecdb150d1 100644 --- a/ports/libmagic/portfile.cmake +++ b/ports/libmagic/portfile.cmake @@ -1,53 +1,62 @@ -set(PATCHES - "0001-Use-pcre2.patch" -) - if(VCPKG_TARGET_IS_WINDOWS) set(PATCHES - ${PATCHES} + "0001-Use-libtre.patch" + "0002-Change-zlib-lib-name-to-match-CMake-output.patch" "0003-Fix-WIN32-macro-checks.patch" "0004-Typedef-POSIX-types-on-Windows.patch" "0005-Include-dirent.h-for-S_ISREG-and-S_ISDIR.patch" "0006-Remove-Wrap-POSIX-headers.patch" "0007-Substitute-unistd-macros-for-MSVC.patch" "0008-Add-FILENO-defines.patch" - "0009-No-fcntl-in-magic.c.patch" "0010-Properly-check-for-the-presence-of-bitmasks.patch" "0011-Remove-pipe-related-functions-in-funcs.c.patch" - "0014-Define-POSIX-macros-if-missing.patch" + "0012-Convert-MSYS2-paths-to-Windows-paths.patch" + "0013-Check-for-backslash-in-argv-0-on-Windows.patch" "0015-MSYS2-Remove-ioctl-call.patch" + "0016-Fix-file_famagic-function.patch" ) endif() vcpkg_from_github( OUT_SOURCE_PATH SOURCE_PATH REPO file/file - REF FILE5_40 - SHA512 d76bfe5326e1b40368e055c2e049a24b4ffdbd727371f4f3aa1dd3f53787d16b88550b3cc71ecf02151e2fb3e567eb2598e4707badab8c391eb71113c2dcc319 + REF FILE5_45 + SHA512 fdd4c5d13d5ea1d25686c76d8ebc3252c54040c4871e3f0f623c4548b3841795d4e36050292a9453eedf0fbf932573890e9d6ac9fa63ccf577215598ae84b9ea HEAD_REF master PATCHES ${PATCHES} ) -file(COPY "${CMAKE_CURRENT_LIST_DIR}/CMakeLists.txt" DESTINATION "${SOURCE_PATH}") -file(COPY "${CMAKE_CURRENT_LIST_DIR}/unofficial-libmagic-config.cmake.in" DESTINATION "${SOURCE_PATH}") -file(COPY "${CMAKE_CURRENT_LIST_DIR}/magic.def" DESTINATION "${SOURCE_PATH}/src") -file(COPY "${CMAKE_CURRENT_LIST_DIR}/config.h" DESTINATION "${SOURCE_PATH}/src") +if(VCPKG_TARGET_IS_WINDOWS) + set(VCPKG_C_FLAGS "${VCPKG_C_FLAGS} -D_CRT_SECURE_NO_WARNINGS -D_CRT_NONSTDC_NO_WARNINGS") + set(VCPKG_CXX_FLAGS "${VCPKG_CXX_FLAGS} -D_CRT_SECURE_NO_WARNINGS -D_CRT_NONSTDC_NO_WARNINGS") +endif() -vcpkg_cmake_configure( - SOURCE_PATH ${SOURCE_PATH} -) +set(CONFIG_OPTIONS) -vcpkg_cmake_install() -vcpkg_copy_pdbs() -vcpkg_fixup_pkgconfig() -vcpkg_copy_tools(TOOL_NAMES file AUTO_CLEAN) -vcpkg_cmake_config_fixup( - CONFIG_PATH lib/cmake/unofficial-libmagic - PACKAGE_NAME unofficial-libmagic) +if(NOT "zlib" IN_LIST FEATURES) + list(APPEND CONFIG_OPTIONS "--disable-zlib") +endif() -file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/include") -file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/share") -file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/share/${PORT}/man5") +if(NOT "bzip2" IN_LIST FEATURES) + list(APPEND CONFIG_OPTIONS "--disable-bzlib") +endif() + +if(NOT "lzma" IN_LIST FEATURES) + list(APPEND CONFIG_OPTIONS "--disable-xzlib") +endif() + +if(NOT "zstd" IN_LIST FEATURES) + list(APPEND CONFIG_OPTIONS "--disable-zstdlib") +endif() + +vcpkg_configure_make( + AUTOCONFIG + SOURCE_PATH "${SOURCE_PATH}" + OPTIONS + ${CONFIG_OPTIONS} + "--disable-lzlib" + "--disable-libseccomp" +) if(VCPKG_CROSSCOMPILING) vcpkg_add_to_path(PREPEND "${CURRENT_HOST_INSTALLED_DIR}/tools/libmagic/bin") @@ -55,23 +64,37 @@ elseif(VCPKG_TARGET_IS_WINDOWS AND VCPKG_LIBRARY_LINKAGE STREQUAL dynamic) set(EXTRA_ARGS "ADD_BIN_TO_PATH") endif() +vcpkg_install_make(${EXTRA_ARGS}) +vcpkg_copy_tool_dependencies("${CURRENT_PACKAGES_DIR}/tools/${PORT}/bin") +vcpkg_copy_tool_dependencies("${CURRENT_PACKAGES_DIR}/tools/${PORT}/debug/bin") +vcpkg_fixup_pkgconfig() + if(VCPKG_LIBRARY_LINKAGE STREQUAL static) file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/bin" "${CURRENT_PACKAGES_DIR}/debug/bin") endif() -set(UNOFFICIAL_PORT unofficial-${PORT}) - if(VCPKG_TARGET_IS_WINDOWS) if(NOT VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "release") - file(MAKE_DIRECTORY "${CURRENT_PACKAGES_DIR}/tools/${UNOFFICIAL_PORT}/share/misc") - file(COPY "${CURRENT_PACKAGES_DIR}/share/${UNOFFICIAL_PORT}/magic.mgc" DESTINATION "${CURRENT_PACKAGES_DIR}/tools/${UNOFFICIAL_PORT}/share/misc") + file(MAKE_DIRECTORY "${CURRENT_PACKAGES_DIR}/tools/${PORT}/share/misc") + file(COPY "${CURRENT_PACKAGES_DIR}/share/${PORT}/misc/magic.mgc" DESTINATION "${CURRENT_PACKAGES_DIR}/tools/${PORT}/share/misc") endif() if(NOT VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "debug") - file(MAKE_DIRECTORY "${CURRENT_PACKAGES_DIR}/tools/${UNOFFICIAL_PORT}/debug/share/misc") - file(COPY "${CURRENT_PACKAGES_DIR}/share/${UNOFFICIAL_PORT}/magic.mgc" DESTINATION "${CURRENT_PACKAGES_DIR}/tools/${UNOFFICIAL_PORT}/debug/share/misc") + file(MAKE_DIRECTORY "${CURRENT_PACKAGES_DIR}/tools/${PORT}/debug/share/misc") + file(COPY "${CURRENT_PACKAGES_DIR}/share/${PORT}/misc/magic.mgc" DESTINATION "${CURRENT_PACKAGES_DIR}/tools/${PORT}/debug/share/misc") endif() endif() +file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/include") +file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/share") +file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/share/${PORT}/man5") + +include(CMakePackageConfigHelpers) +configure_package_config_file( + "${CMAKE_CURRENT_LIST_DIR}/unofficial-${PORT}-config.cmake.in" + "${CURRENT_PACKAGES_DIR}/share/unofficial-${PORT}/unofficial-${PORT}-config.cmake" + INSTALL_DESTINATION "share/unofficial-${PORT}" +) + # Handle copyright and usage vcpkg_install_copyright(FILE_LIST "${SOURCE_PATH}/COPYING") file(INSTALL "${CMAKE_CURRENT_LIST_DIR}/usage" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}") diff --git a/ports/libmagic/unofficial-libmagic-config.cmake.in b/ports/libmagic/unofficial-libmagic-config.cmake.in index d3671f89b47..5ff3b0380aa 100644 --- a/ports/libmagic/unofficial-libmagic-config.cmake.in +++ b/ports/libmagic/unofficial-libmagic-config.cmake.in @@ -1,12 +1,69 @@ @PACKAGE_INIT@ -include(CMakeFindDependencyMacro) -find_dependency(PCRE2 COMPONENTS 8BIT POSIX) +if(WIN32 AND "@VCPKG_LIBRARY_LINKAGE@" STREQUAL "static") + include(CMakeFindDependencyMacro) + find_dependency(unofficial-tre) +endif() -include("${CMAKE_CURRENT_LIST_DIR}/@TARGETS_EXPORT_NAME@.cmake") +# Compute the installation prefix relative to this file. +get_filename_component(_IMPORT_PREFIX "${CMAKE_CURRENT_LIST_FILE}" PATH) +get_filename_component(_IMPORT_PREFIX "${_IMPORT_PREFIX}" PATH) +get_filename_component(_IMPORT_PREFIX "${_IMPORT_PREFIX}" PATH) +if(_IMPORT_PREFIX STREQUAL "/") + set(_IMPORT_PREFIX "") +endif() -set(unofficial-libmagic_VERSION @CMAKE_PROJECT_VERSION@) -set(unofficial-libmagic_FOUND true) -set(unofficial-libmagic_DICTIONARY "${CMAKE_CURRENT_LIST_DIR}/magic.mgc") +if("@VCPKG_LIBRARY_LINKAGE@" STREQUAL "static") + add_library(unofficial::libmagic::libmagic STATIC IMPORTED) +else() + add_library(unofficial::libmagic::libmagic SHARED IMPORTED) +endif() -check_required_components("unofficial-libmagic") +set_target_properties(unofficial::libmagic::libmagic PROPERTIES + INTERFACE_INCLUDE_DIRECTORIES "${_IMPORT_PREFIX}/include" +) + +if(WIN32 AND "@VCPKG_LIBRARY_LINKAGE@" STREQUAL "static") + set_target_properties(unofficial::libmagic::libmagic PROPERTIES + INTERFACE_LINK_LIBRARIES "\$" + ) +endif() + +macro(add_library_config config prefix) + set_property(TARGET unofficial::libmagic::libmagic APPEND PROPERTY IMPORTED_CONFIGURATIONS ${config}) + if("@VCPKG_LIBRARY_LINKAGE@" STREQUAL "static") + set_target_properties(unofficial::libmagic::libmagic PROPERTIES + IMPORTED_LOCATION_${config} "${_IMPORT_PREFIX}/${prefix}lib/@VCPKG_TARGET_STATIC_LIBRARY_PREFIX@magic@VCPKG_TARGET_STATIC_LIBRARY_SUFFIX@" + IMPORTED_LINK_INTERFACE_LANGUAGES_${config} "C" + ) + else() + if(WIN32) + set(library_dir "${_IMPORT_PREFIX}/${prefix}bin/") + set(soversion_suffix "-1") + set_target_properties(unofficial::libmagic::libmagic PROPERTIES + IMPORTED_IMPLIB_${config} "${_IMPORT_PREFIX}/${prefix}/lib/@VCPKG_TARGET_IMPORT_LIBRARY_PREFIX@magic@VCPKG_TARGET_IMPORT_LIBRARY_SUFFIX@" + ) + else() + set(library_dir "${_IMPORT_PREFIX}/${prefix}lib/") + endif() + set_target_properties(unofficial::libmagic::libmagic PROPERTIES + IMPORTED_LOCATION_${config} "${library_dir}@VCPKG_TARGET_SHARED_LIBRARY_PREFIX@magic${soversion_suffix}@VCPKG_TARGET_SHARED_LIBRARY_SUFFIX@" + ) + unset(soversion_suffix) + unset(library_dir) + endif() +endmacro() + +if("@VCPKG_BUILD_TYPE@" STREQUAL "" OR "@VCPKG_BUILD_TYPE@" STREQUAL "debug") + add_library_config(DEBUG "debug/") +endif() + +if("@VCPKG_BUILD_TYPE@" STREQUAL "" OR "@VCPKG_BUILD_TYPE@" STREQUAL "release") + add_library_config(RELEASE "") +endif() + +set_and_check(unofficial-libmagic_DICTIONARY "${_IMPORT_PREFIX}/share/libmagic/misc/magic.mgc") + +unset(_IMPORT_PREFIX) + +check_required_components(unofficial-libmagic) diff --git a/ports/libmagic/vcpkg.json b/ports/libmagic/vcpkg.json index 63944114b56..e809501e900 100644 --- a/ports/libmagic/vcpkg.json +++ b/ports/libmagic/vcpkg.json @@ -1,26 +1,52 @@ { "name": "libmagic", - "version-string": "5.40", - "port-version": 1, + "version": "5.45", + "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", "dependencies": [ { - "name": "vcpkg-cmake", - "host": true + "name": "dirent", + "platform": "windows" }, { - "name": "vcpkg-cmake-config", - "host": true + "name": "getopt", + "platform": "windows" }, { - "name": "dirent", - "platform": "windows" + "name": "libmagic", + "host": true }, { - "name": "getopt", - "platform": "windows & !mingw" + "name": "tre", + "platform": "windows | mingw" + } + ], + "features": { + "zlib": { + "description": "Enable zlib support", + "dependencies": [ + "zlib" + ] + }, + "bzlib": { + "description": "Enable Bzip2 support", + "dependencies": [ + "bzip2" + ] + }, + "xzlib": { + "description": "Enable liblzma/xz support", + "dependencies": [ + "liblzma" + ] }, - "pcre2" - ] + "zstdlib": { + "description": "Enable zstdlib support", + "dependencies": [ + "zstd" + ] + } + } } diff --git a/ports/pcre2/fix-cmake.patch b/ports/pcre2/fix-cmake.patch deleted file mode 100644 index 93d2f719695..00000000000 --- a/ports/pcre2/fix-cmake.patch +++ /dev/null @@ -1,334 +0,0 @@ -diff --git a/CMakeLists.txt b/CMakeLists.txt -index cec7dfb..84d1769 100644 ---- a/CMakeLists.txt -+++ b/CMakeLists.txt -@@ -100,6 +100,9 @@ - # 2021-08-28 PH increased minimum version - # 2021-08-28 PH added test for realpath() - # 2022-12-10 PH added support for pcre2posix_test -+# 2023-01-15 Carlo added C99 as the minimum required -+# 2023-06-03 Theodore used standard CMake constructs to export the library's targets. -+# 2023-08-06 PH added support for setting variable length lookbehind maximum - - # Increased minimum to 2.8.5 to support GNUInstallDirs. - # Increased minimum to 3.1 to support imported targets. -@@ -136,6 +139,7 @@ INCLUDE(CheckFunctionExists) - INCLUDE(CheckSymbolExists) - INCLUDE(CheckIncludeFile) - INCLUDE(CheckTypeSize) -+INCLUDE(CMakePackageConfigHelpers) - INCLUDE(GNUInstallDirs) # for CMAKE_INSTALL_LIBDIR - - CHECK_INCLUDE_FILE(dirent.h HAVE_DIRENT_H) -@@ -705,7 +709,9 @@ IF(PCRE2_BUILD_PCRE2_8) - VERSION ${LIBPCRE2_8_VERSION} - SOVERSION ${LIBPCRE2_8_SOVERSION}) - TARGET_COMPILE_DEFINITIONS(pcre2-8-static PUBLIC PCRE2_STATIC) -- TARGET_INCLUDE_DIRECTORIES(pcre2-8-static PUBLIC ${PROJECT_BINARY_DIR}) -+ TARGET_INCLUDE_DIRECTORIES(pcre2-8-static PUBLIC -+ $ -+ $) - IF(REQUIRE_PTHREAD) - TARGET_LINK_LIBRARIES(pcre2-8-static Threads::Threads) - ENDIF(REQUIRE_PTHREAD) -@@ -718,8 +724,9 @@ IF(PCRE2_BUILD_PCRE2_8) - VERSION ${LIBPCRE2_POSIX_VERSION} - SOVERSION ${LIBPCRE2_POSIX_SOVERSION}) - TARGET_LINK_LIBRARIES(pcre2-posix-static pcre2-8-static) -- TARGET_COMPILE_DEFINITIONS(pcre2-posix-static PUBLIC PCRE2_STATIC) -- TARGET_INCLUDE_DIRECTORIES(pcre2-posix-static PUBLIC ${PROJECT_BINARY_DIR}) -+ TARGET_INCLUDE_DIRECTORIES(pcre2-posix-static PUBLIC -+ $ -+ $) - SET(targets ${targets} pcre2-posix-static) - - IF(MSVC) -@@ -736,7 +743,9 @@ IF(PCRE2_BUILD_PCRE2_8) - - IF(BUILD_SHARED_LIBS) - ADD_LIBRARY(pcre2-8-shared SHARED ${PCRE2_HEADERS} ${PCRE2_SOURCES} ${PROJECT_BINARY_DIR}/config.h) -- TARGET_INCLUDE_DIRECTORIES(pcre2-8-shared PUBLIC ${PROJECT_BINARY_DIR}) -+ TARGET_INCLUDE_DIRECTORIES(pcre2-8-shared PUBLIC -+ $ -+ $) - SET_TARGET_PROPERTIES(pcre2-8-shared PROPERTIES - COMPILE_DEFINITIONS PCRE2_CODE_UNIT_WIDTH=8 - MACHO_COMPATIBILITY_VERSION "${LIBPCRE2_8_MACHO_COMPATIBILITY_VERSION}" -@@ -749,7 +758,9 @@ IF(PCRE2_BUILD_PCRE2_8) - ENDIF(REQUIRE_PTHREAD) - SET(targets ${targets} pcre2-8-shared) - ADD_LIBRARY(pcre2-posix-shared SHARED ${PCRE2POSIX_HEADERS} ${PCRE2POSIX_SOURCES}) -- TARGET_INCLUDE_DIRECTORIES(pcre2-posix-shared PUBLIC ${PROJECT_BINARY_DIR}) -+ TARGET_INCLUDE_DIRECTORIES(pcre2-posix-shared PUBLIC -+ $ -+ $) - SET_TARGET_PROPERTIES(pcre2-posix-shared PROPERTIES - COMPILE_DEFINITIONS PCRE2_CODE_UNIT_WIDTH=8 - MACHO_COMPATIBILITY_VERSION "${LIBPCRE2_POSIX_MACHO_COMPATIBILITY_VERSION}" -@@ -786,7 +797,9 @@ ENDIF(PCRE2_BUILD_PCRE2_8) - IF(PCRE2_BUILD_PCRE2_16) - IF(BUILD_STATIC_LIBS) - ADD_LIBRARY(pcre2-16-static STATIC ${PCRE2_HEADERS} ${PCRE2_SOURCES} ${PROJECT_BINARY_DIR}/config.h) -- TARGET_INCLUDE_DIRECTORIES(pcre2-16-static PUBLIC ${PROJECT_BINARY_DIR}) -+ TARGET_INCLUDE_DIRECTORIES(pcre2-16-static PUBLIC -+ $ -+ $) - SET_TARGET_PROPERTIES(pcre2-16-static PROPERTIES - COMPILE_DEFINITIONS PCRE2_CODE_UNIT_WIDTH=16 - MACHO_COMPATIBILITY_VERSION "${LIBPCRE2_32_MACHO_COMPATIBILITY_VERSION}" -@@ -811,7 +824,9 @@ IF(PCRE2_BUILD_PCRE2_16) - - IF(BUILD_SHARED_LIBS) - ADD_LIBRARY(pcre2-16-shared SHARED ${PCRE2_HEADERS} ${PCRE2_SOURCES} ${PROJECT_BINARY_DIR}/config.h) -- TARGET_INCLUDE_DIRECTORIES(pcre2-16-shared PUBLIC ${PROJECT_BINARY_DIR}) -+ TARGET_INCLUDE_DIRECTORIES(pcre2-16-shared PUBLIC -+ $ -+ $) - SET_TARGET_PROPERTIES(pcre2-16-shared PROPERTIES - COMPILE_DEFINITIONS PCRE2_CODE_UNIT_WIDTH=16 - MACHO_COMPATIBILITY_VERSION "${LIBPCRE2_32_MACHO_COMPATIBILITY_VERSION}" -@@ -848,7 +863,9 @@ ENDIF(PCRE2_BUILD_PCRE2_16) - IF(PCRE2_BUILD_PCRE2_32) - IF(BUILD_STATIC_LIBS) - ADD_LIBRARY(pcre2-32-static STATIC ${PCRE2_HEADERS} ${PCRE2_SOURCES} ${PROJECT_BINARY_DIR}/config.h) -- TARGET_INCLUDE_DIRECTORIES(pcre2-32-static PUBLIC ${PROJECT_BINARY_DIR}) -+ TARGET_INCLUDE_DIRECTORIES(pcre2-32-static PUBLIC -+ $ -+ $) - SET_TARGET_PROPERTIES(pcre2-32-static PROPERTIES - COMPILE_DEFINITIONS PCRE2_CODE_UNIT_WIDTH=32 - MACHO_COMPATIBILITY_VERSION "${LIBPCRE2_32_MACHO_COMPATIBILITY_VERSION}" -@@ -873,7 +890,9 @@ IF(PCRE2_BUILD_PCRE2_32) - - IF(BUILD_SHARED_LIBS) - ADD_LIBRARY(pcre2-32-shared SHARED ${PCRE2_HEADERS} ${PCRE2_SOURCES} ${PROJECT_BINARY_DIR}/config.h) -- TARGET_INCLUDE_DIRECTORIES(pcre2-32-shared PUBLIC ${PROJECT_BINARY_DIR}) -+ TARGET_INCLUDE_DIRECTORIES(pcre2-32-shared PUBLIC -+ $ -+ $) - SET_TARGET_PROPERTIES(pcre2-32-shared PROPERTIES - COMPILE_DEFINITIONS PCRE2_CODE_UNIT_WIDTH=32 - MACHO_COMPATIBILITY_VERSION "${LIBPCRE2_32_MACHO_COMPATIBILITY_VERSION}" -@@ -1075,9 +1094,13 @@ ENDIF(PCRE2_BUILD_TESTS) - SET(CMAKE_INSTALL_ALWAYS 1) - - INSTALL(TARGETS ${targets} -- RUNTIME DESTINATION bin -+ EXPORT pcre2-targets -+ RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} - LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} - ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) -+INSTALL(EXPORT pcre2-targets -+ DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/pcre2 -+ NAMESPACE pcre2::) - INSTALL(FILES ${pkg_config_files} DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig) - INSTALL(FILES "${CMAKE_CURRENT_BINARY_DIR}/pcre2-config" - DESTINATION bin -@@ -1089,11 +1112,12 @@ INSTALL(FILES ${PCRE2_HEADERS} ${PCRE2POSIX_HEADERS} DESTINATION include) - # CMake config files. - set(PCRE2_CONFIG_IN ${CMAKE_CURRENT_SOURCE_DIR}/cmake/pcre2-config.cmake.in) - set(PCRE2_CONFIG_OUT ${CMAKE_CURRENT_BINARY_DIR}/cmake/pcre2-config.cmake) --configure_file(${PCRE2_CONFIG_IN} ${PCRE2_CONFIG_OUT} @ONLY) --set(PCRE2_CONFIG_VERSION_IN ${CMAKE_CURRENT_SOURCE_DIR}/cmake/pcre2-config-version.cmake.in) -+configure_package_config_file(${PCRE2_CONFIG_IN} ${PCRE2_CONFIG_OUT} INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/pcre2) - set(PCRE2_CONFIG_VERSION_OUT ${CMAKE_CURRENT_BINARY_DIR}/cmake/pcre2-config-version.cmake) --configure_file(${PCRE2_CONFIG_VERSION_IN} ${PCRE2_CONFIG_VERSION_OUT} @ONLY) --install(FILES ${PCRE2_CONFIG_OUT} ${PCRE2_CONFIG_VERSION_OUT} DESTINATION cmake) -+write_basic_package_version_file(${PCRE2_CONFIG_VERSION_OUT} -+ VERSION ${PCRE2_MAJOR}.${PCRE2_MINOR}.0 -+ COMPATIBILITY SameMajorVersion) -+install(FILES ${PCRE2_CONFIG_OUT} ${PCRE2_CONFIG_VERSION_OUT} DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/pcre2) - - FILE(GLOB html ${PROJECT_SOURCE_DIR}/doc/html/*.html) - FILE(GLOB man1 ${PROJECT_SOURCE_DIR}/doc/*.1) -diff --git a/cmake/pcre2-config-version.cmake.in b/cmake/pcre2-config-version.cmake.in -deleted file mode 100644 -index dac149e..0000000 ---- a/cmake/pcre2-config-version.cmake.in -+++ /dev/null -@@ -1,15 +0,0 @@ --set(PACKAGE_VERSION_MAJOR @PCRE2_MAJOR@) --set(PACKAGE_VERSION_MINOR @PCRE2_MINOR@) --set(PACKAGE_VERSION_PATCH 0) --set(PACKAGE_VERSION @PCRE2_MAJOR@.@PCRE2_MINOR@.0) -- --# Check whether the requested PACKAGE_FIND_VERSION is compatible --if(PACKAGE_VERSION VERSION_LESS PACKAGE_FIND_VERSION OR -- PACKAGE_VERSION_MAJOR GREATER PACKAGE_FIND_VERSION_MAJOR) -- set(PACKAGE_VERSION_COMPATIBLE FALSE) --else() -- set(PACKAGE_VERSION_COMPATIBLE TRUE) -- if(PACKAGE_VERSION VERSION_EQUAL PACKAGE_FIND_VERSION) -- set(PACKAGE_VERSION_EXACT TRUE) -- endif() --endif() -diff --git a/cmake/pcre2-config.cmake.in b/cmake/pcre2-config.cmake.in -index b313d6d..159669b 100644 ---- a/cmake/pcre2-config.cmake.in -+++ b/cmake/pcre2-config.cmake.in -@@ -5,11 +5,17 @@ - # - # Static vs. shared - # ----------------- --# To make use of the static library instead of the shared one, one needs -+# To force using the static library instead of the shared one, one needs - # to set the variable PCRE2_USE_STATIC_LIBS to ON before calling find_package. -+# If the variable is not set, the static library will be used if only that has -+# been built, otherwise the shared library will be used. -+# -+# The following components are supported: 8BIT, 16BIT, 32BIT and POSIX. -+# They used to be required but not anymore; all available targets will -+# be defined regardless of the requested components. - # Example: - # set(PCRE2_USE_STATIC_LIBS ON) --# find_package(PCRE2 CONFIG COMPONENTS 8BIT) -+# find_package(PCRE2 CONFIG) - # - # This will define the following variables: - # -@@ -23,70 +29,42 @@ - # PCRE2::32BIT - The 32 bit PCRE2 library. - # PCRE2::POSIX - The POSIX PCRE2 library. - --set(PCRE2_NON_STANDARD_LIB_PREFIX @NON_STANDARD_LIB_PREFIX@) --set(PCRE2_NON_STANDARD_LIB_SUFFIX @NON_STANDARD_LIB_SUFFIX@) --set(PCRE2_8BIT_NAME pcre2-8) --set(PCRE2_16BIT_NAME pcre2-16) --set(PCRE2_32BIT_NAME pcre2-32) --set(PCRE2_POSIX_NAME pcre2-posix) --find_path(PCRE2_INCLUDE_DIR NAMES pcre2.h DOC "PCRE2 include directory") --if (PCRE2_USE_STATIC_LIBS) -- if (MSVC) -- set(PCRE2_8BIT_NAME pcre2-8-static) -- set(PCRE2_16BIT_NAME pcre2-16-static) -- set(PCRE2_32BIT_NAME pcre2-32-static) -- set(PCRE2_POSIX_NAME pcre2-posix-static) -- endif () -+@PACKAGE_INIT@ - -- set(PCRE2_PREFIX ${CMAKE_STATIC_LIBRARY_PREFIX}) -- set(PCRE2_SUFFIX ${CMAKE_STATIC_LIBRARY_SUFFIX}) --else () -- set(PCRE2_PREFIX ${CMAKE_SHARED_LIBRARY_PREFIX}) -- if (MINGW AND PCRE2_NON_STANDARD_LIB_PREFIX) -- set(PCRE2_PREFIX "") -- endif () -+include(CMakeFindDependencyMacro) -+if("@REQUIRE_PTHREAD@") # REQUIRE_PTHREAD -+ find_dependency(Threads) -+endif() - -- set(PCRE2_SUFFIX ${CMAKE_SHARED_LIBRARY_SUFFIX}) -- if (MINGW AND PCRE2_NON_STANDARD_LIB_SUFFIX) -- set(PCRE2_SUFFIX "-0.dll") -- endif () --endif () --find_library(PCRE2_8BIT_LIBRARY NAMES ${PCRE2_PREFIX}${PCRE2_8BIT_NAME}${PCRE2_SUFFIX} ${PCRE2_PREFIX}${PCRE2_8BIT_NAME}d${PCRE2_SUFFIX} DOC "8 bit PCRE2 library") --find_library(PCRE2_16BIT_LIBRARY NAMES ${PCRE2_PREFIX}${PCRE2_16BIT_NAME}${PCRE2_SUFFIX} ${PCRE2_PREFIX}${PCRE2_8BIT_NAME}d${PCRE2_SUFFIX} DOC "16 bit PCRE2 library") --find_library(PCRE2_32BIT_LIBRARY NAMES ${PCRE2_PREFIX}${PCRE2_32BIT_NAME}${PCRE2_SUFFIX} ${PCRE2_PREFIX}${PCRE2_8BIT_NAME}d${PCRE2_SUFFIX} DOC "32 bit PCRE2 library") --find_library(PCRE2_POSIX_LIBRARY NAMES ${PCRE2_PREFIX}${PCRE2_POSIX_NAME}${PCRE2_SUFFIX} ${PCRE2_PREFIX}${PCRE2_8BIT_NAME}d${PCRE2_SUFFIX} DOC "8 bit POSIX PCRE2 library") --unset(PCRE2_NON_STANDARD_LIB_PREFIX) --unset(PCRE2_NON_STANDARD_LIB_SUFFIX) --unset(PCRE2_8BIT_NAME) --unset(PCRE2_16BIT_NAME) --unset(PCRE2_32BIT_NAME) --unset(PCRE2_POSIX_NAME) -+include("${CMAKE_CURRENT_LIST_DIR}/pcre2-targets.cmake") - - # Set version --if (PCRE2_INCLUDE_DIR) -- set(PCRE2_VERSION "@PCRE2_MAJOR@.@PCRE2_MINOR@.0") --endif () -+set(PCRE2_VERSION "@PCRE2_MAJOR@.@PCRE2_MINOR@.0") - --# Which components have been found. --if (PCRE2_8BIT_LIBRARY) -- set(PCRE2_8BIT_FOUND TRUE) --endif () --if (PCRE2_16BIT_LIBRARY) -- set(PCRE2_16BIT_FOUND TRUE) --endif () --if (PCRE2_32BIT_LIBRARY) -- set(PCRE2_32BIT_FOUND TRUE) --endif () --if (PCRE2_POSIX_LIBRARY) -- set(PCRE2_POSIX_FOUND TRUE) --endif () -- --# Check if at least one component has been specified. --list(LENGTH PCRE2_FIND_COMPONENTS PCRE2_NCOMPONENTS) --if (PCRE2_NCOMPONENTS LESS 1) -- message(FATAL_ERROR "No components have been specified. This is not allowed. Please, specify at least one component.") --endif () --unset(PCRE2_NCOMPONENTS) -+# Chooses the linkage of the library to expose in the -+# unsuffixed edition of the target. -+macro(_pcre2_add_component_target component target) -+ # If the static library exists and either PCRE2_USE_STATIC_LIBS -+ # is defined, or the dynamic library does not exist, use the static library. -+ if(NOT TARGET PCRE2::${component}) -+ if(TARGET pcre2::pcre2-${target}-static AND (PCRE2_USE_STATIC_LIBS OR NOT TARGET pcre2::pcre2-${target}-shared)) -+ add_library(PCRE2::${component} ALIAS pcre2::pcre2-${target}-static) -+ set(PCRE2_${component}_FOUND TRUE) -+ # Otherwise use the dynamic library if it exists. -+ elseif(TARGET pcre2::pcre2-${target}-shared AND NOT PCRE2_USE_STATIC_LIBS) -+ add_library(PCRE2::${component} ALIAS pcre2::pcre2-${target}-shared) -+ set(PCRE2_${component}_FOUND TRUE) -+ endif() -+ if(PCRE2_${component}_FOUND) -+ get_target_property(PCRE2_${component}_LIBRARY PCRE2::${component} IMPORTED_LOCATION) -+ set(PCRE2_LIBRARIES ${PCRE2_LIBRARIES} ${PCRE2_${component}_LIBRARY}) -+ endif() -+ endif() -+endmacro() -+_pcre2_add_component_target(8BIT 8) -+_pcre2_add_component_target(16BIT 16) -+_pcre2_add_component_target(32BIT 32) -+_pcre2_add_component_target(POSIX posix) - - # When POSIX component has been specified make sure that also 8BIT component is specified. - set(PCRE2_8BIT_COMPONENT FALSE) -@@ -105,41 +83,5 @@ endif() - unset(PCRE2_8BIT_COMPONENT) - unset(PCRE2_POSIX_COMPONENT) - --include(FindPackageHandleStandardArgs) --set(${CMAKE_FIND_PACKAGE_NAME}_CONFIG "${CMAKE_CURRENT_LIST_FILE}") --find_package_handle_standard_args(PCRE2 -- FOUND_VAR PCRE2_FOUND -- REQUIRED_VARS PCRE2_INCLUDE_DIR -- HANDLE_COMPONENTS -- VERSION_VAR PCRE2_VERSION -- CONFIG_MODE --) -- --set(PCRE2_LIBRARIES) --if (PCRE2_FOUND) -- foreach(component ${PCRE2_FIND_COMPONENTS}) -- if (PCRE2_USE_STATIC_LIBS) -- add_library(PCRE2::${component} STATIC IMPORTED) -- target_compile_definitions(PCRE2::${component} INTERFACE PCRE2_STATIC) -- else () -- add_library(PCRE2::${component} SHARED IMPORTED) -- endif () -- set_target_properties(PCRE2::${component} PROPERTIES -- IMPORTED_LOCATION "${PCRE2_${component}_LIBRARY}" -- INTERFACE_INCLUDE_DIRECTORIES "${PCRE2_INCLUDE_DIR}" -- ) -- if (component STREQUAL "POSIX") -- set_target_properties(PCRE2::${component} PROPERTIES -- INTERFACE_LINK_LIBRARIES "PCRE2::8BIT" -- LINK_LIBRARIES "PCRE2::8BIT" -- ) -- endif () -- -- set(PCRE2_LIBRARIES ${PCRE2_LIBRARIES} ${PCRE2_${component}_LIBRARY}) -- mark_as_advanced(PCRE2_${component}_LIBRARY) -- endforeach() --endif () -- --mark_as_advanced( -- PCRE2_INCLUDE_DIR --) -+# Check for required components. -+check_required_components("PCRE2") diff --git a/ports/pcre2/no-static-suffix.patch b/ports/pcre2/no-static-suffix.patch deleted file mode 100644 index 7f41bcd566c..00000000000 --- a/ports/pcre2/no-static-suffix.patch +++ /dev/null @@ -1,33 +0,0 @@ -diff --git a/CMakeLists.txt b/CMakeLists.txt -index fa2181e..3bf5317 100644 ---- a/CMakeLists.txt -+++ b/CMakeLists.txt -@@ -711,8 +711,8 @@ IF(PCRE2_BUILD_PCRE2_8) - SET(targets ${targets} pcre2-posix-static) - - IF(MSVC) -- SET_TARGET_PROPERTIES(pcre2-8-static PROPERTIES OUTPUT_NAME pcre2-8-static) -- SET_TARGET_PROPERTIES(pcre2-posix-static PROPERTIES OUTPUT_NAME pcre2-posix-static) -+ SET_TARGET_PROPERTIES(pcre2-8-static PROPERTIES OUTPUT_NAME pcre2-8) -+ SET_TARGET_PROPERTIES(pcre2-posix-static PROPERTIES OUTPUT_NAME pcre2-posix) - ELSE(MSVC) - SET_TARGET_PROPERTIES(pcre2-8-static PROPERTIES OUTPUT_NAME pcre2-8) - SET_TARGET_PROPERTIES(pcre2-posix-static PROPERTIES OUTPUT_NAME pcre2-posix) -@@ -777,7 +777,7 @@ IF(PCRE2_BUILD_PCRE2_16) - SET(targets ${targets} pcre2-16-static) - - IF(MSVC) -- SET_TARGET_PROPERTIES(pcre2-16-static PROPERTIES OUTPUT_NAME pcre2-16-static) -+ SET_TARGET_PROPERTIES(pcre2-16-static PROPERTIES OUTPUT_NAME pcre2-16) - ELSE(MSVC) - SET_TARGET_PROPERTIES(pcre2-16-static PROPERTIES OUTPUT_NAME pcre2-16) - ENDIF(MSVC) -@@ -829,7 +829,7 @@ IF(PCRE2_BUILD_PCRE2_32) - SET(targets ${targets} pcre2-32-static) - - IF(MSVC) -- SET_TARGET_PROPERTIES(pcre2-32-static PROPERTIES OUTPUT_NAME pcre2-32-static) -+ SET_TARGET_PROPERTIES(pcre2-32-static PROPERTIES OUTPUT_NAME pcre2-32) - ELSE(MSVC) - SET_TARGET_PROPERTIES(pcre2-32-static PROPERTIES OUTPUT_NAME pcre2-32) - ENDIF(MSVC) diff --git a/ports/pcre2/pcre2-10.35_fix-uwp.patch b/ports/pcre2/pcre2-10.35_fix-uwp.patch deleted file mode 100644 index 476dde0f6a4..00000000000 --- a/ports/pcre2/pcre2-10.35_fix-uwp.patch +++ /dev/null @@ -1,10 +0,0 @@ ---- a/CMakeLists.txt 2020-05-09 16:43:10.000000000 +0200 -+++ b/CMakeLists.txt 2020-06-03 20:57:17.026182500 +0200 -@@ -619,6 +619,7 @@ - - IF(MSVC) - ADD_DEFINITIONS(-D_CRT_SECURE_NO_DEPRECATE -D_CRT_SECURE_NO_WARNINGS) -+ add_compile_options(/wd4146) - ENDIF(MSVC) - - SET(CMAKE_INCLUDE_CURRENT_DIR 1) diff --git a/ports/pcre2/portfile.cmake b/ports/pcre2/portfile.cmake deleted file mode 100644 index 5d6c5c39b6a..00000000000 --- a/ports/pcre2/portfile.cmake +++ /dev/null @@ -1,73 +0,0 @@ -vcpkg_from_github( - OUT_SOURCE_PATH SOURCE_PATH - REPO PCRE2Project/pcre2 - REF "pcre2-${VERSION}" - SHA512 3d0ee66e23809d3da2fe2bf4ed6e20b0fb96c293a91668935f6319e8d02e480eeef33da01e08a7436a18a1a85a116d83186b953520f394c866aad3cea73c7f5c - HEAD_REF master - PATCHES - pcre2-10.35_fix-uwp.patch - no-static-suffix.patch - fix-cmake.patch -) - -string(COMPARE EQUAL "${VCPKG_LIBRARY_LINKAGE}" "static" BUILD_STATIC) -string(COMPARE EQUAL "${VCPKG_LIBRARY_LINKAGE}" "dynamic" INSTALL_PDB) -string(COMPARE EQUAL "${VCPKG_CRT_LINKAGE}" "static" BUILD_STATIC_CRT) - -vcpkg_check_features( - OUT_FEATURE_OPTIONS FEATURE_OPTIONS - FEATURES - jit PCRE2_SUPPORT_JIT -) - -vcpkg_cmake_configure( - SOURCE_PATH "${SOURCE_PATH}" - OPTIONS - ${FEATURE_OPTIONS} - -DBUILD_STATIC_LIBS=${BUILD_STATIC} - -DPCRE2_STATIC_RUNTIME=${BUILD_STATIC_CRT} - -DPCRE2_BUILD_PCRE2_8=ON - -DPCRE2_BUILD_PCRE2_16=ON - -DPCRE2_BUILD_PCRE2_32=ON - -DPCRE2_SUPPORT_UNICODE=ON - -DPCRE2_BUILD_TESTS=OFF - -DPCRE2_BUILD_PCRE2GREP=OFF - -DCMAKE_DISABLE_FIND_PACKAGE_BZip2=ON - -DCMAKE_DISABLE_FIND_PACKAGE_ZLIB=ON - -DCMAKE_DISABLE_FIND_PACKAGE_Readline=ON - -DCMAKE_DISABLE_FIND_PACKAGE_Editline=ON - -DINSTALL_MSVC_PDB=${INSTALL_PDB} - ) - -vcpkg_cmake_install() -vcpkg_copy_pdbs() - -file(READ "${CURRENT_PACKAGES_DIR}/include/pcre2.h" PCRE2_H) -if(BUILD_STATIC) - string(REPLACE "defined(PCRE2_STATIC)" "1" PCRE2_H "${PCRE2_H}") -else() - string(REPLACE "defined(PCRE2_STATIC)" "0" PCRE2_H "${PCRE2_H}") -endif() -file(WRITE "${CURRENT_PACKAGES_DIR}/include/pcre2.h" "${PCRE2_H}") - -vcpkg_fixup_pkgconfig() -vcpkg_cmake_config_fixup(CONFIG_PATH lib/cmake/${PORT}) - -file(REMOVE_RECURSE - "${CURRENT_PACKAGES_DIR}/man" - "${CURRENT_PACKAGES_DIR}/share/doc" - "${CURRENT_PACKAGES_DIR}/debug/include" - "${CURRENT_PACKAGES_DIR}/debug/man" - "${CURRENT_PACKAGES_DIR}/debug/share") - -if(BUILD_STATIC) - file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/bin" "${CURRENT_PACKAGES_DIR}/debug/bin") -elseif(VCPKG_TARGET_IS_WINDOWS) - vcpkg_replace_string("${CURRENT_PACKAGES_DIR}/bin/pcre2-config" "${CURRENT_PACKAGES_DIR}" "`dirname $0`/..") - if(EXISTS "${CURRENT_PACKAGES_DIR}/debug/bin/pcre2-config") - vcpkg_replace_string("${CURRENT_PACKAGES_DIR}/debug/bin/pcre2-config" "${CURRENT_PACKAGES_DIR}" "`dirname $0`/../..") - endif() -endif() - -file(INSTALL "${CMAKE_CURRENT_LIST_DIR}/usage" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}") -vcpkg_install_copyright(FILE_LIST "${SOURCE_PATH}/COPYING") diff --git a/ports/pcre2/usage b/ports/pcre2/usage deleted file mode 100644 index a8e97871bd5..00000000000 --- a/ports/pcre2/usage +++ /dev/null @@ -1,6 +0,0 @@ -The package pcre2 is compatible with built-in CMake targets: - - # Each component imports a target: - # TARGETS: pcre2::8BIT pcre2::16BIT pcre2::32BIT pcre2::POSIX - find_package(pcre2 CONFIG REQUIRED) - target_link_libraries(main PRIVATE pcre2::8BIT pcre2::POSIX) diff --git a/ports/pcre2/vcpkg.json b/ports/pcre2/vcpkg.json deleted file mode 100644 index 3dd6b9455d5..00000000000 --- a/ports/pcre2/vcpkg.json +++ /dev/null @@ -1,39 +0,0 @@ -{ - "name": "pcre2", - "version": "10.42", - "port-version": 1, - "description": "Regular Expression pattern matching using the same syntax and semantics as Perl 5.", - "homepage": "https://github.com/PCRE2Project/pcre2", - "license": "BSD-3-Clause", - "dependencies": [ - { - "name": "vcpkg-cmake", - "host": true - }, - { - "name": "vcpkg-cmake-config", - "host": true - } - ], - "default-features": [ - "platform-default-features" - ], - "features": { - "jit": { - "description": "Enable support for Just-In-Time compiling regex matchers", - "supports": "!emscripten" - }, - "platform-default-features": { - "description": "Enable default features", - "dependencies": [ - { - "name": "pcre2", - "features": [ - "jit" - ], - "platform": "!emscripten" - } - ] - } - } -} diff --git a/tiledb/CMakeLists.txt b/tiledb/CMakeLists.txt index e245c55109f..2d59b59cd80 100644 --- a/tiledb/CMakeLists.txt +++ b/tiledb/CMakeLists.txt @@ -431,6 +431,8 @@ target_link_libraries(TILEDB_CORE_OBJECTS INTERFACE object_store_definitions) ############################################################ # provide actions/target for preparation of magic.mgc data for embedding/build +find_package(Magic_EP REQUIRED) + set(MGC_GZIPPED_BIN_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/..") set(MGC_GZIPPED_BIN_OUTPUT_FILE "${MGC_GZIPPED_BIN_OUTPUT_DIRECTORY}/magic_mgc_gzipped.bin") set(MGC_GZIPPED_BIN_INPUT_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/sm/misc") @@ -449,7 +451,7 @@ add_dependencies(TILEDB_CORE_OBJECTS gen_mgc_unarch) add_custom_target( update-embedded-magic-data - COMMAND "$" < "${libmagic_DICTIONARY}" "${MGC_GZIPPED_BIN_OUTPUT_FILE}" + COMMAND tdb_gzip_embedded_data ${libmagic_DICTIONARY} ${MGC_GZIPPED_BIN_OUTPUT_FILE} # need to work in 'local' directory with no prefix paths so no paths are included in archive WORKING_DIRECTORY "${MGC_GZIPPED_BIN_OUTPUT_DIRECTORY}" COMMAND ${CMAKE_COMMAND} -E tar cvj "magic_mgc_gzipped.bin.tar.bz2" "magic_mgc_gzipped.bin" @@ -618,7 +620,6 @@ find_package(LZ4_EP REQUIRED) find_package(Spdlog_EP REQUIRED) find_package(Zlib_EP REQUIRED) find_package(Zstd_EP REQUIRED) -find_package(Magic_EP REQUIRED) target_link_libraries(TILEDB_CORE_OBJECTS_ILIB INTERFACE BZip2::BZip2 diff --git a/tiledb/sm/compressors/util/tdb_gzip_embedded_data.cc b/tiledb/sm/compressors/util/tdb_gzip_embedded_data.cc index 6c15ad3d66a..23ac215c97a 100644 --- a/tiledb/sm/compressors/util/tdb_gzip_embedded_data.cc +++ b/tiledb/sm/compressors/util/tdb_gzip_embedded_data.cc @@ -75,14 +75,25 @@ int main(int argc, char* argv[]) { // output stream. if (argc > 1) { - outfile = fopen(argv[1], "w+b"); - if (!outfile) { + if (argc != 3) { + printf("Usage: tdb_gzip_embedded_data \n"); + printf( + "If neither nor are specified, they will be stdin " + "and stdout respectively.\n"); + } + infile = fopen(argv[1], "rb"); + if (!infile) { fprintf(stderr, "Unable to create file %s\n", argv[1]); exit(-2); } + outfile = fopen(argv[2], "wb"); + if (!outfile) { + fprintf(stderr, "Unable to create file %s\n", argv[2]); + exit(-2); + } } - auto closefile = [&]() { fclose(outfile); }; - tiledb::common::ScopedExecutor onexit1(closefile); + tiledb::common::ScopedExecutor onexit1([&]() { fclose(infile); }); + tiledb::common::ScopedExecutor onexit2([&]() { fclose(outfile); }); #ifdef _WIN32 // need to be sure in/out are in binay mode, windows default won't be!!! diff --git a/tiledb/sm/misc/magic_mgc_gzipped.bin.tar.bz2 b/tiledb/sm/misc/magic_mgc_gzipped.bin.tar.bz2 index d23e06bc82a..9c821f153b8 100644 Binary files a/tiledb/sm/misc/magic_mgc_gzipped.bin.tar.bz2 and b/tiledb/sm/misc/magic_mgc_gzipped.bin.tar.bz2 differ diff --git a/vcpkg.json b/vcpkg.json index c8b9831f013..eccafa372ca 100644 --- a/vcpkg.json +++ b/vcpkg.json @@ -80,12 +80,5 @@ "libwebp" ] } - }, - "overrides": [ - { - "$note": "Remove this when the custom port for libmagic gets removed", - "name": "dirent", - "version": "1.23.2#3" - } - ] + } }