-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcollect.extra-libs.in
94 lines (82 loc) · 3.58 KB
/
collect.extra-libs.in
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
#!@SHELL@
# ICON
#
# ------------------------------------------
# Copyright (C) 2004-2024, DWD, MPI-M, DKRZ, KIT, ETH, MeteoSwiss
# Contact information: icon-model.org
# See AUTHORS.TXT for a list of authors
# See LICENSES/ for license information
# SPDX-License-Identifier: BSD-3-Clause
# ------------------------------------------
script_prefix=`echo "$0" | sed 's@[^/]*$@@'`
(unset CDPATH) >/dev/null 2>&1 && unset CDPATH
cd "$script_prefix"
# Collect extra dependencies of the bundled libraries:
test $# -ne 0 || {
set dummy @icon_bundled_builddirs@; shift
}
result=''
for subdir in "$@"; do
test -f "$subdir/Makefile" || {
echo "$0: WARNING: directory '$subdir' is not configured" >&2
continue
}
extra_libs=''
case $subdir in
externals/comin/build)
# Extract dl libs from comin cmake variable
extra_libs=`@CMAKE@ -L $subdir | sed -n 's/^COMIN_DL_LIBS\(:[A-Z]\+\)=\(-l\)\?\(.\+\)/-l\3/p'`
;;
externals/sct)
# The bundled version of SCT, which we link statically, might require
# additional linker flags:
# 1) a flag enabling linking to librt;
sct_LIBS=`echo '@''LIBS@' | "$subdir/config.status" -q --file=-`
case " $sct_LIBS " in
*' -lrt '*) extra_libs='-lrt' ;;
*) ;;
esac
# 2) a flag enabling linking to C code that uses OpenMP.
sct_OPENMP_FC_C_FLAGS=`echo '@''OPENMP_FC_C_FLAGS@' | "$subdir/config.status" -q --file=-`
extra_libs="$sct_OPENMP_FC_C_FLAGS${extra_libs:+ }$extra_libs"
;;
externals/cdi)
# The bundled version of CDI, which we link statically, might require
# additional linker flags enabling linking to librt:
extra_libs=`echo '@''LIBRT@' | "$subdir/config.status" -q --file=-`
if test -z $extra_libs; then
cdi_ENABLE_MPI_TRUE=`echo '@''ENABLE_MPI_TRUE@' | "$subdir/config.status" -q --file=-`
if test -z $cdi_ENABLE_MPI_TRUE; then
# We are here because either CDI does not depend on librt or the
# dependency is hidden by the libtool script of CDI (e.g. it found a
# libtool .la file that has '-lrt' among the 'dependency_libs',
# overlinked to librt and the configure script of CDI reported that no
# additional linker flags are required to link to the library, hence
# LIBRT was set to an empty string). The absence of the dependency on
# librt is very unlikely and here we could simply set the variable
# extra_libs to '-lrt'. However, we use this case as an example of how
# such issues can be resolved in general. Note that libcdipio.la might
# not exist yet, therefore we cannot parse it. Instead, we are going
# to run the libtool script of CDI in a way that is close to how the
# make program will call it:
@MKDIR_P@ conftest.dir
(
cd conftest.dir
cdi_LINK=`echo "@""SHELL@ ../$subdir/libtool --tag=CC --mode=link @""CC@ @""CFLAGS@ @""LDFLAGS@ -o libconftest.la @""LIBS@" | "$subdir/config.status" -q --file=-`
# If calling the libtool script of CDI is successful and the created
# dummy libtool file 'libconftest.la' has '-lrt' among the
# 'dependency_libs', we set extra_libs to '-lrt':
(eval $cdi_LINK) >/dev/null 2>&1
if test $? -eq 0 && grep "dependency_libs=.*[ ']-lrt[ '].*" libconftest.la >/dev/null 2>&1; then
extra_libs='-lrt'
fi
)
rm -rf conftest.dir
fi
fi
;;
*) ;;
esac
result="$extra_libs${result:+${extra_libs:+ }}$result"
done
echo "$result"