diff options
Diffstat (limited to 'Makefile.lib')
-rw-r--r-- | Makefile.lib | 28 |
1 files changed, 18 insertions, 10 deletions
diff --git a/Makefile.lib b/Makefile.lib index b045534dcca8..3ebb8df7c98b 100644 --- a/Makefile.lib +++ b/Makefile.lib @@ -25,15 +25,15 @@ QUIET = @ # Pass -fPIC if we're building dynamic libraries. ifeq ($(BUILD_SHARED_LIBS), 1) -GLOBAL_CFLAGS += -fPIC -GLOBAL_CXXFLAGS += -fPIC + GLOBAL_CFLAGS += -fPIC + GLOBAL_CXXFLAGS += -fPIC endif # Pass -g if we want debug info. ifeq ($(BUILD_DEBUG), 1) -GLOBAL_CFLAGS += -g -GLOBAL_CXXFLAGS += -g + GLOBAL_CFLAGS += -g + GLOBAL_CXXFLAGS += -g endif @@ -53,11 +53,19 @@ define LIBS_template = _d := $$($(1)_DIR) _srcs := $$(foreach src, $$($(1)_SOURCES), $$(_d)/$$(src)) _objs := $$(addsuffix .o, $$(basename $$(_srcs))) - _libs := $$(foreach lib, $$($(1)_LIBS), $$(lib).a) - _lib := $$(_d)/$(1).a - $$(_lib): $$(_objs) + ifeq ($(BUILD_SHARED_LIBS), 1) + _lib := $$(_d)/$(1).so + $$(_lib): $$(_objs) + $(QUIET) $(CC) -o $$@ -shared $$^ $$($(1)_LDFLAGS) + else + _lib := $$(_d)/$(1).a + $$(_lib): $$(_objs) $(QUIET) ar crs $$@ $$? + $(1)_LDFLAGS_PROPAGATED += $$($(1)_LDFLAGS) + endif + + $(1)_NAME := $$(_lib) # Propagate CXXFLAGS to the individual object files. $$(foreach obj, $$(_objs), $$(eval $$(obj)_CXXFLAGS=$$($(1)_CXXFLAGS))) @@ -65,7 +73,7 @@ define LIBS_template = include $$(wildcard $$(_d)/*.dep) libs_list += $$(_lib) - clean_list += $$(_d)/*.a $$(_d)/*.o $$(_d)/*.dep + clean_list += $$(_d)/*.a $$(_d)/*.so $$(_d)/*.o $$(_d)/*.dep dist_files += $$(_srcs) endef @@ -79,11 +87,11 @@ define PROGRAMS_template = _d := $$($(1)_DIR) _srcs := $$(foreach src, $$($(1)_SOURCES), $$(_d)/$$(src)) _objs := $$(addsuffix .o, $$(basename $$(_srcs))) - _libs := $$(foreach lib, $$($(1)_LIBS), $$($$(lib)_DIR)/$$(lib).a) + _libs := $$(foreach lib, $$($(1)_LIBS), $$($$(lib)_NAME)) _prog := $$(_d)/$(1) $$(_prog): $$(_objs) $$(_libs) - $(QUIET) g++ -o $$@ $$^ $$($(1)_LDFLAGS) $$(foreach lib, $$($(1)_LIBS), $$($$(lib)_LDFLAGS)) + $(QUIET) $(CXX) -o $$@ -Wl,--no-copy-dt-needed-entries $$^ $$($(1)_LDFLAGS) $$(foreach lib, $$($(1)_LIBS), $$($$(lib)_LDFLAGS_PROPAGATED)) # Propagate CXXFLAGS to the individual object files. $$(foreach obj, $$(_objs), $$(eval $$(obj)_CXXFLAGS=$$($(1)_CXXFLAGS))) |