git: ce9c325a2e92 - main - krb5: Build pkgconfig files with libraries

From: Lexi Winter <ivy_at_FreeBSD.org>
Date: Mon, 18 Aug 2025 18:59:15 UTC
The branch main has been updated by ivy:

URL: https://cgit.FreeBSD.org/src/commit/?id=ce9c325a2e9254eef3def2999a3b65848b574727

commit ce9c325a2e9254eef3def2999a3b65848b574727
Author:     Lexi Winter <ivy@FreeBSD.org>
AuthorDate: 2025-08-18 17:45:26 +0000
Commit:     Lexi Winter <ivy@FreeBSD.org>
CommitDate: 2025-08-18 18:57:59 +0000

    krb5: Build pkgconfig files with libraries
    
    For various reasons, trying to build 32-bit compatibility PCFILES
    outside of a directory which is not a library doesn't work. Add a
    new krb5/Makefile.pc with the build rule for .pc.in.pc, and use
    this to build each pc file along with the library it's associated
    with.
    
    This means we automatically get 32-bit pcfiles in /usr/lib32, and
    is arguably more correct anyway since if we don't build a library
    for some reason, we also won't build its pcfiles.
    
    Reviewed by:    des
    Differential Revision:  https://reviews.freebsd.org/D51986
---
 krb5/Makefile                          |  2 +-
 krb5/{libdata/Makefile => Makefile.pc} | 30 +++++-------------------------
 krb5/lib/gssapi/Makefile               | 13 ++++++++++---
 krb5/lib/kadm5clnt/Makefile            | 13 +++++++++----
 krb5/lib/kadm5srv/Makefile             | 13 +++++++++----
 krb5/lib/kdb/Makefile                  | 13 +++++++++----
 krb5/lib/krb5/Makefile                 | 14 ++++++++++----
 krb5/lib/rpc/Makefile                  | 13 +++++++++----
 8 files changed, 62 insertions(+), 49 deletions(-)

diff --git a/krb5/Makefile b/krb5/Makefile
index e9bbcae106c1..c49601990c4a 100644
--- a/krb5/Makefile
+++ b/krb5/Makefile
@@ -1,7 +1,7 @@
 SUBDIR=	util .WAIT \
 	include .WAIT \
 	lib .WAIT\
-	plugins libdata libexec usr.bin usr.sbin
+	plugins libexec usr.bin usr.sbin
 # SUBDIR_PARALLEL=
 
 .include <bsd.subdir.mk>
diff --git a/krb5/libdata/Makefile b/krb5/Makefile.pc
similarity index 73%
rename from krb5/libdata/Makefile
rename to krb5/Makefile.pc
index c9a2e8e9259f..693a4636d749 100644
--- a/krb5/libdata/Makefile
+++ b/krb5/Makefile.pc
@@ -2,26 +2,15 @@
 #
 # SPDX-License-Identifier: BSD-2-Clause OR ISC
 
-.include "../Makefile.inc"
-
-.PATH: ${KRB5_DIR}/build-tools
-
-PACKAGE=kerberos-lib
-
-PCFILES=gssrpc.pc \
-	kadm-client.pc \
-	kadm-server.pc \
-	kdb.pc \
-	krb5.pc \
-	krb5-gssapi.pc \
-	mit-krb5.pc \
-	mit-krb5-gssapi.pc
-
-CLEANFILES+=	${PCFILES}
 
 .SUFFIXES: .pc .pc.in
 
 .pc.in.pc:
+	@if ! grep -q "^PACKAGE_VERSION='${KRB5_VERSION}'$$" ${KRB5_DIR}/configure; then \
+		echo "KRB5_VERSION ${KRB5_VERSION} does not match the source:"; \
+		grep "^PACKAGE_VERSION=" ${KRB5_DIR}/configure; \
+		exit 1; \
+	fi >&2
 	sed -e 's,@prefix@,/usr,g ; \
 		s,@exec_prefix@,$${prefix},g ; \
 		s,@libdir@,${LIBDIR},g ; \
@@ -33,12 +22,3 @@ CLEANFILES+=	${PCFILES}
 		s,@DEFCKTNAME@,FILE:/var/krb5/user/%{euid}/client.keytab,g ; \
 		s,@COM_ERR_LIB@,-lcom_err,g ;' \
 		${.IMPSRC} > ${.TARGET}
-
-all: ${PCFILES}
-	@if ! grep -q "^PACKAGE_VERSION='${KRB5_VERSION}'$$" ${KRB5_DIR}/configure; then \
-		echo "KRB5_VERSION ${KRB5_VERSION} does not match the source:"; \
-		grep "^PACKAGE_VERSION=" ${KRB5_DIR}/configure; \
-		exit 1; \
-	fi >&2
-
-.include <bsd.lib.mk>
diff --git a/krb5/lib/gssapi/Makefile b/krb5/lib/gssapi/Makefile
index c3948c6ffe28..a434b29a2dfb 100644
--- a/krb5/lib/gssapi/Makefile
+++ b/krb5/lib/gssapi/Makefile
@@ -10,12 +10,15 @@
 .include <src.opts.mk>
 
 .include "../Makefile.inc"
+.include "${KRB5_SRCTOP}/Makefile.pc"
 
 LIB=		gssapi_krb5
-# SHLIB_MAJOR=	2
-LDFLAGS=-Wl,--no-undefined
-LIBADD=	krb5 k5crypto com_err krb5profile krb5support
+LDFLAGS=	-Wl,--no-undefined
+LIBADD=		krb5 k5crypto com_err krb5profile krb5support
 VERSION_MAP=	${.CURDIR}/version.map
+PCFILES=	krb5-gssapi.pc \
+		mit-krb5-gssapi.pc
+CLEANFILES+=	${PCFILES}
 
 # This is a contcatonation of:
 #	crypto/krb5/src/lib/gssapi/libgssapi_krb5.exports
@@ -44,4 +47,8 @@ CFLAGS+=${DEFINES} \
 
 .include <bsd.lib.mk>
 
+all: ${PCFILES}
+
 .SUFFIXES: .h .c .et
+
+.PATH: ${KRB5_DIR}/build-tools
diff --git a/krb5/lib/kadm5clnt/Makefile b/krb5/lib/kadm5clnt/Makefile
index 9b17644e86de..52a7187cf9bb 100644
--- a/krb5/lib/kadm5clnt/Makefile
+++ b/krb5/lib/kadm5clnt/Makefile
@@ -10,12 +10,14 @@
 .include <src.opts.mk>
 
 .include "../Makefile.inc"
+.include "${KRB5_SRCTOP}/Makefile.pc"
 
 LIB=		kadm5clnt_mit
-# SHLIB_MAJOR=	12
-LDFLAGS=-Wl,--no-undefined
-LIBADD=	krb5profile gssrpc gssapi_krb5 krb5 k5crypto krb5support com_err
+LDFLAGS=	-Wl,--no-undefined
+LIBADD=		krb5profile gssrpc gssapi_krb5 krb5 k5crypto krb5support com_err
 VERSION_MAP=	${.CURDIR}/version.map
+PCFILES=	kadm-client.pc
+CLEANFILES+=	${PCFILES}
 
 SRCS=	alt_prof.c \
 	chpass_util.c \
@@ -88,6 +90,9 @@ afterinstall:
 
 .include <bsd.lib.mk>
 
+all: ${PCFILES}
+
 .SUFFIXES: .h .c
 
-.PATH:	${KRB5_DIR}/lib/kadm5
+.PATH:	${KRB5_DIR}/build-tools \
+	${KRB5_DIR}/lib/kadm5
diff --git a/krb5/lib/kadm5srv/Makefile b/krb5/lib/kadm5srv/Makefile
index c3996af2225b..9eecd20ca822 100644
--- a/krb5/lib/kadm5srv/Makefile
+++ b/krb5/lib/kadm5srv/Makefile
@@ -10,12 +10,14 @@
 .include <src.opts.mk>
 
 .include "../Makefile.inc"
+.include "${KRB5_SRCTOP}/Makefile.pc"
 
 LIB=		kadm5srv_mit
-# SHLIB_MAJOR=	12
-LDFLAGS=-Wl,--no-undefined
-LIBADD=	krb5profile gssrpc gssapi_krb5 kdb5 krb5 k5crypto krb5support com_err
+LDFLAGS=	-Wl,--no-undefined
+LIBADD=		krb5profile gssrpc gssapi_krb5 kdb5 krb5 k5crypto krb5support com_err
 VERSION_MAP=	${.CURDIR}/version.map
+PCFILES=	kadm-server.pc
+CLEANFILES+=	${PCFILES}
 
 SRCS=	alt_prof.c \
 	chpass_util.c \
@@ -88,6 +90,9 @@ ${GEN_CHPASS_UTIL_STRINGS_C}: ${GEN_CHPASS_UTIL_STRINGS}
 
 .include <bsd.lib.mk>
 
+all: ${PCFILES}
+
 .SUFFIXES: .h .c .et
 
-.PATH:	${KRB5_DIR}/lib/kadm5
+.PATH:	${KRB5_DIR}/build-tools \
+	${KRB5_DIR}/lib/kadm5
diff --git a/krb5/lib/kdb/Makefile b/krb5/lib/kdb/Makefile
index d6fbc71b7584..80039ad83502 100644
--- a/krb5/lib/kdb/Makefile
+++ b/krb5/lib/kdb/Makefile
@@ -10,12 +10,14 @@
 .include <src.opts.mk>
 
 .include "../Makefile.inc"
+.include "${KRB5_SRCTOP}/Makefile.pc"
 
 LIB=		kdb5
-# SHLIB_MAJOR=	10
-LDFLAGS=-Wl,--no-undefined
-LIBADD=	krb5profile gssrpc krb5 k5crypto com_err krb5support gssapi_krb5
+LDFLAGS=	-Wl,--no-undefined
+LIBADD=		krb5profile gssrpc krb5 k5crypto com_err krb5support gssapi_krb5
 VERSION_MAP=	${.CURDIR}/version.map
+PCFILES=	kdb.pc
+CLEANFILES+=	${PCFILES}
 
 SRCS=	decrypt_key.c \
 	encrypt_key.c \
@@ -60,6 +62,9 @@ ${ADB_ERR_C}: ${ADB_ERR}
 
 .include <bsd.lib.mk>
 
+all: ${PCFILES}
+
 .SUFFIXES: .h .c
 
-.PATH:	${KRB5_DIR}/lib/kdb
+.PATH:	${KRB5_DIR}/build-tools \
+	${KRB5_DIR}/lib/kdb
diff --git a/krb5/lib/krb5/Makefile b/krb5/lib/krb5/Makefile
index a1576fcc256f..b3587cf58c2b 100644
--- a/krb5/lib/krb5/Makefile
+++ b/krb5/lib/krb5/Makefile
@@ -10,12 +10,15 @@
 .include <src.opts.mk>
 
 .include "../Makefile.inc"
+.include "${KRB5_SRCTOP}/Makefile.pc"
 
 LIB=		krb5
-LDFLAGS=-Wl,--no-undefined
-LIBADD=	krb5profile k5crypto com_err krb5support
-# SHLIB_MAJOR=	3
+LDFLAGS=	-Wl,--no-undefined
+LIBADD=		krb5profile k5crypto com_err krb5support
 VERSION_MAP=	${.CURDIR}/version.map
+PCFILES=	krb5.pc \
+		mit-krb5.pc
+CLEANFILES+=	${PCFILES}
 
 SRCS=	krb5_libinit.c
 
@@ -67,6 +70,8 @@ KDCPACKAGE=	kerberos-kdc
 
 .include <bsd.lib.mk>
 
+all: ${PCFILES}
+
 .SUFFIXES: .et .man
 
 .man.5:
@@ -75,5 +80,6 @@ KDCPACKAGE=	kerberos-kdc
 .man.7:
 	@cp ${.ALLSRC} ${.TARGET}
 
-.PATH:	${KRB5_DIR}/lib/krb5 \
+.PATH:	${KRB5_DIR}/build-tools \
+	${KRB5_DIR}/lib/krb5 \
 	${KRB5_DIR}/man
diff --git a/krb5/lib/rpc/Makefile b/krb5/lib/rpc/Makefile
index 6f09020261e1..7e37a5479132 100644
--- a/krb5/lib/rpc/Makefile
+++ b/krb5/lib/rpc/Makefile
@@ -10,12 +10,14 @@
 .include <src.opts.mk>
 
 .include "../Makefile.inc"
+.include "${KRB5_SRCTOP}/Makefile.pc"
 
 LIB=		gssrpc
-# SHLIB_MAJOR=	4
-LDFLAGS=-Wl,--no-undefined
-LIBADD=	gssapi_krb5 krb5 k5crypto com_err krb5support
+LDFLAGS=	-Wl,--no-undefined
+LIBADD=		gssapi_krb5 krb5 k5crypto com_err krb5support
 VERSION_MAP=	${.CURDIR}/version.map
+PCFILES=	gssrpc.pc
+CLEANFILES+=	${PCFILES}
 
 SRCS=	auth_gss.c \
 	auth_gssapi.c \
@@ -75,4 +77,7 @@ CFLAGS+=-I${KRB5_DIR}/lib/rpc \
 
 .include <bsd.lib.mk>
 
-.PATH:	${KRB5_DIR}/lib/rpc
+all: ${PCFILES}
+
+.PATH:	${KRB5_DIR}/build-tools \
+	${KRB5_DIR}/lib/rpc