diff options
author | Eelco Dolstra <eelco.dolstra@logicblox.com> | 2014-01-09T21·14+0100 |
---|---|---|
committer | Eelco Dolstra <eelco.dolstra@logicblox.com> | 2014-01-09T21·14+0100 |
commit | e991ab942b6ed1bc50a63afafe55ffe5cae8cbad (patch) | |
tree | df439623a575e14366e84b49bd353d3f8ffe67e2 /libraries.mk | |
parent | 70d8e8fdded9e21995fecc3ecc68e14cf4f53be7 (diff) |
Add support for building shared libraries on Mac OS X
Diffstat (limited to 'libraries.mk')
-rw-r--r-- | libraries.mk | 22 |
1 files changed, 17 insertions, 5 deletions
diff --git a/libraries.mk b/libraries.mk index 98cc9f363f44..818c3d2172a1 100644 --- a/libraries.mk +++ b/libraries.mk @@ -1,5 +1,11 @@ libs_list := +ifeq ($(OS), Darwin) + SO_EXT = dylib +else + SO_EXT = so +endif + # Build a library with symbolic name $(1). The library is defined by # various variables prefixed by ‘$(1)_’: # @@ -46,18 +52,24 @@ define build-library = ifeq ($(BUILD_SHARED_LIBS), 1) - ifndef $(1)_ALLOW_UNDEFINED - $(1)_LDFLAGS += -z defs + ifdef $(1)_ALLOW_UNDEFINED + ifeq ($(OS), Darwin) + $(1)_LDFLAGS += -undefined suppress -flat_namespace + endif + else + ifneq ($(OS), Darwin) + $(1)_LDFLAGS += -z defs + endif endif - $(1)_PATH := $$(_d)/$$($(1)_NAME).so + $(1)_PATH := $$(_d)/$$($(1)_NAME).$(SO_EXT) $$($(1)_PATH): $$($(1)_OBJS) $$(_libs) $(QUIET) $(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 + $(1)_INSTALL_PATH := $$($(1)_INSTALL_DIR)/$$($(1)_NAME).$(SO_EXT) _libs_final := $$(foreach lib, $$($(1)_LIBS), $$($$(lib)_INSTALL_PATH)) @@ -99,6 +111,6 @@ define build-library = -include $$($(1)_DEPS) libs_list += $$($(1)_PATH) - clean_files += $$(_d)/*.a $$(_d)/*.so $$(_d)/*.o $$(_d)/*.dep $$($(1)_DEPS) $$($(1)_OBJS) + clean_files += $$(_d)/*.a $$(_d)/*.$(SO_EXT) $$(_d)/*.o $$(_d)/*.dep $$($(1)_DEPS) $$($(1)_OBJS) dist_files += $$(_srcs) endef |