From patchwork Thu Oct 22 17:59:33 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luca Boccassi X-Patchwork-Id: 11851743 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 511E216BC for ; Thu, 22 Oct 2020 17:59:54 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1F5F221534 for ; Thu, 22 Oct 2020 17:59:54 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="lSaY1v7H" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S369475AbgJVR7x (ORCPT ); Thu, 22 Oct 2020 13:59:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37904 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S368666AbgJVR7x (ORCPT ); Thu, 22 Oct 2020 13:59:53 -0400 Received: from mail-wm1-x341.google.com (mail-wm1-x341.google.com [IPv6:2a00:1450:4864:20::341]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 88CD5C0613CE for ; Thu, 22 Oct 2020 10:59:52 -0700 (PDT) Received: by mail-wm1-x341.google.com with SMTP id l15so3397493wmi.3 for ; Thu, 22 Oct 2020 10:59:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=5yfHbieTQRmUltQv9ufETZDmgk21Lswzw+/9hf6In+Q=; b=lSaY1v7Hc0gKXcibQS6YllbbsOHl6yEAV42TnT+wvaFHvInWQ7iAaJ2ur4zLn2Mp/J HYqDSqb20Fg584Trt4HqtSRWGylQSFsFGdxL6h9rj/dmFJ7EcXwYd3X///trSimiPrr2 PL5BQTame7iIQhpHHqa5IPb84FUTQZINKNE5n9WY19lMlvCXouheFAOVYXLMekeOSXx+ k1SM7UbBp8U+Iy/sXeEWRzSVOFupUNlkVy2Rkrh6pHigLuHUFwVkDRmyOmH2SwT9YwxO qAe4UBz+MgzGak0U8zvrxEc5ej/XZ3tdI+2eCydtkau15JPWTbujya9tvFtvW+HinlSr ZA1A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=5yfHbieTQRmUltQv9ufETZDmgk21Lswzw+/9hf6In+Q=; b=rkM3uRTsBBwm780YnYEuOomHTjlRs+6K4Cc/SEd4G+6uy5lmC6WCvKiYxG1zj7ws5g RCu24hsOLpL2XfJUA3poIeGg221dayNYl7kp0CGP1ixv10p6hpfceKa8Lb2BHnigVadK cDTLJpQPwsw3ad2seXrswepTUhcu1sNkJsJtC6pg9GMldhBjIRBQcSPvKg8mgBKK+hRL nEzOBNv0tUCd9KfwcKu2XszaMLgGiL7sIw8IDlj4B+LFF1eFNH/GRK0CE4v6l+QJUo+Z FC5T25MwEoiAC5JESSnZ0kxYRizsZ9FKf43i2S0j3Ep2tEU4U74440xLPxgWyRXOxAMZ cqSg== X-Gm-Message-State: AOAM530GLYTF6yEBuwUKz0+D3XmhD7qCo2ILrA9n76PrkgmxssYffIFi MDxnWRvUvaUG6Xp2Lw6OFvQPDovVaYj0Ow== X-Google-Smtp-Source: ABdhPJzg9XfOyeBAXwC77KZltUy/NmbUg1jsh449N7K3p1kk6lpsJY70RFBhJfSkNcIBSUwmey49VA== X-Received: by 2002:a1c:a90e:: with SMTP id s14mr3779754wme.46.1603389590332; Thu, 22 Oct 2020 10:59:50 -0700 (PDT) Received: from localhost ([88.98.246.218]) by smtp.gmail.com with ESMTPSA id j13sm5252070wru.86.2020.10.22.10.59.48 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Oct 2020 10:59:49 -0700 (PDT) From: luca.boccassi@gmail.com To: linux-fscrypt@vger.kernel.org Subject: [fsverity-utils PATCH 1/2] Use pkg-config to get libcrypto build flags Date: Thu, 22 Oct 2020 18:59:33 +0100 Message-Id: <20201022175934.2999543-1-luca.boccassi@gmail.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-fscrypt@vger.kernel.org From: Luca Boccassi Especially when cross-compiling or other such cases, it might be necessary to pass additional compiler flags. This is commonly done via pkg-config, so use it if available, and fall back to the hardcoded -lcrypto if not. Signed-off-by: Luca Boccassi --- Makefile | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 3fc1bec..122c0a2 100644 --- a/Makefile +++ b/Makefile @@ -58,6 +58,7 @@ BINDIR ?= $(PREFIX)/bin INCDIR ?= $(PREFIX)/include LIBDIR ?= $(PREFIX)/lib DESTDIR ?= +PKGCONF ?= pkg-config # Rebuild if a user-specified setting that affects the build changed. .build-config: FORCE @@ -69,7 +70,8 @@ DESTDIR ?= DEFAULT_TARGETS := COMMON_HEADERS := $(wildcard common/*.h) -LDLIBS := -lcrypto +LDLIBS := $(shell $(PKGCONF) libcrypto --libs 2>/dev/null || echo -lcrypto) +CFLAGS += $(shell $(PKGCONF) libcrypto --cflags 2>/dev/null || echo) # If we are dynamically linking, when running tests we need to override # LD_LIBRARY_PATH as no RPATH is set From patchwork Thu Oct 22 17:59:34 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luca Boccassi X-Patchwork-Id: 11851745 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id F301914B7 for ; Thu, 22 Oct 2020 18:00:02 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C7ABB2466D for ; Thu, 22 Oct 2020 18:00:02 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="hbQy9Odq" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2504374AbgJVSAC (ORCPT ); Thu, 22 Oct 2020 14:00:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37916 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S369478AbgJVR76 (ORCPT ); Thu, 22 Oct 2020 13:59:58 -0400 Received: from mail-wr1-x442.google.com (mail-wr1-x442.google.com [IPv6:2a00:1450:4864:20::442]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B8699C0613CE for ; Thu, 22 Oct 2020 10:59:56 -0700 (PDT) Received: by mail-wr1-x442.google.com with SMTP id x7so3674284wrl.3 for ; Thu, 22 Oct 2020 10:59:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=3COIAKMiRaCZvU+z1UGm0wDOnatxAwrbULuU6Uy5+Eo=; b=hbQy9OdqPNMPCNUWc3zSFS8O6eV7cqfBkCi8lkwQ5nRDdZL/3lS6ajblswKPSFHFjT c61J91z6MsZ8pf4Unscw6nL1s8o3+CgTqsYfFGSfYDNbDIu0pEwuGfz0seqZOlKEFxzY 8GAXwGW5FBc518AgkSrDjrluBW0pY1YUTOTn+O/KjYuH1GGOquniln+1aexyj2/SpFXt dkRPNy8XYdDOmWFRMkvgY+CQQ5klYfBCYb0oA9yPuziuHad1RZIRVWtmwpFbEUuE7ojY vTZjhHclJx47ikOChcwqOYHe54nPIjF47eB6mRIb9gRLkDLVv8ewDGNRqL88e/VHrBRP 3LNg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=3COIAKMiRaCZvU+z1UGm0wDOnatxAwrbULuU6Uy5+Eo=; b=rJcuii5IAAqAaDCxyIw4jaRW/irgQmRnEz92AJIAlHStVhagwr6NdYACf9vewhoAq/ yifiWsDZpKi17Nd2oUAtt5E0EkPVwEXUUcj+2eCxHvFXgOTGEEf/2rlie8JkrKcb35sp CaUYNBBaweNWoCX2FmFdeMLNdGbEBkYXxi6xe9ERE3/oCeFpoJ1LWxmpZ4Yayib9HFOm QOrfVYgtlBDb/wpXFkIF67jc7CB/x+IZTu7C8vRGyWgXP94KsLr81JALCrfN2QyFtxU/ Lr0lxF1qjuFOV2AFp9ir/7eQv+mRnc1KnsFlCtXoGIMzZzQKTJE2KcH/iFMaMZrvaSba 7jCA== X-Gm-Message-State: AOAM531nWjoI/qF0gazxc4nGrFGqrz41I7t5h/kFybUpaTOPd4Fd79AP Tiew/agqUndDHHDUZiBATU4yaikjRDoNpw== X-Google-Smtp-Source: ABdhPJzEi6Hqu3h0HoxGCNP73fFwdAeHFtbqr6Fj4HqV+kNFRugrQn/hicvWuSw3MpP8N1Lt52tAmw== X-Received: by 2002:adf:e8c7:: with SMTP id k7mr3989755wrn.102.1603389595041; Thu, 22 Oct 2020 10:59:55 -0700 (PDT) Received: from localhost ([88.98.246.218]) by smtp.gmail.com with ESMTPSA id x81sm4902822wmb.11.2020.10.22.10.59.54 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Oct 2020 10:59:54 -0700 (PDT) From: luca.boccassi@gmail.com To: linux-fscrypt@vger.kernel.org Subject: [fsverity-utils PATCH 2/2] Generate and install libfsverity.pc Date: Thu, 22 Oct 2020 18:59:34 +0100 Message-Id: <20201022175934.2999543-2-luca.boccassi@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20201022175934.2999543-1-luca.boccassi@gmail.com> References: <20201022175934.2999543-1-luca.boccassi@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-fscrypt@vger.kernel.org From: Luca Boccassi 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 --- Makefile | 13 ++++++++++++- lib/libfsverity.pc.in | 10 ++++++++++ scripts/do-release.sh | 2 ++ 3 files changed, 24 insertions(+), 1 deletion(-) create mode 100644 lib/libfsverity.pc.in diff --git a/Makefile b/Makefile index 122c0a2..07b828f 100644 --- a/Makefile +++ b/Makefile @@ -119,6 +119,15 @@ libfsverity.so:libfsverity.so.$(SOVERSION) DEFAULT_TARGETS += libfsverity.so +# Create the pkg-config file +libfsverity.pc: + sed -e "s|@PREFIX@|$(PREFIX)|" \ + -e "s|@LIBDIR@|$(LIBDIR)|" \ + -e "s|@INCDIR@|$(INCDIR)|" \ + lib/libfsverity.pc.in > $@ + +DEFAULT_TARGETS += libfsverity.pc + ############################################################################## #### Programs @@ -190,11 +199,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 +212,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"