about summary refs log tree commit diff
path: root/mk/libraries.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/libraries.mk
parent2a469ad31da7cac5c4ecab6838c364956319821f (diff)
parenta210c995cdd9279ed4137ec5d2e4cc928cb36097 (diff)
Merge commit 'a210c995cdd9279ed4137ec5d2e4cc928cb36097'
Diffstat (limited to 'mk/libraries.mk')
-rw-r--r--mk/libraries.mk14
1 files changed, 8 insertions, 6 deletions
diff --git a/mk/libraries.mk b/mk/libraries.mk
index 69dede9af418..c41694794b60 100644
--- a/mk/libraries.mk
+++ b/mk/libraries.mk
@@ -50,6 +50,8 @@ define build-library
   $(1)_LDFLAGS_USE :=
   $(1)_LDFLAGS_USE_INSTALLED :=
 
+  $$(eval $$(call create-dir, $$(_d)))
+
   ifeq ($(BUILD_SHARED_LIBS), 1)
 
     ifdef $(1)_ALLOW_UNDEFINED
@@ -64,21 +66,21 @@ define build-library
 
     $(1)_PATH := $$(_d)/$$($(1)_NAME).$(SO_EXT)
 
-    $$($(1)_PATH): $$($(1)_OBJS) $$(_libs)
+    $$($(1)_PATH): $$($(1)_OBJS) $$(_libs) | $$(_d)
 	$$(trace-ld) $(CXX) -o $$@ -shared $(GLOBAL_LDFLAGS) $$($(1)_OBJS) $$($(1)_LDFLAGS) $$($(1)_LDFLAGS_PROPAGATED) $$(foreach lib, $$($(1)_LIBS), $$($$(lib)_LDFLAGS_USE))
 
     $(1)_LDFLAGS_USE += -L$$(_d) -Wl,-rpath,$$(abspath $$(_d)) -l$$(patsubst lib%,%,$$(strip $$($(1)_NAME)))
 
-    $(1)_INSTALL_PATH := $$($(1)_INSTALL_DIR)/$$($(1)_NAME).$(SO_EXT)
+    $(1)_INSTALL_PATH := $(DESTDIR)$$($(1)_INSTALL_DIR)/$$($(1)_NAME).$(SO_EXT)
 
     _libs_final := $$(foreach lib, $$($(1)_LIBS), $$($$(lib)_INSTALL_PATH))
 
-    $$(eval $$(call create-dir,$$($(1)_INSTALL_DIR)))
+    $$(eval $$(call create-dir, $$($(1)_INSTALL_DIR)))
 
-    $$($(1)_INSTALL_PATH): $$($(1)_OBJS) $$(_libs_final) | $$($(1)_INSTALL_DIR)
+    $$($(1)_INSTALL_PATH): $$($(1)_OBJS) $$(_libs_final) | $(DESTDIR)$$($(1)_INSTALL_DIR)
 	$$(trace-ld) $(CXX) -o $$@ -shared $(GLOBAL_LDFLAGS) $$($(1)_OBJS) $$($(1)_LDFLAGS) $$($(1)_LDFLAGS_PROPAGATED) $$(foreach lib, $$($(1)_LIBS), $$($$(lib)_LDFLAGS_USE_INSTALLED))
 
-    $(1)_LDFLAGS_USE_INSTALLED += -L$$($(1)_INSTALL_DIR) -Wl,-rpath,$$($(1)_INSTALL_DIR) -l$$(patsubst lib%,%,$$(strip $$($(1)_NAME)))
+    $(1)_LDFLAGS_USE_INSTALLED += -L$$(DESTDIR)$$($(1)_INSTALL_DIR) -Wl,-rpath,$$($(1)_INSTALL_DIR) -l$$(patsubst lib%,%,$$(strip $$($(1)_NAME)))
 
     ifdef $(1)_FORCE_INSTALL
       install: $$($(1)_INSTALL_PATH)
@@ -88,7 +90,7 @@ define build-library
 
     $(1)_PATH := $$(_d)/$$($(1)_NAME).a
 
-    $$($(1)_PATH): $$($(1)_OBJS)
+    $$($(1)_PATH): $$($(1)_OBJS) | $$(_d)
 	$(trace-ar) ar crs $$@ $$?
 
     $(1)_LDFLAGS_USE += $$($(1)_PATH) $$($(1)_LDFLAGS)