git: 4357da1d4e4d - main - dns/c-ares: Update to 1.19.0 and switch to CMake

From: Daniel Engberg <diizzy_at_FreeBSD.org>
Date: Sun, 29 Jan 2023 18:50:30 UTC
The branch main has been updated by diizzy:

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

commit 4357da1d4e4deb422e7744e1dfd6927a196195c1
Author:     Daniel Engberg <diizzy@FreeBSD.org>
AuthorDate: 2023-01-29 18:47:33 +0000
Commit:     Daniel Engberg <diizzy@FreeBSD.org>
CommitDate: 2023-01-29 18:49:36 +0000

    dns/c-ares: Update to 1.19.0 and switch to CMake
    
    - Use GitHub as primary mirror for better connectivity and use
      main site as fallback
    - Switch to CMake to provide .cmake files, improve compilation
      performance and adhere framework options
      Additionally also aligns port with other distributions such as
      Alpine, Arch, Fedora, MacPorts and openSUSE
    - Drop CONFIG_INFO patch, this is no longer needed by UnrealIRCd
    - Enable "make test", only build test suite when requested, disable
      online tests and use Googletest from tree instead of bundled version
    
    Changelog: https://c-ares.org/changelog.html#1_19_0
    
    PR:             268538
    Reviewed by:    zi (maintainer)
---
 dns/c-ares/Makefile                        | 37 ++++++---------
 dns/c-ares/distinfo                        |  6 +--
 dns/c-ares/files/ares-config-info.patch    | 73 ------------------------------
 dns/c-ares/files/patch-test_CMakeLists.txt | 34 ++++++++++++++
 dns/c-ares/pkg-plist                       | 10 +++-
 5 files changed, 59 insertions(+), 101 deletions(-)

diff --git a/dns/c-ares/Makefile b/dns/c-ares/Makefile
index a74b169139f0..179979ba5251 100644
--- a/dns/c-ares/Makefile
+++ b/dns/c-ares/Makefile
@@ -1,10 +1,8 @@
 PORTNAME=	c-ares
-PORTVERSION=	1.18.1
-PORTREVISION=	1
+DISTVERSION=	1.19.0
 CATEGORIES=	dns
-MASTER_SITES=	https://c-ares.org/download/ \
-		https://c-ares.haxx.se/download/ \
-		ZI
+MASTER_SITES=	https://github.com/${PORTNAME}/${PORTNAME}/releases/download/cares-${DISTVERSION:S/./_/g}/ \
+		https://c-ares.org/download/
 
 MAINTAINER=	zi@FreeBSD.org
 COMMENT=	Asynchronous DNS resolver library
@@ -13,29 +11,22 @@ WWW=		https://c-ares.haxx.se/
 LICENSE=	MIT
 LICENSE_FILE=	${WRKSRC}/LICENSE.md
 
-GNU_CONFIGURE=	yes
-CONFIGURE_ARGS=	--disable-werror
-INSTALL_TARGET=	install-strip
-USES=		libtool pathfix compiler:c++11-lang gmake
+USES=		cmake compiler:c++11-lang pathfix
 USE_LDCONFIG=	yes
 
-PROGRAMS=	acountry adig ahost
+CONFLICTS=	py*-ripe.atlas.tools
 
-OPTIONS_DEFINE=		CONFIG_INFO DEBUG HIDE_SYMBOLS OPTIMIZED_CFLAGS
-OPTIONS_DEFAULT=	CONFIG_INFO HIDE_SYMBOLS
+CMAKE_ARGS=		-DCMAKE_INSTALL_MANDIR:PATH=${MANPREFIX}/man
 
-CONFIG_INFO_DESC=	Add the ares_config_info patch
-HIDE_SYMBOLS_DESC=	Hide internal library symbols
-OPTIMIZED_CFLAGS_DESC=	Build with compiler optimizations
+OPTIONS_DEFINE=		TEST
 
-CONFLICTS=		py*-ripe.atlas.tools
+TEST_USES=		localbase:ldflags
+TEST_BUILD_DEPENDS=	googletest>0:devel/googletest
+TEST_TEST_TARGET=	test
+TEST_CMAKE_BOOL=	CARES_BUILD_TESTS
 
-CONFIG_INFO_EXTRA_PATCHES=	${FILESDIR}/ares-config-info.patch
-DEBUG_CONFIGURE_ENABLE=	debug
-HIDE_SYMBOLS_CONFIGURE_ENABLE=	symbol-hiding
-OPTIMIZED_CFLAGS_CONFIGURE_ENABLE=	optimize
-
-post-install:
-	${INSTALL_PROGRAM} ${PROGRAMS:S@^@${WRKSRC}/src/tools/.libs/@} ${STAGEDIR}${PREFIX}/bin/
+post-patch:
+	@${REINPLACE_CMD} -e 's|ares-test-live.cc||g' \
+		${PATCH_WRKSRC}/test/Makefile.inc
 
 .include <bsd.port.mk>
diff --git a/dns/c-ares/distinfo b/dns/c-ares/distinfo
index 8032329c6126..44f7c46673ea 100644
--- a/dns/c-ares/distinfo
+++ b/dns/c-ares/distinfo
@@ -1,3 +1,3 @@
-TIMESTAMP = 1649437591
-SHA256 (c-ares-1.18.1.tar.gz) = 1a7d52a8a84a9fbffb1be9133c0f6e17217d91ea5a6fa61f6b4729cda78ebbcf
-SIZE (c-ares-1.18.1.tar.gz) = 1560165
+TIMESTAMP = 1674949471
+SHA256 (c-ares-1.19.0.tar.gz) = bfceba37e23fd531293829002cac0401ef49a6dc55923f7f92236585b7ad1dd3
+SIZE (c-ares-1.19.0.tar.gz) = 1572210
diff --git a/dns/c-ares/files/ares-config-info.patch b/dns/c-ares/files/ares-config-info.patch
deleted file mode 100644
index 9f0c3e4bca78..000000000000
--- a/dns/c-ares/files/ares-config-info.patch
+++ /dev/null
@@ -1,73 +0,0 @@
-Description: Add the ares_get_config() routine used by Unreal IRCd.
- Originally taken from the Unreal IRCd distribution, later modified
- by me to properly support IPv6 nameserver addresses since c-ares-1.7.1.
-Origin: the Unreal IRCd distribution
-Author: Peter Pentchev <roam@FreeBSD.org>
-Forwarded: no
-Last-Update: 2010-12-19
-
---- include/ares.h.orig
-+++ include/ares.h
-@@ -260,6 +260,14 @@
-   int nsort;
- };
- 
-+/** Public available config (readonly) interface for ares_get_config(). */
-+struct ares_config_info {
-+	int timeout;
-+	int tries;
-+	int numservers;
-+	char **servers;
-+};
-+
- struct hostent;
- struct timeval;
- struct sockaddr;
-@@ -530,6 +538,8 @@
- CARES_EXTERN int ares_get_servers(ares_channel channel,
-                                   struct ares_addr_node **servers);
- 
-+CARES_EXTERN int ares_get_config(struct ares_config_info *d, ares_channel c);
-+
- #ifdef  __cplusplus
- }
- #endif
---- src/lib/ares_init.c.orig	2013-02-17 11:44:02.000000000 -0500
-+++ src/lib/ares_init.c	2013-05-15 13:43:31.000000000 -0400
-@@ -1875,6 +1875,36 @@
- }
- #endif  /* !WIN32 & !WATT32 & !ANDROID & !__ANDROID__ */
- 
-+int ares_get_config(struct ares_config_info *d, ares_channel c)
-+{
-+	int i;
-+	const char *p;
-+	char tmp[sizeof("ffff:ffff:ffff:ffff:ffff:ffff:255.255.255.255")];
-+
-+	memset(d, 0, sizeof(struct ares_config_info));
-+
-+	d->timeout = c->timeout;
-+	d->tries = c->tries;
-+	d->numservers = c->nservers;
-+	d->servers = calloc(sizeof(char *), c->nservers);
-+	for (i = 0; i < c->nservers; i++)
-+	{
-+		if (c->servers[i].addr.family == AF_INET)
-+			p = ares_inet_ntop(c->servers[i].addr.family,
-+			    (const char *)&c->servers[i].addr.addrV4,
-+			    tmp, sizeof(tmp));
-+		else if (c->servers[i].addr.family == AF_INET6)
-+			p = ares_inet_ntop(c->servers[i].addr.family,
-+			    (const char *)&c->servers[i].addr.addrV6,
-+			    tmp, sizeof(tmp));
-+		else
-+			p = NULL;
-+		d->servers[i] = p ? strdup(p) : NULL;
-+	}
-+
-+	return ARES_SUCCESS;
-+}
-+
- /* initialize an rc4 key. If possible a cryptographically secure random key
-    is generated using a suitable function (for example win32's RtlGenRandom as
-    described in
diff --git a/dns/c-ares/files/patch-test_CMakeLists.txt b/dns/c-ares/files/patch-test_CMakeLists.txt
new file mode 100644
index 000000000000..cf03e2fdb77b
--- /dev/null
+++ b/dns/c-ares/files/patch-test_CMakeLists.txt
@@ -0,0 +1,34 @@
+--- test/CMakeLists.txt.orig	2022-11-08 12:40:00 UTC
++++ test/CMakeLists.txt
+@@ -25,14 +25,14 @@ ELSE ()
+ ENDIF ()
+ 
+ # Google Test and Mock
+-set(GMOCK_DIR gmock-1.11.0)
+-add_library(gmock STATIC
+-  ${GMOCK_DIR}/gmock-gtest-all.cc
+-  ${GMOCK_DIR}/gmock/gmock.h
+-  ${GMOCK_DIR}/gtest/gtest.h
+-)
+-target_include_directories(gmock PUBLIC SYSTEM ${GMOCK_DIR})
+-target_link_libraries(gmock PRIVATE ${CMAKE_THREAD_LIBS_INIT})
++# set(GMOCK_DIR gmock-1.11.0)
++# add_library(gmock STATIC
++#   ${GMOCK_DIR}/gmock-gtest-all.cc
++#   ${GMOCK_DIR}/gmock/gmock.h
++#   ${GMOCK_DIR}/gtest/gtest.h
++# )
++# target_include_directories(gmock PUBLIC SYSTEM ${GMOCK_DIR})
++# target_link_libraries(gmock PRIVATE ${CMAKE_THREAD_LIBS_INIT})
+ 
+ # test targets
+ 
+@@ -43,7 +43,7 @@ configure_file(${CARES_TOPLEVEL_DIR}/src/lib/ares_conf
+ 
+ add_executable(arestest ${TESTSOURCES} ${TESTHEADERS})
+ target_include_directories(arestest PRIVATE ${CMAKE_CURRENT_BINARY_DIR})
+-target_link_libraries(arestest PRIVATE caresinternal gmock)
++target_link_libraries(arestest PRIVATE caresinternal gtest gmock)
+ 
+ IF (CARES_BUILD_CONTAINER_TESTS)
+   target_compile_definitions(arestest PRIVATE HAVE_USER_NAMESPACE HAVE_UTS_NAMESPACE)
diff --git a/dns/c-ares/pkg-plist b/dns/c-ares/pkg-plist
index 045da584c65c..830db5d990f3 100644
--- a/dns/c-ares/pkg-plist
+++ b/dns/c-ares/pkg-plist
@@ -7,11 +7,17 @@ include/ares_dns.h
 include/ares_nameser.h
 include/ares_rules.h
 include/ares_version.h
-lib/libcares.a
+lib/cmake/c-ares/c-ares-config-version.cmake
+lib/cmake/c-ares/c-ares-config.cmake
+lib/cmake/c-ares/c-ares-targets-%%CMAKE_BUILD_TYPE%%.cmake
+lib/cmake/c-ares/c-ares-targets.cmake
 lib/libcares.so
 lib/libcares.so.2
-lib/libcares.so.2.5.1
+lib/libcares.so.2.6.0
 libdata/pkgconfig/libcares.pc
+man/man1/acountry.1.gz
+man/man1/adig.1.gz
+man/man1/ahost.1.gz
 man/man3/ares_cancel.3.gz
 man/man3/ares_create_query.3.gz
 man/man3/ares_destroy.3.gz