[PATCH bzip2 6/6] install a pkg-config file with instructions for linking to libbz2
~eschwartz
eschwartz@git.sr.ht
Fri Jun 3 05:09:12 GMT 2022
From: Eli Schwartz <eschwartz93@gmail.com>
A pkg-config file is necessary in order to robustly communicate across
build systems that bz2 is installed, *where* it is installed, and the
correct CFLAGS / LDFLAGS to use in order to compile and link against it.
---
Makefile.in | 3 +++
bzip2.pc.in | 11 +++++++++++
configure.ac | 2 +-
3 files changed, 15 insertions(+), 1 deletion(-)
create mode 100644 bzip2.pc.in
diff --git a/Makefile.in b/Makefile.in
index dff9422..86f1bdc 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -78,6 +78,7 @@ test: bzip2
install: bzip2 bzip2recover
if ( test ! -d $(DESTDIR)$(bindir) ) ; then mkdir -p $(DESTDIR)$(bindir) ; fi
if ( test ! -d $(DESTDIR)$(libdir) ) ; then mkdir -p $(DESTDIR)$(libdir) ; fi
+ if ( test ! -d $(DESTDIR)$(libdir)/pkgconfig ) ; then mkdir -p $(DESTDIR)$(libdir)/pkgconfig ; fi
if ( test ! -d $(DESTDIR)$(mandir) ) ; then mkdir -p $(DESTDIR)$(mandir) ; fi
if ( test ! -d $(DESTDIR)$(mandir)/man1 ) ; then mkdir -p $(DESTDIR)$(mandir)/man1 ; fi
if ( test ! -d $(DESTDIR)$(includedir) ) ; then mkdir -p $(DESTDIR)$(includedir) ; fi
@@ -116,6 +117,7 @@ install: bzip2 bzip2recover
echo ".so man1/bzgrep.1" > $(DESTDIR)$(mandir)/man1/bzfgrep.1
echo ".so man1/bzmore.1" > $(DESTDIR)$(mandir)/man1/bzless.1
echo ".so man1/bzdiff.1" > $(DESTDIR)$(mandir)/man1/bzcmp.1
+ cp -f bzip2.pc $(DESTDIR)$(libdir)/pkgconfig/bzip2.pc
clean:
rm -f *.o libbz2.a bzip2 bzip2recover \
@@ -165,6 +167,7 @@ dist: check manual
$(DISTNAME)/configure.ac \
$(DISTNAME)/configure \
$(DISTNAME)/Makefile.in \
+ $(DISTNAME)/bzip2.pc.in \
$(DISTNAME)/LICENSE \
$(DISTNAME)/bzip2.1 \
$(DISTNAME)/bzip2.1.preformatted \
diff --git a/bzip2.pc.in b/bzip2.pc.in
new file mode 100644
index 0000000..11c14e1
--- /dev/null
+++ b/bzip2.pc.in
@@ -0,0 +1,11 @@
+prefix=@prefix@
+exec_prefix=@exec_prefix@
+includedir=@includedir@
+libdir=@libdir@
+
+Name: bzip2
+URL: https://sourceware.org/bzip2/
+Description: A file compression library
+Version: @PACKAGE_VERSION@
+Libs: -L${libdir} -lbz2
+Cflags: -I${includedir}
diff --git a/configure.ac b/configure.ac
index 8f26062..5936b5c 100644
--- a/configure.ac
+++ b/configure.ac
@@ -5,6 +5,6 @@ AC_PROG_CC
AC_CHECK_TOOL([AR], [ar])
AC_CHECK_TOOL([RANLIB], [ranlib])
-AC_CONFIG_FILES([Makefile Makefile-libbz2_so])
+AC_CONFIG_FILES([Makefile Makefile-libbz2_so bzip2.pc])
AC_OUTPUT
--
2.34.2
More information about the Bzip2-devel
mailing list