Makefile: allow overriding the binary executable target dir

Distros tend to change this to specific locations (eg. on MVCC installs),
therefore introduce a generic environment variable that's a common practise
since 30+ years and thus already well known and supported by distros.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
This commit is contained in:
Enrico Weigelt, metux IT consult 2021-05-06 17:33:04 +02:00
parent 165f8e414e
commit cac8b6f4bd

View File

@ -24,6 +24,7 @@ ROOTDIR=$(dir $(abspath $(lastword $(MAKEFILE_LIST))))
# The files will be installed under `$(DESTDIR)/$(PREFIX)`. # The files will be installed under `$(DESTDIR)/$(PREFIX)`.
# The convention of `DESTDIR` was changed in containerd v1.6. # The convention of `DESTDIR` was changed in containerd v1.6.
PREFIX ?= /usr/local PREFIX ?= /usr/local
BINDIR ?= $(PREFIX)/bin
DATADIR ?= $(PREFIX)/share DATADIR ?= $(PREFIX)/share
MANDIR ?= $(DATADIR)/man MANDIR ?= $(DATADIR)/man
@ -408,12 +409,12 @@ clean-test: ## clean up debris from previously failed tests
install: ## install binaries install: ## install binaries
@echo "$(WHALE) $@ $(BINARIES)" @echo "$(WHALE) $@ $(BINARIES)"
@$(INSTALL) -d $(DESTDIR)$(PREFIX)/bin @$(INSTALL) -d $(DESTDIR)$(BINDIR)
@$(INSTALL) $(BINARIES) $(DESTDIR)$(PREFIX)/bin @$(INSTALL) $(BINARIES) $(DESTDIR)$(BINDIR)
uninstall: uninstall:
@echo "$(WHALE) $@" @echo "$(WHALE) $@"
@rm -f $(addprefix $(DESTDIR)$(PREFIX)/bin/,$(notdir $(BINARIES))) @rm -f $(addprefix $(DESTDIR)$(BINDIR)/,$(notdir $(BINARIES)))
ifeq ($(GOOS),windows) ifeq ($(GOOS),windows)
install-deps: install-deps: