about summary refs log tree commit diff
path: root/mk/install.mk
diff options
context:
space:
mode:
authorEelco Dolstra <eelco.dolstra@logicblox.com>2014-02-07T15·27+0100
committerEelco Dolstra <eelco.dolstra@logicblox.com>2014-02-07T15·27+0100
commit764d90597a2ef9f5f5a5041993b728e020fb08b0 (patch)
tree1539f267f6c6368943cc8c19d5b66433ccd9fbd4 /mk/install.mk
parent2a469ad31da7cac5c4ecab6838c364956319821f (diff)
parenta210c995cdd9279ed4137ec5d2e4cc928cb36097 (diff)
Merge commit 'a210c995cdd9279ed4137ec5d2e4cc928cb36097'
Diffstat (limited to 'mk/install.mk')
-rw-r--r--mk/install.mk29
1 files changed, 17 insertions, 12 deletions
diff --git a/mk/install.mk b/mk/install.mk
index e8543f6b6ab9..e4bc734e11fb 100644
--- a/mk/install.mk
+++ b/mk/install.mk
@@ -1,10 +1,11 @@
 # Add a rule for creating $(1) as a directory.  This template may be
 # called multiple times for the same directory.
 define create-dir
-  ifndef $(1)_SEEN
-    $(1)_SEEN = 1
-    $(1):
-	$$(trace-install) install -d $(1)
+   _i := $(DESTDIR)$$(strip $(1))
+  ifndef $$(_i)_SEEN
+    $$(_i)_SEEN = 1
+    $$(_i):
+	$$(trace-mkdir) install -d "$$@"
   endif
 endef
 
@@ -13,12 +14,14 @@ endef
 # The directory containing $(2) will be created automatically.
 define install-file-as
 
-  install: $(2)
+  _i := $(DESTDIR)$$(strip $(2))
 
-  $$(eval $$(call create-dir,$$(dir $(2))))
+  install: $$(_i)
 
-  $(2): $(1) | $$(dir $(2))
-	$$(trace-install) install -m $(3) $(1) $(2)
+  $$(_i): $(1) | $$(dir $$(_i))
+	$$(trace-install) install -m $(3) $(1) "$$@"
+
+  $$(eval $$(call create-dir, $$(dir $(2))))
 
 endef
 
@@ -43,12 +46,14 @@ endef
 # Install a symlink from $(2) to $(1).  Note that $(1) need not exist.
 define install-symlink
 
-  install: $(2)
+  _i := $(DESTDIR)$$(strip $(2))
+
+  install: $$(_i)
 
-  $$(eval $$(call create-dir,$$(dir $(2))))
+  $$(_i): | $$(dir $$(_i))
+	$$(trace-install) ln -sfn $(1) "$$@"
 
-  $(2): | $$(dir $(2))
-	$$(trace-install) ln -sfn $(1) $(2)
+  $$(eval $$(call create-dir, $$(dir $(2))))
 
 endef