git: 41067961b6f3 - stable/13 - openssl: install pc files

From: Baptiste Daroussin <bapt_at_FreeBSD.org>
Date: Wed, 12 Oct 2022 08:34:16 UTC
The branch stable/13 has been updated by bapt:

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

commit 41067961b6f3a0b5667e40e768b7b46e4092348e
Author:     Baptiste Daroussin <bapt@FreeBSD.org>
AuthorDate: 2022-08-26 14:02:09 +0000
Commit:     Baptiste Daroussin <bapt@FreeBSD.org>
CommitDate: 2022-10-12 08:34:03 +0000

    openssl: install pc files
    
    most programs in ports are looking for .pc files in order to get the
    necessary information on how to compile and link against openssl.
    
    The ports now also has a way to hide or force a path for pkgconf.
    
    Providing .pc files along with openssl in base will allow (once all
    the supported version of FreeBSD has it) so improve the framework to
    deal with openssl in base vs openssl in ports (and libressl)
    
    This will also greatly reduce the number of patches necessary to
    workaround the build systems which only knows how to detect where
    openssl is installed via pkgconf.
    
    PR:             266051
    MFC After:      3 weeks
    Reviewed by:    jkim, delphij
    Exp-run by:     antoine
    Differential Revision:  https://reviews.freebsd.org/D36360
    
    (cherry picked from commit b323fa85f15268ac44b8ff90faf90bce5d87b608)
---
 secure/lib/libcrypto/Makefile        |  1 +
 secure/lib/libcrypto/Makefile.inc    |  6 ++++++
 secure/lib/libcrypto/libcrypto.pc.in | 12 ++++++++++++
 secure/lib/libssl/Makefile           |  2 ++
 secure/lib/libssl/libssl.pc.in       | 11 +++++++++++
 secure/lib/libssl/openssl.pc.in      |  9 +++++++++
 6 files changed, 41 insertions(+)

diff --git a/secure/lib/libcrypto/Makefile b/secure/lib/libcrypto/Makefile
index cf9259a19e16..8a38f0f563a0 100644
--- a/secure/lib/libcrypto/Makefile
+++ b/secure/lib/libcrypto/Makefile
@@ -12,6 +12,7 @@ SHLIB_MAJOR=	111
 VERSION_MAP=	${.CURDIR}/Version.map
 
 NO_LINT=
+PCFILES=	libcrypto.pc
 
 .include "Makefile.man"
 .include "Makefile.inc"
diff --git a/secure/lib/libcrypto/Makefile.inc b/secure/lib/libcrypto/Makefile.inc
index 846692c679c6..2fa17420be43 100644
--- a/secure/lib/libcrypto/Makefile.inc
+++ b/secure/lib/libcrypto/Makefile.inc
@@ -113,3 +113,9 @@ CFLAGS+=	-DENGINESDIR="\"${LIBDIR}/engines\""
 CFLAGS+=	-DNDEBUG
 
 MANDIR=		${SHAREDIR}/openssl/man/man
+
+.for pcfile in ${PCFILES}
+${pcfile}:	${pcfile}.in
+	sed -e 's,@openssl_ver@,${OPENSSL_VER},g' ${.ALLSRC} > ${.TARGET}
+.endfor
+CLEANFILES+=	${PCFILES}
diff --git a/secure/lib/libcrypto/libcrypto.pc.in b/secure/lib/libcrypto/libcrypto.pc.in
new file mode 100644
index 000000000000..d0da079d9f19
--- /dev/null
+++ b/secure/lib/libcrypto/libcrypto.pc.in
@@ -0,0 +1,12 @@
+prefix=/usr
+exec_prefix=${prefix}
+libdir=${exec_prefix}/lib
+includedir=${prefix}/include
+enginesdir=${libdir}/engines
+
+Name: OpenSSL-libcrypto
+Description: OpenSSL cryptography library
+Version: @openssl_ver@
+Libs: -L${libdir} -lcrypto
+Libs.private: -pthread 
+Cflags: -I${includedir}
diff --git a/secure/lib/libssl/Makefile b/secure/lib/libssl/Makefile
index 893ea6ebed79..8c72c6221056 100644
--- a/secure/lib/libssl/Makefile
+++ b/secure/lib/libssl/Makefile
@@ -9,6 +9,8 @@ PACKAGE=	openssl
 
 NO_LINT=
 
+PCFILES=	libssl.pc openssl.pc
+
 .include "../libcrypto/Makefile.inc"
 
 SRCS=	bio_ssl.c d1_lib.c d1_msg.c d1_srtp.c methods.c packet.c pqueue.c
diff --git a/secure/lib/libssl/libssl.pc.in b/secure/lib/libssl/libssl.pc.in
new file mode 100644
index 000000000000..c3cf2b606e65
--- /dev/null
+++ b/secure/lib/libssl/libssl.pc.in
@@ -0,0 +1,11 @@
+prefix=/usr/
+exec_prefix=${prefix}
+libdir=${exec_prefix}/lib
+includedir=${prefix}/include
+
+Name: OpenSSL-libssl
+Description: Secure Sockets Layer and cryptography libraries
+Version: @openssl_ver@
+Requires.private: libcrypto
+Libs: -L${libdir} -lssl
+Cflags: -I${includedir}
diff --git a/secure/lib/libssl/openssl.pc.in b/secure/lib/libssl/openssl.pc.in
new file mode 100644
index 000000000000..f2d849dc70ac
--- /dev/null
+++ b/secure/lib/libssl/openssl.pc.in
@@ -0,0 +1,9 @@
+prefix=/usr/
+exec_prefix=${prefix}
+libdir=${exec_prefix}/lib
+includedir=${prefix}/include
+
+Name: OpenSSL
+Description: Secure Sockets Layer and cryptography libraries and tools
+Version: @openssl_ver@
+Requires: libssl libcrypto