From eaedf1fc2022d729828e0677e25293888d884a8e Mon Sep 17 00:00:00 2001 From: Kyle Laker Date: Fri, 3 Jan 2020 21:37:32 -0500 Subject: [PATCH] Allow installation --- Makefile | 17 ++++++++++++++--- src/{list.c => xorlist.c} | 0 2 files changed, 14 insertions(+), 3 deletions(-) rename src/{list.c => xorlist.c} (100%) diff --git a/Makefile b/Makefile index 64f350f..7e5b9fb 100644 --- a/Makefile +++ b/Makefile @@ -6,16 +6,18 @@ override LDFLAGS := $(LDFLAGS) SRCDIR = src OUTDIR = build INCDIR = include +PREFIX = /usr SRCS = $(shell find $(SRCDIR) -type f -name *.c) OBJS = $(patsubst $(SRCDIR)/%,$(OUTDIR)/%,$(SRCS:.c=.o)) +SHOBJS = $(patsubst $(SRCDIR)/%,$(OUTDIR)/lib%,$(SRCS:.c=.so)) INC = -I$(INCDIR) EXE=list_test all: libs -libs: $(OBJS) +libs: $(OBJS) $(SHOBJS) test: make -C tests @@ -29,8 +31,17 @@ $(OUTDIR)/%.o: $(SRCDIR)/%.c mkdir -p $(OUTDIR) $(CC) -c $(CFLAGS) $(INC) $< -o $@ +$(OUTDIR)/lib%.so: $(OUTDIR)/%.o + $(CC) $(CFLAGS) -shared -o $@ $< + +install: $(SHOBJS) + install -d $(DESTDIR)$(PREFIX)/lib/ + install -m 644 $(SHOBJS) $(DESTDIR)$(PREFIX)/lib/ + install -d $(DESTDIR)$(PREFIX)/include/xorlist + install -m 644 $(INCDIR)/* $(DESTDIR)$(PREFIX)/include/xorlist/ + clean: - rm -rf $(OUTDIR)/*.o list_test + rm -rf $(OUTDIR) list_test make -C tests clean -.PHONY: all default clean tests +.PHONY: all default clean tests install diff --git a/src/list.c b/src/xorlist.c similarity index 100% rename from src/list.c rename to src/xorlist.c