Skip to content

Commit 3f9e698

Browse files
committed
mklove: add --no-static option to avoid static linking for certain libs
1 parent 6d9e887 commit 3f9e698

File tree

2 files changed

+41
-21
lines changed

2 files changed

+41
-21
lines changed

configure.self

+1-2
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,7 @@ void foo (void) {
9696
mkl_meta_set "zlib" "deb" "zlib1g-dev"
9797
mkl_meta_set "zlib" "rpm" "zlib-devel"
9898
mkl_meta_set "zlib" "apk" "zlib-dev"
99-
mkl_meta_set "zlib" "static" "libz.a"
100-
mkl_lib_check "zlib" "WITH_ZLIB" disable CC "-lz" \
99+
mkl_lib_check --no-static "zlib" "WITH_ZLIB" disable CC "-lz" \
101100
"#include <zlib.h>"
102101
mkl_check "libssl" disable
103102
mkl_check "libsasl2" disable

mklove/modules/configure.base

+40-19
Original file line numberDiff line numberDiff line change
@@ -1510,6 +1510,7 @@ function mkl_lib_check_static {
15101510
#
15111511
# Arguments:
15121512
# [--override-action=<action>] (internal use, overrides action argument)
1513+
# [--no-static] (do not attempt to link the library statically)
15131514
# [--libname=<lib>] (library name if different from config name, such as
15141515
# when the libname includes a dash)
15151516
# config name (library name (for pkg-config))
@@ -1521,19 +1522,27 @@ function mkl_lib_check_static {
15211522
function mkl_lib_check0 {
15221523

15231524
local override_action=
1524-
if [[ $1 == --override-action=* ]]; then
1525-
override_action=${1#*=}
1526-
shift
1527-
fi
1528-
1529-
local staticopt=$(mkl_meta_get $1 "static" "")
1530-
1525+
local nostaticopt=
15311526
local libnameopt=
1532-
local libname=$1
1533-
if [[ $1 == --libname* ]]; then
1534-
libnameopt=$1
1535-
libname="${libnameopt#*=}"
1527+
local libname=
1528+
1529+
while [[ $1 == --* ]]; do
1530+
if [[ $1 == --override-action=* ]]; then
1531+
override_action=${1#*=}
1532+
elif [[ $1 == --no-static ]]; then
1533+
nostaticopt=$1
1534+
elif [[ $1 == --libname* ]]; then
1535+
libnameopt=$1
1536+
libname="${libnameopt#*=}"
1537+
else
1538+
mkl_err "mkl_lib_check: invalid option $1"
1539+
exit 1
1540+
fi
15361541
shift
1542+
done
1543+
1544+
if [[ -z $libname ]]; then
1545+
libname=$1
15371546
fi
15381547

15391548
local action=$3
@@ -1546,13 +1555,16 @@ function mkl_lib_check0 {
15461555
if [[ $WITH_PKGCONFIG == "y" ]]; then
15471556
# Let pkg-config populate CFLAGS, et.al.
15481557
# Return on success.
1549-
mkl_pkg_config_check $libnameopt "$1" "$2" cont "$4" "$6" && return $?
1558+
mkl_pkg_config_check $nostaticopt $libnameopt "$1" "$2" cont "$4" "$6" && return $?
15501559
fi
15511560

15521561
local libs="$5"
1553-
local stlibs=$(mkl_lib_check_static $1 "$libs")
1554-
if [[ -n $stlibs ]]; then
1555-
libs=$stlibs
1562+
1563+
if [[ -z $nostaticopt ]]; then
1564+
local stlibs=$(mkl_lib_check_static $1 "$libs")
1565+
if [[ -n $stlibs ]]; then
1566+
libs=$stlibs
1567+
fi
15561568
fi
15571569

15581570
if ! mkl_compile_check "$1" "$2" "$action" "$4" "$libs" "$6"; then
@@ -1606,7 +1618,7 @@ function mkl_lib_check {
16061618
# being used is in-fact from the dependency builder (if supported),
16071619
# rather than a system installed alternative, so skip the pre-check and
16081620
# go directly to dependency installation/build below.
1609-
if [[ $MKL_SOURCE_DEPS_ONLY != y ]] || ! mkl_dep_has_builder $1 ; then
1621+
if [[ $MKL_SOURCE_DEPS_ONLY != y ]] || ! mkl_dep_has_builder $name ; then
16101622
mkl_lib_check0 --override-action=cont "$1" "$2" "$3" "$4" "$5" "$6" "$7" "$8"
16111623
retcode=$?
16121624
if [[ $retcode -eq 0 ]]; then
@@ -1632,6 +1644,7 @@ function mkl_lib_check {
16321644
# Check for library with pkg-config
16331645
# Automatically sets CFLAGS and LIBS from pkg-config information.
16341646
# Arguments:
1647+
# [--no-static] (do not attempt to link the library statically)
16351648
# [--libname=<lib>] (library name if different from config name, such as
16361649
# when the libname includes a dash)
16371650
# config name
@@ -1641,6 +1654,12 @@ function mkl_lib_check {
16411654
# source snippet
16421655
function mkl_pkg_config_check {
16431656

1657+
local nostaticopt=
1658+
if [[ $1 == --no-static ]]; then
1659+
nostaticopt=$1
1660+
shift
1661+
fi
1662+
16441663
local libname=$1
16451664
if [[ $1 == --libname* ]]; then
16461665
libname="${libnameopt#*=}"
@@ -1697,9 +1716,11 @@ $cflags"
16971716

16981717
mkl_mkvar_append $1 "CFLAGS" "$cflags"
16991718

1700-
local stlibs=$(mkl_lib_check_static $1 "$libs")
1701-
if [[ -n $stlibs ]]; then
1702-
libs=$stlibs
1719+
if [[ -z $nostaticopt ]]; then
1720+
local stlibs=$(mkl_lib_check_static $1 "$libs")
1721+
if [[ -n $stlibs ]]; then
1722+
libs=$stlibs
1723+
fi
17031724
fi
17041725

17051726
mkl_dbg "$1: from pkg-config: LIBS: prepend $libs"

0 commit comments

Comments
 (0)