On Darwin (macOS), the flags needed to create a shared
library are different. Moreover, the extension is .dylib
and the version portion of the soname is inserted between
the library name and the libext, e.g. lifoo.1.2.3.dylib.

Signed-off-by: Caleb Xu <calebcen...@live.com>
---
 makefiles/Makefile.clang |  7 ++++++-
 makefiles/Makefile.gcc   |  6 +++++-
 makefiles/Makefile.tools |  6 +++++-
 makefiles/Makefile.top   | 14 +++++++++++---
 4 files changed, 27 insertions(+), 6 deletions(-)

diff --git a/makefiles/Makefile.clang b/makefiles/Makefile.clang
index 50f8a82..bcd14e3 100644
--- a/makefiles/Makefile.clang
+++ b/makefiles/Makefile.clang
@@ -21,7 +21,12 @@ CXXSHR := -fPIC
 
 LDDBG := -g
 # Reevaluation is required here
-LDSHR = -shared -Wl,-soname,$(SONAME)
+ifeq ($(findstring darwin,$(HOST)),darwin)
+       LDSHR = -dynamiclib -install_name $(SONAME)
+else
+       LDSHR = -shared -Wl,-soname,$(SONAME)
+endif
+
 
 ARFLG := cru
 
diff --git a/makefiles/Makefile.gcc b/makefiles/Makefile.gcc
index b5119ac..4a9dff7 100644
--- a/makefiles/Makefile.gcc
+++ b/makefiles/Makefile.gcc
@@ -20,7 +20,11 @@ CXXSHR := -fPIC
 
 LDDBG := -g
 # Reevaluation is required here
-LDSHR = -shared -Wl,-soname,$(SONAME)
+ifeq ($(findstring darwin,$(HOST)),darwin)
+       LDSHR = -dynamiclib -install_name $(SONAME)
+else
+       LDSHR = -shared -Wl,-soname,$(SONAME)
+endif
 
 ARFLG := cru
 
diff --git a/makefiles/Makefile.tools b/makefiles/Makefile.tools
index 112e7f8..e5504e7 100644
--- a/makefiles/Makefile.tools
+++ b/makefiles/Makefile.tools
@@ -478,7 +478,11 @@ LDFLAGS := $(LDFLAGS) $(OPTLDFLAGS)
 ifeq ($(COMPONENT_TYPE),lib-static)
   LIBEXT ?= .a
 else
-  LIBEXT ?= .so
+  ifeq ($(findstring darwin,$(HOST)),darwin)
+    LIBEXT ?= .dylib
+  else
+    LIBEXT ?= .so
+  endif
 endif
 
 # If we're building a shared library, modify the flags appropriately
diff --git a/makefiles/Makefile.top b/makefiles/Makefile.top
index caac166..0b0fe22 100644
--- a/makefiles/Makefile.top
+++ b/makefiles/Makefile.top
@@ -189,9 +189,17 @@ endif
 # Determine the output filename
 ifeq ($(findstring lib,$(COMPONENT_TYPE)),lib)
   ifeq ($(findstring lib-shared,$(COMPONENT_TYPE)),lib-shared)
-    SHAREDLIBNAME := lib$(COMPONENT)$(LIBEXT)
-    SONAME := $(SHAREDLIBNAME).$(major-version)
-    OUTPUT := $(BUILDDIR)/$(SHAREDLIBNAME).$(COMPONENT_VERSION)
+    ifeq ($(findstring darwin,$(HOST)),darwin)
+      # In macOS, shared lib filenames are of the form libfoo.dylib,
+      # libfoo.1.dylib, or libfoo.1.2.3.dylib
+      SONAME := lib$(COMPONENT).$(major-version)$(LIBEXT)
+      SHAREDLIBNAME := lib$(COMPONENT)$(LIBEXT)
+      OUTPUT := $(BUILDDIR)/lib$(COMPONENT).$(COMPONENT_VERSION)$(LIBEXT)
+    else
+      SHAREDLIBNAME := lib$(COMPONENT)$(LIBEXT)
+      SONAME := $(SHAREDLIBNAME).$(major-version)
+      OUTPUT := $(BUILDDIR)/$(SHAREDLIBNAME).$(COMPONENT_VERSION)
+    endif
   else
     OUTPUT := $(BUILDDIR)/lib$(COMPONENT)$(LIBEXT)
   endif
-- 
2.41.0
_______________________________________________
netsurf-dev mailing list -- netsurf-dev@netsurf-browser.org
To unsubscribe send an email to netsurf-dev-le...@netsurf-browser.org

Reply via email to