From a2daed581781419dd3327cfd7a3769e20b97d83f Mon Sep 17 00:00:00 2001 From: Daniel Bertalan Date: Tue, 1 Aug 2023 21:16:22 +0200 Subject: [PATCH] Ports/gettext: Replace manually linking `libintl` with a libtool patch The `gettext` port comprises of multiple libraries, however `libintl.so` is the one most commonly used in external executables/libraries, so porting the patches to this one is enough. --- Ports/gettext/package.sh | 6 - .../0001-Stub-out-some-wctype-functions.patch | 4 +- ...hared-library-support-for-SerenityOS.patch | 108 ++++++++++++++++++ Ports/gettext/patches/ReadMe.md | 19 +++ 4 files changed, 129 insertions(+), 8 deletions(-) create mode 100644 Ports/gettext/patches/0002-libtool-Enable-shared-library-support-for-SerenityOS.patch diff --git a/Ports/gettext/package.sh b/Ports/gettext/package.sh index a7f3400fde..be099c8bdf 100755 --- a/Ports/gettext/package.sh +++ b/Ports/gettext/package.sh @@ -6,9 +6,3 @@ files="https://ftpmirror.gnu.org/gettext/gettext-${version}.tar.gz gettext-${ver depends=("libiconv") use_fresh_config_sub='true' config_sub_paths=("build-aux/config.sub" "libtextstyle/build-aux/config.sub") - -install() { - run make DESTDIR=${SERENITY_INSTALL_ROOT} "${installopts[@]}" install - ${CC} -shared -pthread -o ${SERENITY_INSTALL_ROOT}/usr/local/lib/libintl.so -Wl,-soname,libintl.so -Wl,--whole-archive ${SERENITY_INSTALL_ROOT}/usr/local/lib/libintl.a -Wl,--no-whole-archive -liconv - rm -f ${SERENITY_INSTALL_ROOT}/usr/local/lib/libintl.la -} diff --git a/Ports/gettext/patches/0001-Stub-out-some-wctype-functions.patch b/Ports/gettext/patches/0001-Stub-out-some-wctype-functions.patch index 6828c05b13..13793fcab8 100644 --- a/Ports/gettext/patches/0001-Stub-out-some-wctype-functions.patch +++ b/Ports/gettext/patches/0001-Stub-out-some-wctype-functions.patch @@ -8,10 +8,10 @@ Subject: [PATCH] Stub out some wctype functions 1 file changed, 12 insertions(+) diff --git a/gettext-tools/gnulib-lib/fnmatch.c b/gettext-tools/gnulib-lib/fnmatch.c -index 3937ce3..84aa6e6 100644 +index b33a127d9802be15eeafef4622e63aac709bef8e..87f1f7c218c1708f84f3e4394eaa219e1d7c5858 100644 --- a/gettext-tools/gnulib-lib/fnmatch.c +++ b/gettext-tools/gnulib-lib/fnmatch.c -@@ -106,6 +106,18 @@ extern int fnmatch (const char *pattern, const char *string, int flags); +@@ -112,6 +112,18 @@ typedef ptrdiff_t idx_t; # define CHAR_CLASS_MAX_LENGTH 256 #endif diff --git a/Ports/gettext/patches/0002-libtool-Enable-shared-library-support-for-SerenityOS.patch b/Ports/gettext/patches/0002-libtool-Enable-shared-library-support-for-SerenityOS.patch new file mode 100644 index 0000000000..b7a14d2ed0 --- /dev/null +++ b/Ports/gettext/patches/0002-libtool-Enable-shared-library-support-for-SerenityOS.patch @@ -0,0 +1,108 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Tim Schumacher +Date: Tue, 1 Aug 2023 20:45:12 +0200 +Subject: [PATCH] libtool: Enable shared library support for SerenityOS + +For some odd reason, libtool handles the configuration for shared +libraries entirely statically and in its configure script. If no +shared library support is "present", building shared libraries is +disabled entirely. + +Fix that by just adding the appropriate configuration options for +`serenity`. This allows us to finally create dynamic libraries +automatically using libtool, without having to manually link the +static library into a shared library. + +This patch here is a bit more elaborate for other ports, as libintl's +configure includes the code for detecting dynamic linker characteristics +twice, and it also queries the C++ compiler for shared library support. + +Co-Authored-By: Daniel Bertalan +--- + gettext-runtime/configure | 38 ++++++++++++++++++++++++++++++++++++++ + 1 file changed, 38 insertions(+) + +diff --git a/gettext-runtime/configure b/gettext-runtime/configure +index 56cc8e17be7ed390b4a692dde31434dceff45a94..268c7c572abde069814834be25d08175e51f195e 100755 +--- a/gettext-runtime/configure ++++ b/gettext-runtime/configure +@@ -10219,6 +10219,10 @@ tpf*) + os2*) + lt_cv_deplibs_check_method=pass_all + ;; ++ ++serenity*) ++ lt_cv_deplibs_check_method=pass_all ++ ;; + esac + + fi +@@ -13707,6 +13711,10 @@ lt_prog_compiler_static= + lt_prog_compiler_static='-Bstatic' + ;; + ++ serenity*) ++ lt_prog_compiler_can_build_shared=yes ++ ;; ++ + *) + lt_prog_compiler_can_build_shared=no + ;; +@@ -15239,6 +15247,10 @@ printf "%s\n" "$lt_cv_irix_exported_symbol" >&6; } + hardcode_shlibpath_var=no + ;; + ++ serenity*) ++ ld_shlibs=yes ++ ;; ++ + *) + ld_shlibs=no + ;; +@@ -16311,6 +16323,17 @@ uts4*) + shlibpath_var=LD_LIBRARY_PATH + ;; + ++serenity*) ++ version_type=linux ++ need_lib_prefix=no ++ need_version=no ++ library_names_spec='${libname}${release}${shared_ext}${versuffix} ${libname}${release}${shared_ext}${major} ${libname}${shared_ext}' ++ soname_spec='${libname}${release}${shared_ext}${major}' ++ shlibpath_var=LD_LIBRARY_PATH ++ shlibpath_overrides_runpath=no ++ dynamic_linker='SerenityOS LibELF' ++ ;; ++ + *) + dynamic_linker=no + ;; +@@ -18601,6 +18624,10 @@ fi + ld_shlibs_CXX=no + ;; + ++ serenity*) ++ ld_shlibs_CXX=yes ++ ;; ++ + *) + # FIXME: insert proper C++ library support + ld_shlibs_CXX=no +@@ -20300,6 +20327,17 @@ uts4*) + shlibpath_var=LD_LIBRARY_PATH + ;; + ++serenity*) ++ version_type=linux ++ need_lib_prefix=no ++ need_version=no ++ library_names_spec='${libname}${release}${shared_ext}${versuffix} ${libname}${release}${shared_ext}${major} ${libname}${shared_ext}' ++ soname_spec='${libname}${release}${shared_ext}${major}' ++ shlibpath_var=LD_LIBRARY_PATH ++ shlibpath_overrides_runpath=no ++ dynamic_linker='SerenityOS LibELF' ++ ;; ++ + *) + dynamic_linker=no + ;; diff --git a/Ports/gettext/patches/ReadMe.md b/Ports/gettext/patches/ReadMe.md index 3f6ddf37a5..8729e2d2c7 100644 --- a/Ports/gettext/patches/ReadMe.md +++ b/Ports/gettext/patches/ReadMe.md @@ -5,3 +5,22 @@ Stub out some wctype functions +## `0002-libtool-Enable-shared-library-support-for-SerenityOS.patch` + +libtool: Enable shared library support for SerenityOS + +For some odd reason, libtool handles the configuration for shared +libraries entirely statically and in its configure script. If no +shared library support is "present", building shared libraries is +disabled entirely. + +Fix that by just adding the appropriate configuration options for +`serenity`. This allows us to finally create dynamic libraries +automatically using libtool, without having to manually link the +static library into a shared library. + +This patch here is a bit more elaborate for other ports, as libintl's +configure includes the code for detecting dynamic linker characteristics +twice, and it also queries the C++ compiler for shared library support. + +