@@ -1,6 +1,5 @@
EXE := fsverity
STATIC := fsverity-static
-LIB := libfsverity.so
INC := libfsverity.h
CFLAGS := -O2 -Wall
CPPFLAGS := -D_FILE_OFFSET_BITS=64
@@ -15,12 +14,17 @@ SSRC := libverity.c hash_algs.c
SHOBJ := libverity.so hash_algs.so
STOBJ := libverity.o hash_algs.o
HDRS := $(wildcard *.h)
+LIB_MAJOR := 1
+LIB_MINOR := 0.0
+LIB_SO := libfsverity.so
+LIB_SONAME := $(LIB_SO).$(LIB_MAJOR)
+LIB_FULL := $(LIB_SONAME).$(LIB_MINOR)
all:$(EXE)
static:$(STATIC)
-$(EXE):$(OBJ) $(LIB)
+$(EXE):$(OBJ) $(LIB_FULL)
$(CC) -o $@ $(OBJ) $(LDLIBS) -L . -l fsverity
$(STATIC):$(OBJ) $(STOBJ)
@@ -35,16 +39,21 @@ $(STOBJ): %.o: %.c $(HDRS)
$(SHOBJ): %.so: %.c $(HDRS)
$(CC) -c -fPIC $(CFLAGS) $(CPPFLAGS) $< -o $@
-libfsverity.so: $(SHOBJ)
- $(CC) $(LDLIBS) -shared -o $@ $(SHOBJ)
+$(LIB_FULL): $(SHOBJ)
+ $(CC) $(LDLIBS) -shared -Wl,-soname,$(LIB_SONAME) -o $@ $(SHOBJ)
+ rm -f $(LIB_SONAME) $(LIB_SO)
+ ln -s $(LIB_FULL) $(LIB_SONAME)
+ ln -s $(LIB_SONAME) $(LIB_SO)
clean:
- rm -f $(EXE) $(OBJ) $(SHOBJ) $(LIB) $(STOBJ) $(STATIC)
+ rm -f $(EXE) $(OBJ) $(SHOBJ) $(LIB_SONAME) $(LIB_SO) $(LIB_FULL) $(STOBJ) $(STATIC)
install:all
- install -Dm755 -t $(BINDIR) $(EXE)
- install -Dm755 -t $(LIBDIR) $(LIB)
- install -Dm644 -t $(INCDIR) $(INC)
+ install -Dm755 -t $(DESTDIR)$(BINDIR) $(EXE)
+ install -Dm755 -t $(DESTDIR)$(LIBDIR) $(LIB_FULL)
+ ln -s $(LIB_FULL) $(DESTDIR)$(LIBDIR)/$(LIB_SONAME)
+ ln -s $(LIB_SONAME) $(DESTDIR)$(LIBDIR)/$(LIB_SO)
+ install -Dm644 -t $(DESTDIR)$(INCDIR) $(INC)
install-static:static
install -Dm755 -t $(BINDIR) $(STATIC)