git: 3ab0c8c9a420 - 2022Q2 - print/ghostscript9-agpl-base: Fix build on armv7

From: Mikael Urankar <mikael_at_FreeBSD.org>
Date: Sun, 03 Apr 2022 15:24:27 UTC
The branch 2022Q2 has been updated by mikael:

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

commit 3ab0c8c9a420bc144618ec4e3d97c611f36cacd9
Author:     Robert Clausecker <fuz@fuz.su>
AuthorDate: 2022-04-02 12:51:22 +0000
Commit:     Mikael Urankar <mikael@FreeBSD.org>
CommitDate: 2022-04-03 15:24:13 +0000

    print/ghostscript9-agpl-base: Fix build on armv7
    
    The bundled version of tesseract requires the <asm/hwcap.h> header
    to detect the availability of NEON instructions on armv7.  This
    issue has already been reported to up stream.
    
    Reported upstream:      https://github.com/tesseract-ocr/tesseract/pull/3782
    
    PR:             263003
    Approved by:    portmgr (build fix blanket)
    
    (cherry picked from commit 16f0acba590a9b850c9a23759ed37427507910bd)
---
 .../files/patch-tesseract_src_arch_simddetect.cpp  | 34 ++++++++++++++++++++++
 1 file changed, 34 insertions(+)

diff --git a/print/ghostscript9-agpl-base/files/patch-tesseract_src_arch_simddetect.cpp b/print/ghostscript9-agpl-base/files/patch-tesseract_src_arch_simddetect.cpp
new file mode 100644
index 000000000000..85afcf5d10f9
--- /dev/null
+++ b/print/ghostscript9-agpl-base/files/patch-tesseract_src_arch_simddetect.cpp
@@ -0,0 +1,34 @@
+--- tesseract/src/arch/simddetect.cpp.orig	2021-09-27 07:44:02 UTC
++++ tesseract/src/arch/simddetect.cpp
+@@ -40,10 +40,13 @@
+ #if defined(HAVE_NEON) && !defined(__aarch64__)
+ #ifdef ANDROID
+ #include <cpu-features.h>
+-#else
++#elif defined(__linux__)
+ /* Assume linux */
+ #include <sys/auxv.h>
+ #include <asm/hwcap.h>
++#elif defined(__FreeBSD__)
++#include <sys/auxv.h>
++#include <sys/elf.h>
+ #endif
+ #endif
+ 
+@@ -188,9 +191,15 @@ SIMDDetect::SIMDDetect() {
+       neon_available_ = (android_getCpuFeatures() &
+                          ANDROID_CPU_ARM_FEATURE_NEON);
+   }
+-#else
++#elif defined(__linux__)
+   /* Assume linux */
+   neon_available_ = getauxval(AT_HWCAP) & HWCAP_NEON;
++#elif defined(__FreeBSD__)
++  unsigned long hwcap = 0;
++  elf_aux_info(AT_HWCAP, &hwcap, sizeof hwcap);
++  neon_available_ = hwcap & HWCAP_NEON;
++#else
++  neon_available_ = 0;
+ #endif
+ #endif
+