1
# _GA_FC_LIBRARY_LDFLAGS
2
# ======================
5
# Until autoconf is fixed to support Sun Studio compilers using -Y, we replace
6
# _AC_FC_LIBRARY_LDFLAGS. The rest of the marco is directly copied from
7
# autoconf-2.67/lib/autoconf/fortran.m4
8
# ----------------------------------------------------------------------------
10
# Determine the linker flags (e.g. "-L" and "-l") for the Fortran
11
# intrinsic and runtime libraries that are required to successfully
12
# link a Fortran program or shared library. The output variable
13
# FLIBS/FCLIBS is set to these flags.
15
# This macro is intended to be used in those situations when it is
16
# necessary to mix, e.g. C++ and Fortran, source code into a single
17
# program or shared library.
19
# For example, if object files from a C++ and Fortran compiler must
20
# be linked together, then the C++ compiler/linker must be used for
21
# linking (since special C++-ish things need to happen at link time
22
# like calling global constructors, instantiating templates, enabling
23
# exception support, etc.).
25
# However, the Fortran intrinsic and runtime libraries must be
26
# linked in as well, but the C++ compiler/linker doesn't know how to
27
# add these Fortran libraries. Hence, the macro
28
# "AC_F77_LIBRARY_LDFLAGS" was created to determine these Fortran
31
# This macro was packaged in its current form by Matthew D. Langston.
32
# However, nearly all of this macro came from the "OCTAVE_FLIBS" macro
33
# in "octave-2.0.13/aclocal.m4", and full credit should go to John
34
# W. Eaton for writing this extremely useful macro. Thank you John.
35
AC_DEFUN([_GA_FC_LIBRARY_LDFLAGS],
36
[_AC_FORTRAN_ASSERT()dnl
38
AC_CACHE_CHECK([for _AC_LANG libraries of $[]_AC_FC[]], ac_cv_[]_AC_LANG_ABBREV[]_libs,
39
[if test "x$[]_AC_LANG_PREFIX[]LIBS" != "x"; then
40
ac_cv_[]_AC_LANG_ABBREV[]_libs="$[]_AC_LANG_PREFIX[]LIBS" # Let the user override the test.
45
ac_cv_[]_AC_LANG_ABBREV[]_libs=
47
# Save positional arguments (if any)
48
ac_save_positional="$[@]"
50
set X $ac_[]_AC_LANG_ABBREV[]_v_output
51
while test $[@%:@] != 1; do
55
[[\\/]]*.a | ?:[[\\/]]*.a)
56
_AC_LIST_MEMBER_IF($ac_arg, $ac_cv_[]_AC_LANG_ABBREV[]_libs, ,
57
ac_cv_[]_AC_LANG_ABBREV[]_libs="$ac_cv_[]_AC_LANG_ABBREV[]_libs $ac_arg")
60
_AC_LIST_MEMBER_IF($ac_arg, $ac_cv_[]_AC_LANG_ABBREV[]_libs, ,
61
[_AC_LINKER_OPTION([$ac_arg], ac_cv_[]_AC_LANG_ABBREV[]_libs)])
64
-lang* | -lcrt*.o | -lc | -lgcc* | -lSystem | -libmil | -little \
65
|-LANG:=* | -LIST:* | -LNO:* | -link)
68
test x"$CYGWIN" != xyes && ac_cv_[]_AC_LANG_ABBREV[]_libs="$ac_cv_[]_AC_LANG_ABBREV[]_libs $ac_arg"
71
# These flags, when seen by themselves, take an argument.
72
# We remove the space between option and argument and re-iterate
73
# unless we find an empty arg or a new option (starting with -)
84
for ac_j in `AS_ECHO(["$ac_arg"]) | sed -e 's/-YP,/-L/;s/:/ -L/g'`; do
85
_AC_LIST_MEMBER_IF($ac_j, $ac_cv_[]_AC_LANG_ABBREV[]_libs, ,
86
[ac_arg="$ac_arg $ac_j"
87
ac_cv_[]_AC_LANG_ABBREV[]_libs="$ac_cv_[]_AC_LANG_ABBREV[]_libs $ac_j"])
92
for ac_j in `AS_ECHO(["$ac_arg"]) | sed -e 's/-Y/-L/;s/"//g;s/:/ -L/g'`; do
93
_AC_LIST_MEMBER_IF($ac_j, $ac_cv_[]_AC_LANG_ABBREV[]_libs, ,
94
[ac_arg="$ac_arg $ac_j"
95
ac_cv_[]_AC_LANG_ABBREV[]_libs="$ac_cv_[]_AC_LANG_ABBREV[]_libs $ac_j"])
100
_AC_LIST_MEMBER_IF($ac_arg, $ac_cv_[]_AC_LANG_ABBREV[]_libs, ,
101
ac_cv_[]_AC_LANG_ABBREV[]_libs="$ac_cv_[]_AC_LANG_ABBREV[]_libs $ac_arg")
103
-zallextract*| -zdefaultextract)
104
ac_cv_[]_AC_LANG_ABBREV[]_libs="$ac_cv_[]_AC_LANG_ABBREV[]_libs $ac_arg"
106
# Ignore everything else.
109
# restore positional arguments
110
set X $ac_save_positional; shift
112
# We only consider "LD_RUN_PATH" on Solaris systems. If this is seen,
113
# then we insist that the "run path" must be an absolute path (i.e. it
114
# must begin with a "/").
115
case `(uname -sr) 2>/dev/null` in
117
ac_ld_run_path=`AS_ECHO(["$ac_[]_AC_LANG_ABBREV[]_v_output"]) |
118
sed -n 's,^.*LD_RUN_PATH *= *\(/[[^ ]]*\).*$,-R\1,p'`
119
test "x$ac_ld_run_path" != x &&
120
_AC_LINKER_OPTION([$ac_ld_run_path], ac_cv_[]_AC_LANG_ABBREV[]_libs)
123
fi # test "x$[]_AC_LANG_PREFIX[]LIBS" = "x"
125
[]_AC_LANG_PREFIX[]LIBS="$ac_cv_[]_AC_LANG_ABBREV[]_libs"
126
AC_SUBST([]_AC_LANG_PREFIX[]LIBS)
127
])# _GA_FC_LIBRARY_LDFLAGS
130
# GA_F77_LIBRARY_LDFLAGS
131
# ----------------------
132
# Wrap AC_F77_LIBRARY_LDFLAGS in case user disables Fortran 77.
133
# When mixing gcc and ifort, we sometimes need to add -lgcc_s to the FLIBS.
134
# Lastly, Sun Studio compilers are not (yet) completely supported.
135
AC_DEFUN([GA_F77_LIBRARY_LDFLAGS], [
137
AC_F77_LIBRARY_LDFLAGS
139
AC_CACHE_CHECK([whether FLIBS needs -lgcc_s], [ga_cv_flibs_gcc_s],
141
ga_save_LIBS="$LIBS"; LIBS="$LIBS $FLIBS"
142
ga_save_FLIBS="$FLIBS"
145
[AC_LANG_PROGRAM([],[])],
146
[ga_cv_flibs_gcc_s=no],
147
[LIBS="$LIBS -lgcc_s"
149
[AC_LANG_PROGRAM([],[])],
150
[FLIBS="$FLIBS -lgcc_s"
151
ga_cv_flibs_gcc_s=yes],
153
FLIBS="$ga_save_FLIBS"
154
ga_cv_flibs_gcc_s=no])])
157
dnl hack to support Sun Studio -Y linker flag
158
AS_IF([test "x$happy" = xno],
159
[AS_UNSET([ac_cv_f77_libs])
161
_GA_FC_LIBRARY_LDFLAGS
162
ga_save_LIBS="$LIBS"; LIBS="$LIBS $FLIBS"
165
[AC_LANG_PROGRAM([],[])],
166
[happy=yes], [happy=no])
169
AS_IF([test "x$happy" = xno],
170
[AC_MSG_WARN([FLIBS does not work])])