about summary refs log tree commit diff
path: root/mk/programs.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/programs.mk
parent2a469ad31da7cac5c4ecab6838c364956319821f (diff)
parenta210c995cdd9279ed4137ec5d2e4cc928cb36097 (diff)
Merge commit 'a210c995cdd9279ed4137ec5d2e4cc928cb36097'
Diffstat (limited to 'mk/programs.mk')
-rw-r--r--mk/programs.mk12
1 files changed, 7 insertions, 5 deletions
diff --git a/mk/programs.mk b/mk/programs.mk
index 74f2982a5f1c..ab04ff93e910 100644
--- a/mk/programs.mk
+++ b/mk/programs.mk
@@ -22,26 +22,28 @@ define build-program
   _libs := $$(foreach lib, $$($(1)_LIBS), $$($$(lib)_PATH))
   $(1)_PATH := $$(_d)/$(1)
 
-  $$($(1)_PATH): $$($(1)_OBJS) $$(_libs)
+  $$(eval $$(call create-dir, $$(_d)))
+
+  $$($(1)_PATH): $$($(1)_OBJS) $$(_libs) | $$(_d)
 	$$(trace-ld) $(CXX) -o $$@ $(GLOBAL_LDFLAGS) $$($(1)_OBJS) $$($(1)_LDFLAGS) $$(foreach lib, $$($(1)_LIBS), $$($$(lib)_LDFLAGS_USE))
 
   $(1)_INSTALL_DIR ?= $$(bindir)
   $(1)_INSTALL_PATH := $$($(1)_INSTALL_DIR)/$(1)
 
-  $$(eval $$(call create-dir,$$($(1)_INSTALL_DIR)))
+  $$(eval $$(call create-dir, $$($(1)_INSTALL_DIR)))
 
-  install: $$($(1)_INSTALL_PATH)
+  install: $(DESTDIR)$$($(1)_INSTALL_PATH)
 
   ifeq ($(BUILD_SHARED_LIBS), 1)
 
     _libs_final := $$(foreach lib, $$($(1)_LIBS), $$($$(lib)_INSTALL_PATH))
 
-    $$($(1)_INSTALL_PATH): $$($(1)_OBJS) $$(_libs_final) | $$($(1)_INSTALL_DIR)
+    $(DESTDIR)$$($(1)_INSTALL_PATH): $$($(1)_OBJS) $$(_libs_final) | $(DESTDIR)$$($(1)_INSTALL_DIR)
 	$$(trace-ld) $(CXX) -o $$@ $(GLOBAL_LDFLAGS) $$($(1)_OBJS) $$($(1)_LDFLAGS) $$(foreach lib, $$($(1)_LIBS), $$($$(lib)_LDFLAGS_USE_INSTALLED))
 
   else
 
-    $$($(1)_INSTALL_PATH): $$($(1)_PATH) | $$($(1)_INSTALL_DIR)
+    $(DESTDIR)$$($(1)_INSTALL_PATH): $$($(1)_PATH) | $(DESTDIR)$$($(1)_INSTALL_DIR)
 	install -t $$($(1)_INSTALL_DIR) $$<
 
   endif