aboutsummaryrefslogtreecommitdiff
path: root/Makefile.lib
diff options
context:
space:
mode:
authorEelco Dolstra <eelco.dolstra@logicblox.com>2013-11-23 17:20:15 +0100
committerEelco Dolstra <eelco.dolstra@logicblox.com>2013-11-23 17:26:43 +0100
commitd1b3ca0b4a57f48f94a555c97f6a555c3a1f3639 (patch)
tree1ae5117ad9c9197066b9e23c9ef00d5c6a3ada0a /Makefile.lib
parent6dd74b48f8d587fcc215e9f4721eacace7f8f462 (diff)
Improve building dynamic libraries
They now get a correct RPATH.
Diffstat (limited to 'Makefile.lib')
-rw-r--r--Makefile.lib16
1 files changed, 10 insertions, 6 deletions
diff --git a/Makefile.lib b/Makefile.lib
index 3ebb8df7c..d197fa6c1 100644
--- a/Makefile.lib
+++ b/Makefile.lib
@@ -50,21 +50,25 @@ endif
libs_list :=
define LIBS_template =
- _d := $$($(1)_DIR)
+ _d := $$(strip $$($(1)_DIR))
_srcs := $$(foreach src, $$($(1)_SOURCES), $$(_d)/$$(src))
_objs := $$(addsuffix .o, $$(basename $$(_srcs)))
+ $(1)_LDFLAGS_USE :=
+
ifeq ($(BUILD_SHARED_LIBS), 1)
_lib := $$(_d)/$(1).so
$$(_lib): $$(_objs)
$(QUIET) $(CC) -o $$@ -shared $$^ $$($(1)_LDFLAGS)
+ $(1)_LDFLAGS_USE += -L$$(_d) -Wl,-rpath,$$(abspath $$(_d)) -l$$(patsubst lib%,%,$$(strip $(1)))
else
_lib := $$(_d)/$(1).a
$$(_lib): $$(_objs)
$(QUIET) ar crs $$@ $$?
- $(1)_LDFLAGS_PROPAGATED += $$($(1)_LDFLAGS)
+ $(1)_LDFLAGS_USE += $$(_lib) $$($(1)_LDFLAGS)
endif
+ $(1)_LDFLAGS_USE += $$($(1)_LDFLAGS_PROPAGATED)
$(1)_NAME := $$(_lib)
# Propagate CXXFLAGS to the individual object files.
@@ -86,15 +90,15 @@ programs_list :=
define PROGRAMS_template =
_d := $$($(1)_DIR)
_srcs := $$(foreach src, $$($(1)_SOURCES), $$(_d)/$$(src))
- _objs := $$(addsuffix .o, $$(basename $$(_srcs)))
+ $(1)_OBJS := $$(addsuffix .o, $$(basename $$(_srcs)))
_libs := $$(foreach lib, $$($(1)_LIBS), $$($$(lib)_NAME))
_prog := $$(_d)/$(1)
- $$(_prog): $$(_objs) $$(_libs)
- $(QUIET) $(CXX) -o $$@ -Wl,--no-copy-dt-needed-entries $$^ $$($(1)_LDFLAGS) $$(foreach lib, $$($(1)_LIBS), $$($$(lib)_LDFLAGS_PROPAGATED))
+ $$(_prog): $$($(1)_OBJS) $$(_libs)
+ $(QUIET) $(CXX) -o $$@ -Wl,--no-copy-dt-needed-entries $$($(1)_OBJS) $$($(1)_LDFLAGS) $$(foreach lib, $$($(1)_LIBS), $$($$(lib)_LDFLAGS_USE))
# Propagate CXXFLAGS to the individual object files.
- $$(foreach obj, $$(_objs), $$(eval $$(obj)_CXXFLAGS=$$($(1)_CXXFLAGS)))
+ $$(foreach obj, $$($(1)_OBJS), $$(eval $$(obj)_CXXFLAGS=$$($(1)_CXXFLAGS)))
include $$(wildcard $$(_d)/*.dep)