public inbox for linux-fscrypt@vger.kernel.org
 help / color / mirror / Atom feed
From: Eric Biggers <ebiggers@kernel.org>
To: Jes Sorensen <jes.sorensen@gmail.com>
Cc: linux-fscrypt@vger.kernel.org, kernel-team@fb.com,
	Jes Sorensen <jsorensen@fb.com>
Subject: Re: [PATCH 1/9] Build basic shared library framework
Date: Sat, 21 Mar 2020 22:23:43 -0700	[thread overview]
Message-ID: <20200322052343.GE111151@sol.localdomain> (raw)
In-Reply-To: <20200312214758.343212-2-Jes.Sorensen@gmail.com>

On Thu, Mar 12, 2020 at 05:47:50PM -0400, Jes Sorensen wrote:
> From: Jes Sorensen <jsorensen@fb.com>
> 
> This introduces a dummy shared library to start moving things into.
> 
> Signed-off-by: Jes Sorensen <jsorensen@fb.com>
> ---
>  Makefile    | 18 +++++++++++++++---
>  libverity.c | 10 ++++++++++
>  2 files changed, 25 insertions(+), 3 deletions(-)
>  create mode 100644 libverity.c
> 
> diff --git a/Makefile b/Makefile
> index b9c09b9..bb85896 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -1,20 +1,32 @@
>  EXE := fsverity
> +LIB := libfsverity.so
>  CFLAGS := -O2 -Wall
>  CPPFLAGS := -D_FILE_OFFSET_BITS=64
>  LDLIBS := -lcrypto
>  DESTDIR := /usr/local
> +LIBDIR := /usr/lib64
>  SRC := $(wildcard *.c)
> -OBJ := $(SRC:.c=.o)
> +OBJ := fsverity.o hash_algs.o cmd_enable.o cmd_measure.o cmd_sign.o util.o
> +SSRC := libverity.c
> +SOBJ := libverity.so
>  HDRS := $(wildcard *.h)
>  
>  all:$(EXE)
>  
> -$(EXE):$(OBJ)
> +$(EXE):$(OBJ) $(LIB)
> +	$(CC) -o $@ $(OBJ) $(LDLIBS) -L . -l fsverity
>  
>  $(OBJ): %.o: %.c $(HDRS)
> +	$(CC) -c $(CFLAGS) $(CPPFLAGS) $< -o $@
> +
> +$(SOBJ): %.so: %.c $(HDRS)
> +	$(CC) -c -fPIC $(CFLAGS) $(CPPFLAGS) $< -o $@
> +
> +libfsverity.so: $(SOBJ)
> +	$(CC) $(LDLIBS) -shared -o libfsverity.so $(SOBJ)
>  
>  clean:
> -	rm -f $(EXE) $(OBJ)
> +	rm -f $(EXE) $(OBJ) $(SOBJ) $(LIB)
>  
>  install:all
>  	install -Dm755 -t $(DESTDIR)/bin $(EXE)
> diff --git a/libverity.c b/libverity.c
> new file mode 100644
> index 0000000..6821aa2
> --- /dev/null
> +++ b/libverity.c
> @@ -0,0 +1,10 @@
> +// SPDX-License-Identifier: GPL-2.0+
> +/*
> + * The 'fsverity library'
> + *
> + * Copyright (C) 2018 Google LLC
> + * Copyright (C) 2020 Facebook
> + *
> + * Written by Eric Biggers and Jes Sorensen.
> + */
> +

Could you preserve the option to build the 'fsverity' program as a statically
linked binary?  Having to deal with installing libfsverity.so in some
environments can be annoying.

We maybe should use proper build system that would handle things like this --
though, for small projects like this it's nice to just have a simple Makefile.
What I've done in another project that uses just a Makefile is support building
both a static library a shared library, where the static library is created from
.o files and the shared library is built from .shlib.o files.  Then the binaries
can be linked to either one based on a 'make' variable.

- Eric

  reply	other threads:[~2020-03-22  5:23 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-12 21:47 [PATCH v3 0/9] Split fsverity-utils into a shared library Jes Sorensen
2020-03-12 21:47 ` [PATCH 1/9] Build basic shared library framework Jes Sorensen
2020-03-22  5:23   ` Eric Biggers [this message]
2020-03-22  5:33   ` Eric Biggers
2020-04-21 21:00     ` Jes Sorensen
2020-03-12 21:47 ` [PATCH 2/9] Change compute_file_measurement() to take a file descriptor as argument Jes Sorensen
2020-03-12 21:47 ` [PATCH 3/9] Move fsverity_descriptor definition to libfsverity.h Jes Sorensen
2020-03-22  4:57   ` Eric Biggers
2020-04-21 16:07     ` Jes Sorensen
2020-04-21 16:16       ` Eric Biggers
2020-04-21 16:20         ` Jes Sorensen
2020-03-12 21:47 ` [PATCH 4/9] Move hash algorithm code to shared library Jes Sorensen
2020-03-22  5:38   ` Eric Biggers
2020-04-22 17:57     ` Jes Sorensen
2020-03-12 21:47 ` [PATCH 5/9] Create libfsverity_compute_digest() and adapt cmd_sign to use it Jes Sorensen
2020-03-22  5:40   ` Eric Biggers
2020-03-12 21:47 ` [PATCH 6/9] Introduce libfsverity_sign_digest() Jes Sorensen
2020-03-12 21:47 ` [PATCH 7/9] Validate input arguments to libfsverity_compute_digest() Jes Sorensen
2020-03-12 21:47 ` [PATCH 8/9] Validate input parameters for libfsverity_sign_digest() Jes Sorensen
2020-03-22  5:27   ` Eric Biggers
2020-03-12 21:47 ` [PATCH 9/9] Document API of libfsverity Jes Sorensen
2020-03-22  5:54   ` Eric Biggers
2020-03-22  5:05 ` [PATCH v3 0/9] Split fsverity-utils into a shared library 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=20200322052343.GE111151@sol.localdomain \
    --to=ebiggers@kernel.org \
    --cc=jes.sorensen@gmail.com \
    --cc=jsorensen@fb.com \
    --cc=kernel-team@fb.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