diff options
author | Robin Haberkorn <rhaberkorn@fmsbw.de> | 2025-10-06 19:15:52 +0300 |
---|---|---|
committer | Robin Haberkorn <rhaberkorn@fmsbw.de> | 2025-10-06 19:15:52 +0300 |
commit | c16ef4276d9b3773ff12adf9e7cf2683c182826e (patch) | |
tree | 71494e422d5cbd2ca810f6fd8095fb2e270f12c5 | |
parent | bd3d9e6e35608791465cef02813a97407ebd06bb (diff) | |
download | sciteco-c16ef4276d9b3773ff12adf9e7cf2683c182826e.tar.gz |
./configure: define TE_CHECK_MODULES() which takes static linking into account
* There already was --enable-static-executables which would pass `-static`
to the linker, but it did not help with library dependencies (that have to be
pulled in transitively when linking statically).
pkg-config does have `--static` support though.
* Now all pkg-config found libraries will use `pkg-config --static` when
--enable-static-executables, which simplifies linking statically.
Previously you'd either need to set PKG_CONFIG="pkg-config --static"
or you would have to manually list library dependencies.
-rwxr-xr-x | .fmsbw/10-freebsd14-msys-sciteco | 5 | ||||
-rwxr-xr-x | .fmsbw/20-freebsd14-osx-sciteco | 3 | ||||
-rw-r--r-- | configure.ac | 42 |
3 files changed, 27 insertions, 23 deletions
diff --git a/.fmsbw/10-freebsd14-msys-sciteco b/.fmsbw/10-freebsd14-msys-sciteco index 1c71b17..037ac66 100755 --- a/.fmsbw/10-freebsd14-msys-sciteco +++ b/.fmsbw/10-freebsd14-msys-sciteco @@ -80,11 +80,8 @@ export CURSES_CFLAGS=-I/mingw64/include/pdcurses/ # helper binaries are still linked dynamically, forcing us to ship # all DLLs anyway. Therefore it makes little sense to link SciTECO # itself statically - it only wastes a few MB. -# You will also have to add --enable-static-executables. -# The additional Windows libraries are for PDCursesMod/WinGUI: -#export LIBGLIB_LIBS="-lglib-2.0 -lintl -liconv -lpcre -lole32 -lws2_32 -luuid" +# You would also have to add --enable-static-executables. # FIXME: Once there is an --enable-lto, we should use that. -#export CFLAGS="-O3 -flto -DGLIB_STATIC_COMPILATION" # NOTE: LTO is broken with libstdc++. # https://github.com/HolyBlackCat/quasi-msys2/issues/44 export CFLAGS="-O3 -flto=thin" diff --git a/.fmsbw/20-freebsd14-osx-sciteco b/.fmsbw/20-freebsd14-osx-sciteco index a3eea1f..3279053 100755 --- a/.fmsbw/20-freebsd14-osx-sciteco +++ b/.fmsbw/20-freebsd14-osx-sciteco @@ -45,13 +45,10 @@ export LDFLAGS="-flto=thin" mkdir build-osx cd build-osx -# FIXME: Perhaps SciTECO's configure.ac should use PKG_CHECK_MODULES_STATIC() -# whenever --enable-static-executables is used. # NOTE: Make sure we pick up the SDK's ncurses instead of the one pulled in # via MacPorts. ../configure --host=x86_64-apple-darwin25 --disable-bootstrap --with-interface=ncurses \ --enable-static-executables --with-scitecodatadir=../share/sciteco \ - PKG_CONFIG="x86_64-apple-darwin25-pkg-config --static" \ CURSES_CFLAGS="-D_DARWIN_C_SOURCE -DNCURSES_WIDECHAR" CURSES_LIBS="-lncurses" gmake install-strip DESTDIR=`pwd`/temp-install # There are libraries we cannot link against statically. diff --git a/configure.ac b/configure.ac index 689e8c1..9d5f74d 100644 --- a/configure.ac +++ b/configure.ac @@ -38,6 +38,30 @@ AC_SUBST(SCINTILLA_CXXFLAGS) # Necessary so we can change their default values here AC_SUBST(AM_CPPFLAGS) +# This cannot be done with --enable-static as it only controls +# which kind of libraries libtool builds. +# Also, it cannot be controlled reliably by setting LDFLAGS for +# ./configure, as this would be used for linking the test cases +# without libtool and libtool would ignore it. +# It is only possible to call `make LDFLAGS="-all-static"` but +# this is inconvenient... +AC_ARG_ENABLE(static-executables, + AS_HELP_STRING([--enable-static-executables], + [Link in as many runtime dependencies as possible + statically [default=no]]), + [static_executables=$enableval], [static_executables=no]) +AM_CONDITIONAL(STATIC_EXECUTABLES, [test x$static_executables = xyes]) + +# Wrapper around PKG_CHECK_MODULES(), but takes --enable-static-executables +# into account. +AC_DEFUN([TE_CHECK_MODULES], [ + AS_IF([test x$static_executables = xyes], [ + PKG_CHECK_MODULES_STATIC([$1], [$2], [$3], [$4]) + ], [ + PKG_CHECK_MODULES([$1], [$2], [$3], [$4]) + ]) +]) + # Auxiliary functions # expand $1 and print its absolute path @@ -135,7 +159,7 @@ AC_SUBST(DOXYGEN_HAVE_DOT) AC_CHECK_PROG(SCITECO, sciteco, sciteco) # Checks for libraries. -PKG_CHECK_MODULES(LIBGLIB, [glib-2.0 >= 2.44 gmodule-2.0], [ +TE_CHECK_MODULES(LIBGLIB, [glib-2.0 >= 2.44 gmodule-2.0], [ CFLAGS="$CFLAGS $LIBGLIB_CFLAGS" CXXFLAGS="$CXXFLAGS $LIBGLIB_CFLAGS" LIBS="$LIBS $LIBGLIB_LIBS" @@ -371,7 +395,7 @@ case $INTERFACE in ;; gtk) - PKG_CHECK_MODULES(LIBGTK, [gtk+-3.0 >= 3.24], [ + TE_CHECK_MODULES(LIBGTK, [gtk+-3.0 >= 3.24], [ CFLAGS="$CFLAGS $LIBGTK_CFLAGS" CXXFLAGS="$CXXFLAGS $LIBGTK_CFLAGS" LIBS="$LIBS $LIBGTK_LIBS" @@ -475,20 +499,6 @@ else esac fi -# This cannot be done with --enable-static as it only controls -# which kind of libraries libtool builds. -# Also, it cannot be controlled reliably by setting LDFLAGS for -# ./configure, as this would be used for linking the test cases -# without libtool and libtool would ignore it. -# It is only possible to call `make LDFLAGS="-all-static"` but -# this is inconvenient... -AC_ARG_ENABLE(static-executables, - AS_HELP_STRING([--enable-static-executables], - [Link in as many runtime dependencies as possible - statically [default=no]]), - [static_executables=$enableval], [static_executables=no]) -AM_CONDITIONAL(STATIC_EXECUTABLES, [test x$static_executables = xyes]) - AC_ARG_WITH(launcher, AS_HELP_STRING([--with-launcher=LAUNCHER], [Use the given launcher when executing SciTECO (e.g. wine)]), |