aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib.mk5
-rw-r--r--libraries.mk22
2 files changed, 21 insertions, 6 deletions
diff --git a/lib.mk b/lib.mk
index 2d8ceef55..5b0d2633c 100644
--- a/lib.mk
+++ b/lib.mk
@@ -9,6 +9,7 @@ default: all
QUIET = @
bin_SCRIPTS :=
noinst_SCRIPTS :=
+OS = $(shell uname -s)
# Default installation paths.
@@ -27,7 +28,9 @@ BUILD_SHARED_LIBS ?= 1
ifeq ($(BUILD_SHARED_LIBS), 1)
GLOBAL_CFLAGS += -fPIC
GLOBAL_CXXFLAGS += -fPIC
- GLOBAL_LDFLAGS += -Wl,--no-copy-dt-needed-entries
+ ifneq ($(OS), Darwin)
+ GLOBAL_LDFLAGS += -Wl,--no-copy-dt-needed-entries
+ endif
endif
diff --git a/libraries.mk b/libraries.mk
index 98cc9f363..818c3d217 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