@@ -172,6 +172,40 @@ __only_compiling () {
172
172
# End configured variables, now process them and build compile/link command
173
173
# --------------------------------------------------------------------------
174
174
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
+
175
209
# Always make extensions module available, user can choose whether to `use` it or not
176
210
caf_pre_flags=(" ${mod_dir_flag}${prefix%/ } /${caf_mod_dir} " )
177
211
198
232
# Now do libraries, IN CORRECT ORDER, to append to command
199
233
if [[ -n " ${caf_libs[*]:- } " ]]; then
200
234
for lib in " ${caf_libs[@]:- } " ; do
201
- caf_added_libs+=(" ${prefix%/ } /${lib} " )
235
+ caf_added_libs+=(" $( substitute_lib " $ {prefix%/ } /${lib} " ) " )
202
236
done
203
237
fi
204
238
if [[ -n " ${mpi_libs[*]:- } " ]]; then
205
239
for lib in " ${mpi_libs[@]:- } " ; do
206
- caf_added_libs+=(" ${lib} " )
240
+ caf_added_libs+=(" $( substitute_lib " $ {lib}" ) " )
207
241
done
208
242
fi
209
243
0 commit comments