From: Jes Sorensen <jsorensen@xxxxxx> In addition this adds a 'static' build target, which links in libfsverity statically rather than relying on the shared library. This also honors PREFIX for installation location. Signed-off-by: Jes Sorensen <jsorensen@xxxxxx> --- Makefile | 34 ++++++++++++++++++++++++++-------- 1 file changed, 26 insertions(+), 8 deletions(-) diff --git a/Makefile b/Makefile index 966afa0..5bbcd87 100644 --- a/Makefile +++ b/Makefile @@ -1,34 +1,52 @@ EXE := fsverity +STATIC := fsverity-static LIB := libfsverity.so +INC := libfsverity.h CFLAGS := -O2 -Wall CPPFLAGS := -D_FILE_OFFSET_BITS=64 LDLIBS := -lcrypto -DESTDIR := /usr/local -LIBDIR := /usr/lib64 +PREFIX = /usr +BINDIR := $(PREFIX)/bin +LIBDIR := $(PREFIX)/lib64 +INCDIR := $(PREFIX)/include SRC := $(wildcard *.c) OBJ := fsverity.o cmd_enable.o cmd_measure.o cmd_sign.o util.o SSRC := libverity.c hash_algs.c -SOBJ := libverity.so hash_algs.so +SHOBJ := libverity.so hash_algs.so +STOBJ := libverity.o hash_algs.o HDRS := $(wildcard *.h) all:$(EXE) +static:$(STATIC) + $(EXE):$(OBJ) $(LIB) $(CC) -o $@ $(OBJ) $(LDLIBS) -L . -l fsverity +$(STATIC):$(OBJ) $(STOBJ) + $(CC) -o $@ $(OBJ) $(STOBJ) $(LDLIBS) + $(OBJ): %.o: %.c $(HDRS) $(CC) -c $(CFLAGS) $(CPPFLAGS) $< -o $@ -$(SOBJ): %.so: %.c $(HDRS) +$(STOBJ): %.o: %.c $(HDRS) + $(CC) -c $(CFLAGS) $(CPPFLAGS) $< -o $@ + +$(SHOBJ): %.so: %.c $(HDRS) $(CC) -c -fPIC $(CFLAGS) $(CPPFLAGS) $< -o $@ -libfsverity.so: $(SOBJ) - $(CC) $(LDLIBS) -shared -o libfsverity.so $(SOBJ) +libfsverity.so: $(SHOBJ) + $(CC) $(LDLIBS) -shared -o $@ $(SHOBJ) clean: - rm -f $(EXE) $(OBJ) $(SOBJ) $(LIB) + rm -f $(EXE) $(OBJ) $(SHOBJ) $(LIB) $(STOBJ) $(STATIC) install:all - install -Dm755 -t $(DESTDIR)/bin $(EXE) + install -Dm755 -t $(BINDIR) $(EXE) + install -Dm755 -t $(LIBDIR) $(LIB) + install -Dm644 -t $(INCDIR) $(INC) + +install-static:static + install -Dm755 -t $(BINDIR) $(STATIC) .PHONY: all clean install -- 2.25.3