Generate a pkg-config support file #140

We pull the version out of libdeflate.h into the
Makefile, and then sed a few macros out of the new
file libdeflate.pc.in. Set the necessary Cflags
and Libs (CFLAGS and LFLAGS) based off compile-time
definitions. Depend on the Makefile to pick up
version changes. Update uninstall target.

Signed-off-by: nick black <dankamongmen@gmail.com>
This commit is contained in:
nick black 2021-11-21 21:44:25 -05:00 committed by Eric Biggers
parent 22c0dd7afd
commit 0a2b40203d
2 changed files with 26 additions and 3 deletions

View File

@ -40,6 +40,8 @@
#
##############################################################################
VERSION=$(shell sed -n 's/\#define LIBDEFLATE_VERSION_STRING.*"\(.*\)"/\1/p' libdeflate.h)
#### Common compiler flags. You can add additional flags by defining CFLAGS
#### in the environment or on the 'make' command line.
####
@ -308,14 +310,24 @@ DEFAULT_TARGETS += gunzip$(PROG_SUFFIX)
all:$(DEFAULT_TARGETS)
# we don't generate the pkg-config file until install time, as needed
# definitions might not exist until then.
PKGCONFBASE:=libdeflate.pc.in
# Install the files. Note: not all versions of the 'install' program have the
# '-D' and '-t' options, so don't use them; use portable commands only.
install:all
install -d $(DESTDIR)$(LIBDIR) $(DESTDIR)$(INCDIR) $(DESTDIR)$(BINDIR)
install:all $(PKGCONFBASE)
install -d $(DESTDIR)$(LIBDIR)/pkgconfig $(DESTDIR)$(INCDIR) $(DESTDIR)$(BINDIR)
install -m644 $(STATIC_LIB) $(DESTDIR)$(LIBDIR)
if [ -z "$(DISABLE_SHARED)" ]; then \
install -m755 $(SHARED_LIB) $(DESTDIR)$(LIBDIR); \
fi
sed -e "s|@PREFIX@|$(PREFIX)|" \
-e "s|@LIBDIR@|$(LIBDIR)|" \
-e "s|@INCDIR@|$(INCDIR)|" \
-e "s|@VERSION@|$(VERSION)|" \
$(PKGCONFBASE) > \
$(DESTDIR)$(LIBDIR)/pkgconfig/$(basename $(PKGCONFBASE))
install -m644 libdeflate.h $(DESTDIR)$(INCDIR)
install -m755 gzip$(PROG_SUFFIX) \
$(DESTDIR)$(BINDIR)/libdeflate-gzip$(PROG_SUFFIX)
@ -331,7 +343,8 @@ uninstall:
$(DESTDIR)$(LIBDIR)/$(SHARED_LIB) \
$(DESTDIR)$(INCDIR)/libdeflate.h \
$(DESTDIR)$(BINDIR)/libdeflate-gzip$(PROG_SUFFIX) \
$(DESTDIR)$(BINDIR)/libdeflate-gunzip$(PROG_SUFFIX)
$(DESTDIR)$(BINDIR)/libdeflate-gunzip$(PROG_SUFFIX) \
$(DESTDIR)$(LIBDIR)/pkgconfig/libdeflate.pc
if [ -n "$(SHARED_LIB_SYMLINK)" ]; then \
rm -f $(DESTDIR)$(LIBDIR)/$(SHARED_LIB_SYMLINK); \
fi

10
libdeflate.pc.in Normal file
View File

@ -0,0 +1,10 @@
prefix=@PREFIX@
exec_prefix=${prefix}
includedir=@INCDIR@
libdir=@LIBDIR@
Name: libdeflate
Description: Fast implementation of DEFLATE, zlib, and gzip
Version: @VERSION@
Libs: -L${libdir} -ldeflate
Cflags: -I${includedir}