git: f365fd9b0f0a - main - multimedia/libtheora: fix build on armv7

From: Robert Clausecker <fuz_at_FreeBSD.org>
Date: Sun, 11 Jan 2026 15:28:19 UTC
The branch main has been updated by fuz:

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

commit f365fd9b0f0a6fdff4efd8c8452d210cfaea56e3
Author:     Robert Clausecker <fuz@FreeBSD.org>
AuthorDate: 2026-01-07 15:40:34 +0000
Commit:     Robert Clausecker <fuz@FreeBSD.org>
CommitDate: 2026-01-11 15:27:47 +0000

    multimedia/libtheora: fix build on armv7
    
     - switch to gmake, which is needed for arm-specific pattern rules
     - depend on Perl, which is needed to run an assembly-mangling script
     - depend on GNU as, which is needed for pre-UAL style ARM menmonics
     - switch to gitlab tarball as the official tarball is missing some
       important files
     - turn static REINPLACE_CMD into patch files were possible
     - make sure "make check" actually runs test suite
     - add the usual elf_aux_info() polyfill
     - enable X86 assembly code (builds fine, passes test suite)
    
    MFH:            2025Q4
    Approved by:    mmel (multimedia)
    Reported by:    mmel
---
 multimedia/libtheora/Makefile                     | 31 +++++++++++++----------
 multimedia/libtheora/distinfo                     |  6 ++---
 multimedia/libtheora/files/patch-Makefile.am      | 11 ++++++++
 multimedia/libtheora/files/patch-Makefile.in      | 11 --------
 multimedia/libtheora/files/patch-configure.ac     | 11 ++++++++
 multimedia/libtheora/files/patch-lib_arm_armcpu.c | 24 ++++++++++++++++++
 6 files changed, 67 insertions(+), 27 deletions(-)

diff --git a/multimedia/libtheora/Makefile b/multimedia/libtheora/Makefile
index d581695c0bec..1101ce297051 100644
--- a/multimedia/libtheora/Makefile
+++ b/multimedia/libtheora/Makefile
@@ -1,8 +1,8 @@
 PORTNAME=	libtheora
-PORTVERSION=	1.2.0
+DISTVERSIONPREFIX=	v
+DISTVERSION=	1.2.0
+PORTREVISION=	1
 CATEGORIES=	multimedia
-MASTER_SITES=	https://downloads.xiph.org/releases/theora/ \
-		https://ftp.osuosl.org/pub/xiph/releases/theora/
 
 MAINTAINER=	multimedia@FreeBSD.org
 COMMENT=	Theora video codec for the Ogg multimedia streaming system
@@ -11,24 +11,29 @@ WWW=		https://www.theora.org/
 LICENSE=	BSD3CLAUSE
 LICENSE_FILE=	${WRKSRC}/COPYING
 
+BUILD_DEPENDS_armv7=	as:devel/binutils
+BUILD_DEPENDS=	${BUILD_DEPENDS_${ARCH}}
+
 LIB_DEPENDS=	libogg.so:audio/libogg
 
-USES=		libtool localbase pathfix tar:xz
+USES_armv7=	perl5 shebangfix
+USES=		autoreconf gmake libtool localbase pathfix ${USES_${ARCH}}
+USE_GITLAB=	yes
+GL_SITE=	https://gitlab.xiph.org
+GL_ACCOUNT=	xiph
+GL_PROJECT=	theora
+
 GNU_CONFIGURE=	yes
 CONFIGURE_ARGS=	--disable-sdltest \
 		--disable-examples
 INSTALL_TARGET=	install-strip
 TEST_TARGET=	check
 USE_LDCONFIG=	yes
+USE_PERL5=	build
+SHEBANG_FILES=	lib/arm/arm2gnu.pl
 
-.include <bsd.port.options.mk>
-
-post-patch:
-	@${REINPLACE_CMD} -e 's|doc||g' ${WRKSRC}/Makefile.in
-	@${REINPLACE_CMD} -e 's,  x86_64),  x86_64|amd64),; \
-		/ac_lib/ s,compat,,' ${WRKSRC}/configure
-.if ${ARCH}=="amd64"
-	@${REINPLACE_CMD} -e 's|#define OC_X86_ASM|#undef OC_X86_ASM|' ${WRKSRC}/configure
-.endif
+# clang's own assembler doesn't like the armv7 assembly used here
+CFLAGS_armv7=	-fno-integrated-as
+CLFAGS+=	${CFLAGS_${ARCH}}
 
 .include <bsd.port.mk>
diff --git a/multimedia/libtheora/distinfo b/multimedia/libtheora/distinfo
index 035287a9fa29..683316cc2a0c 100644
--- a/multimedia/libtheora/distinfo
+++ b/multimedia/libtheora/distinfo
@@ -1,3 +1,3 @@
-TIMESTAMP = 1766633951
-SHA256 (libtheora-1.2.0.tar.xz) = ebdf77a8f5c0a8f7a9e42323844fa09502b34eb1d1fece7b5f54da41fe2122ec
-SIZE (libtheora-1.2.0.tar.xz) = 1803124
+TIMESTAMP = 1767799067
+SHA256 (theora-v1.2.0.tar.bz2) = 3363393c262baf1be16bab6d82aeb75594a07be95ee4c8c4fdd9a5f202176c9a
+SIZE (theora-v1.2.0.tar.bz2) = 1043069
diff --git a/multimedia/libtheora/files/patch-Makefile.am b/multimedia/libtheora/files/patch-Makefile.am
new file mode 100644
index 000000000000..8e4401d99247
--- /dev/null
+++ b/multimedia/libtheora/files/patch-Makefile.am
@@ -0,0 +1,11 @@
+--- Makefile.am.orig	2026-01-07 15:22:12 UTC
++++ Makefile.am
+@@ -9,7 +9,7 @@ endif
+ EXAMPLES_DIR =
+ endif
+ 
+-SUBDIRS = lib include doc tests m4 $(EXAMPLES_DIR)
++SUBDIRS = lib include tests m4
+ 
+ EXTRA_DIST = \
+ 	README.md CHANGES COPYING LICENSE \
diff --git a/multimedia/libtheora/files/patch-Makefile.in b/multimedia/libtheora/files/patch-Makefile.in
deleted file mode 100644
index b44ea4bcdeab..000000000000
--- a/multimedia/libtheora/files/patch-Makefile.in
+++ /dev/null
@@ -1,11 +0,0 @@
---- Makefile.in.orig	2025-03-29 06:07:40 UTC
-+++ Makefile.in
-@@ -191,7 +191,7 @@ am__define_uniq_tagged_files = \
-   unique=`for i in $$list; do \
-     if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
-   done | $(am__uniquify_input)`
--DIST_SUBDIRS = lib include doc tests m4 examples
-+DIST_SUBDIRS = lib include m4
- am__DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/config.h.in \
- 	$(srcdir)/libtheora.spec.in $(srcdir)/theora-uninstalled.pc.in \
- 	$(srcdir)/theora.pc.in $(srcdir)/theoradec-uninstalled.pc.in \
diff --git a/multimedia/libtheora/files/patch-configure.ac b/multimedia/libtheora/files/patch-configure.ac
new file mode 100644
index 000000000000..76a215906938
--- /dev/null
+++ b/multimedia/libtheora/files/patch-configure.ac
@@ -0,0 +1,11 @@
+--- configure.ac.orig	2026-01-07 15:23:13 UTC
++++ configure.ac
+@@ -239,7 +239,7 @@ if test "x${ac_enable_asm}" = xyes; then
+       THEORA_LDFLAGS="$THEORA_LDFLAGS  -Wl,-read_only_relocs,suppress"
+     fi
+       ;;
+-  x86_64)
++  amd64|x86_64)
+     cpu_x86_64=yes
+     cpu_optimization="64 bit x86"
+     AC_DEFINE([OC_X86_ASM], [],  [make use of x86 asm optimization])
diff --git a/multimedia/libtheora/files/patch-lib_arm_armcpu.c b/multimedia/libtheora/files/patch-lib_arm_armcpu.c
new file mode 100644
index 000000000000..73caab49cc63
--- /dev/null
+++ b/multimedia/libtheora/files/patch-lib_arm_armcpu.c
@@ -0,0 +1,24 @@
+--- lib/arm/armcpu.c.orig	2026-01-07 15:27:46 UTC
++++ lib/arm/armcpu.c
+@@ -107,6 +107,21 @@ ogg_uint32_t oc_cpu_flags_get(void){
+   return flags;
+ }
+ 
++#elif defined(__FreeBSD__)
++# include <sys/auxv.h>
++
++ogg_uint32_t oc_cpu_flags_get(void){
++  ogg_uint32_t  flags = OC_CPU_ARM_MEDIA; /* FreeBSD requires ARMv6 or newer */
++  unsigned long auxv = 0;
++
++  elf_aux_info(AT_HWCAP, &auxv, sizeof auxv);
++
++  if (auxv & HWCAP_EDSP) flags |= OC_CPU_ARM_EDSP;
++  if (auxv & HWCAP_NEON) flags |= OC_CPU_ARM_NEON;
++
++  return flags;
++}
++
+ #elif defined(__riscos__)
+ #include <kernel.h>
+ #include <swis.h>