bsdunzip_CPPFLAGS= -I$(top_srcdir)/libarchive -I$(top_srcdir)/libarchive_fe $(bsdunzip_ccstatic) $(PLATFORMCPPFLAGS)
bsdunzip_LDFLAGS= $(bsdunzip_ldstatic) $(DEAD_CODE_REMOVAL)
+if INC_WINDOWS_FILES
+# Embed an application manifest marking bsdunzip as long-path aware.
+unzip/bsdunzip_rc.$(OBJEXT): $(top_srcdir)/unzip/bsdunzip.rc $(top_srcdir)/unzip/bsdunzip.exe.manifest
+ $(AM_V_GEN)$(WINDRES) -I $(top_srcdir)/unzip -i $(top_srcdir)/unzip/bsdunzip.rc -o $@
+bsdunzip_LDADD += unzip/bsdunzip_rc.$(OBJEXT)
+bsdunzip_DEPENDENCIES += unzip/bsdunzip_rc.$(OBJEXT)
+CLEANFILES += unzip/bsdunzip_rc.$(OBJEXT)
+endif
+
bsdunzip_EXTRA_DIST= \
unzip/bsdunzip_windows.h \
unzip/bsdunzip_windows.c \
+ unzip/bsdunzip.rc \
+ unzip/bsdunzip.exe.manifest \
unzip/bsdunzip.1 \
unzip/CMakeLists.txt
IF(WIN32 AND NOT CYGWIN)
LIST(APPEND bsdunzip_SOURCES bsdunzip_windows.c)
LIST(APPEND bsdunzip_SOURCES bsdunzip_windows.h)
+ IF(NOT MSVC)
+ # The GNU toolchains (MinGW/Clang) do not generate an application
+ # manifest, so we embed one through a resource script.
+ ENABLE_LANGUAGE(RC)
+ INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR})
+ LIST(APPEND bsdunzip_SOURCES bsdunzip.rc)
+ SET_SOURCE_FILES_PROPERTIES(bsdunzip.rc PROPERTIES
+ OBJECT_DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/bsdunzip.exe.manifest)
+ ENDIF(NOT MSVC)
ENDIF(WIN32 AND NOT CYGWIN)
# bsdunzip documentation
SET_TARGET_PROPERTIES(bsdunzip PROPERTIES COMPILE_DEFINITIONS
LIBARCHIVE_STATIC)
ENDIF(ENABLE_UNZIP_SHARED)
+ IF(WIN32 AND NOT CYGWIN AND MSVC)
+ # MSVC merges .manifest sources into the linker's default manifest
+ TARGET_SOURCES(bsdunzip PRIVATE bsdunzip.exe.manifest)
+ ENDIF(WIN32 AND NOT CYGWIN AND MSVC)
# Installation rules
IF(ENABLE_INSTALL)
--- /dev/null
+<?xml version="1.0" encoding="utf-8"?>
+<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
+ <trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
+ <security>
+ <requestedPrivileges>
+ <requestedExecutionLevel level="asInvoker" uiAccess="false"/>
+ </requestedPrivileges>
+ </security>
+ </trustInfo>
+ <application xmlns="urn:schemas-microsoft-com:asm.v3">
+ <windowsSettings xmlns:ws2="http://schemas.microsoft.com/SMI/2016/WindowsSettings">
+ <ws2:longPathAware>true</ws2:longPathAware>
+ </windowsSettings>
+ </application>
+</assembly>
--- /dev/null
+/*
+ * SPDX-License-Identifier: BSD-2-Clause
+ *
+ * Embed an application manifest that marks bsdunzip as long-path aware.
+ *
+ * bsdunzip's file name handling is limited to MAX_PATH (260) characters unless
+ * the process opts in to long paths via a "longPathAware" manifest.
+ * A system-wide LongPathsEnabled registry value is not sufficient on its own;
+ * the executable must also carry this manifest. Without it, extracting into
+ * deeply nested destination directories fails.
+ *
+ * See:
+ * https://learn.microsoft.com/windows/win32/fileio/maximum-file-path-limitation
+ */
+
+#define RT_MANIFEST 24
+#define CREATEPROCESS_MANIFEST_RESOURCE_ID 1
+
+CREATEPROCESS_MANIFEST_RESOURCE_ID RT_MANIFEST "bsdunzip.exe.manifest"