git: b6bf306d87ea - main - archivers/7-zip: Update to 21.07

From: Max Brazhnikov <makc_at_FreeBSD.org>
Date: Tue, 28 Dec 2021 14:44:51 UTC
The branch main has been updated by makc:

URL: https://cgit.FreeBSD.org/ports/commit/?id=b6bf306d87ea3b01bbdeb47688b2456fdca04ad7

commit b6bf306d87ea3b01bbdeb47688b2456fdca04ad7
Author:     Max Brazhnikov <makc@FreeBSD.org>
AuthorDate: 2021-12-28 14:32:52 +0000
Commit:     Max Brazhnikov <makc@FreeBSD.org>
CommitDate: 2021-12-28 14:32:57 +0000

    archivers/7-zip: Update to 21.07
    
    Merge patches to fix build on arm64 [1].
    
    PR:             260329 [1]
    Reported by:    diizzy@
    Submitted by:   mikael@
---
 archivers/7-zip/Makefile                           |  6 ++--
 archivers/7-zip/distinfo                           |  6 ++--
 .../7-zip/files/patch-CPP_Windows_SystemInfo.cpp   | 11 ++++++-
 archivers/7-zip/files/patch-C_CpuArch.c            | 34 ++++++++++++++++++++++
 4 files changed, 50 insertions(+), 7 deletions(-)

diff --git a/archivers/7-zip/Makefile b/archivers/7-zip/Makefile
index d40fb1080e21..8a7f59629053 100644
--- a/archivers/7-zip/Makefile
+++ b/archivers/7-zip/Makefile
@@ -1,6 +1,5 @@
 PORTNAME=	7-zip
-DISTVERSION=	21.06
-PORTREVISION=	1
+DISTVERSION=	21.07
 CATEGORIES=	archivers
 MASTER_SITES=	https://www.7-zip.org/a/
 DISTNAME=	7z${DISTVERSION:S/.//}-src
@@ -28,7 +27,8 @@ MAKE_ARGS=	LOCAL_FLAGS="${CFLAGS}" \
 
 NO_WRKSUBDIR=	yes
 BUILD_WRKSRC=	${WRKSRC}/CPP/7zip/Bundles/Alone2
-DOS2UNIX_FILES=	CPP/7zip/7zip_gcc.mak \
+DOS2UNIX_FILES=	C/CpuArch.c \
+		CPP/7zip/7zip_gcc.mak \
 		CPP/7zip/var_gcc.mak \
 		CPP/Windows/SystemInfo.cpp
 
diff --git a/archivers/7-zip/distinfo b/archivers/7-zip/distinfo
index 3e4e5ddbc137..2b0234a96661 100644
--- a/archivers/7-zip/distinfo
+++ b/archivers/7-zip/distinfo
@@ -1,3 +1,3 @@
-TIMESTAMP = 1639126647
-SHA256 (7z2106-src.7z) = 675eaa90de3c6a3cd69f567bba4faaea309199ca75a6ad12bac731dcdae717ac
-SIZE (7z2106-src.7z) = 1215031
+TIMESTAMP = 1640701508
+SHA256 (7z2107-src.7z) = d1074d56f415aab99d99e597a7b66dc455dba6349ae8a4c89df76475b6a1284c
+SIZE (7z2107-src.7z) = 1219373
diff --git a/archivers/7-zip/files/patch-CPP_Windows_SystemInfo.cpp b/archivers/7-zip/files/patch-CPP_Windows_SystemInfo.cpp
index bc362d111086..1f99e0c5da91 100644
--- a/archivers/7-zip/files/patch-CPP_Windows_SystemInfo.cpp
+++ b/archivers/7-zip/files/patch-CPP_Windows_SystemInfo.cpp
@@ -1,4 +1,4 @@
---- CPP/Windows/SystemInfo.cpp.orig	2021-12-10 11:30:40 UTC
+--- CPP/Windows/SystemInfo.cpp.orig	2021-12-28 14:08:56 UTC
 +++ CPP/Windows/SystemInfo.cpp
 @@ -20,6 +20,15 @@
  
@@ -16,3 +16,12 @@
  // #undef AT_HWCAP    // to debug
  // #undef AT_HWCAP2   // to debug
  
+@@ -36,7 +45,7 @@
+ #endif
+ */
+ 
+-#ifdef MY_CPU_ARM_OR_ARM64
++#if defined(MY_CPU_ARM_OR_ARM64) && !defined(__FreeBSD__)
+ #include <asm/hwcap.h>
+ #endif
+ #endif
diff --git a/archivers/7-zip/files/patch-C_CpuArch.c b/archivers/7-zip/files/patch-C_CpuArch.c
new file mode 100644
index 000000000000..579b684d4337
--- /dev/null
+++ b/archivers/7-zip/files/patch-C_CpuArch.c
@@ -0,0 +1,34 @@
+--- C/CpuArch.c.orig	2021-12-12 14:45:15 UTC
++++ C/CpuArch.c
+@@ -417,6 +417,23 @@ BoolInt CPU_IsSupported_AES (void) { return APPLE_CRYP
+ 
+ #include <sys/auxv.h>
+ 
++#if defined(__FreeBSD__)
++static UInt64 get_hwcap() {
++  unsigned long hwcap;
++  if(elf_aux_info(AT_HWCAP, &hwcap, sizeof(unsigned long)) != 0) {
++        return(0);
++  }
++  return hwcap;
++}
++
++BoolInt CPU_IsSupported_CRC32(void) { return get_hwcap() & HWCAP_CRC32; }
++BoolInt CPU_IsSupported_NEON(void) { return 1; }
++BoolInt CPU_IsSupported_SHA1(void){ return get_hwcap() & HWCAP_SHA1; }
++BoolInt CPU_IsSupported_SHA2(void) { return get_hwcap() & HWCAP_SHA2; }
++BoolInt CPU_IsSupported_AES(void) { return get_hwcap() & HWCAP_AES; }
++
++#else // __FreeBSD__
++
+ #define USE_HWCAP
+ 
+ #ifdef USE_HWCAP
+@@ -450,6 +467,7 @@ MY_HWCAP_CHECK_FUNC (SHA1)
+ MY_HWCAP_CHECK_FUNC (SHA2)
+ MY_HWCAP_CHECK_FUNC (AES)
+ 
++#endif // FreeBSD
+ #endif // __APPLE__
+ #endif // _WIN32
+