Эх сурвалжийг харах

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>
Peter Jones 5 жил өмнө
parent
commit
4ee8cf5610
1 өөрчлөгдсөн 13 нэмэгдсэн , 1 устгасан
  1. 13 1
      Make.defaults

+ 13 - 1
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