git: 01c086fdc8ba - main - devel/apr1: Fix output of `apu-1-config --libs` when default version of berkeley db is 18

From: Jochen Neumeister <joneum_at_FreeBSD.org>
Date: Wed, 23 Feb 2022 12:18:52 UTC
The branch main has been updated by joneum:

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

commit 01c086fdc8ba6e15aa430c515c71b4d3e1679e2e
Author:     Jochen Neumeister <joneum@FreeBSD.org>
AuthorDate: 2022-02-23 12:15:49 +0000
Commit:     Jochen Neumeister <joneum@FreeBSD.org>
CommitDate: 2022-02-23 12:15:49 +0000

    devel/apr1: Fix output of `apu-1-config --libs` when default version of berkeley db is 18
    
    When default version of berkeley db is 18, `apu-1-config --libs` returns following output.
    
    yasu@eastasia[2137]% apu-1-config --libs
      -ldb -lgdbm  -lexpat
    yasu@eastasia[2146]%
    
    However, it is not libdb.so but libdb-18.1.so that is installed under ${PREFIX}/lib when you install database/db18. And it results in build failure of some ports that depend on devel/apr1 and use the output of `apu-1-config --libs` to get the options necessary for linking libraries properly. So fix the output by adding patch that makes configure script detects library name correctly.
    
    PR:     262137
    Submitted by:   yasu
    Approved by:    apache (with hat)
    Sponsored by:   Netzkommune GmbH
---
 devel/apr1/Makefile          |   4 +-
 devel/apr1/files/patch-bdb18 | 107 +++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 110 insertions(+), 1 deletion(-)

diff --git a/devel/apr1/Makefile b/devel/apr1/Makefile
index b44d6b247f4a..36e44fa40ad2 100644
--- a/devel/apr1/Makefile
+++ b/devel/apr1/Makefile
@@ -2,7 +2,7 @@
 
 PORTNAME=	apr
 PORTVERSION=	${APR_VERSION}.${APU_VERSION}
-PORTREVISION=	1
+PORTREVISION=	2
 CATEGORIES=	devel
 MASTER_SITES=	APACHE/apr
 DISTFILES=	apr-${APR_VERSION}.tar.gz \
@@ -13,6 +13,7 @@ COMMENT=	Apache Portability Library
 
 LICENSE=	APACHE20
 
+BUILD_DEPENDS+=	automake>=1.16.1:devel/automake
 LIB_DEPENDS=	libexpat.so:textproc/expat2
 
 USES=		iconv pathfix libtool cpe
@@ -138,6 +139,7 @@ do-configure:
 		${SETENV} ${APR_CONF_ENV} ./configure ${APR_CONF_ARGS} ${CONFIGURE_ARGS})
 	@${ECHO_MSG} "# ===> ${.TARGET} apr-util-${APU_VERSION}"
 	(cd ${APU_WRKDIR} && \
+		autoreconf -f -i && \
 		${SETENV} ${APU_CONF_ENV} ./configure ${APU_CONF_ARGS} ${CONFIGURE_ARGS})
 
 do-build:
diff --git a/devel/apr1/files/patch-bdb18 b/devel/apr1/files/patch-bdb18
new file mode 100644
index 000000000000..302dfca4d6ac
--- /dev/null
+++ b/devel/apr1/files/patch-bdb18
@@ -0,0 +1,107 @@
+diff --git apr-util-1.6.1/build/dbm.m4 apr-util-1.6.1/build/dbm.m4
+index 57bd131f..5cbee4b3 100644
+--- apr-util-1.6.1/build/dbm.m4
++++ apr-util-1.6.1/build/dbm.m4
+@@ -112,7 +112,7 @@ AC_DEFUN([APU_CHECK_BERKELEY_DB], [
+         changequote([,])
+         unset $cache_id
+         AC_CHECK_HEADER([$bdb_header], [
+-          if test "$1" = "3" -o "$1" = "4" -o "$1" = "5" -o "$1" = "6"; then
++          if test "$1" = "3" -o "$1" = "4" -o "$1" = "5" -o "$1" = "6" -o "$1" = "18"; then
+             # We generate a separate cache variable for each prefix and libname
+             # we search under.  That way, we avoid caching information that
+             # changes if the user runs `configure' with a different set of
+@@ -432,7 +432,15 @@ AC_DEFUN([APU_CHECK_DB], [
+       AC_MSG_ERROR(Berkeley db$db_major not found)
+     fi
+     ;;
+-  db[[456]])
++  db18[[0-9]])
++    db_major=`echo "$requested" | sed -e 's/db//' -e 's/.$//'`
++    db_minor=`echo "$requested" | sed -e 's/db//' -e 's/..//'`
++    APU_CHECK_DBXY("$check_places", "$db_major", "$db_minor")
++    if test "$apu_db_version" != "$db_major"; then
++      AC_MSG_ERROR(Berkeley db$db_major not found)
++    fi
++    ;;
++  db[[456]] | db18)
+     db_major=`echo "$requested" | sed -e 's/db//'`
+     # Start version search at version x.9
+     db_minor=9
+@@ -455,17 +463,21 @@ AC_DEFUN([APU_CHECK_DB], [
+ ])
+ 
+ dnl
+-dnl APU_CHECK_DB_ALL: Try all Berkeley DB versions, from 6.X to 1.
++dnl APU_CHECK_DB_ALL: Try all Berkeley DB versions, from 18.X to 1.
+ dnl
+ AC_DEFUN([APU_CHECK_DB_ALL], [
+   all_places=$1
+ 
+-  # Start version search at version 6.9
+-  db_version=69
++  # Start version search at version 18.9
++  db_version=189
+   while [[ $db_version -ge 40 ]]
+   do
+     db_major=`echo $db_version | sed -e 's/.$//'`
+-    db_minor=`echo $db_version | sed -e 's/.//'`
++    if test "$db_version" -ge "100" ; then
++      db_minor=`echo $db_version | sed -e 's/..//'`
++    else
++      db_minor=`echo $db_version | sed -e 's/.//'`
++    fi
+     APU_CHECK_DBXY("$all_places", "$db_major", "$db_minor")
+     if test "$apu_have_db" = "1"; then
+       break
+@@ -511,7 +523,7 @@ AC_DEFUN([APU_CHECK_DBM], [
+   apu_db_version=0
+ 
+   # Maximum supported version announced in help string.
+-  # Although we search for all versions up to 6.9,
++  # Although we search for all versions up to 18.9,
+   # we should only include existing versions in our
+   # help string.
+   dbm_list="sdbm, gdbm, ndbm, db, db1, db185, db2, db3, db4"
+@@ -531,7 +543,7 @@ AC_DEFUN([APU_CHECK_DBM], [
+     dbm_list="$dbm_list, db$db_version"
+     db_version=`expr $db_version + 1`
+   done
+-  db_max_version=60
++  db_max_version=62
+   db_min_version=60
+   db_version="$db_min_version"
+   while [[ $db_version -le $db_max_version ]]
+@@ -539,9 +551,17 @@ AC_DEFUN([APU_CHECK_DBM], [
+     dbm_list="$dbm_list, db$db_version"
+     db_version=`expr $db_version + 1`
+   done
++  db_max_version=181
++  db_min_version=180
++  db_version="$db_min_version"
++  while [[ $db_version -le $db_max_version ]]
++  do
++    dbm_list="$dbm_list, db$db_version"
++    db_version=`expr $db_version + 1`
++  done
+ 
+   AC_ARG_WITH(dbm, [APR_HELP_STRING([--with-dbm=DBM], [choose the DBM type to use.
+-      DBM={sdbm,gdbm,ndbm,db,db1,db185,db2,db3,db4,db4X,db5X,db6X} for some X=0,...,9])],
++      DBM={sdbm,gdbm,ndbm,db,db1,db185,db2,db3,db4,db4X,db5X,db6X,db18x} for some X=0,...,9])],
+   [
+     if test "$withval" = "yes"; then
+       AC_MSG_ERROR([--with-dbm needs to specify a DBM type to use.
+@@ -684,11 +704,11 @@ AC_DEFUN([APU_CHECK_DBM], [
+       eval "apu_use_$requested=1"
+       apu_default_dbm=$requested
+       ;;
+-    db185 | db[[123456]])
++    db185 | db[[123456]] | db18)
+       apu_use_db=1
+       apu_default_dbm=$requested
+       ;;
+-    db[[456]][[0-9]])
++    db[[456]][[0-9]] | db18[[0-9]])
+       apu_use_db=1
+       apu_default_dbm=`echo $requested | sed -e 's/.$//'`
+       ;;