summaryrefslogtreecommitdiffstats
path: root/Makefile
diff options
context:
space:
mode:
authorAlejandro Colomar <alx.manpages@gmail.com>2022-05-06 00:47:19 +0200
committerAlejandro Colomar <alx.manpages@gmail.com>2022-05-06 00:52:25 +0200
commit9669bdf02d5389b3ff0134c52e175678f241f292 (patch)
tree5727e78d67f735e07d6bc6f5624af8e7c0127025 /Makefile
parent1d6fe852a3b891709a3fcd272aae3eb87b6fbc44 (diff)
Makefile: Add targets to install and uninstall
Signed-off-by: Alejandro Colomar <alx.manpages@gmail.com>
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile86
1 files changed, 86 insertions, 0 deletions
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..64d2a43
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,86 @@
+MAKEFLAGS += --no-builtin-rules
+MAKEFLAGS += --no-builtin-variables
+MAKEFLAGS += --no-print-directory
+MAKEFLAGS += --warn-undefined-variables
+
+
+package := grepc
+
+
+srcdir := .
+DESTDIR :=
+prefix := /usr/local
+exec_prefix := $(prefix)
+
+
+BINDIR := $(srcdir)/bin
+
+bindir := $(exec_prefix)/bin
+
+_prefix := $(DESTDIR)$(prefix)
+_exec_prefix := $(DESTDIR)$(exec_prefix)
+_bindir := $(DESTDIR)$(bindir)
+
+_bindirs := $(_bindir)
+
+_dirs := $(_bindirs)
+
+
+BIN := $(sort $(shell find $(BINDIR) -type f))
+
+_bin := $(patsubst $(BINDIR)/%,$(_bindir)/%,$(BIN))
+
+_bin_rm := $(addsuffix -rm,$(wildcard $(_bin)))
+
+
+INSTALL := install
+INSTALL_DIR := $(INSTALL) -d
+INSTALL_PROGRAM := $(INSTALL)
+RM := rm
+
+
+modules := bin
+install := $(foreach x,$(modules),install-$(x))
+installdirs := $(foreach x,$(modules),installdirs-$(x))
+uninstall := $(addprefix un,$(install))
+
+
+.PHONY: all
+all:
+ @:
+
+
+.PHONY: install $(install)
+.PHONY: installdirs $(installdirs)
+.PHONY: uninstall $(uninstall)
+
+
+.SECONDEXPANSION:
+
+install: $(install)
+$(install): install-%: $$(_%)
+installdirs: $(installdirs)
+$(installdirs): installdirs-%: $$(_%dirs)
+uninstall: $(uninstall)
+$(uninstall): uninstall-%: $$(_%_rm)
+
+
+$(_bin): $(_bindir)/%: $(BINDIR)/% Makefile | $$(@D)
+ $(info INSTALL $@)
+ $(INSTALL_PROGRAM) -T $< $@
+
+$(_dirs): | $$(@D)
+ $(info INSTALL $@/)
+ $(INSTALL_DIR) $@
+
+$(sort $(_prefix) $(_exec_prefix)):
+ $(info INSTALL $@/)
+ $(INSTALL_DIR) $@
+
+%-rm:
+ $(info RM $*)
+ $(RM) $*
+
+
+V :=
+$(V).SILENT: