From: Martin Matuska Date: Fri, 14 Jul 2023 15:37:19 +0000 (+0200) Subject: unzip: disable build on Windows X-Git-Tag: v3.7.0~10 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=386412e24e2646015119c2a790005bc7dafade49;p=thirdparty%2Flibarchive.git unzip: disable build on Windows Bsdunzip has not been ported to Windows yet. Add header checks for fcntl.h and sys/queue.h Add function check for fcntl() --- diff --git a/CMakeLists.txt b/CMakeLists.txt index d2315adbb..646484b79 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -225,8 +225,13 @@ OPTION(ENABLE_CPIO "Enable cpio building" ON) OPTION(ENABLE_CPIO_SHARED "Enable dynamic build of cpio" FALSE) OPTION(ENABLE_CAT "Enable cat building" ON) OPTION(ENABLE_CAT_SHARED "Enable dynamic build of cat" FALSE) -OPTION(ENABLE_UNZIP "Enable unzip building" ON) -OPTION(ENABLE_UNZIP_SHARED "Enable dynamic build of unzip" FALSE) +IF(WIN32 AND NOT CYGWIN) + SET(ENABLE_UNZIP FALSE) + SET(ENABLE_UNZIP_SHARED FALSE) +ELSE() + OPTION(ENABLE_UNZIP "Enable unzip building" ON) + OPTION(ENABLE_UNZIP_SHARED "Enable dynamic build of unzip" FALSE) +ENDIF() OPTION(ENABLE_XATTR "Enable extended attribute support" ON) OPTION(ENABLE_ACL "Enable ACL support" ON) OPTION(ENABLE_ICONV "Enable iconv support" ON) @@ -689,6 +694,7 @@ CHECK_C_SOURCE_COMPILES("#include int main(void) { return EXT2_IOC_GETFLAGS; }" HAVE_WORKING_EXT2_IOC_GETFLAGS) LA_CHECK_INCLUDE_FILE("fcntl.h" HAVE_FCNTL_H) +LA_CHECK_INCLUDE_FILE("fnmatch.h" HAVE_FNMATCH_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) @@ -728,6 +734,7 @@ LA_CHECK_INCLUDE_FILE("sys/mkdev.h" HAVE_SYS_MKDEV_H) LA_CHECK_INCLUDE_FILE("sys/mount.h" HAVE_SYS_MOUNT_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/queue.h" HAVE_SYS_QUEUE_H) LA_CHECK_INCLUDE_FILE("sys/richacl.h" HAVE_SYS_RICHACL_H) LA_CHECK_INCLUDE_FILE("sys/select.h" HAVE_SYS_SELECT_H) LA_CHECK_INCLUDE_FILE("sys/stat.h" HAVE_SYS_STAT_H) @@ -1366,6 +1373,7 @@ 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(fdopendir HAVE_FDOPENDIR) +CHECK_FUNCTION_EXISTS_GLIBC(fnmatch HAVE_FNMATCH) CHECK_FUNCTION_EXISTS_GLIBC(fork HAVE_FORK) CHECK_FUNCTION_EXISTS_GLIBC(fstat HAVE_FSTAT) CHECK_FUNCTION_EXISTS_GLIBC(fstatat HAVE_FSTATAT) diff --git a/build/cmake/config.h.in b/build/cmake/config.h.in index 204660971..3de2ebd8c 100644 --- a/build/cmake/config.h.in +++ b/build/cmake/config.h.in @@ -588,6 +588,12 @@ typedef uint64_t uintmax_t; /* Define to 1 if you have the `flistxattr' function. */ #cmakedefine HAVE_FLISTXATTR 1 +/* Define to 1 if you have the `fnmatch' function. */ +#cmakedefine HAVE_FNMATCH 1 + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_FNMATCH_H 1 + /* Define to 1 if you have the `fork' function. */ #cmakedefine HAVE_FORK 1 @@ -1106,6 +1112,9 @@ typedef uint64_t uintmax_t; /* Define to 1 if you have the header file. */ #cmakedefine HAVE_SYS_POLL_H 1 +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_SYS_QUEUE_H 1 + /* Define to 1 if you have the header file. */ #cmakedefine HAVE_SYS_RICHACL_H 1 diff --git a/configure.ac b/configure.ac index 7d50c0295..a2a0a5c25 100644 --- a/configure.ac +++ b/configure.ac @@ -271,13 +271,21 @@ esac # Options for building bsdunzip. # # Default is to build bsdunzip, but allow people to override that. +# Bsdunzip has not yet been ported for Windows # -AC_ARG_ENABLE([bsdunzip], - [AS_HELP_STRING([--enable-bsdunzip], [enable build of bsdunzip (default)]) - AS_HELP_STRING([--enable-bsdunzip=static], [force static build of bsdunzip]) - AS_HELP_STRING([--enable-bsdunzip=shared], [force dynamic build of bsdunzip]) -AS_HELP_STRING([--disable-bsdunzip], [disable build of bsdunzip])], - [], [enable_bsdunzip=yes]) +case "$host_os" in + *mingw* | *msys*) + enable_bsdunzip=no + ;; + *) + AC_ARG_ENABLE([bsdunzip], + [AS_HELP_STRING([--enable-bsdunzip], [enable build of bsdunzip (default)]) + AS_HELP_STRING([--enable-bsdunzip=static], [force static build of bsdunzip]) + AS_HELP_STRING([--enable-bsdunzip=shared], [force dynamic build of bsdunzip]) + AS_HELP_STRING([--disable-bsdunzip], [disable build of bsdunzip])], + [], [enable_bsdunzip=yes]) + ;; +esac case "$enable_bsdunzip" in yes) @@ -316,7 +324,7 @@ AC_HEADER_DIRENT AC_HEADER_SYS_WAIT AC_CHECK_HEADERS([acl/libacl.h attr/xattr.h]) AC_CHECK_HEADERS([copyfile.h ctype.h]) -AC_CHECK_HEADERS([errno.h ext2fs/ext2_fs.h fcntl.h grp.h]) +AC_CHECK_HEADERS([errno.h ext2fs/ext2_fs.h fcntl.h fnmatch.h grp.h]) AC_CACHE_CHECK([whether EXT2_IOC_GETFLAGS is usable], [ac_cv_have_decl_EXT2_IOC_GETFLAGS], @@ -349,7 +357,7 @@ AC_CHECK_HEADERS([locale.h membership.h paths.h poll.h pthread.h pwd.h]) AC_CHECK_HEADERS([readpassphrase.h signal.h spawn.h]) AC_CHECK_HEADERS([stdarg.h stdint.h stdlib.h string.h]) AC_CHECK_HEADERS([sys/acl.h sys/cdefs.h sys/ea.h sys/extattr.h]) -AC_CHECK_HEADERS([sys/ioctl.h sys/mkdev.h sys/mount.h]) +AC_CHECK_HEADERS([sys/ioctl.h sys/mkdev.h sys/mount.h sys/queue.h]) AC_CHECK_HEADERS([sys/param.h sys/poll.h sys/richacl.h]) AC_CHECK_HEADERS([sys/select.h sys/statfs.h sys/statvfs.h sys/sysmacros.h]) AC_CHECK_HEADERS([sys/time.h sys/utime.h sys/utsname.h sys/vfs.h sys/xattr.h]) @@ -718,7 +726,7 @@ AC_FUNC_VPRINTF # workarounds, we use 'void *' for 'struct SECURITY_ATTRIBUTES *' AC_CHECK_STDCALL_FUNC([CreateHardLinkA],[const char *, const char *, void *]) AC_CHECK_FUNCS([arc4random_buf chflags chown chroot ctime_r]) -AC_CHECK_FUNCS([fchdir fchflags fchmod fchown fcntl fdopendir fork]) +AC_CHECK_FUNCS([fchdir fchflags fchmod fchown fcntl fdopendir fnmatch fork]) AC_CHECK_FUNCS([fstat fstatat fstatfs fstatvfs ftruncate]) AC_CHECK_FUNCS([futimens futimes futimesat]) AC_CHECK_FUNCS([geteuid getpid getgrgid_r getgrnam_r]) diff --git a/unzip/bsdunzip.c b/unzip/bsdunzip.c index 3280963bf..469c69fd6 100644 --- a/unzip/bsdunzip.c +++ b/unzip/bsdunzip.c @@ -38,7 +38,9 @@ #include "bsdunzip_platform.h" +#ifdef HAVE_SYS_QUEUE_H #include +#endif #ifdef HAVE_SYS_STAT_H #include #endif @@ -52,7 +54,9 @@ #ifdef HAVE_FCNTL_H #include #endif +#ifdef HAVE_FNMATCH_H #include +#endif #ifdef HAVE_STDARG_H #include #endif @@ -313,8 +317,12 @@ match_pattern(struct pattern_list *list, const char *str) struct pattern *entry; STAILQ_FOREACH(entry, list, link) { +#ifdef HAVE_FNMATCH if (fnmatch(entry->pattern, str, C_opt ? FNM_CASEFOLD : 0) == 0) return (1); +#else +#error "Unsupported platform: fnmatch() is required" +#endif } return (0); }