diff options
author | Eelco Dolstra <eelco.dolstra@logicblox.com> | 2013-11-23T20·11+0000 |
---|---|---|
committer | Eelco Dolstra <eelco.dolstra@logicblox.com> | 2013-11-23T20·11+0000 |
commit | 90dfb37f147941e5edf262c27e269cdfd1e8dcfb (patch) | |
tree | 31293e2bfb2e401f6dd8aa39bc74c2ed895c0b4e /Makefile.lib | |
parent | 14772783e66a6e67726872926834c0e9f7210e6d (diff) |
Allow (dynamic) libraries to depend on other libraries
Diffstat (limited to 'Makefile.lib')
-rw-r--r-- | Makefile.lib | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/Makefile.lib b/Makefile.lib index 0a2fcccadcc6..612550e92133 100644 --- a/Makefile.lib +++ b/Makefile.lib @@ -52,7 +52,8 @@ libs_list := define LIBS_template = _d := $$(strip $$($(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)) $(1)_LDFLAGS_USE := $(1)_LDFLAGS_USE_INSTALLED := @@ -60,8 +61,8 @@ define LIBS_template = ifeq ($(BUILD_SHARED_LIBS), 1) _lib := $$(_d)/$(1).so - $$(_lib): $$(_objs) - $(QUIET) $(CC) -o $$@ -shared $$^ $$($(1)_LDFLAGS) + $$(_lib): $$($(1)_OBJS) $$(_libs) + $(QUIET) $(CC) -o $$@ -shared -Wl,--no-copy-dt-needed-entries $$($(1)_OBJS) $$($(1)_LDFLAGS) $$(foreach lib, $$($(1)_LIBS), $$($$(lib)_LDFLAGS_USE)) $(1)_LDFLAGS_USE += -L$$(_d) -Wl,-rpath,$$(abspath $$(_d)) -l$$(patsubst lib%,%,$$(strip $(1))) @@ -69,16 +70,18 @@ define LIBS_template = $(1)_INSTALL_PATH := $$($(1)_INSTALL_DIR)/$(1).so - $$($(1)_INSTALL_PATH): $$(_objs) + _libs_final := $$(foreach lib, $$($(1)_LIBS), $$($$(lib)_INSTALL_PATH)) + + $$($(1)_INSTALL_PATH): $$($(1)_OBJS) $$(_libs_final) install -d $$($(1)_INSTALL_DIR) - $(QUIET) $(CC) -o $$@ -shared $$^ $$($(1)_LDFLAGS) + $(QUIET) $(CC) -o $$@ -shared -Wl,--no-copy-dt-needed-entries $$($(1)_OBJS) $$($(1)_LDFLAGS) $$(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))) else _lib := $$(_d)/$(1).a - $$(_lib): $$(_objs) + $$(_lib): $$($(1)_OBJS) $(QUIET) ar crs $$@ $$? $(1)_LDFLAGS_USE += $$(_lib) $$($(1)_LDFLAGS) @@ -92,7 +95,7 @@ define LIBS_template = $(1)_NAME := $$(_lib) # 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) |