git: 4ce881e02d7c - 2025Q3 - devel/git: Handle libsysinfo properly

From: Renato Botelho <garga_at_FreeBSD.org>
Date: Thu, 10 Jul 2025 12:25:49 UTC
The branch 2025Q3 has been updated by garga:

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

commit 4ce881e02d7cfd7ecad4c25be118aed4e3c2f459
Author:     Renato Botelho <garga@FreeBSD.org>
AuthorDate: 2025-07-03 14:45:01 +0000
Commit:     Renato Botelho <garga@FreeBSD.org>
CommitDate: 2025-07-10 12:25:44 +0000

    devel/git: Handle libsysinfo properly
    
    git 2.50.0 was failing to build when libsysinfo was installed and, to
    workaround this issue, an option LIBSYSINFO was added to the port and a
    small change made on configure.ac to make it possible to disable this
    knob.
    
    After some discussion with git developers they prpoposed a different
    approach to just ignore libsysinfo if it's installed because git should
    never use it on FreeBSD.  It should use BSD_SYSCTL option instead.
    
    This change removes the LIBSYSINFO option and properly change
    configure.ac to ignore LIBSYSINFO when HAVE_BSD_SYSCTL is set.  This way
    git will build exactly the same when libsysinfo is or not installed.
    
    Obtained from:  https://lore.kernel.org/git/b57b1418-2179-480c-92a3-a107388d71f2@gentoo.org/T/#ma65c83afdc1918ffdb18c9cae9ead29db4738b0f
    Sponsored by:   Rubicon Communications, LLC ("Netgate")
    
    (cherry picked from commit 5b6183a160c3d97feefb4f02f1adec877ebf28ca)
---
 devel/git/Makefile                 |  8 +---
 devel/git/files/patch-configure.ac | 86 +++++++++++++++++++++++++++++++-------
 2 files changed, 74 insertions(+), 20 deletions(-)

diff --git a/devel/git/Makefile b/devel/git/Makefile
index 12b9fc972980..164556ca0ff0 100644
--- a/devel/git/Makefile
+++ b/devel/git/Makefile
@@ -1,5 +1,6 @@
 PORTNAME=	git
 DISTVERSION=	2.50.0
+PORTREVISION=	1
 CATEGORIES=	devel
 MASTER_SITES=	KERNEL_ORG/software/scm/git
 DISTFILES=	${DISTNAME}${EXTRACT_SUFX} \
@@ -71,7 +72,7 @@ CONFIGURE_ARGS=	--enable-pthreads=-pthread ac_cv_header_libcharset_h=no
 .if ${SUBPORT} == core
 
 OPTIONS_DEFINE=	CONTRIB CURL DOCS GITWEB ICONV NLS PCRE2 PERL SEND_EMAIL \
-		SUBTREE SYSINFO
+		SUBTREE
 OPTIONS_DEFAULT=CONTRIB CURL GITWEB ICONV PCRE2 PERL SEND_EMAIL SUBTREE
 
 . if ${FLAVOR:U} == lite
@@ -93,7 +94,6 @@ GITWEB_DESC=	Install gitweb
 PCRE2_DESC=	Use Perl Compatible Regular Expressions (v2)
 SEND_EMAIL_DESC=Enable the git-send-email(1) script
 SUBTREE_DESC=	Install git-subtree
-SYSINFO_DESC=	Use libsysinfo
 
 NLS_USES=		gettext
 NLS_MAKE_ARGS_OFF=	NO_GETTEXT=yes
@@ -127,10 +127,6 @@ DOCS_DISTFILES=	${PORTNAME}-htmldocs-${DISTVERSION}${EXTRACT_SUFX}
 SUBTREE_BUILD_DEPENDS=	asciidoctor:textproc/rubygem-asciidoctor \
 			xmlto:textproc/xmlto
 
-SYSINFO_LIB_DEPENDS=	libsysinfo.so:devel/libsysinfo
-SYSINFO_CONFIGURE_ON=	--with-libsysinfo
-SYSINFO_LDFLAGS=	-lsysinfo
-
 .else
 
 NO_ARCH=	yes
diff --git a/devel/git/files/patch-configure.ac b/devel/git/files/patch-configure.ac
index d75441bb721f..35ed793fa5c4 100644
--- a/devel/git/files/patch-configure.ac
+++ b/devel/git/files/patch-configure.ac
@@ -12,20 +12,78 @@
  #
  # Define PYTHON_PATH to provide path to Python.
  GIT_ARG_SET_PATH(python, allow-without)
-@@ -1070,6 +1070,8 @@ GIT_CONF_SUBST([CHARSET_LIB])
- #
- # Define HAVE_SYSINFO=YesPlease if sysinfo is available.
+@@ -1068,32 +1068,6 @@ GIT_CONF_SUBST([CHARSET_LIB])
+ GIT_CONF_SUBST([CHARSET_LIB])
+ 
  #
-+AC_ARG_WITH(libsysinfo,
-+AS_HELP_STRING([--with-libsysinfo],[support libsysinfo (default is NO)]),
- AC_DEFUN([HAVE_SYSINFO_SRC], [
- AC_LANG_PROGRAM([[
- #include <stdint.h>
-@@ -1091,6 +1093,7 @@ AC_COMPILE_IFELSE([HAVE_SYSINFO_SRC],
- 	HAVE_SYSINFO=YesPlease],
+-# Define HAVE_SYSINFO=YesPlease if sysinfo is available.
+-#
+-AC_DEFUN([HAVE_SYSINFO_SRC], [
+-AC_LANG_PROGRAM([[
+-#include <stdint.h>
+-#include <sys/sysinfo.h>
+-]], [[
+-struct sysinfo si;
+-uint64_t t = 0;
+-if (!sysinfo(&si)) {
+-	t = si.totalram;
+-	if (si.mem_unit > 1)
+-		t *= (uint64_t)si.mem_unit;
+-}
+-return t;
+-]])])
+-
+-AC_MSG_CHECKING([for sysinfo])
+-AC_COMPILE_IFELSE([HAVE_SYSINFO_SRC],
+-	[AC_MSG_RESULT([yes])
+-	HAVE_SYSINFO=YesPlease],
+-	[AC_MSG_RESULT([no])
+-	HAVE_SYSINFO=])
+-GIT_CONF_SUBST([HAVE_SYSINFO])
+-
+-#
+ # Define HAVE_CLOCK_GETTIME=YesPlease if clock_gettime is available.
+ GIT_CHECK_FUNC(clock_gettime,
+ 	[HAVE_CLOCK_GETTIME=YesPlease],
+@@ -1220,6 +1194,41 @@ GIT_CONF_SUBST([HAVE_BSD_SYSCTL])
  	[AC_MSG_RESULT([no])
- 	HAVE_SYSINFO=])
-+)
- GIT_CONF_SUBST([HAVE_SYSINFO])
+ 	HAVE_BSD_SYSCTL=])
+ GIT_CONF_SUBST([HAVE_BSD_SYSCTL])
++
++#
++# Define HAVE_SYSINFO=YesPlease if sysinfo is available.
++#
++
++HAVE_SYSINFO=
++# on a *BSD system, sysctl() takes precedence over the
++# sysinfo() compatibility library (if installed).
++
++if test -z "$HAVE_BSD_SYSCTL"; then
++
++  AC_DEFUN([HAVE_SYSINFO_SRC], [
++  AC_LANG_PROGRAM([[
++  #include <stdint.h>
++  #include <sys/sysinfo.h>
++  ]], [[
++  struct sysinfo si;
++  uint64_t t = 0;
++  if (!sysinfo(&si)) {
++	t = si.totalram;
++	if (si.mem_unit > 1)
++		t *= (uint64_t)si.mem_unit;
++  }
++  return t;
++  ]])])
++
++  AC_MSG_CHECKING([for sysinfo])
++  AC_COMPILE_IFELSE([HAVE_SYSINFO_SRC],
++	[AC_MSG_RESULT([yes])
++	HAVE_SYSINFO=YesPlease],
++	[AC_MSG_RESULT([no])
++	HAVE_SYSINFO=])
++  GIT_CONF_SUBST([HAVE_SYSINFO])
++
++fi
  
- #
+ ## Other checks.
+ # Define NO_SYMLINK_HEAD if you never want .git/HEAD to be a symbolic link.