commit:     897f1c0224cdd6d7df1f4aa2de75b81f094e4d14
Author:     Alexey Sokolov <alexey+gentoo <AT> asokolov <DOT> org>
AuthorDate: Wed Feb 19 22:01:37 2025 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Sat Feb 22 16:49:13 2025 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=897f1c02

dev-libs/bglibs: fix build with gcc 14

Closes: https://bugs.gentoo.org/938087
Closes: https://bugs.gentoo.org/944233
Signed-off-by: Alexey Sokolov <alexey+gentoo <AT> asokolov.org>
Signed-off-by: Sam James <sam <AT> gentoo.org>

 dev-libs/bglibs/bglibs-2.04-r4.ebuild          | 98 ++++++++++++++++++++++++++
 dev-libs/bglibs/files/bglibs-2.04-gcc14.patch  | 81 +++++++++++++++++++++
 dev-libs/bglibs/files/bglibs-2.04-prefix.patch | 14 ++++
 3 files changed, 193 insertions(+)

diff --git a/dev-libs/bglibs/bglibs-2.04-r4.ebuild 
b/dev-libs/bglibs/bglibs-2.04-r4.ebuild
new file mode 100644
index 000000000000..8f63793fcb29
--- /dev/null
+++ b/dev-libs/bglibs/bglibs-2.04-r4.ebuild
@@ -0,0 +1,98 @@
+# Copyright 1999-2025 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=8
+
+inherit toolchain-funcs
+
+DESCRIPTION="Bruce Guenter's Libraries Collection"
+HOMEPAGE="https://untroubled.org/bglibs/";
+SRC_URI="https://untroubled.org/bglibs/archive/${P}.tar.gz";
+
+LICENSE="LGPL-2.1+"
+SLOT="0/2"
+KEYWORDS="~alpha ~amd64 ~arm ~hppa ~loong ~mips ~ppc ~ppc64 ~riscv ~sparc ~x86"
+IUSE="doc"
+
+BDEPEND="
+       dev-build/libtool
+       doc? (
+               app-text/doxygen
+               dev-texlive/texlive-latexrecommended
+               dev-texlive/texlive-latex
+               dev-texlive/texlive-latexextra
+               virtual/latex-base
+       )
+"
+
+PATCHES=(
+       "${FILESDIR}"/bglibs-2.04-stack-buffers.patch
+       "${FILESDIR}"/bglibs-2.04-feature-tests.patch
+       "${FILESDIR}"/bglibs-2.04-musl.patch
+       "${FILESDIR}"/bglibs-2.04-gcc14.patch
+       "${FILESDIR}"/bglibs-2.04-prefix.patch
+)
+
+src_prepare() {
+       default
+
+       # Remove the tests from the default target so that we can run
+       # them only when the user has enabled them.
+       sed -i '/^all:/s|selftests||' Makefile || die
+       sed -i '/selftests/d' TARGETS || die
+
+       # The selftests.sh script collects the list of tests to run by
+       # grepping for "#ifdef SELFTEST_MAIN", which is defined in each *.c
+       # file to be tested. We can therefore disable individual tests by
+       # clobbering that line. (This should be safe; the contents of that
+       # ifdef are the test program, which we are disabling anyway.)
+       #
+       # This test requires network access, and currently fails even
+       # if you have it (https://github.com/bruceg/bglibs/issues/5).
+       sed -e 's/#ifdef SELFTEST_MAIN/#ifdef UNDEFINED/' \
+               -i net/resolve_ipv4addr.c || die
+}
+
+src_configure() {
+       echo "$(tc-getCC) ${CFLAGS}" > conf-cc || die
+       echo "$(tc-getCC) ${LDFLAGS}" > conf-ld || die
+}
+
+src_compile() {
+       # Parallel build fails, bug #343617
+       MAKEOPTS+=" -j1" default
+
+       if use doc; then
+               emake -C doc/latex pdf
+       fi
+}
+
+src_test() {
+       einfo "Running selftests"
+       emake selftests
+}
+
+src_install() {
+       echo "${ED}/usr/bin" > conf-bin || die
+       echo "${ED}/usr/$(get_libdir)/bglibs" > conf-lib || die
+       echo "${ED}/usr/include" > conf-include || die
+       echo "${ED}/usr/share/man" > conf-man || die
+
+       default
+
+       # Install .so into LDPATH
+       mv "${ED}"/usr/$(get_libdir)/bglibs/libbg.so.2.0.0 \
+               "${ED}"/usr/$(get_libdir)/ \
+               || die
+       dosym libbg.so.2.0.0 /usr/$(get_libdir)/libbg.so.2
+       dosym libbg.so.2.0.0 /usr/$(get_libdir)/libbg.so
+       dosym ../libbg.so.2.0.0 /usr/$(get_libdir)/bglibs/libbg.so.2.0.0
+
+       rm "${ED}"/usr/$(get_libdir)/bglibs/libbg.la || die
+
+       dodoc ANNOUNCEMENT NEWS README ChangeLog TODO VERSION
+       dodoc -r doc/html/
+       if use doc; then
+               dodoc doc/latex/refman.pdf
+       fi
+}

diff --git a/dev-libs/bglibs/files/bglibs-2.04-gcc14.patch 
b/dev-libs/bglibs/files/bglibs-2.04-gcc14.patch
new file mode 100644
index 000000000000..467a2dcb6b2c
--- /dev/null
+++ b/dev-libs/bglibs/files/bglibs-2.04-gcc14.patch
@@ -0,0 +1,81 @@
+https://github.com/bruceg/bglibs/pull/10
+
+--- a/include/resolve.h
++++ b/include/resolve.h
+@@ -26,7 +26,7 @@ extern int __resolve_error;
+ #define resolve_error() (__resolve_error)
+ 
+ struct dns_result;
+-extern int resolve_calldns(int (*dnsfn)(), struct dns_result* out, const 
void* param);
++extern int resolve_calldns(int (*dnsfn)(struct dns_result*, const void*), 
struct dns_result* out, const void* param);
+ extern int resolve_qualdns(int (*dnsfn)(struct dns_transmit*, struct 
dns_result* out, const char*),
+                            struct dns_result* out, const char* name);
+ 
+--- a/net/resolve_calldns.c
++++ b/net/resolve_calldns.c
+@@ -5,7 +5,7 @@
+ int __resolve_error = 0;
+ 
+ /** Call a dns_* function and save an error code if necessary. */
+-int resolve_calldns(int (*dnsfn)(), struct dns_result* out, const void* param)
++int resolve_calldns(int (*dnsfn)(struct dns_result*, const void*), struct 
dns_result* out, const void* param)
+ {
+   if (dnsfn(out, param) < 0) {
+     __resolve_error = RESOLVE_TEMPFAIL;
+--- a/net/resolve_ipv4addr.c
++++ b/net/resolve_ipv4addr.c
+@@ -1,11 +1,15 @@
+ #include "dns.h"
+ #include "resolve.h"
+ 
++static int dns_name4_wrapper(struct dns_result *res, const void *ptr) {
++  return dns_name4(res, (const ipv4addr*)ptr);
++}
++
+ /** Look up the domain name corresponding to an IPv4 address. */
+ const char* resolve_ipv4addr(const ipv4addr* addr)
+ {
+   static struct dns_result out = {0};
+-  if (!resolve_calldns(dns_name4, &out, addr))
++  if (!resolve_calldns(dns_name4_wrapper, &out, addr))
+     return 0;
+   return out.rr.name[0];
+ }
+--- a/sys/hassysselect.h0
++++ b/sys/hassysselect.h0
+@@ -4,6 +4,5 @@
+ /* sysdep: -sysselect */
+ 
+ #include <sys/time.h>
+-extern int select();
+ 
+ #endif
+--- a/sys/hassysselect.h1
++++ b/sys/hassysselect.h1
+@@ -5,6 +5,5 @@
+ 
+ #include <sys/time.h>
+ #include <sys/select.h>
+-extern int select();
+ 
+ #endif
+--- a/sys/hasvfork.h0
++++ b/sys/hasvfork.h0
+@@ -2,7 +2,6 @@
+ #define FORK_H
+ 
+ /* sysdep: -vfork */
+-extern pid_t fork();
+ #define vfork fork
+ 
+ #endif
+--- a/sys/hasvfork.h1
++++ b/sys/hasvfork.h1
+@@ -2,7 +2,5 @@
+ #define FORK_H
+ 
+ /* sysdep: +vfork */
+-extern pid_t fork();
+-extern pid_t vfork();
+ 
+ #endif

diff --git a/dev-libs/bglibs/files/bglibs-2.04-prefix.patch 
b/dev-libs/bglibs/files/bglibs-2.04-prefix.patch
new file mode 100644
index 000000000000..c0fa1b8c27d2
--- /dev/null
+++ b/dev-libs/bglibs/files/bglibs-2.04-prefix.patch
@@ -0,0 +1,14 @@
+--- a/Makefile
++++ b/Makefile
+@@ -863,9 +863,8 @@ path/mktemp.lo path/mktemp.o: ltcompile path/mktemp.c 
systime.h include/bglibs/p
+       ./ltcompile path/mktemp.c
+ 
+ perl-head.pl: 
+-      ( set -e; PATH="/bin:/usr/bin:/usr/local/bin:$$PATH"; export PATH; \
+-        perl=`which perl`; \
+-        echo "#! $$perl"; \
++      ( set -e; \
++        echo "#!/usr/bin/env perl"; \
+         echo "# WARNING: This file was auto-generated. Do not edit!"; \
+         echo ) >perl-head.pl
+ 

Reply via email to