mupdf/0008-Makefile-scripts-wrap-__main__.py-Set-SONAME-when-li.patch
2024-02-16 18:24:35 +01:00

79 lines
3.2 KiB
Diff

From 65545bbe5248cc0850ba9eeb20f60e8498794c17 Mon Sep 17 00:00:00 2001
Message-ID: <65545bbe5248cc0850ba9eeb20f60e8498794c17.1708103252.git.mjg@fedoraproject.org>
In-Reply-To: <1932a672db047da3204a445880007fcc522fa7d7.1708103252.git.mjg@fedoraproject.org>
References: <1932a672db047da3204a445880007fcc522fa7d7.1708103252.git.mjg@fedoraproject.org>
From: Julian Smith <julian.smith@artifex.com>
Date: Tue, 9 Jan 2024 18:47:47 +0000
Subject: [PATCH 08/10] Makefile scripts/wrap/__main__.py: Set SONAME when
linking shared libs on Linux.
We add link arg `-Wl,-soname,libmupdf[cpp].so,MAJOR.MINOR`.
Also only create libmupdf[cpp].so softlinks if we are on Linux.
(cherry picked from commit 82db7fcd5bdf59652d03a56b06bf2e853140282b)
---
Makefile | 9 +++++++--
scripts/wrap/__main__.py | 6 +++++-
2 files changed, 12 insertions(+), 3 deletions(-)
diff --git a/Makefile b/Makefile
index f8a8dfaa9..369127981 100644
--- a/Makefile
+++ b/Makefile
@@ -42,6 +42,9 @@ VERSION_PATCH = $(shell grep "define FZ_VERSION_PATCH" include/mupdf/fitz/versio
ifeq ($(LINUX_OR_OPENBSD),yes)
SO_VERSION = .$(VERSION_MINOR).$(VERSION_PATCH)
+ ifeq ($(OS),Linux)
+ SO_VERSION_LINUX := yes
+ endif
endif
# --- Commands ---
@@ -93,9 +96,11 @@ $(OUT)/%.exe: %.c
$(LINK_CMD)
$(OUT)/%.$(SO)$(SO_VERSION):
- $(LINK_CMD) $(LIB_LDFLAGS) $(THIRD_LIBS) $(LIBCRYPTO_LIBS)
-ifneq ($(SO_VERSION),)
+ifeq ($(SO_VERSION_LINUX),yes)
+ $(LINK_CMD) -Wl,-soname,$(notdir $@) $(LIB_LDFLAGS) $(THIRD_LIBS) $(LIBCRYPTO_LIBS)
ln -sf $(notdir $@) $(patsubst %$(SO_VERSION), %, $@)
+else
+ $(LINK_CMD) $(LIB_LDFLAGS) $(THIRD_LIBS) $(LIBCRYPTO_LIBS)
endif
$(OUT)/%.def: $(OUT)/%.$(SO)$(SO_VERSION)
diff --git a/scripts/wrap/__main__.py b/scripts/wrap/__main__.py
index d7e86c755..80dd2bf1e 100644
--- a/scripts/wrap/__main__.py
+++ b/scripts/wrap/__main__.py
@@ -1737,10 +1737,14 @@ def build( build_dirs, swig_command, args, vs_upgrade, make_command):
)
elif 'shared' in dir_so_flags:
+ link_soname_arg = ''
+ if state.state_.linux:
+ link_soname_arg = f'-Wl,-soname,{os.path.basename(libmupdfcpp)}'
command = ( textwrap.dedent(
f'''
{compiler}
-o {os.path.relpath(libmupdfcpp)}
+ {link_soname_arg}
{build_dirs.cpp_flags}
-fPIC -shared
-I {include1}
@@ -1757,7 +1761,7 @@ def build( build_dirs, swig_command, args, vs_upgrade, make_command):
)
if command_was_run:
macos_patch( libmupdfcpp, f'{build_dirs.dir_so}/libmupdf.dylib{so_version}')
- if so_version:
+ if so_version and state.state_.linux:
jlib.system(f'ln -sf libmupdfcpp.so{so_version} {build_dirs.dir_so}/libmupdfcpp.so')
elif 'fpic' in dir_so_flags:
--
2.44.0.rc1.222.g52f20dec8d