I like to be able to look up lzlib via pkg-config, I searched the mailing list
and found that others want it too. So here are patches that make this work.
The install-pc target is not run by default, I leave it up to Antonio to decide
if the pkg-config file should be installed automatically or if install-pc has to
be run separately.

Niclas Rosenvik
--- configure.orig	2023-01-16 16:57:49.600274588 +0100
+++ configure	2023-01-16 18:04:42.582560847 +0100
@@ -28,6 +28,7 @@
 infodir='$(datarootdir)/info'
 libdir='$(exec_prefix)/lib'
 mandir='$(datarootdir)/man'
+pkgconfigdir='$(libdir)/pkgconfig'
 CC=gcc
 AR=ar
 CPPFLAGS=
@@ -76,6 +77,7 @@
 		echo "  --infodir=DIR         info files directory [${infodir}]"
 		echo "  --libdir=DIR          object code libraries [${libdir}]"
 		echo "  --mandir=DIR          man pages directory [${mandir}]"
+		echo "  --pkgconfigdir=DIR    pkg-config directory [${pkgconfigdir}]"
 		echo "  --disable-static      don't build a static library [enable]"
 		echo "                        (implies --enable-shared)"
 		echo "  --enable-shared       build also a shared library [disable]"
@@ -101,6 +103,8 @@
 	--infodir)          infodir=$1 ; arg2=yes ;;
 	--libdir)            libdir=$1 ; arg2=yes ;;
 	--mandir)            mandir=$1 ; arg2=yes ;;
+	--pkgconfigdir)
+			pkgconfigdir=$1 ; arg2=yes ;;
 
 	--srcdir=*)            srcdir=${optarg} ;;
 	--prefix=*)            prefix=${optarg} ;;
@@ -111,6 +115,8 @@
 	--infodir=*)          infodir=${optarg} ;;
 	--libdir=*)            libdir=${optarg} ;;
 	--mandir=*)            mandir=${optarg} ;;
+	--pkgconfigdir=*)
+			pkgconfigdir=${optarg} ;;
 	--no-create)              no_create=yes ;;
 	--disable-static)
 		progname_static=
@@ -194,6 +200,7 @@
 echo "infodir = ${infodir}"
 echo "libdir = ${libdir}"
 echo "mandir = ${mandir}"
+echo "pkgconfigdir = ${pkgconfigdir}"
 echo "CC = ${CC}"
 echo "AR = ${AR}"
 echo "CPPFLAGS = ${CPPFLAGS}"
@@ -227,6 +234,7 @@
 infodir = ${infodir}
 libdir = ${libdir}
 mandir = ${mandir}
+pkgconfigdir = ${pkgconfigdir}
 CC = ${CC}
 AR = ${AR}
 CPPFLAGS = ${CPPFLAGS}
@@ -236,4 +244,23 @@
 EOF
 cat "${srcdir}/Makefile.in" >> Makefile
 
+rm -f ${pkgname}.pc
+cat > ${pkgname}.pc << EOF
+prefix=${prefix}
+exec_prefix=${exec_prefix}
+includedir=${includedir}
+libdir=${libdir}
+
+Name: ${pkgname}
+Description: Compression library for the lzip file format
+URL: https://www.nongnu.org/lzip/lzlib.html
+Version: ${pkgversion}
+
+Cflags: -I\${includedir}
+Libs: -L\${libdir} -l${libname}
+EOF
+
+sed -e s/\(/{/g -e s/\)/}/g ${pkgname}.pc > ${pkgname}.pc.tmp
+mv -f ${pkgname}.pc.tmp ${pkgname}.pc
+
 echo "OK. Now you can run make."
--- Makefile.in.orig	2023-01-16 16:58:00.768342397 +0100
+++ Makefile.in	2023-01-16 17:47:21.397018437 +0100
@@ -144,6 +144,11 @@
 	-rm -f "$(DESTDIR)$(bindir)/lzip"
 	cd "$(DESTDIR)$(bindir)" && ln -s $(progname) lzip
 
+install-pc :
+	if [ ! -d "$(DESTDIR)$(pkgconfigdir)" ] ; then $(INSTALL_DIR) "$(DESTDIR)$(pkgconfigdir)" ; fi
+	-rm -f "$(DESTDIR)$(pkgconfigdir)/$(pkgname).pc"*
+	$(INSTALL_DATA) $(pkgname).pc "$(DESTDIR)$(pkgconfigdir)/$(pkgname).pc"
+
 uninstall : uninstall-info uninstall-lib
 
 uninstall-bin :
@@ -165,6 +170,9 @@
 uninstall-man :
 	-rm -f "$(DESTDIR)$(mandir)/man1/$(progname).1"*
 
+uninstall-pc :
+	-rm -f "$(DESTDIR)$(pkgconfigdir)/$(pkgname).pc"*
+
 dist : doc
 	ln -sf $(VPATH) $(DISTNAME)
 	tar -Hustar --owner=root --group=root -cvf $(DISTNAME).tar \

Reply via email to