aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorEgor Tensin <egor@tensin.name>2026-09-28 13:34:53 +0500
committerEgor Tensin <egor@tensin.name>2026-09-28 13:34:53 +0500
commit1b0ee92e8a114daf1194caa46950a32f6518e9ea (patch)
treefdb6ac7b82a1d602a503d9bd91b9b1eff3041905
parenttest: add tst-root.sh (diff)
downloadconfig-links-1b0ee92e8a114daf1194caa46950a32f6518e9ea.tar.gz
config-links-1b0ee92e8a114daf1194caa46950a32f6518e9ea.zip
Makefile: add install: target
-rw-r--r--Makefile20
-rw-r--r--prelude.mk2
2 files changed, 21 insertions, 1 deletions
diff --git a/Makefile b/Makefile
index fe20548..7a56499 100644
--- a/Makefile
+++ b/Makefile
@@ -3,6 +3,12 @@ include prelude.mk
.PHONY: DO
DO:
+PKG_NAME ?= config-links
+DESTDIR ?=
+
+$(eval $(call noexpand,PKG_NAME))
+$(eval $(call noexpand,DESTDIR))
+
.PHONY: all
all: test
@@ -22,3 +28,17 @@ test/docker/%: DO
# Keep the list repositories synced with the GitHub actions workflow.
.PHONY: test/docker
test/docker: test/docker/xenial test/docker/focal
+
+.PHONY: install
+install:
+ install -D -m 0644 -t '$(call escape,$(DESTDIR)/usr/share/$(PKG_NAME))' LICENSE.txt
+ install -D -m 0644 -t '$(call escape,$(DESTDIR)/usr/share/doc/$(PKG_NAME))' README.md
+
+ find bin -type f -exec install -D -m 0755 -t '$(call escape,$(DESTDIR)/usr/lib/$(PKG_NAME)/bin)' {} ';'
+ find lib -type f -exec install -D -m 0644 -t '$(call escape,$(DESTDIR)/usr/lib/$(PKG_NAME)/lib)' {} ';'
+
+ install -d '$(call escape,$(DESTDIR)/usr/bin)'
+ find '$(call escape,$(DESTDIR)/usr/lib/$(PKG_NAME)/bin)' -type f -printf '%P\0' | \
+ while IFS= read -d '' -r file; do \
+ ln -s -- '$(call escape,/usr/lib/$(PKG_NAME)/bin/)'"$$file" '$(call escape,$(DESTDIR)/usr/bin)' ; \
+ done
diff --git a/prelude.mk b/prelude.mk
index 374111e..da836d7 100644
--- a/prelude.mk
+++ b/prelude.mk
@@ -1,4 +1,4 @@
-# Please see https://egort.name/blog/notes/makefile.html
+# Please see https://tensin.name/blog/notes/makefile.html
MAKEFLAGS += --no-builtin-rules --no-builtin-variables --warn-undefined-variables
unexport MAKEFLAGS