git: ac175bd33a21 - main - Install working pkgconfig .pc files for compat libraries

From: Alex Richardson <arichardson_at_FreeBSD.org>
Date: Thu, 11 Aug 2022 22:46:51 UTC
The branch main has been updated by arichardson:

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

commit ac175bd33a21b7f357cffe37117dc5afa6d7c5fb
Author:     Alex Richardson <arichardson@FreeBSD.org>
AuthorDate: 2022-08-11 22:17:52 +0000
Commit:     Alex Richardson <arichardson@FreeBSD.org>
CommitDate: 2022-08-11 22:18:34 +0000

    Install working pkgconfig .pc files for compat libraries
    
    The default ones are install them to /usr/libdata/pkgconfig, and we can't
    use this path for compat libraries, so we use /usr/lib<suffix>/pkgconfigi here.
    
    Test Plan:      grep -rn libdir= ./usr/lib32/pkgconfig/*.pc
    MFC after:      1 week
    Differential Revision: https://reviews.freebsd.org/D34939
---
 Makefile.libcompat                             | 1 +
 etc/mtree/BSD.lib32.dist                       | 2 ++
 lib/liblzma/Makefile                           | 5 +++--
 lib/libmagic/Makefile                          | 6 +++---
 lib/libusb/Makefile                            | 6 ++++++
 lib/libusb/{libusb-0.1.pc => libusb-0.1.pc.in} | 5 +++--
 lib/libusb/{libusb-1.0.pc => libusb-1.0.pc.in} | 5 +++--
 lib/libusb/{libusb-2.0.pc => libusb-2.0.pc.in} | 5 +++--
 lib/libz/Makefile                              | 6 +++---
 lib/ncurses/tinfo/Makefile                     | 4 ++--
 share/mk/bsd.compat.mk                         | 1 +
 share/mk/bsd.lib.mk                            | 2 +-
 12 files changed, 31 insertions(+), 17 deletions(-)

diff --git a/Makefile.libcompat b/Makefile.libcompat
index a1f683c77a49..c8a71225f802 100644
--- a/Makefile.libcompat
+++ b/Makefile.libcompat
@@ -15,6 +15,7 @@ LIBCOMPATWMAKEENV+= \
 		SYSROOT=${WORLDTMP} \
 		LIBDIR=/usr/lib${libcompat} \
 		SHLIBDIR=/usr/lib${libcompat} \
+		LIBDATADIR=/usr/lib${libcompat} \
 		DTRACE="${LIB$COMPATDTRACE:U${DTRACE}}"
 .if ${MK_META_MODE} != "no"
 # Don't rebuild build-tools targets during normal build.
diff --git a/etc/mtree/BSD.lib32.dist b/etc/mtree/BSD.lib32.dist
index ce7d4bdc07fb..fb922224fc3c 100644
--- a/etc/mtree/BSD.lib32.dist
+++ b/etc/mtree/BSD.lib32.dist
@@ -18,5 +18,7 @@
             encoder
             ..
         ..
+        pkgconfig
+        ..
     ..
 ..
diff --git a/lib/liblzma/Makefile b/lib/liblzma/Makefile
index 4f38ef391e4a..0bdcc6af5ddc 100644
--- a/lib/liblzma/Makefile
+++ b/lib/liblzma/Makefile
@@ -159,8 +159,9 @@ PCFILES=	liblzma.pc
 liblzma.pc: liblzma.pc.in
 	sed -e 's,@prefix@,/usr,g ; \
 		s,@exec_prefix@,/usr,g ; \
-		s,@libdir@,/usr/lib,g ; \
-		s,@includedir@,/usr/include,g ; \
+		s,@libdir@,${LIBDIR},g ; \
+		s,@sharedlibdir@,${SHLIBDIR},g ; \
+		s,@includedir@,${INCLUDEDIR},g ; \
 		s,@LIBS@,-pthread -lmd,g ; \
 		s,@PACKAGE_URL@,https://tukaani.org/xz/,g ; \
 		s,@PACKAGE_VERSION@,${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH},g ; \
diff --git a/lib/libmagic/Makefile b/lib/libmagic/Makefile
index 5f967102fe02..3ddbf506eb81 100644
--- a/lib/libmagic/Makefile
+++ b/lib/libmagic/Makefile
@@ -42,9 +42,9 @@ PACKAGE_VERSION!=	sed -n '/define.*PACKAGE_VERSION/{s,[^0-9.],,gp;q;}' ${.CURDIR
 libmagic.pc: libmagic.pc.in
 	sed -e 's,@prefix@,/usr,g ; \
 		s,@exec_prefix@,$${prefix},g ; \
-		s,@libdir@,$${exec_prefix}/lib,g ; \
-		s,@sharedlibdir@,$${libdir},g ; \
-		s,@includedir@,$${prefix}/include,g ; \
+		s,@libdir@,${LIBDIR},g ; \
+		s,@sharedlibdir@,${SHLIBDIR},g ; \
+		s,@includedir@,${INCLUDEDIR},g ; \
 		s,@VERSION@,${PACKAGE_VERSION},g ; \
 		s,@LIBS@,,g ;' \
                 ${.ALLSRC} > ${.TARGET}
diff --git a/lib/libusb/Makefile b/lib/libusb/Makefile
index 3cb2fbd7a462..59389d74e179 100644
--- a/lib/libusb/Makefile
+++ b/lib/libusb/Makefile
@@ -35,6 +35,12 @@ SRCS+=		libusb10_hotplug.c
 SRCS+=		libusb10_io.c
 
 PCFILES=	libusb-0.1.pc libusb-1.0.pc libusb-2.0.pc
+.for pcfile in ${PCFILES}
+${pcfile}: ${pcfile}.in
+	sed -e 's,@libdir@,${LIBDIR},g ; s,@sharedlibdir@,${SHLIBDIR},g ; \
+		s,@includedir@,${INCLUDEDIR},g ;' ${.ALLSRC} > ${.TARGET}
+.endfor
+CLEANFILES+=	${PCFILES}
 
 #
 # Cross platform support
diff --git a/lib/libusb/libusb-0.1.pc b/lib/libusb/libusb-0.1.pc.in
similarity index 74%
rename from lib/libusb/libusb-0.1.pc
rename to lib/libusb/libusb-0.1.pc.in
index afd7a9960798..3082594415fd 100644
--- a/lib/libusb/libusb-0.1.pc
+++ b/lib/libusb/libusb-0.1.pc.in
@@ -1,8 +1,9 @@
 # $FreeBSD$
 prefix=/usr
 exec_prefix=${prefix}
-libdir=${exec_prefix}/lib
-includedir=${prefix}/include
+libdir=@libdir@
+sharedlibdir=@sharedlibdir@
+includedir=@includedir@
 
 Name: libusb-0.1
 Description: Library that abstracts ways to access USB devices (v0.1)
diff --git a/lib/libusb/libusb-1.0.pc b/lib/libusb/libusb-1.0.pc.in
similarity index 74%
rename from lib/libusb/libusb-1.0.pc
rename to lib/libusb/libusb-1.0.pc.in
index b31affadbed6..3a687bed2f10 100644
--- a/lib/libusb/libusb-1.0.pc
+++ b/lib/libusb/libusb-1.0.pc.in
@@ -1,8 +1,9 @@
 # $FreeBSD$
 prefix=/usr
 exec_prefix=${prefix}
-libdir=${exec_prefix}/lib
-includedir=${prefix}/include
+libdir=@libdir@
+sharedlibdir=@sharedlibdir@
+includedir=@includedir@
 
 Name: libusb-1.0
 Description: Library that abstracts ways to access USB devices (v1.0)
diff --git a/lib/libusb/libusb-2.0.pc b/lib/libusb/libusb-2.0.pc.in
similarity index 74%
rename from lib/libusb/libusb-2.0.pc
rename to lib/libusb/libusb-2.0.pc.in
index 34eabb88ab17..f35a9f7c6518 100644
--- a/lib/libusb/libusb-2.0.pc
+++ b/lib/libusb/libusb-2.0.pc.in
@@ -1,8 +1,9 @@
 # $FreeBSD$
 prefix=/usr
 exec_prefix=${prefix}
-libdir=${exec_prefix}/lib
-includedir=${prefix}/include
+libdir=@libdir@
+sharedlibdir=@sharedlibdir@
+includedir=@includedir@
 
 Name: libusb-2.0
 Description: Library that abstracts ways to access USB devices (v2.0)
diff --git a/lib/libz/Makefile b/lib/libz/Makefile
index d6155b6955a6..d8d466805649 100644
--- a/lib/libz/Makefile
+++ b/lib/libz/Makefile
@@ -63,9 +63,9 @@ ZLIB_VERSION!=	sed -n '/define.*ZLIB_VERSION/{s,[^0-9.],,gp;q;}' ${ZLIBSRC}/zlib
 zlib.pc: zlib.pc.in
 	sed -e 's,@prefix@,/usr,g ; \
 		s,@exec_prefix@,$${prefix},g ; \
-		s,@libdir@,$${exec_prefix}/lib,g ; \
-		s,@sharedlibdir@,$${libdir},g ; \
-		s,@includedir@,$${prefix}/include,g ; \
+		s,@libdir@,${LIBDIR},g ; \
+		s,@sharedlibdir@,${SHLIBDIR},g ; \
+		s,@includedir@,${INCLUDEDIR},g ; \
 		s,@VERSION@,${ZLIB_VERSION},g ;' \
 		${.ALLSRC} > ${.TARGET}
 
diff --git a/lib/ncurses/tinfo/Makefile b/lib/ncurses/tinfo/Makefile
index d7b7343dfcdc..fc4e4447562e 100644
--- a/lib/ncurses/tinfo/Makefile
+++ b/lib/ncurses/tinfo/Makefile
@@ -1038,9 +1038,9 @@ gen-pkgconfig: gen-pkgconfig.in
 		s,@PC_MODULE_SUFFIX@,,g ; \
 		s,@prefix@,/usr,g ; \
 		s,@exec_prefix@,$${prefix},g ; \
-		s,@includedir@,/usr/include,g ; \
+		s,@includedir@,${INCLUDEDIR},g ; \
 		s,@includesubdir@,,g ; \
-		s,@libdir@,/usr/lib,g ; \
+		s,@libdir@,${LIBDIR},g ; \
 		s,@RPATH_LIST@,$${libdir},g ; \
 		s,@PRIVATE_LIBS@,,g ; \
 		s,@USE_ARG_SUFFIX@,,g ; \
diff --git a/share/mk/bsd.compat.mk b/share/mk/bsd.compat.mk
index db6c82e099d9..f7b40ce47532 100644
--- a/share/mk/bsd.compat.mk
+++ b/share/mk/bsd.compat.mk
@@ -122,6 +122,7 @@ LIBCOMPATCFLAGS+=	-B${WORLDTMP}/usr/lib${libcompat}
 
 .if defined(WANT_COMPAT)
 LIBDIR_BASE:=	/usr/lib${libcompat}
+LIBDATADIR:=	/usr/lib${libcompat}
 _LIB_OBJTOP=	${LIBCOMPAT_OBJTOP}
 CFLAGS+=	${LIBCOMPATCFLAGS}
 LDFLAGS+=	${CFLAGS} ${LIBCOMPATLDFLAGS}
diff --git a/share/mk/bsd.lib.mk b/share/mk/bsd.lib.mk
index 5e58e1d010ab..c98dec9045bf 100644
--- a/share/mk/bsd.lib.mk
+++ b/share/mk/bsd.lib.mk
@@ -470,7 +470,7 @@ installpcfiles: installpcfiles-${pcfile}
 installpcfiles-${pcfile}: ${pcfile}
 	${INSTALL} ${TAG_ARGS:D${TAG_ARGS},dev} -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \
 	    ${_INSTALLFLAGS} \
-	    ${.ALLSRC} ${DESTDIR}${LIBDATADIR}/pkgconfig
+	    ${.ALLSRC} ${DESTDIR}${LIBDATADIR}/pkgconfig/
 .endfor
 .endif
 installpcfiles: .PHONY