Skip to content

Commit 9fb66dd

Browse files
committed
Honour DESTDIR & allow dirs to be overridden
Signed-off-by: Alastair D'Silva <alastair@d-silva.org>
1 parent 9263595 commit 9fb66dd

2 files changed

Lines changed: 17 additions & 17 deletions

File tree

Makefile

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@ CFLAGS += -I src/include -I kernel/include -fPIC -D_FILE_OFFSET_BITS=64
77

88
VERS_LIB = $(VERSION_MAJOR).$(VERSION_MINOR)
99
LIBNAME = libocxl.so.$(VERS_LIB)
10-
VERS_SONAME=$(VERSION_MAJOR)
11-
LIBSONAME = libocxl.so.$(VERS_SONAME)
10+
LIBSONAME = libocxl.so.$(VERSION_MAJOR)
1211
SONAMEOPT = -Wl,-soname,$(LIBSONAME)
1312

1413
DOCDIR = docs
@@ -90,20 +89,21 @@ clean:
9089
rm -rf obj testobj sampleobj docs $(VERSION_DIR) $(VERSION_DIR).txz
9190

9291
install: all docs
93-
mkdir -p $(libdir)
94-
mkdir -p $(includedir)
95-
mkdir -p $(mandir)/man3
96-
mkdir -p $(datadir)/libocxl/search
97-
install -m 0755 obj/$(LIBNAME) $(libdir)/
98-
cp -d obj/libocxl.so obj/$(LIBSONAME) $(libdir)/
99-
install -m 0644 src/include/libocxl.h $(includedir)/
100-
install -m 0644 -D docs/man/man3/* $(mandir)/man3
101-
install -m 0644 -D docs/html/*.* $(datadir)/libocxl
102-
install -m 0644 -D docs/html/search/* $(datadir)/libocxl/search
92+
mkdir -p $(DESTDIR)$(libdir)
93+
mkdir -p $(DESTDIR)$(includedir)
94+
mkdir -p $(DESTDIR)$(mandir)/man3
95+
mkdir -p $(DESTDIR)$(datadir)/libocxl/search
96+
install -m 0755 obj/$(LIBNAME) $(DESTDIR)$(libdir)/
97+
ln -s $(LIBNAME) $(DESTDIR)$(libdir)/$(LIBSONAME)
98+
ln -s $(LIBNAME) $(DESTDIR)$(libdir)/libocxl.so
99+
install -m 0644 src/include/libocxl.h $(DESTDIR)$(includedir)/
100+
install -m 0644 -D docs/man/man3/* $(DESTDIR)$(mandir)/man3
101+
install -m 0644 -D docs/html/*.* $(DESTDIR)$(datadir)/libocxl
102+
install -m 0644 -D docs/html/search/* $(DESTDIR)$(datadir)/libocxl/search
103103

104104
dist:
105105
ln -s . $(VERSION_DIR)
106-
tar Jcf $(VERSION_DIR).txz --exclude $(VERSION_DIR)/debian --exclude $(VERSION_DIR)/.git --exclude $(VERSION_DIR)/$(VERSION_DIR) $(VERSION_DIR)/*
106+
tar Jcf $(VERSION_DIR).txz --exclude $(VERSION_DIR)/packages --exclude $(VERSION_DIR)/.git --exclude $(VERSION_DIR)/$(VERSION_DIR) $(VERSION_DIR)/*
107107
rm $(VERSION_DIR)
108108

109109
.PHONY: clean all install docs precommit cppcheck cppcheck-xml dist check_ocxl_header

Makefile.rules

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ testobj/%.o : src/%.c src/include/libocxl.h src/libocxl_internal.h | testobj
2828
testobj/%.o-test : unittests/%.c testobj/libocxl.a
2929
$(call Q,CC, $(CC) $(CPPFLAGS) $(TESTCFLAGS) -c -o $@ $<, $@)
3030

31-
datadir = $(PREFIX)/share
32-
includedir = $(PREFIX)/include
33-
mandir = $(datadir)/man
34-
libdir = $(PREFIX)/lib64
31+
datadir ?= $(PREFIX)/share
32+
includedir ?= $(PREFIX)/include
33+
mandir ?= $(datadir)/man
34+
libdir ?= $(PREFIX)/lib64

0 commit comments

Comments
 (0)