diff --git a/Makefile b/Makefile index 0541de9..b3f3f09 100644 --- a/Makefile +++ b/Makefile @@ -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 diff --git a/libdeflate.pc.in b/libdeflate.pc.in new file mode 100644 index 0000000..3ee55a3 --- /dev/null +++ b/libdeflate.pc.in @@ -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}