Skip to content

Commit 709969f

Browse files
committed
Fixes #575: Fall back on shared libraries
Let the `caf` wrapper script search for shared libs when static libs missing.
1 parent 95edc1b commit 709969f

File tree

1 file changed

+36
-2
lines changed

1 file changed

+36
-2
lines changed

src/extensions/caf.in

Lines changed: 36 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,40 @@ __only_compiling () {
172172
# End configured variables, now process them and build compile/link command
173173
#--------------------------------------------------------------------------
174174

175+
176+
substitute_lib () {
177+
# Try to substitute a shared or static library if requested library is missing
178+
# Some package managers only install dynamic or static libs
179+
if ! [[ -f "${1}" ]] ; then
180+
case "${1##*.}" in
181+
a|lib)
182+
for suff in so dylib dll ; do
183+
if [[ -f "${1%%.*}.${suff}" ]] ; then
184+
echo "${1%%.*}.${suff}"
185+
return
186+
fi
187+
done
188+
# If we get here, original lib DNE, and no alternates found
189+
echo "Failed to find static library ${1} or shared library alternatives." >&2
190+
exit 1
191+
;;
192+
so|dylib|dll)
193+
for suff in a lib ; do
194+
if [[ -f "${1%%.*}.${suff}" ]] ; then
195+
echo "${1%%.*}.${suff}"
196+
return
197+
fi
198+
done
199+
# If we get here, original lib DNE, and no alternates found
200+
echo "Failed to find shared library ${1} or static library alternatives." >&2
201+
exit 1
202+
;;
203+
esac
204+
else
205+
echo "${1}"
206+
fi
207+
}
208+
175209
# Always make extensions module available, user can choose whether to `use` it or not
176210
caf_pre_flags=("${mod_dir_flag}${prefix%/}/${caf_mod_dir}")
177211

@@ -198,12 +232,12 @@ fi
198232
# Now do libraries, IN CORRECT ORDER, to append to command
199233
if [[ -n "${caf_libs[*]:-}" ]]; then
200234
for lib in "${caf_libs[@]:-}"; do
201-
caf_added_libs+=("${prefix%/}/${lib}")
235+
caf_added_libs+=("$(substitute_lib "${prefix%/}/${lib}")")
202236
done
203237
fi
204238
if [[ -n "${mpi_libs[*]:-}" ]]; then
205239
for lib in "${mpi_libs[@]:-}"; do
206-
caf_added_libs+=("${lib}")
240+
caf_added_libs+=("$(substitute_lib "${lib}")")
207241
done
208242
fi
209243

0 commit comments

Comments
 (0)