summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Jones <pjones@redhat.com>2019-10-25 15:39:35 -0400
committerNigel Croxon <ncroxon@redhat.com>2023-04-04 09:28:42 -0400
commit4ee8cf5610bdf81cf88b078a7046832ea7371823 (patch)
treed036242cf32065b51153638775a2ab50e3a18a55
parent4b5db35e9d1f4295fa7a8f393021fd2f433a90e4 (diff)
downloadgnu-efi-4ee8cf5610bdf81cf88b078a7046832ea7371823.tar.gz
Make: make "make DESTDIR=../foo install" work right.
This makes the normal DESTDIR= variable work on the command line, and makes relative paths always relative to the top-level directory. Signed-off-by: Peter Jones <pjones@redhat.com>
-rwxr-xr-xMake.defaults14
1 files changed, 13 insertions, 1 deletions
diff --git a/Make.defaults b/Make.defaults
index d663397..516caad 100755
--- a/Make.defaults
+++ b/Make.defaults
@@ -45,7 +45,19 @@ TOPDIR := $(shell if [ "$$PWD" != "" ]; then echo $$PWD; else pwd; fi)
# Where to install the package. GNU-EFI will create and access
# lib and include under the root
#
-INSTALLROOT := /
+DESTDIR ?= /
+ifeq ($(origin INSTALLROOT),undefined)
+INSTALLROOT = $(DESTDIR)
+endif
+
+empty :=
+space := $(empty) $(empty)
+stripped = $(subst $(space),/,$(strip $(subst /,$(space),$(1))))
+unstripped = $(subst $(space),/,$(subst /,$(space),$(1)))
+is_absolute = $(subst $(call stripped,$(1)),$(empty),$(call unstripped,$(1)))
+
+override INSTALLROOT:=$(if $(call is_absolute,$(INSTALLROOT)),,$(TOPDIR)/)$(INSTALLROOT)
+
PREFIX := /usr/local
LIBDIR := $(PREFIX)/lib
INSTALL := install