@@ -12,7 +12,7 @@ dnl Copyright (c) 2004-2005 The Regents of the University of California.
12
12
dnl All rights reserved.
13
13
dnl Copyright (c) 2006-2010 Oracle and/or its affiliates. All rights reserved.
14
14
dnl Copyright (c) 2009-2015 Cisco Systems, Inc. All rights reserved.
15
- dnl Copyright (c) 2015 Research Organization for Information Science
15
+ dnl Copyright (c) 2015-2016 Research Organization for Information Science
16
16
dnl and Technology (RIST). All rights reserved.
17
17
dnl $COPYRIGHT $
18
18
dnl
172
172
173
173
AS_IF([test -n " $rpath_args " ],
174
174
[WRAPPER_RPATH_SUPPORT= rpath
175
- AC_MSG_RESULT([yes ($rpath_args )])],
175
+ cat > $rpath_script << EOF
176
+ #! /bin/sh
177
+
178
+ # Slurp in the libtool config into my environment
179
+
180
+ # Apparently, "libtoool --config" calls "exit", so we can't source it
181
+ # (because if script A sources script B, and B calls "exit", then both
182
+ # B and A will exit). Instead, we have to send the output to a file
183
+ # and then source that.
184
+ $OPAL_TOP_BUILDDIR /libtool --tag= FC --config > $rpath_outfile
185
+
186
+ chmod +x $rpath_outfile
187
+ . ./$rpath_outfile
188
+ rm -f $rpath_outfile
189
+
190
+ # Evaluate \$hardcode_libdir_flag_spec, and substitute in LIBDIR for \$libdir
191
+ libdir= LIBDIR
192
+ flags= " \` eval echo \$ hardcode_libdir_flag_spec\` "
193
+ echo \$ flags
194
+
195
+ # Done
196
+ exit 0
197
+ EOF
198
+ chmod +x $rpath_script
199
+ rpath_fc_args= ` ./$rpath_script `
200
+ rm -f $rpath_script
201
+ AC_MSG_RESULT([yes ($rpath_args + $rpath_fc_args )])],
176
202
[WRAPPER_RPATH_SUPPORT= unnecessary
177
203
AC_MSG_RESULT([yes (no extra flags needed)])])
178
204
191
217
# If DT_RUNPATH is supported, then we'll use *both* the RPATH and
192
218
# RUNPATH flags in the LDFLAGS.
193
219
AC_DEFUN([OPAL_SETUP_RUNPATH],[
194
- OPAL_VAR_SCOPE_PUSH([LDFLAGS_save])
220
+ OPAL_VAR_SCOPE_PUSH([LDFLAGS_save rpath_script rpath_outfile wl_fc ])
195
221
196
222
AC_MSG_CHECKING([if linker supports RUNPATH])
197
223
# Set the output in $runpath_args
@@ -205,6 +231,44 @@ AC_DEFUN([OPAL_SETUP_RUNPATH],[
205
231
AC_MSG_RESULT([yes (-Wl,--enable-new-dtags)])],
206
232
[AC_MSG_RESULT([no])])
207
233
AC_LANG_POP([C])
234
+ # Output goes into globally-visible $rpath_args. Run this in a
235
+ # sub-process so that we don't pollute the current process
236
+ # environment.
237
+ rpath_script= conftest.$$ .sh
238
+ rpath_outfile= conftest.$$ .out
239
+ rm -f $rpath_script $rpath_outfile
240
+ cat > $rpath_script << EOF
241
+ #! /bin/sh
242
+
243
+ # Slurp in the libtool config into my environment
244
+
245
+ # Apparently, "libtoool --config" calls "exit", so we can't source it
246
+ # (because if script A sources script B, and B calls "exit", then both
247
+ # B and A will exit). Instead, we have to send the output to a file
248
+ # and then source that.
249
+ $OPAL_TOP_BUILDDIR /libtool --tag= FC--config > $rpath_outfile
250
+
251
+ chmod +x $rpath_outfile
252
+ . ./$rpath_outfile
253
+ rm -f $rpath_outfile
254
+
255
+ wl= " \` eval echo \$ wl\` "
256
+ echo \$ wl
257
+
258
+ # Done
259
+ exit 0
260
+ EOF
261
+ chmod +x $rpath_script
262
+ wl_fc= ` ./$rpath_script `
263
+ rm -f $rpath_script
264
+
265
+ LDFLAGS= " $LDFLAGS_save ${wl_fc} --enable-new-dtags"
266
+ AC_LANG_PUSH([Fortran])
267
+ AC_LINK_IFELSE([AC_LANG_SOURCE([[program test
268
+ end program]])],
269
+ [runpath_fc_args= " ${wl_fc} --enable-new-dtags" ],
270
+ [runpath_fc_args= " " ])
271
+ AC_LANG_POP([Fortran])
208
272
LDFLAGS= $LDFLAGS_save
209
273
210
274
OPAL_VAR_SCOPE_POP
@@ -214,27 +278,31 @@ AC_DEFUN([OPAL_SETUP_RUNPATH],[
214
278
# for each of them. Then also add in an RPATH for @{libdir} (which
215
279
# will be replaced by the wrapper compile to the installdir libdir at
216
280
# runtime), and the RUNPATH args, if we have them.
217
- AC_DEFUN([RPATHIFY_LDFLAGS ],[
281
+ AC_DEFUN([RPATHIFY_LDFLAGS_INTERNAL ],[
218
282
OPAL_VAR_SCOPE_PUSH([rpath_out rpath_dir rpath_tmp])
219
283
AS_IF([test " $enable_wrapper_rpath " = " yes" && test " $WRAPPER_RPATH_SUPPORT " != " disabled" && test " $WRAPPER_RPATH_SUPPORT " != " unnecessary" ], [
220
284
rpath_out= " "
221
285
for val in ${$1 } ; do
222
286
case $val in
223
287
-L* )
224
288
rpath_dir=` echo $val | cut -c3-`
225
- rpath_tmp=` echo $rpath_args | sed -e s@LIBDIR@$rpath_dir @`
289
+ rpath_tmp=` echo ${ $2 } | sed -e s@LIBDIR@$rpath_dir @`
226
290
rpath_out=" $rpath_out $rpath_tmp "
227
291
;;
228
292
esac
229
293
done
230
294
231
295
# Now add in the RPATH args for @{libdir}, and the RUNPATH args
232
- rpath_tmp= ` echo $rpath_args | sed -e s/LIBDIR/@{libdir}/`
233
- $1 = " ${$1 } $rpath_out $rpath_tmp $runpath_args "
296
+ rpath_tmp= ` echo ${ $2 } | sed -e s/LIBDIR/@{libdir}/`
297
+ $1 = " ${$1 } $rpath_out $rpath_tmp ${ $3 } "
234
298
])
235
299
OPAL_VAR_SCOPE_POP
236
300
])
237
301
302
+ AC_DEFUN([RPATHIFY_LDFLAGS],[RPATHIFY_LDFLAGS_INTERNAL([$1 ], [rpath_args], [runpath_args])])
303
+
304
+ AC_DEFUN([RPATHIFY_FC_LDFLAGS],[RPATHIFY_LDFLAGS_INTERNAL([$1 ], [rpath_fc_args], [runpath_fc_args])])
305
+
238
306
239
307
dnl
240
308
dnl Avoid some repetitive code below
@@ -430,9 +498,12 @@ AC_DEFUN([OPAL_SETUP_WRAPPER_FINAL],[
430
498
431
499
AC_MSG_CHECKING([for OMPI LDFLAGS])
432
500
OMPI_WRAPPER_EXTRA_LDFLAGS= " $ompi_mca_wrapper_extra_ldflags $wrapper_extra_ldflags $with_wrapper_ldflags "
501
+ OMPI_WRAPPER_EXTRA_FC_LDFLAGS= $OMPI_WRAPPER_EXTRA_LDFLAGS
433
502
RPATHIFY_LDFLAGS([OMPI_WRAPPER_EXTRA_LDFLAGS])
434
503
AC_SUBST([OMPI_WRAPPER_EXTRA_LDFLAGS])
435
504
AC_MSG_RESULT([$OMPI_WRAPPER_EXTRA_LDFLAGS ])
505
+ RPATHIFY_FC_LDFLAGS([OMPI_WRAPPER_EXTRA_FC_LDFLAGS])
506
+ AC_SUBST([OMPI_WRAPPER_EXTRA_FC_LDFLAGS])
436
507
437
508
# Convert @{libdir} to ${libdir} for pkg-config
438
509
_OPAL_SETUP_WRAPPER_FINAL_PKGCONFIG([OMPI])
@@ -441,6 +512,7 @@ AC_DEFUN([OPAL_SETUP_WRAPPER_FINAL],[
441
512
OMPI_WRAPPER_EXTRA_LIBS= " $ompi_mca_wrapper_extra_libs "
442
513
OPAL_FLAGS_APPEND_UNIQ([OMPI_WRAPPER_EXTRA_LIBS], [$wrapper_extra_libs ])
443
514
OMPI_WRAPPER_EXTRA_LIBS= " $OMPI_WRAPPER_EXTRA_LIBS $with_wrapper_libs "
515
+ OPAL_FLAGS_APPEND_UNIQ([OMPI_WRAPPER_EXTRA_LIBS], [$LIBS ])
444
516
AC_SUBST([OMPI_WRAPPER_EXTRA_LIBS])
445
517
AC_MSG_RESULT([$OMPI_WRAPPER_EXTRA_LIBS ])
446
518
0 commit comments