@@ -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