Add rule to install to a target directory, /usr/local/blktests by
default.
Signed-off-by: Gwendal Grignou <[email protected]>
---
Makefile | 11 ++++++++++-
README.md | 3 +++
src/Makefile | 6 +++++-
3 files changed, 18 insertions(+), 2 deletions(-)
diff --git a/Makefile b/Makefile
index 38b8ad1..9793a2d 100644
--- a/Makefile
+++ b/Makefile
@@ -1,9 +1,18 @@
+prefix ?= /usr/local
+dest = $(DESTDIR)$(prefix)/blktests
+
all:
$(MAKE) -C src all
clean:
$(MAKE) -C src clean
+install:
+ install -m755 -d $(dest)
+ install check $(dest)
+ cp -R tests common $(dest)
+ $(MAKE) -C src dest=$(dest)/src install
+
# SC2119: "Use foo "$@" if function's $1 should mean script's $1". False
# positives on helpers like _init_scsi_debug.
SHELLCHECK_EXCLUDE := SC2119
@@ -13,4 +22,4 @@ check:
tests/*/rc tests/*/[0-9]*[0-9]
! grep TODO tests/*/rc tests/*/[0-9]*[0-9]
-.PHONY: all check
+.PHONY: all check install
diff --git a/README.md b/README.md
index be55aba..7967569 100644
--- a/README.md
+++ b/README.md
@@ -22,6 +22,9 @@ Some tests require the following:
- multipath-tools (Debian, openSUSE) or device-mapper-multipath (Fedora)
- dmsetup (Debian) or device-mapper (Fedora, openSUSE, Arch Linux)
+Build blktests with `make install`. Optionally, install it to a known location
+with `make install`, `/usr/local/blktests` by default.
+
Add the list of block devices you want to test on in a file named `config`:
```sh
diff --git a/src/Makefile b/src/Makefile
index 15c1022..b2bd321 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -20,10 +20,14 @@ all: $(TARGETS)
clean:
rm -f $(TARGETS)
+install: $(TARGETS)
+ install -m755 -d $(dest)
+ install $(TARGETS) $(dest)
+
$(C_TARGETS): %: %.c
$(CC) $(CPPFLAGS) $(CFLAGS) -o $@ $^
$(CXX_TARGETS): %: %.cpp
$(CXX) $(CPPFLAGS) $(CXXFLAGS) -o $@ $^
-.PHONY: all clean
+.PHONY: all clean install
--
2.18.1