public inbox for linux-fscrypt@vger.kernel.org
 help / color / mirror / Atom feed
From: luca.boccassi@gmail.com
To: linux-fscrypt@vger.kernel.org
Subject: [fsverity-utils PATCH v2 2/2] Generate and install libfsverity.pc
Date: Mon, 26 Oct 2020 11:15:06 +0000	[thread overview]
Message-ID: <20201026111506.3215328-2-luca.boccassi@gmail.com> (raw)
In-Reply-To: <20201026111506.3215328-1-luca.boccassi@gmail.com>

From: Luca Boccassi <luca.boccassi@microsoft.com>

pkg-config is commonly used by libraries to convey information about
compiler flags and dependencies.
As packagers, we heavily rely on it so that all our tools do the right
thing by default regardless of the environment.

Signed-off-by: Luca Boccassi <luca.boccassi@microsoft.com>
---
v2: add pc file to .gitignore
    add and use QUIET_GEN prefix
    add install variables to .build-config
    have libfsverity.pc depend on lib/libfsverity.pc.in

 .gitignore            |  1 +
 Makefile              | 16 ++++++++++++++--
 lib/libfsverity.pc.in | 10 ++++++++++
 scripts/do-release.sh |  2 ++
 4 files changed, 27 insertions(+), 2 deletions(-)
 create mode 100644 lib/libfsverity.pc.in

diff --git a/.gitignore b/.gitignore
index 04f9a6f..572da31 100644
--- a/.gitignore
+++ b/.gitignore
@@ -9,5 +9,6 @@
 /run-tests.log
 /test_*
 cscope.*
+libfsverity.pc
 ncscope.*
 tags
diff --git a/Makefile b/Makefile
index d7e6eb2..6fdf91a 100644
--- a/Makefile
+++ b/Makefile
@@ -51,6 +51,7 @@ QUIET_CC        = @echo '  CC      ' $@;
 QUIET_CCLD      = @echo '  CCLD    ' $@;
 QUIET_AR        = @echo '  AR      ' $@;
 QUIET_LN        = @echo '  LN      ' $@;
+QUIET_GEN       = @echo '  GEN     ' $@;
 endif
 USE_SHARED_LIB  ?=
 PREFIX          ?= /usr/local
@@ -62,7 +63,7 @@ PKGCONF         ?= pkg-config
 
 # Rebuild if a user-specified setting that affects the build changed.
 .build-config: FORCE
-	@flags='$(CC):$(CFLAGS):$(CPPFLAGS):$(LDFLAGS):$(USE_SHARED_LIB)'; \
+	@flags='$(CC):$(CFLAGS):$(CPPFLAGS):$(LDFLAGS):$(USE_SHARED_LIB):$(PREFIX):$(LIBDIR):$(INCDIR):$(BINDIR)'; \
 	if [ "$$flags" != "`cat $@ 2>/dev/null`" ]; then		\
 		[ -e $@ ] && echo "Rebuilding due to new settings";	\
 		echo "$$flags" > $@;					\
@@ -119,6 +120,15 @@ libfsverity.so:libfsverity.so.$(SOVERSION)
 
 DEFAULT_TARGETS += libfsverity.so
 
+# Create the pkg-config file
+libfsverity.pc: lib/libfsverity.pc.in
+	$(QUIET_GEN) sed -e "s|@PREFIX@|$(PREFIX)|" \
+		-e "s|@LIBDIR@|$(LIBDIR)|" \
+		-e "s|@INCDIR@|$(INCDIR)|" \
+		$< > $@
+
+DEFAULT_TARGETS += libfsverity.pc
+
 ##############################################################################
 
 #### Programs
@@ -190,11 +200,12 @@ check:fsverity test_programs
 	@echo "All tests passed!"
 
 install:all
-	install -d $(DESTDIR)$(LIBDIR) $(DESTDIR)$(INCDIR) $(DESTDIR)$(BINDIR)
+	install -d $(DESTDIR)$(LIBDIR)/pkgconfig $(DESTDIR)$(INCDIR) $(DESTDIR)$(BINDIR)
 	install -m755 fsverity $(DESTDIR)$(BINDIR)
 	install -m644 libfsverity.a $(DESTDIR)$(LIBDIR)
 	install -m755 libfsverity.so.$(SOVERSION) $(DESTDIR)$(LIBDIR)
 	ln -sf libfsverity.so.$(SOVERSION) $(DESTDIR)$(LIBDIR)/libfsverity.so
+	install -m644 libfsverity.pc $(DESTDIR)$(LIBDIR)/pkgconfig
 	install -m644 include/libfsverity.h $(DESTDIR)$(INCDIR)
 
 uninstall:
@@ -202,6 +213,7 @@ uninstall:
 	rm -f $(DESTDIR)$(LIBDIR)/libfsverity.a
 	rm -f $(DESTDIR)$(LIBDIR)/libfsverity.so.$(SOVERSION)
 	rm -f $(DESTDIR)$(LIBDIR)/libfsverity.so
+	rm -f $(DESTDIR)$(LIBDIR)/pkgconfig/libfsverity.pc
 	rm -f $(DESTDIR)$(INCDIR)/libfsverity.h
 
 help:
diff --git a/lib/libfsverity.pc.in b/lib/libfsverity.pc.in
new file mode 100644
index 0000000..613e9bc
--- /dev/null
+++ b/lib/libfsverity.pc.in
@@ -0,0 +1,10 @@
+prefix=@PREFIX@
+libdir=@LIBDIR@
+includedir=@INCDIR@
+
+Name: libfsverity
+Description: fs-verity library
+Version: 1.2
+Libs: -L${libdir} -lfsverity
+Requires.private: libcrypto
+Cflags: -I${includedir}
diff --git a/scripts/do-release.sh b/scripts/do-release.sh
index 255fc53..352fcf1 100755
--- a/scripts/do-release.sh
+++ b/scripts/do-release.sh
@@ -28,6 +28,8 @@ minor=$(echo "$VERS" | cut -d. -f2)
 sed -E -i -e "/FSVERITY_UTILS_MAJOR_VERSION/s/[0-9]+/$major/" \
 	  -e "/FSVERITY_UTILS_MINOR_VERSION/s/[0-9]+/$minor/" \
 	  include/libfsverity.h
+sed -E -i "/Version:/s/[0-9]+\.[0-9]+/$VERS/" \
+	  lib/libfsverity.pc.in
 git commit -a --signoff --message="v$VERS"
 git tag --sign "v$VERS" --message="$PKG"
 
-- 
2.20.1


  reply	other threads:[~2020-10-26 11:15 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-22 17:59 [fsverity-utils PATCH 1/2] Use pkg-config to get libcrypto build flags luca.boccassi
2020-10-22 17:59 ` [fsverity-utils PATCH 2/2] Generate and install libfsverity.pc luca.boccassi
2020-10-24  3:56   ` Eric Biggers
2020-10-26 11:16     ` Luca Boccassi
2020-10-24  4:07 ` [fsverity-utils PATCH 1/2] Use pkg-config to get libcrypto build flags Eric Biggers
2020-10-26 11:16   ` Luca Boccassi
2020-10-26 11:15 ` [fsverity-utils PATCH v2 " luca.boccassi
2020-10-26 11:15   ` luca.boccassi [this message]
2020-10-26 17:32     ` [fsverity-utils PATCH v2 2/2] Generate and install libfsverity.pc Eric Biggers
2020-10-26 17:32   ` [fsverity-utils PATCH v2 1/2] Use pkg-config to get libcrypto build flags Eric Biggers

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20201026111506.3215328-2-luca.boccassi@gmail.com \
    --to=luca.boccassi@gmail.com \
    --cc=linux-fscrypt@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox