Blame SOURCES/0035-Make-make-make-DESTDIR-.-foo-install-work-right.patch

92e002
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
92e002
From: Peter Jones <pjones@redhat.com>
92e002
Date: Fri, 25 Oct 2019 15:39:35 -0400
92e002
Subject: [PATCH] Make: make "make DESTDIR=../foo install" work right.
92e002
92e002
This makes the normal DESTDIR= variable work on the command line, and
92e002
makes relative paths always relative to the top-level directory.
92e002
92e002
Signed-off-by: Peter Jones <pjones@redhat.com>
92e002
---
92e002
 Make.defaults | 14 +++++++++++++-
92e002
 1 file changed, 13 insertions(+), 1 deletion(-)
92e002
92e002
diff --git a/Make.defaults b/Make.defaults
92e002
index 696028dd6c2..157559d20ee 100755
92e002
--- a/Make.defaults
92e002
+++ b/Make.defaults
92e002
@@ -47,7 +47,19 @@ ARCHES=aa64 arm ia32 ia64 mips64el x64
92e002
 # Where to install the package. GNU-EFI will create and access
92e002
 # lib and include under the root
92e002
 #
92e002
-INSTALLROOT  := /
92e002
+DESTDIR ?= /
92e002
+ifeq ($(origin INSTALLROOT),undefined)
92e002
+INSTALLROOT = $(DESTDIR)
92e002
+endif
92e002
+
92e002
+empty :=
92e002
+space := $(empty) $(empty)
92e002
+stripped = $(subst $(space),/,$(strip $(subst /,$(space),$(1))))
92e002
+unstripped = $(subst $(space),/,$(subst /,$(space),$(1)))
92e002
+is_absolute = $(subst $(call stripped,$(1)),$(empty),$(call unstripped,$(1)))
92e002
+
92e002
+override INSTALLROOT:=$(if $(call is_absolute,$(INSTALLROOT)),,$(TOPDIR)/)$(INSTALLROOT)
92e002
+
92e002
 PREFIX       := /usr/local
92e002
 LIBDIR 	     := $(PREFIX)/lib
92e002
 INSTALL	     := install