git: bd7b56ae1896 - main - devel/kore: fix build on armv7 and clean up

From: Robert Clausecker <fuz_at_FreeBSD.org>
Date: Sat, 18 Nov 2023 20:22:56 UTC
The branch main has been updated by fuz:

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

commit bd7b56ae1896ca6c74df5ae31fee35efd107caa7
Author:     Robert Clausecker <fuz@FreeBSD.org>
AuthorDate: 2023-11-17 22:23:24 +0000
Commit:     Robert Clausecker <fuz@FreeBSD.org>
CommitDate: 2023-11-18 20:20:44 +0000

    devel/kore: fix build on armv7 and clean up
    
     - fix a warning about a wrong formatting specifier
     - exorcise -Werror so future warnings do not break the build
     - as a result, simplify Makefile
     - switch to C11 to avoid some warnings
     - reinstate %%OPENSSLINC%% patch bits dropped in previous commit
     - patch in %%LOCALBASE%% correctly
    
    MFH:            2023Q4
---
 devel/kore/Makefile                                | 21 ++++--------
 devel/kore/files/patch-Makefile                    | 38 ++++++++++++++++++++--
 devel/kore/files/patch-kodev_Makefile              | 13 +++++---
 devel/kore/files/patch-src_cli.c                   | 11 +++++++
 devel/kore/files/patch-src_python.c                | 11 +++++++
 .../files/patch-tools_kore-serve_conf_build.conf   | 10 ++++++
 6 files changed, 83 insertions(+), 21 deletions(-)

diff --git a/devel/kore/Makefile b/devel/kore/Makefile
index 33de8c0d8d8c..40fd005128fe 100644
--- a/devel/kore/Makefile
+++ b/devel/kore/Makefile
@@ -1,5 +1,6 @@
 PORTNAME=	kore
-PORTVERSION=	4.2.3
+DISTVERSION=	4.2.3
+PORTREVISON=	1
 CATEGORIES=	devel www
 MASTER_SITES=	https://kore.io/releases/
 
@@ -16,9 +17,7 @@ BROKEN_SSL_REASON=	Requires OpenSSL 3.0.0 deprecated RSA_* routines
 USES=		compiler:c11 gmake ssl
 
 MAKE_ARGS=	OPENSSL_PATH=${OPENSSLBASE}
-CFLAGS+=	${CFLAGS_${CHOSEN_COMPILER_TYPE}}
-# 12.0 + -pedantic
-CFLAGS_clang=	-Wno-error=c11-extensions
+CFLAGS+=	-std=c11
 
 PORTEXAMPLES=	*
 
@@ -49,17 +48,9 @@ PYTHON_BINARY_ALIAS=	python3-config=${PYTHON_CMD}-config
 TASKS_MAKE_ARGS=	TASKS=1
 TLS_MAKE_ARGS_OFF=	NOTLS=1
 
-.include <bsd.port.pre.mk>
-
-.if ${COMPILER_TYPE} == clang && ${COMPILER_VERSION} >= 160
-CFLAGS+=	-Wno-error=deprecated-declarations -Wno-error=incompatible-pointer-types-discards-qualifiers
-.endif
-
-post-patch:
-.if ${LOCALBASE} != /usr/local
-	@${REINPLACE_CMD} 's|/usr/local/|${LOCALBASE}/|g' \
+pre-configure:
+	@${REINPLACE_CMD} 's|%%LOCALBASE%%|${LOCALBASE}/|g' \
 		${WRKSRC}/Makefile
-.endif
 	@${REINPLACE_CMD} 's|%%OPENSSLINC%%|${OPENSSLINC}|g' \
 		${WRKSRC}/src/cli.c
 
@@ -71,4 +62,4 @@ post-install-EXAMPLES-on:
 	@cd ${WRKSRC}/examples && ${COPYTREE_SHARE} . ${STAGEDIR}${EXAMPLESDIR}
 	@cd ${WRKSRC}/conf && ${COPYTREE_SHARE} . ${STAGEDIR}${EXAMPLESDIR}
 
-.include <bsd.port.post.mk>
+.include <bsd.port.mk>
diff --git a/devel/kore/files/patch-Makefile b/devel/kore/files/patch-Makefile
index 2413aba71126..6ff3989fb674 100644
--- a/devel/kore/files/patch-Makefile
+++ b/devel/kore/files/patch-Makefile
@@ -1,6 +1,18 @@
---- Makefile.orig	2020-09-08 19:35:30 UTC
+--- Makefile.orig	2022-08-22 11:18:44 UTC
 +++ Makefile
-@@ -48,12 +48,6 @@ ifneq ("$(DEBUG)", "")
+@@ -31,9 +31,9 @@ S_SRC+= src/tls_$(TLS_BACKEND).c
+ FEATURES=
+ FEATURES_INC=
+ 
+-CFLAGS+=-Wall -Werror -Wstrict-prototypes -Wmissing-prototypes
++CFLAGS+=-Wall -Wstrict-prototypes -Wmissing-prototypes
+ CFLAGS+=-Wmissing-declarations -Wshadow -Wpointer-arith -Wcast-qual
+-CFLAGS+=-Wsign-compare -Iinclude/kore -I$(OBJDIR) -std=c99 -pedantic
++CFLAGS+=-Wsign-compare -Iinclude/kore -I$(OBJDIR) -pedantic
+ CFLAGS+=-Wtype-limits -fno-common
+ CFLAGS+=-DPREFIX='"$(PREFIX)"' -fstack-protector-all
+ 
+@@ -66,12 +66,6 @@ ifneq ("$(DEBUG)", "")
  	FEATURES+=-DKORE_DEBUG
  endif
  
@@ -13,3 +25,25 @@
  ifneq ("$(NOSENDFILE)", "")
  	CFLAGS+=-DKORE_NO_SENDFILE
  endif
+@@ -120,8 +114,8 @@ endif
+ 
+ OSNAME=$(shell uname -s | sed -e 's/[-_].*//g' | tr A-Z a-z)
+ ifeq ("$(OSNAME)", "freebsd")
+-	KORE_CURL_LIB=-L/usr/local/lib -lcurl
+-	KORE_CURL_INC=-I/usr/local/include
++	KORE_CURL_LIB=-L%%LOCALBASE%%/lib -lcurl
++	KORE_CURL_INC=-I%%LOCALBASE%%/include
+ endif
+ 
+ ifneq ("$(ACME)", "")
+@@ -161,8 +155,8 @@ else ifeq ("$(OSNAME)", "linux")
+ else
+ 	S_SRC+=src/bsd.c
+ 	ifneq ("$(JSONRPC)", "")
+-		CFLAGS+=-I/usr/local/include
+-		LDFLAGS+=-L/usr/local/lib
++		CFLAGS+=-I%%LOCALBASE%%/include
++		LDFLAGS+=-L%%LOCALBASE%%/lib
+ 	endif
+ endif
+ 
diff --git a/devel/kore/files/patch-kodev_Makefile b/devel/kore/files/patch-kodev_Makefile
index 533af6f02cbd..baa8e5315099 100644
--- a/devel/kore/files/patch-kodev_Makefile
+++ b/devel/kore/files/patch-kodev_Makefile
@@ -1,9 +1,13 @@
---- kodev/Makefile.orig	2020-09-08 19:35:30 UTC
+--- kodev/Makefile.orig	2022-08-22 11:18:44 UTC
 +++ kodev/Makefile
-@@ -12,14 +12,8 @@ S_SRC=	../src/cli.c
- CFLAGS+=-Wall -Werror -Wstrict-prototypes -Wmissing-prototypes
+@@ -9,17 +9,11 @@ INSTALL_DIR=$(PREFIX)/bin
+ 
+ S_SRC=	../src/cli.c
+ 
+-CFLAGS+=-Wall -Werror -Wstrict-prototypes -Wmissing-prototypes
++CFLAGS+=-Wall -Wstrict-prototypes -Wmissing-prototypes
  CFLAGS+=-Wmissing-declarations -Wshadow -Wpointer-arith -Wcast-qual
- CFLAGS+=-Wsign-compare -Iincludes -std=c99 -pedantic
+-CFLAGS+=-Wsign-compare -Iincludes -std=c99 -pedantic
 -CFLAGS+=-DPREFIX='"$(PREFIX)"'
 -LDFLAGS=-lcrypto
 -
@@ -12,6 +16,7 @@
 -else
 -	CFLAGS+=-O2
 -endif
++CFLAGS+=-Wsign-compare -Iincludes -pedantic
 +CFLAGS+=-DPREFIX='"$(PREFIX)"' -I$(OPENSSL_PATH)/include
 +LDFLAGS+=-L$(OPENSSL_PATH)/lib -lcrypto
  
diff --git a/devel/kore/files/patch-src_cli.c b/devel/kore/files/patch-src_cli.c
new file mode 100644
index 000000000000..fb0ba4393640
--- /dev/null
+++ b/devel/kore/files/patch-src_cli.c
@@ -0,0 +1,11 @@
+--- src/cli.c.orig	2022-08-22 11:18:44 UTC
++++ src/cli.c
+@@ -867,6 +867,8 @@ cli_ldflags(int argc, char **argv)
+ 	cli_kore_load_file("linker", NULL, &p, &len);
+ 	printf("%.*s ", (int)len, p);
+ 
++	printf("-I%%OPENSSLINC%% ");
++
+ #if defined(__MACH__)
+ 	printf("-dynamiclib -undefined suppress -flat_namespace ");
+ #else
diff --git a/devel/kore/files/patch-src_python.c b/devel/kore/files/patch-src_python.c
new file mode 100644
index 000000000000..1df8f209a100
--- /dev/null
+++ b/devel/kore/files/patch-src_python.c
@@ -0,0 +1,11 @@
+--- src/python.c.orig	2023-11-17 22:08:08 UTC
++++ src/python.c
+@@ -4828,7 +4828,7 @@ pyhttp_iterobj_next(struct pyhttp_iterobj *iterobj)
+ 	}
+ 
+ 	kore_buf_reset(&iterobj->buf);
+-	kore_buf_appendf(&iterobj->buf, "%lx\r\n", length);
++	kore_buf_appendf(&iterobj->buf, "%zx\r\n", length);
+ 	kore_buf_append(&iterobj->buf, ptr, length);
+ 	kore_buf_appendf(&iterobj->buf, "\r\n");
+ 
diff --git a/devel/kore/files/patch-tools_kore-serve_conf_build.conf b/devel/kore/files/patch-tools_kore-serve_conf_build.conf
new file mode 100644
index 000000000000..be1d1dc8c9a0
--- /dev/null
+++ b/devel/kore/files/patch-tools_kore-serve_conf_build.conf
@@ -0,0 +1,10 @@
+--- tools/kore-serve/conf/build.conf.orig	2022-08-22 11:18:44 UTC
++++ tools/kore-serve/conf/build.conf
+@@ -2,7 +2,6 @@ single_binary=yes
+ kore_source=../../
+ kore_flavor=NOTLS=1
+ 
+-cflags=-std=c99 -Werror
+ cflags=-Wall -Wmissing-declarations -Wshadow
+ cflags=-Wstrict-prototypes -Wmissing-prototypes
+ cflags=-Wpointer-arith -Wcast-qual -Wsign-compare