On Thu, Mar 12, 2020 at 05:47:50PM -0400, Jes Sorensen wrote: > From: Jes Sorensen <jsorensen@xxxxxx> > > This introduces a dummy shared library to start moving things into. > > Signed-off-by: Jes Sorensen <jsorensen@xxxxxx> > --- > 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