1 |
gezelter |
2 |
# This file is part of Autoconf. -*- Autoconf -*- |
2 |
|
|
# Programming languages support. |
3 |
|
|
# Copyright 2000, 2001 |
4 |
|
|
# Free Software Foundation, Inc. |
5 |
|
|
# |
6 |
|
|
# This program is free software; you can redistribute it and/or modify |
7 |
|
|
# it under the terms of the GNU General Public License as published by |
8 |
|
|
# the Free Software Foundation; either version 2, or (at your option) |
9 |
|
|
# any later version. |
10 |
|
|
# |
11 |
|
|
# This program is distributed in the hope that it will be useful, |
12 |
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 |
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
14 |
|
|
# GNU General Public License for more details. |
15 |
|
|
# |
16 |
|
|
# You should have received a copy of the GNU General Public License |
17 |
|
|
# along with this program; if not, write to the Free Software |
18 |
|
|
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA |
19 |
|
|
# 02111-1307, USA. |
20 |
|
|
# |
21 |
|
|
# As a special exception, the Free Software Foundation gives unlimited |
22 |
|
|
# permission to copy, distribute and modify the configure scripts that |
23 |
|
|
# are the output of Autoconf. You need not follow the terms of the GNU |
24 |
|
|
# General Public License when using or distributing such scripts, even |
25 |
|
|
# though portions of the text of Autoconf appear in them. The GNU |
26 |
|
|
# General Public License (GPL) does govern all other use of the material |
27 |
|
|
# that constitutes the Autoconf program. |
28 |
|
|
# |
29 |
|
|
# Certain portions of the Autoconf source text are designed to be copied |
30 |
|
|
# (in certain cases, depending on the input) into the output of |
31 |
|
|
# Autoconf. We call these the "data" portions. The rest of the Autoconf |
32 |
|
|
# source text consists of comments plus executable code that decides which |
33 |
|
|
# of the data portions to output in any given case. We call these |
34 |
|
|
# comments and executable code the "non-data" portions. Autoconf never |
35 |
|
|
# copies any of the non-data portions into its output. |
36 |
|
|
# |
37 |
|
|
# This special exception to the GPL applies to versions of Autoconf |
38 |
|
|
# released by the Free Software Foundation. When you make and |
39 |
|
|
# distribute a modified version of Autoconf, you may extend this special |
40 |
|
|
# exception to the GPL to apply to your modified version as well, *unless* |
41 |
|
|
# your modified version has the potential to copy into its output some |
42 |
|
|
# of the text that was the non-data portion of the version that you started |
43 |
|
|
# with. (In other words, unless your change moves or copies text from |
44 |
|
|
# the non-data portions to the data portions.) If your modification has |
45 |
|
|
# such potential, you must delete any notice of this special exception |
46 |
|
|
# to the GPL from your modified version. |
47 |
|
|
# |
48 |
|
|
# Written by Akim Demaille, Christian Marquardt, Martin Wilks (and probably |
49 |
|
|
# many others). |
50 |
|
|
|
51 |
|
|
|
52 |
|
|
# Table of Contents: |
53 |
|
|
# |
54 |
|
|
# 1. Language selection |
55 |
|
|
# and routines to produce programs in a given language. |
56 |
|
|
# a. Fortran 77 (to be moved from aclang.m4) |
57 |
|
|
# b. Fortran 90 |
58 |
|
|
# c. Fortran 95 |
59 |
|
|
# |
60 |
|
|
# 2. Producing programs in a given language. |
61 |
|
|
# a. Fortran 77 (to be moved from aclang.m4) |
62 |
|
|
# b. Fortran 90 |
63 |
|
|
# c. Fortran 95 |
64 |
|
|
# |
65 |
|
|
# 3. Looking for a compiler |
66 |
|
|
# And possibly the associated preprocessor. |
67 |
|
|
# a. Fortran 77 (to be moved from aclang.m4) |
68 |
|
|
# b. Fortran 90 |
69 |
|
|
# c. Fortran 95 |
70 |
|
|
# |
71 |
|
|
# 4. Compilers' characteristics. |
72 |
|
|
# a. Fortran 77 (to be moved from aclang.m4) |
73 |
|
|
# b. Fortran 90 |
74 |
|
|
# c. Fortran 95 |
75 |
|
|
|
76 |
|
|
# _AC_LIST_MEMBER_IF(ELEMENT, LIST, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND]) |
77 |
|
|
# --------------------------------------------------------------------------- |
78 |
|
|
# |
79 |
|
|
# Processing the elements of a list is tedious in shell programming, |
80 |
|
|
# as lists tend to be implemented as space delimited strings. |
81 |
|
|
# |
82 |
|
|
# This macro searches LIST for ELEMENT, and executes ACTION-IF-FOUND |
83 |
|
|
# if ELEMENT is a member of LIST, otherwise it executes |
84 |
|
|
# ACTION-IF-NOT-FOUND. |
85 |
|
|
AC_DEFUN([_AC_LIST_MEMBER_IF], |
86 |
|
|
[dnl Do some sanity checking of the arguments. |
87 |
|
|
m4_if([$1], , [AC_FATAL([$0: missing argument 1])])dnl |
88 |
|
|
m4_if([$2], , [AC_FATAL([$0: missing argument 2])])dnl |
89 |
|
|
ac_exists=false |
90 |
|
|
for ac_i in $2; do |
91 |
|
|
if test x"$1" = x"$ac_i"; then |
92 |
|
|
ac_exists=true |
93 |
|
|
break |
94 |
|
|
fi |
95 |
|
|
done |
96 |
|
|
|
97 |
|
|
AS_IF([test x"$ac_exists" = xtrue], [$3], [$4])[]dnl |
98 |
|
|
])# _AC_LIST_MEMBER_IF |
99 |
|
|
|
100 |
|
|
|
101 |
|
|
|
102 |
|
|
# _AC_LINKER_OPTION(LINKER-OPTIONS, SHELL-VARIABLE) |
103 |
|
|
# ------------------------------------------------- |
104 |
|
|
# |
105 |
|
|
# Specifying options to the compiler (whether it be the C, C++ or |
106 |
|
|
# Fortran 77 compiler) that are meant for the linker is compiler |
107 |
|
|
# dependent. This macro lets you give options to the compiler that |
108 |
|
|
# are meant for the linker in a portable, compiler-independent way. |
109 |
|
|
# |
110 |
|
|
# This macro take two arguments, a list of linker options that the |
111 |
|
|
# compiler should pass to the linker (LINKER-OPTIONS) and the name of |
112 |
|
|
# a shell variable (SHELL-VARIABLE). The list of linker options are |
113 |
|
|
# appended to the shell variable in a compiler-dependent way. |
114 |
|
|
# |
115 |
|
|
# For example, if the selected language is C, then this: |
116 |
|
|
# |
117 |
|
|
# _AC_LINKER_OPTION([-R /usr/local/lib/foo], foo_LDFLAGS) |
118 |
|
|
# |
119 |
|
|
# will expand into this if the selected C compiler is gcc: |
120 |
|
|
# |
121 |
|
|
# foo_LDFLAGS="-Xlinker -R -Xlinker /usr/local/lib/foo" |
122 |
|
|
# |
123 |
|
|
# otherwise, it will expand into this: |
124 |
|
|
# |
125 |
|
|
# foo_LDFLAGS"-R /usr/local/lib/foo" |
126 |
|
|
# |
127 |
|
|
# You are encouraged to add support for compilers that this macro |
128 |
|
|
# doesn't currently support. |
129 |
|
|
# FIXME: Get rid of this macro. |
130 |
|
|
AC_DEFUN([_AC_LINKER_OPTION], |
131 |
|
|
[if test "$ac_compiler_gnu" = yes; then |
132 |
|
|
for ac_link_opt in $1; do |
133 |
|
|
$2="[$]$2 -Xlinker $ac_link_opt" |
134 |
|
|
done |
135 |
|
|
else |
136 |
|
|
$2="[$]$2 $1" |
137 |
|
|
fi[]dnl |
138 |
|
|
])# _AC_LINKER_OPTION |
139 |
|
|
|
140 |
|
|
|
141 |
|
|
|
142 |
|
|
## ----------------------- ## |
143 |
|
|
## 1. Language selection. ## |
144 |
|
|
## ----------------------- ## |
145 |
|
|
|
146 |
|
|
# ----------------------------- # |
147 |
|
|
# 1b. The Fortran 90 language. # |
148 |
|
|
# ----------------------------- # |
149 |
|
|
|
150 |
|
|
# AC_LANG(Fortran 90) |
151 |
|
|
# ------------------- |
152 |
|
|
m4_define([AC_LANG(Fortran 90)], |
153 |
|
|
[ac_ext=f90 |
154 |
|
|
ac_compile='$F90 -c $F90FLAGS conftest.$ac_ext >&AS_MESSAGE_LOG_FD' |
155 |
|
|
ac_link='$F90 -o conftest$ac_exeext $F90FLAGS $LD90FLAGS $LDFLAGS conftest.$ac_ext $LIBS >&AS_MESSAGE_LOG_FD' |
156 |
|
|
ac_compiler_gnu=$ac_cv_f90_compiler_gnu |
157 |
|
|
]) |
158 |
|
|
|
159 |
|
|
|
160 |
|
|
# _AC_LANG_ABBREV(Fortran 90) |
161 |
|
|
# --------------------------- |
162 |
|
|
m4_define([_AC_LANG_ABBREV(Fortran 90)], [f90]) |
163 |
|
|
|
164 |
|
|
|
165 |
|
|
# ----------------------------- # |
166 |
|
|
# 1c. The Fortran 95 language. # |
167 |
|
|
# ----------------------------- # |
168 |
|
|
|
169 |
|
|
# AC_LANG(Fortran 95) |
170 |
|
|
# ------------------- |
171 |
|
|
m4_define([AC_LANG(Fortran 95)], |
172 |
|
|
[ac_ext=f95 |
173 |
|
|
ac_compile='$F95 -c $F95FLAGS conftest.$ac_ext >&AS_MESSAGE_LOG_FD' |
174 |
|
|
ac_link='$F95 -o conftest$ac_exeext $F95FLAGS $LD95FLAGS $LDFLAGS conftest.$ac_ext $LIBS >&AS_MESSAGE_LOG_FD' |
175 |
|
|
ac_compiler_gnu=$ac_cv_f95_compiler_gnu |
176 |
|
|
]) |
177 |
|
|
|
178 |
|
|
|
179 |
|
|
# _AC_LANG_ABBREV(Fortran 95) |
180 |
|
|
# --------------------------- |
181 |
|
|
m4_define([_AC_LANG_ABBREV(Fortran 95)], [f95]) |
182 |
|
|
|
183 |
|
|
|
184 |
|
|
## ---------------------- ## |
185 |
|
|
## 2.Producing programs. ## |
186 |
|
|
## ---------------------- ## |
187 |
|
|
|
188 |
|
|
# ------------------------ # |
189 |
|
|
# 2b. Fortran 90 sources. # |
190 |
|
|
# ------------------------ # |
191 |
|
|
|
192 |
|
|
# AC_LANG_SOURCE(Fortran 90)(BODY) |
193 |
|
|
# -------------------------------- |
194 |
|
|
m4_copy([AC_LANG_SOURCE(Fortran 77)], [AC_LANG_SOURCE(Fortran 90)]) |
195 |
|
|
|
196 |
|
|
|
197 |
|
|
# AC_LANG_PROGRAM(Fortran 90)([PROLOGUE], [BODY]) |
198 |
|
|
# ----------------------------------------------- |
199 |
|
|
m4_define([AC_LANG_PROGRAM(Fortran 90)], [ |
200 |
|
|
program main |
201 |
|
|
$1 |
202 |
|
|
$2 |
203 |
|
|
end program main |
204 |
|
|
]) |
205 |
|
|
|
206 |
|
|
# AC_LANG_CALL(Fortran 90)(PROLOGUE, FUNCTION) |
207 |
|
|
# -------------------------------------------- |
208 |
|
|
m4_define([AC_LANG_CALL(Fortran 90)], |
209 |
|
|
[AC_LANG_PROGRAM([$1], |
210 |
|
|
[call $2])]) |
211 |
|
|
|
212 |
|
|
|
213 |
|
|
# ------------------------ # |
214 |
|
|
# 2c. Fortran 95 sources. # |
215 |
|
|
# ------------------------ # |
216 |
|
|
|
217 |
|
|
# AC_LANG_SOURCE(Fortran 95)(BODY) |
218 |
|
|
# -------------------------------- |
219 |
|
|
m4_copy([AC_LANG_SOURCE(Fortran 90)], [AC_LANG_SOURCE(Fortran 95)]) |
220 |
|
|
|
221 |
|
|
# AC_LANG_PROGRAM(Fortran 95)([PROLOGUE], [BODY]) |
222 |
|
|
# ----------------------------------------------- |
223 |
|
|
m4_copy([AC_LANG_PROGRAM(Fortran 90)], [AC_LANG_PROGRAM(Fortran 95)]) |
224 |
|
|
|
225 |
|
|
# AC_LANG_CALL(Fortran 95)(PROLOGUE, FUNCTION) |
226 |
|
|
# -------------------------------------------- |
227 |
|
|
m4_copy([AC_LANG_CALL(Fortran 90)], [AC_LANG_CALL(Fortran 90)]) |
228 |
|
|
|
229 |
|
|
|
230 |
|
|
## -------------------------------------------- ## |
231 |
|
|
## 3. Looking for Compilers and Preprocessors. ## |
232 |
|
|
## -------------------------------------------- ## |
233 |
|
|
|
234 |
|
|
# ----------------------------- # |
235 |
|
|
# 3b. The Fortran 90 compiler. # |
236 |
|
|
# ----------------------------- # |
237 |
|
|
|
238 |
|
|
|
239 |
|
|
# AC_LANG_PREPROC(Fortran 90) |
240 |
|
|
# --------------------------- |
241 |
|
|
# Find the Fortran 90 preprocessor. Must be AC_DEFUN'd to be AC_REQUIRE'able. |
242 |
|
|
AC_DEFUN([AC_LANG_PREPROC(Fortran 90)], |
243 |
|
|
[m4_warn([syntax], |
244 |
|
|
[$0: No preprocessor defined for ]_AC_LANG)]) |
245 |
|
|
|
246 |
|
|
|
247 |
|
|
# AC_LANG_COMPILER(Fortran 90) |
248 |
|
|
# ---------------------------- |
249 |
|
|
# Find the Fortran 90 compiler. Must be AC_DEFUN'd to be |
250 |
|
|
# AC_REQUIRE'able. |
251 |
|
|
AC_DEFUN([AC_LANG_COMPILER(Fortran 90)], |
252 |
|
|
[AC_REQUIRE([AC_PROG_F90])]) |
253 |
|
|
|
254 |
|
|
|
255 |
|
|
# AC_PROG_F90([COMPILERS...]) |
256 |
|
|
# --------------------------- |
257 |
|
|
# COMPILERS is a space separated list of Fortran 90 compilers to search |
258 |
|
|
# for. |
259 |
|
|
# |
260 |
|
|
# Compilers are ordered by |
261 |
|
|
# 1. F90, F95 |
262 |
|
|
# 2. Good/tested native compilers, bad/untested native compilers |
263 |
|
|
# |
264 |
|
|
# pgf90 is the Portland Group F90 compilers. |
265 |
|
|
# xlf90/xlf95 are IBM (AIX) F90/F95 compilers. |
266 |
|
|
# lf95 is the Lahey-Fujitsu compiler. |
267 |
|
|
# epcf90 is the "Edinburgh Portable Compiler" F90. |
268 |
|
|
# fort is the Compaq Fortran 90 (now 95) compiler for Tru64 and Linux/Alpha. |
269 |
|
|
AC_DEFUN([AC_PROG_F90], |
270 |
|
|
[AC_LANG_PUSH(Fortran 90)dnl |
271 |
|
|
AC_ARG_VAR([F90], [Fortran 90 compiler command])dnl |
272 |
|
|
AC_ARG_VAR([F90FLAGS], [Fortran 90 compiler flags])dnl |
273 |
|
|
_AC_ARG_VAR_LDFLAGS()dnl |
274 |
|
|
AC_CHECK_TOOLS(F90, |
275 |
|
|
[m4_default([$1], |
276 |
|
|
[f90 xlf90 pgf90 epcf90 f95 xlf95 lf95 fort g95])]) |
277 |
|
|
|
278 |
|
|
m4_expand_once([_AC_COMPILER_EXEEXT])[]dnl |
279 |
|
|
m4_expand_once([_AC_COMPILER_OBJEXT])[]dnl |
280 |
|
|
# If we don't use `.F90' as extension, the preprocessor is not run on the |
281 |
|
|
# input file. |
282 |
|
|
ac_save_ext=$ac_ext |
283 |
|
|
ac_ext=F90 |
284 |
|
|
_AC_LANG_COMPILER_GNU |
285 |
|
|
ac_ext=$ac_save_ext |
286 |
|
|
G95=`test $ac_compiler_gnu = yes && echo yes` |
287 |
|
|
AC_LANG_POP(Fortran 90)dnl |
288 |
|
|
])# AC_PROG_F90 |
289 |
|
|
|
290 |
|
|
|
291 |
|
|
# ----------------------------- # |
292 |
|
|
# 3c. The Fortran 95 compiler. # |
293 |
|
|
# ----------------------------- # |
294 |
|
|
|
295 |
|
|
|
296 |
|
|
# AC_LANG_PREPROC(Fortran 95) |
297 |
|
|
# --------------------------- |
298 |
|
|
# Find the Fortran 95 preprocessor. Must be AC_DEFUN'd to be AC_REQUIRE'able. |
299 |
|
|
AC_DEFUN([AC_LANG_PREPROC(Fortran 95)], |
300 |
|
|
[m4_warn([syntax], |
301 |
|
|
[$0: No preprocessor defined for ]_AC_LANG)]) |
302 |
|
|
|
303 |
|
|
|
304 |
|
|
# AC_LANG_COMPILER(Fortran 95) |
305 |
|
|
# ---------------------------- |
306 |
|
|
# Find the Fortran 95 compiler. Must be AC_DEFUN'd to be |
307 |
|
|
# AC_REQUIRE'able. |
308 |
|
|
AC_DEFUN([AC_LANG_COMPILER(Fortran 95)], |
309 |
|
|
[AC_REQUIRE([AC_PROG_F95])]) |
310 |
|
|
|
311 |
|
|
|
312 |
|
|
# AC_PROG_F95([COMPILERS...]) |
313 |
|
|
# --------------------------- |
314 |
|
|
# COMPILERS is a space separated list of Fortran 95 compilers to search |
315 |
|
|
# for. |
316 |
|
|
# |
317 |
|
|
# Compilers are ordered by |
318 |
|
|
# 1. Good/tested native compilers, bad/untested native compilers |
319 |
|
|
# |
320 |
|
|
# xlf95 is the IBM (AIX) F95 compiler. |
321 |
|
|
# lf95 is the Lahey-Fujitsu compiler. |
322 |
|
|
# fort is the Compaq Fortran 90 (now 95) compiler for Tru64 and Linux/Alpha. |
323 |
|
|
AC_DEFUN([AC_PROG_F95], |
324 |
|
|
[AC_LANG_PUSH(Fortran 95)dnl |
325 |
|
|
AC_ARG_VAR([F95], [Fortran 95 compiler command])dnl |
326 |
|
|
AC_ARG_VAR([F95FLAGS], [Fortran 95 compiler flags])dnl |
327 |
|
|
_AC_ARG_VAR_LDFLAGS()dnl |
328 |
|
|
AC_CHECK_TOOLS(F95, |
329 |
|
|
[m4_default([$1], |
330 |
|
|
[f95 xlf95 lf95 fort g95])]) |
331 |
|
|
|
332 |
|
|
m4_expand_once([_AC_COMPILER_EXEEXT])[]dnl |
333 |
|
|
m4_expand_once([_AC_COMPILER_OBJEXT])[]dnl |
334 |
|
|
# If we don't use `.F95' as extension, the preprocessor is not run on the |
335 |
|
|
# input file. |
336 |
|
|
ac_save_ext=$ac_ext |
337 |
|
|
ac_ext=F95 |
338 |
|
|
_AC_LANG_COMPILER_GNU |
339 |
|
|
ac_ext=$ac_save_ext |
340 |
|
|
G95=`test $ac_compiler_gnu = yes && echo yes` |
341 |
|
|
AC_LANG_POP(Fortran 95)dnl |
342 |
|
|
])# AC_PROG_F95 |
343 |
|
|
|
344 |
|
|
|
345 |
|
|
## ------------------------------- ## |
346 |
|
|
## 4. Compilers' characteristics. ## |
347 |
|
|
## ------------------------------- ## |
348 |
|
|
|
349 |
|
|
|
350 |
|
|
# ---------------------------------------- # |
351 |
|
|
# 4b. Fortan 90 compiler characteristics. # |
352 |
|
|
# ---------------------------------------- # |
353 |
|
|
|
354 |
|
|
|
355 |
|
|
# _AC_PROG_F90_V_OUTPUT([FLAG = $ac_cv_prog_f90_v]) |
356 |
|
|
# ------------------------------------------------- |
357 |
|
|
# Link a trivial Fortran program, compiling with a verbose output FLAG |
358 |
|
|
# (which default value, $ac_cv_prog_f90_v, is computed by |
359 |
|
|
# _AC_PROG_F90_V), and return the output in $ac_f90_v_output. This |
360 |
|
|
# output is processed in the way expected by AC_F90_LIBRARY_LDFLAGS, |
361 |
|
|
# so that any link flags that are echoed by the compiler appear as |
362 |
|
|
# space-separated items. |
363 |
|
|
AC_DEFUN([_AC_PROG_F90_V_OUTPUT], |
364 |
|
|
[AC_REQUIRE([AC_PROG_F90])dnl |
365 |
|
|
AC_LANG_PUSH(Fortran 90)dnl |
366 |
|
|
|
367 |
|
|
AC_LANG_CONFTEST([AC_LANG_PROGRAM([])]) |
368 |
|
|
|
369 |
|
|
# Compile and link our simple test program by passing a flag (argument |
370 |
|
|
# 1 to this macro) to the Fortran 90 compiler in order to get |
371 |
|
|
# "verbose" output that we can then parse for the Fortran 90 linker |
372 |
|
|
# flags. |
373 |
|
|
ac_save_F90FLAGS=$F90FLAGS |
374 |
|
|
F90FLAGS="$F90FLAGS m4_default([$1], [$ac_cv_prog_f90_v])" |
375 |
|
|
|
376 |
|
|
(eval echo $as_me:__oline__: \"$ac_link\") >&AS_MESSAGE_LOG_FD |
377 |
|
|
ac_f90_v_output=`eval $ac_link AS_MESSAGE_LOG_FD>&1 2>&1 | grep -v 'Driving:'` |
378 |
|
|
echo "$ac_f90_v_output" >&AS_MESSAGE_LOG_FD |
379 |
|
|
F90FLAGS=$ac_save_F90FLAGS |
380 |
|
|
|
381 |
|
|
rm -f conftest.* |
382 |
|
|
AC_LANG_POP(Fortran 90)dnl |
383 |
|
|
|
384 |
|
|
# If we are using xlf then replace all the commas with spaces. |
385 |
|
|
if echo $ac_f90_v_output | grep xlfentry >/dev/null 2>&1; then |
386 |
|
|
ac_f90_v_output=`echo $ac_f90_v_output | sed 's/,/ /g'` |
387 |
|
|
fi |
388 |
|
|
|
389 |
|
|
# If we are using Cray Fortran then delete quotes. |
390 |
|
|
# Use "\"" instead of '"' for font-lock-mode. |
391 |
|
|
# FIXME: a more general fix for quoted arguments with spaces? |
392 |
|
|
if echo $ac_f90_v_output | grep cft90 >/dev/null 2>&1; then |
393 |
|
|
ac_f90_v_output=`echo $ac_f90_v_output | sed "s/\"//g"` |
394 |
|
|
fi[]dnl |
395 |
|
|
])# _AC_PROG_F90_V_OUTPUT |
396 |
|
|
|
397 |
|
|
|
398 |
|
|
# _AC_PROG_F90_V |
399 |
|
|
# -------------- |
400 |
|
|
# |
401 |
|
|
# Determine the flag that causes the Fortran 90 compiler to print |
402 |
|
|
# information of library and object files (normally -v) |
403 |
|
|
# Needed for AC_F90_LIBRARY_FLAGS |
404 |
|
|
# Some compilers don't accept -v (Lahey: -verbose, xlf: -V, Fujitsu: -###) |
405 |
|
|
AC_DEFUN([_AC_PROG_F90_V], |
406 |
|
|
[AC_CACHE_CHECK([how to get verbose linking output from $F90], |
407 |
|
|
[ac_cv_prog_f90_v], |
408 |
|
|
[AC_LANG_ASSERT(Fortran 90) |
409 |
|
|
AC_COMPILE_IFELSE([AC_LANG_PROGRAM()], |
410 |
|
|
[ac_cv_prog_f90_v= |
411 |
|
|
# Try some options frequently used verbose output |
412 |
|
|
for ac_verb in -v -verbose --verbose -V -\#\#\#; do |
413 |
|
|
_AC_PROG_F90_V_OUTPUT($ac_verb) |
414 |
|
|
# look for -l* and *.a constructs in the output |
415 |
|
|
for ac_arg in $ac_f90_v_output; do |
416 |
|
|
case $ac_arg in |
417 |
|
|
[[\\/]]*.a | ?:[[\\/]]*.a | -[[lLRu]]*) |
418 |
|
|
ac_cv_prog_f90_v=$ac_verb |
419 |
|
|
break 2 ;; |
420 |
|
|
esac |
421 |
|
|
done |
422 |
|
|
done |
423 |
|
|
if test -z "$ac_cv_prog_f90_v"; then |
424 |
|
|
AC_MSG_WARN([cannot determine how to obtain linking information from $F90]) |
425 |
|
|
fi], |
426 |
|
|
[AC_MSG_WARN([compilation failed])]) |
427 |
|
|
])])# _AC_PROG_F90_V |
428 |
|
|
|
429 |
|
|
|
430 |
|
|
# AC_F90_LIBRARY_LDFLAGS |
431 |
|
|
# ---------------------- |
432 |
|
|
# |
433 |
|
|
# Determine the linker flags (e.g. "-L" and "-l") for the Fortran 90 |
434 |
|
|
# intrinsic and run-time libraries that are required to successfully |
435 |
|
|
# link a Fortran 90 program or shared library. The output variable |
436 |
|
|
# F90LIBS is set to these flags. |
437 |
|
|
# |
438 |
|
|
# This macro is intended to be used in those situations when it is |
439 |
|
|
# necessary to mix, e.g. C++ and Fortran 90, source code into a single |
440 |
|
|
# program or shared library. |
441 |
|
|
# |
442 |
|
|
# For example, if object files from a C++ and Fortran 90 compiler must |
443 |
|
|
# be linked together, then the C++ compiler/linker must be used for |
444 |
|
|
# linking (since special C++-ish things need to happen at link time |
445 |
|
|
# like calling global constructors, instantiating templates, enabling |
446 |
|
|
# exception support, etc.). |
447 |
|
|
# |
448 |
|
|
# However, the Fortran 90 intrinsic and run-time libraries must be |
449 |
|
|
# linked in as well, but the C++ compiler/linker doesn't know how to |
450 |
|
|
# add these Fortran 90 libraries. Hence, the macro |
451 |
|
|
# "AC_F90_LIBRARY_LDFLAGS" was created to determine these Fortran 90 |
452 |
|
|
# libraries. |
453 |
|
|
# |
454 |
|
|
# This macro was copied from the Fortran 77 version by Matthew D. Langston. |
455 |
|
|
AC_DEFUN([AC_F90_LIBRARY_LDFLAGS], |
456 |
|
|
[AC_LANG_PUSH(Fortran 90)dnl |
457 |
|
|
_AC_PROG_F90_V |
458 |
|
|
AC_CACHE_CHECK([for Fortran 90 libraries], ac_cv_flibs, |
459 |
|
|
[if test "x$F90LIBS" != "x"; then |
460 |
|
|
ac_cv_f90libs="$F90LIBS" # Let the user override the test. |
461 |
|
|
else |
462 |
|
|
|
463 |
|
|
_AC_PROG_F90_V_OUTPUT |
464 |
|
|
|
465 |
|
|
ac_cv_f90libs= |
466 |
|
|
|
467 |
|
|
# Save positional arguments (if any) |
468 |
|
|
ac_save_positional="$[@]" |
469 |
|
|
|
470 |
|
|
set X $ac_f90_v_output |
471 |
|
|
while test $[@%:@] != 1; do |
472 |
|
|
shift |
473 |
|
|
ac_arg=$[1] |
474 |
|
|
case $ac_arg in |
475 |
|
|
[[\\/]]*.a | ?:[[\\/]]*.a) |
476 |
|
|
_AC_LIST_MEMBER_IF($ac_arg, $ac_cv_f90libs, , |
477 |
|
|
ac_cv_f90libs="$ac_cv_f90libs $ac_arg") |
478 |
|
|
;; |
479 |
|
|
-bI:*) |
480 |
|
|
_AC_LIST_MEMBER_IF($ac_arg, $ac_cv_f90libs, , |
481 |
|
|
[_AC_LINKER_OPTION([$ac_arg], ac_cv_f90libs)]) |
482 |
|
|
;; |
483 |
|
|
# Ignore these flags. |
484 |
|
|
-lang* | [-lcrt[012].o] | -lc | -lgcc | -LANG:=*) |
485 |
|
|
;; |
486 |
|
|
-lkernel32) |
487 |
|
|
test x"$CYGWIN" != xyes && ac_cv_f90libs="$ac_cv_f90libs $ac_arg" |
488 |
|
|
;; |
489 |
|
|
-[[LRuY]]) |
490 |
|
|
# These flags, when seen by themselves, take an argument. |
491 |
|
|
# We remove the space between option and argument and re-iterate |
492 |
|
|
# unless we find an empty arg or a new option (starting with -) |
493 |
|
|
case $[2] in |
494 |
|
|
"" | -*);; |
495 |
|
|
*) |
496 |
|
|
ac_arg="$ac_arg$[2]" |
497 |
|
|
|
498 |
|
|
shift; shift |
499 |
|
|
set X $ac_arg "$[@]" |
500 |
|
|
;; |
501 |
|
|
esac |
502 |
|
|
;; |
503 |
|
|
-YP,*) |
504 |
|
|
for ac_j in `echo $ac_arg | sed -e 's/-YP,/-L/;s/:/ -L/g'`; do |
505 |
|
|
_AC_LIST_MEMBER_IF($ac_j, $ac_cv_f90libs, , |
506 |
|
|
[ac_arg="$ac_arg $ac_j" |
507 |
|
|
ac_cv_f90libs="$ac_cv_f90libs $ac_j"]) |
508 |
|
|
done |
509 |
|
|
;; |
510 |
|
|
-[[lLR]]*) |
511 |
|
|
_AC_LIST_MEMBER_IF($ac_arg, $ac_cv_f90libs, , |
512 |
|
|
ac_cv_f90libs="$ac_cv_f90libs $ac_arg") |
513 |
|
|
;; |
514 |
|
|
# Ignore everything else. |
515 |
|
|
esac |
516 |
|
|
done |
517 |
|
|
# restore positional arguments |
518 |
|
|
set X $ac_save_positional; shift |
519 |
|
|
|
520 |
|
|
# We only consider "LD_RUN_PATH" on Solaris systems. If this is seen, |
521 |
|
|
# then we insist that the "run path" must be an absolute path (i.e. it |
522 |
|
|
# must begin with a "/"). |
523 |
|
|
case `(uname -sr) 2>/dev/null` in |
524 |
|
|
"SunOS 5"*) |
525 |
|
|
ac_ld_run_path=`echo $ac_f90_v_output | |
526 |
|
|
sed -n 's,^.*LD_RUN_PATH *= *\(/[[^ ]]*\).*$,-R\1,p'` |
527 |
|
|
test "x$ac_ld_run_path" != x && |
528 |
|
|
|
529 |
|
|
_AC_LINKER_OPTION([$ac_ld_run_path], ac_cv_f90libs) |
530 |
|
|
;; |
531 |
|
|
esac |
532 |
|
|
fi # test "x$F90LIBS" = "x" |
533 |
|
|
]) |
534 |
|
|
F90LIBS="$ac_cv_f90libs" |
535 |
|
|
AC_SUBST(F90LIBS) |
536 |
|
|
AC_LANG_POP(Fortran 90)dnl |
537 |
|
|
])# AC_F90_LIBRARY_LDFLAGS |
538 |
|
|
|
539 |
|
|
|
540 |
|
|
# _AC_F90_NAME_MANGLING |
541 |
|
|
# --------------------- |
542 |
|
|
# Test for the name mangling scheme used by the Fortran 90 compiler. |
543 |
|
|
# |
544 |
|
|
# Sets ac_cv_f90_mangling. The value contains three fields, separated |
545 |
|
|
# by commas: |
546 |
|
|
# |
547 |
|
|
# lower case / upper case: |
548 |
|
|
# case translation of the Fortan 90 symbols |
549 |
|
|
# underscore / no underscore: |
550 |
|
|
# whether the compiler appends "_" to symbol names |
551 |
|
|
# extra underscore / no extra underscore: |
552 |
|
|
# whether the compiler appends an extra "_" to symbol names already |
553 |
|
|
# containing at least one underscore |
554 |
|
|
# |
555 |
|
|
AC_DEFUN([_AC_F90_NAME_MANGLING], |
556 |
|
|
[AC_REQUIRE([AC_F90_LIBRARY_LDFLAGS])dnl |
557 |
|
|
AC_CACHE_CHECK([for Fortran 90 name-mangling scheme], |
558 |
|
|
ac_cv_f90_mangling, |
559 |
|
|
[AC_LANG_PUSH(Fortran 90)dnl |
560 |
|
|
AC_COMPILE_IFELSE( |
561 |
|
|
[subroutine foobar() |
562 |
|
|
return |
563 |
|
|
end |
564 |
|
|
subroutine foo_bar() |
565 |
|
|
return |
566 |
|
|
end], |
567 |
|
|
[mv conftest.$ac_objext cf90_test.$ac_objext |
568 |
|
|
|
569 |
|
|
AC_LANG_PUSH(C)dnl |
570 |
|
|
|
571 |
|
|
ac_save_LIBS=$LIBS |
572 |
|
|
LIBS="cf90_test.$ac_objext $F90LIBS $LIBS" |
573 |
|
|
|
574 |
|
|
ac_success=no |
575 |
|
|
for ac_foobar in foobar FOOBAR; do |
576 |
|
|
for ac_underscore in "" "_"; do |
577 |
|
|
ac_func="$ac_foobar$ac_underscore" |
578 |
|
|
AC_TRY_LINK_FUNC($ac_func, |
579 |
|
|
[ac_success=yes; break 2]) |
580 |
|
|
done |
581 |
|
|
done |
582 |
|
|
|
583 |
|
|
if test "$ac_success" = "yes"; then |
584 |
|
|
case $ac_foobar in |
585 |
|
|
foobar) |
586 |
|
|
ac_case=lower |
587 |
|
|
ac_foo_bar=foo_bar |
588 |
|
|
;; |
589 |
|
|
FOOBAR) |
590 |
|
|
ac_case=upper |
591 |
|
|
ac_foo_bar=FOO_BAR |
592 |
|
|
;; |
593 |
|
|
esac |
594 |
|
|
|
595 |
|
|
ac_success_extra=no |
596 |
|
|
for ac_extra in "" "_"; do |
597 |
|
|
ac_func="$ac_foo_bar$ac_underscore$ac_extra" |
598 |
|
|
|
599 |
|
|
AC_TRY_LINK_FUNC($ac_func, |
600 |
|
|
[ac_success_extra=yes; break]) |
601 |
|
|
done |
602 |
|
|
|
603 |
|
|
if test "$ac_success_extra" = "yes"; then |
604 |
|
|
ac_cv_f90_mangling="$ac_case case" |
605 |
|
|
if test -z "$ac_underscore"; then |
606 |
|
|
ac_cv_f90_mangling="$ac_cv_f90_mangling, no underscore" |
607 |
|
|
else |
608 |
|
|
ac_cv_f90_mangling="$ac_cv_f90_mangling, underscore" |
609 |
|
|
|
610 |
|
|
fi |
611 |
|
|
if test -z "$ac_extra"; then |
612 |
|
|
ac_cv_f90_mangling="$ac_cv_f90_mangling, no extra underscore" |
613 |
|
|
else |
614 |
|
|
ac_cv_f90_mangling="$ac_cv_f90_mangling, extra underscore" |
615 |
|
|
fi |
616 |
|
|
else |
617 |
|
|
ac_cv_f90_mangling="unknown" |
618 |
|
|
fi |
619 |
|
|
else |
620 |
|
|
ac_cv_f90_mangling="unknown" |
621 |
|
|
|
622 |
|
|
fi |
623 |
|
|
|
624 |
|
|
LIBS=$ac_save_LIBS |
625 |
|
|
AC_LANG_POP(C)dnl |
626 |
|
|
rm -f cf90_test* conftest*]) |
627 |
|
|
AC_LANG_POP(Fortran 90)dnl |
628 |
|
|
]) |
629 |
|
|
])# _AC_F90_NAME_MANGLING |
630 |
|
|
|
631 |
|
|
# The replacement is empty. |
632 |
|
|
AU_DEFUN([AC_F90_NAME_MANGLING], []) |
633 |
|
|
|
634 |
|
|
|
635 |
|
|
# AC_F90_WRAPPERS |
636 |
|
|
# --------------- |
637 |
|
|
# Defines C macros F90_FUNC(name,NAME) and F90_FUNC_(name,NAME) to |
638 |
|
|
# properly mangle the names of C identifiers, and C identifiers with |
639 |
|
|
# underscores, respectively, so that they match the name mangling |
640 |
|
|
# scheme used by the Fortran 90 compiler. |
641 |
|
|
AC_DEFUN([AC_F90_WRAPPERS], |
642 |
|
|
[AC_REQUIRE([_AC_F90_NAME_MANGLING])dnl |
643 |
|
|
AH_TEMPLATE([F90_FUNC], |
644 |
|
|
[Define to a macro mangling the given C identifier (in lower and upper |
645 |
|
|
case), which must not contain underscores, for linking with Fortran 90.])dnl |
646 |
|
|
AH_TEMPLATE([F90_FUNC_], |
647 |
|
|
[As F90_FUNC, but for C identifiers containing underscores.])dnl |
648 |
|
|
case $ac_cv_f90_mangling in |
649 |
|
|
"lower case, no underscore, no extra underscore") |
650 |
|
|
AC_DEFINE([F90_FUNC(name,NAME)], [name]) |
651 |
|
|
AC_DEFINE([F90_FUNC_(name,NAME)], [name]) ;; |
652 |
|
|
"lower case, no underscore, extra underscore") |
653 |
|
|
AC_DEFINE([F90_FUNC(name,NAME)], [name]) |
654 |
|
|
AC_DEFINE([F90_FUNC_(name,NAME)], [name ## _]) ;; |
655 |
|
|
"lower case, underscore, no extra underscore") |
656 |
|
|
AC_DEFINE([F90_FUNC(name,NAME)], [name ## _]) |
657 |
|
|
AC_DEFINE([F90_FUNC_(name,NAME)], [name ## _]) ;; |
658 |
|
|
"lower case, underscore, extra underscore") |
659 |
|
|
AC_DEFINE([F90_FUNC(name,NAME)], [name ## _]) |
660 |
|
|
AC_DEFINE([F90_FUNC_(name,NAME)], [name ## __]) ;; |
661 |
|
|
"upper case, no underscore, no extra underscore") |
662 |
|
|
AC_DEFINE([F90_FUNC(name,NAME)], [NAME]) |
663 |
|
|
AC_DEFINE([F90_FUNC_(name,NAME)], [NAME]) ;; |
664 |
|
|
"upper case, no underscore, extra underscore") |
665 |
|
|
AC_DEFINE([F90_FUNC(name,NAME)], [NAME]) |
666 |
|
|
AC_DEFINE([F90_FUNC_(name,NAME)], [NAME ## _]) ;; |
667 |
|
|
"upper case, underscore, no extra underscore") |
668 |
|
|
AC_DEFINE([F90_FUNC(name,NAME)], [NAME ## _]) |
669 |
|
|
AC_DEFINE([F90_FUNC_(name,NAME)], [NAME ## _]) ;; |
670 |
|
|
"upper case, underscore, extra underscore") |
671 |
|
|
AC_DEFINE([F90_FUNC(name,NAME)], [NAME ## _]) |
672 |
|
|
AC_DEFINE([F90_FUNC_(name,NAME)], [NAME ## __]) ;; |
673 |
|
|
*) |
674 |
|
|
AC_MSG_WARN([unknown Fortran 90 name-mangling scheme]) |
675 |
|
|
;; |
676 |
|
|
esac |
677 |
|
|
])# AC_F90_WRAPPERS |
678 |
|
|
|
679 |
|
|
|
680 |
|
|
# AC_F90_FUNC(NAME, [SHELLVAR = NAME]) |
681 |
|
|
# ------------------------------------ |
682 |
|
|
# For a Fortran subroutine of given NAME, define a shell variable |
683 |
|
|
# $SHELLVAR to the Fortran 90 mangled name. If the SHELLVAR |
684 |
|
|
# argument is not supplied, it defaults to NAME. |
685 |
|
|
AC_DEFUN([AC_F90_FUNC], |
686 |
|
|
[AC_REQUIRE([_AC_F90_NAME_MANGLING])dnl |
687 |
|
|
case $ac_cv_f90_mangling in |
688 |
|
|
upper*) ac_val="m4_toupper([$1])" ;; |
689 |
|
|
lower*) ac_val="m4_tolower([$1])" ;; |
690 |
|
|
*) ac_val="unknown" ;; |
691 |
|
|
esac |
692 |
|
|
case $ac_cv_f90_mangling in *," underscore"*) ac_val="$ac_val"_ ;; esac |
693 |
|
|
m4_if(m4_index([$1],[_]),-1,[], |
694 |
|
|
[case $ac_cv_f90_mangling in *," extra underscore"*) ac_val="$ac_val"_ ;; esac |
695 |
|
|
]) |
696 |
|
|
m4_default([$2],[$1])="$ac_val" |
697 |
|
|
|
698 |
|
|
])# AC_F90_FUNC |
699 |
|
|
|
700 |
|
|
|
701 |
|
|
# ---------------------------------------- # |
702 |
|
|
# 4c. Fortan 95 compiler characteristics. # |
703 |
|
|
# ---------------------------------------- # |
704 |
|
|
|
705 |
|
|
|
706 |
|
|
# _AC_PROG_F95_V_OUTPUT([FLAG = $ac_cv_prog_f95_v]) |
707 |
|
|
# ------------------------------------------------- |
708 |
|
|
# Link a trivial Fortran program, compiling with a verbose output FLAG |
709 |
|
|
# (which default value, $ac_cv_prog_f95_v, is computed by |
710 |
|
|
# _AC_PROG_F95_V), and return the output in $ac_f95_v_output. This |
711 |
|
|
# output is processed in the way expected by AC_F95_LIBRARY_LDFLAGS, |
712 |
|
|
# so that any link flags that are echoed by the compiler appear as |
713 |
|
|
# space-separated items. |
714 |
|
|
AC_DEFUN([_AC_PROG_F95_V_OUTPUT], |
715 |
|
|
[AC_REQUIRE([AC_PROG_F95])dnl |
716 |
|
|
AC_LANG_PUSH(Fortran 95)dnl |
717 |
|
|
|
718 |
|
|
AC_LANG_CONFTEST([AC_LANG_PROGRAM([])]) |
719 |
|
|
|
720 |
|
|
# Compile and link our simple test program by passing a flag (argument |
721 |
|
|
# 1 to this macro) to the Fortran 95 compiler in order to get |
722 |
|
|
# "verbose" output that we can then parse for the Fortran 95 linker |
723 |
|
|
# flags. |
724 |
|
|
ac_save_F95FLAGS=$F95FLAGS |
725 |
|
|
F95FLAGS="$F95FLAGS m4_default([$1], [$ac_cv_prog_f95_v])" |
726 |
|
|
(eval echo $as_me:__oline__: \"$ac_link\") >&AS_MESSAGE_LOG_FD |
727 |
|
|
ac_f95_v_output=`eval $ac_link AS_MESSAGE_LOG_FD>&1 2>&1 | grep -v 'Driving:'` |
728 |
|
|
echo "$ac_f95_v_output" >&AS_MESSAGE_LOG_FD |
729 |
|
|
F95FLAGS=$ac_save_F95FLAGS |
730 |
|
|
|
731 |
|
|
rm -f conftest.* |
732 |
|
|
AC_LANG_POP(Fortran 95)dnl |
733 |
|
|
|
734 |
|
|
# If we are using xlf then replace all the commas with spaces. |
735 |
|
|
if echo $ac_f95_v_output | grep xlfentry >/dev/null 2>&1; then |
736 |
|
|
ac_f95_v_output=`echo $ac_f95_v_output | sed 's/,/ /g'` |
737 |
|
|
fi |
738 |
|
|
|
739 |
|
|
# If we are using Cray Fortran then delete quotes. |
740 |
|
|
# Use "\"" instead of '"' for font-lock-mode. |
741 |
|
|
# FIXME: a more general fix for quoted arguments with spaces? |
742 |
|
|
if echo $ac_f95_v_output | grep cft95 >/dev/null 2>&1; then |
743 |
|
|
ac_f95_v_output=`echo $ac_f95_v_output | sed "s/\"//g"` |
744 |
|
|
fi[]dnl |
745 |
|
|
])# _AC_PROG_F95_V_OUTPUT |
746 |
|
|
|
747 |
|
|
|
748 |
|
|
# _AC_PROG_F95_V |
749 |
|
|
# -------------- |
750 |
|
|
# |
751 |
|
|
# Determine the flag that causes the Fortran 95 compiler to print |
752 |
|
|
# information of library and object files (normally -v) |
753 |
|
|
# Needed for AC_F95_LIBRARY_FLAGS |
754 |
|
|
# Some compilers don't accept -v (Lahey: -verbose, xlf: -V, Fujitsu: -###) |
755 |
|
|
AC_DEFUN([_AC_PROG_F95_V], |
756 |
|
|
[AC_CACHE_CHECK([how to get verbose linking output from $F95], |
757 |
|
|
[ac_cv_prog_f95_v], |
758 |
|
|
[AC_LANG_ASSERT(Fortran 95) |
759 |
|
|
AC_COMPILE_IFELSE([AC_LANG_PROGRAM()], |
760 |
|
|
[ac_cv_prog_f95_v= |
761 |
|
|
# Try some options frequently used verbose output |
762 |
|
|
for ac_verb in -v -verbose --verbose -V -\#\#\#; do |
763 |
|
|
_AC_PROG_F95_V_OUTPUT($ac_verb) |
764 |
|
|
# look for -l* and *.a constructs in the output |
765 |
|
|
for ac_arg in $ac_f95_v_output; do |
766 |
|
|
case $ac_arg in |
767 |
|
|
[[\\/]]*.a | ?:[[\\/]]*.a | -[[lLRu]]*) |
768 |
|
|
ac_cv_prog_f95_v=$ac_verb |
769 |
|
|
break 2 ;; |
770 |
|
|
esac |
771 |
|
|
done |
772 |
|
|
done |
773 |
|
|
if test -z "$ac_cv_prog_f95_v"; then |
774 |
|
|
AC_MSG_WARN([cannot determine how to obtain linking information from $F95]) |
775 |
|
|
fi], |
776 |
|
|
[AC_MSG_WARN([compilation failed])]) |
777 |
|
|
])])# _AC_PROG_F95_V |
778 |
|
|
|
779 |
|
|
|
780 |
|
|
# AC_F95_LIBRARY_LDFLAGS |
781 |
|
|
# ---------------------- |
782 |
|
|
# |
783 |
|
|
# Determine the linker flags (e.g. "-L" and "-l") for the Fortran 95 |
784 |
|
|
# intrinsic and run-time libraries that are required to successfully |
785 |
|
|
# link a Fortran 95 program or shared library. The output variable |
786 |
|
|
# F95LIBS is set to these flags. |
787 |
|
|
# |
788 |
|
|
# This macro is intended to be used in those situations when it is |
789 |
|
|
# necessary to mix, e.g. C++ and Fortran 95, source code into a single |
790 |
|
|
# program or shared library. |
791 |
|
|
# |
792 |
|
|
# For example, if object files from a C++ and Fortran 95 compiler must |
793 |
|
|
# be linked together, then the C++ compiler/linker must be used for |
794 |
|
|
# linking (since special C++-ish things need to happen at link time |
795 |
|
|
# like calling global constructors, instantiating templates, enabling |
796 |
|
|
# exception support, etc.). |
797 |
|
|
# |
798 |
|
|
# However, the Fortran 95 intrinsic and run-time libraries must be |
799 |
|
|
# linked in as well, but the C++ compiler/linker doesn't know how to |
800 |
|
|
# add these Fortran 95 libraries. Hence, the macro |
801 |
|
|
# "AC_F95_LIBRARY_LDFLAGS" was created to determine these Fortran 95 |
802 |
|
|
# libraries. |
803 |
|
|
# |
804 |
|
|
# This macro was copied from the Fortran 77 version by Matthew D. Langston. |
805 |
|
|
AC_DEFUN([AC_F95_LIBRARY_LDFLAGS], |
806 |
|
|
[AC_LANG_PUSH(Fortran 95)dnl |
807 |
|
|
_AC_PROG_F95_V |
808 |
|
|
AC_CACHE_CHECK([for Fortran 95 libraries], ac_cv_flibs, |
809 |
|
|
[if test "x$F95LIBS" != "x"; then |
810 |
|
|
ac_cv_f95libs="$F95LIBS" # Let the user override the test. |
811 |
|
|
else |
812 |
|
|
|
813 |
|
|
_AC_PROG_F95_V_OUTPUT |
814 |
|
|
|
815 |
|
|
ac_cv_f95libs= |
816 |
|
|
|
817 |
|
|
# Save positional arguments (if any) |
818 |
|
|
ac_save_positional="$[@]" |
819 |
|
|
|
820 |
|
|
set X $ac_f95_v_output |
821 |
|
|
while test $[@%:@] != 1; do |
822 |
|
|
shift |
823 |
|
|
ac_arg=$[1] |
824 |
|
|
case $ac_arg in |
825 |
|
|
[[\\/]]*.a | ?:[[\\/]]*.a) |
826 |
|
|
_AC_LIST_MEMBER_IF($ac_arg, $ac_cv_f95libs, , |
827 |
|
|
ac_cv_f95libs="$ac_cv_f95libs $ac_arg") |
828 |
|
|
;; |
829 |
|
|
-bI:*) |
830 |
|
|
_AC_LIST_MEMBER_IF($ac_arg, $ac_cv_f95libs, , |
831 |
|
|
[_AC_LINKER_OPTION([$ac_arg], ac_cv_f95libs)]) |
832 |
|
|
;; |
833 |
|
|
# Ignore these flags. |
834 |
|
|
-lang* | -lcrt0.o | -lc | -lgcc | -LANG:=*) |
835 |
|
|
;; |
836 |
|
|
-lkernel32) |
837 |
|
|
test x"$CYGWIN" != xyes && ac_cv_f95libs="$ac_cv_f95libs $ac_arg" |
838 |
|
|
;; |
839 |
|
|
-[[LRuY]]) |
840 |
|
|
# These flags, when seen by themselves, take an argument. |
841 |
|
|
# We remove the space between option and argument and re-iterate |
842 |
|
|
# unless we find an empty arg or a new option (starting with -) |
843 |
|
|
case $[2] in |
844 |
|
|
"" | -*);; |
845 |
|
|
*) |
846 |
|
|
ac_arg="$ac_arg$[2]" |
847 |
|
|
|
848 |
|
|
shift; shift |
849 |
|
|
set X $ac_arg "$[@]" |
850 |
|
|
;; |
851 |
|
|
esac |
852 |
|
|
;; |
853 |
|
|
-YP,*) |
854 |
|
|
for ac_j in `echo $ac_arg | sed -e 's/-YP,/-L/;s/:/ -L/g'`; do |
855 |
|
|
_AC_LIST_MEMBER_IF($ac_j, $ac_cv_f95libs, , |
856 |
|
|
[ac_arg="$ac_arg $ac_j" |
857 |
|
|
ac_cv_f95libs="$ac_cv_f95libs $ac_j"]) |
858 |
|
|
done |
859 |
|
|
;; |
860 |
|
|
-[[lLR]]*) |
861 |
|
|
_AC_LIST_MEMBER_IF($ac_arg, $ac_cv_f95libs, , |
862 |
|
|
ac_cv_f95libs="$ac_cv_f95libs $ac_arg") |
863 |
|
|
;; |
864 |
|
|
# Ignore everything else. |
865 |
|
|
esac |
866 |
|
|
done |
867 |
|
|
# restore positional arguments |
868 |
|
|
set X $ac_save_positional; shift |
869 |
|
|
|
870 |
|
|
# We only consider "LD_RUN_PATH" on Solaris systems. If this is seen, |
871 |
|
|
# then we insist that the "run path" must be an absolute path (i.e. it |
872 |
|
|
# must begin with a "/"). |
873 |
|
|
case `(uname -sr) 2>/dev/null` in |
874 |
|
|
"SunOS 5"*) |
875 |
|
|
ac_ld_run_path=`echo $ac_f95_v_output | |
876 |
|
|
sed -n 's,^.*LD_RUN_PATH *= *\(/[[^ ]]*\).*$,-R\1,p'` |
877 |
|
|
test "x$ac_ld_run_path" != x && |
878 |
|
|
|
879 |
|
|
_AC_LINKER_OPTION([$ac_ld_run_path], ac_cv_f95libs) |
880 |
|
|
;; |
881 |
|
|
esac |
882 |
|
|
fi # test "x$F95LIBS" = "x" |
883 |
|
|
]) |
884 |
|
|
F95LIBS="$ac_cv_f95libs" |
885 |
|
|
AC_SUBST(F95LIBS) |
886 |
|
|
AC_LANG_POP(Fortran 95)dnl |
887 |
|
|
])# AC_F95_LIBRARY_LDFLAGS |
888 |
|
|
|
889 |
|
|
|
890 |
|
|
# _AC_F95_NAME_MANGLING |
891 |
|
|
# --------------------- |
892 |
|
|
# Test for the name mangling scheme used by the Fortran 95 compiler. |
893 |
|
|
# |
894 |
|
|
# Sets ac_cv_f95_mangling. The value contains three fields, separated |
895 |
|
|
# by commas: |
896 |
|
|
# |
897 |
|
|
# lower case / upper case: |
898 |
|
|
# case translation of the Fortan 95 symbols |
899 |
|
|
# underscore / no underscore: |
900 |
|
|
# whether the compiler appends "_" to symbol names |
901 |
|
|
# extra underscore / no extra underscore: |
902 |
|
|
# whether the compiler appends an extra "_" to symbol names already |
903 |
|
|
# containing at least one underscore |
904 |
|
|
# |
905 |
|
|
AC_DEFUN([_AC_F95_NAME_MANGLING], |
906 |
|
|
[AC_REQUIRE([AC_F95_LIBRARY_LDFLAGS])dnl |
907 |
|
|
AC_CACHE_CHECK([for Fortran 95 name-mangling scheme], |
908 |
|
|
ac_cv_f95_mangling, |
909 |
|
|
[AC_LANG_PUSH(Fortran 95)dnl |
910 |
|
|
AC_COMPILE_IFELSE( |
911 |
|
|
[subroutine foobar() |
912 |
|
|
return |
913 |
|
|
end |
914 |
|
|
subroutine foo_bar() |
915 |
|
|
return |
916 |
|
|
end], |
917 |
|
|
[mv conftest.$ac_objext cf95_test.$ac_objext |
918 |
|
|
|
919 |
|
|
AC_LANG_PUSH(C)dnl |
920 |
|
|
|
921 |
|
|
ac_save_LIBS=$LIBS |
922 |
|
|
LIBS="cf95_test.$ac_objext $F95LIBS $LIBS" |
923 |
|
|
|
924 |
|
|
ac_success=no |
925 |
|
|
for ac_foobar in foobar FOOBAR; do |
926 |
|
|
for ac_underscore in "" "_"; do |
927 |
|
|
ac_func="$ac_foobar$ac_underscore" |
928 |
|
|
AC_TRY_LINK_FUNC($ac_func, |
929 |
|
|
[ac_success=yes; break 2]) |
930 |
|
|
done |
931 |
|
|
done |
932 |
|
|
|
933 |
|
|
if test "$ac_success" = "yes"; then |
934 |
|
|
case $ac_foobar in |
935 |
|
|
foobar) |
936 |
|
|
ac_case=lower |
937 |
|
|
ac_foo_bar=foo_bar |
938 |
|
|
;; |
939 |
|
|
FOOBAR) |
940 |
|
|
ac_case=upper |
941 |
|
|
ac_foo_bar=FOO_BAR |
942 |
|
|
;; |
943 |
|
|
esac |
944 |
|
|
|
945 |
|
|
ac_success_extra=no |
946 |
|
|
for ac_extra in "" "_"; do |
947 |
|
|
ac_func="$ac_foo_bar$ac_underscore$ac_extra" |
948 |
|
|
|
949 |
|
|
AC_TRY_LINK_FUNC($ac_func, |
950 |
|
|
[ac_success_extra=yes; break]) |
951 |
|
|
done |
952 |
|
|
|
953 |
|
|
if test "$ac_success_extra" = "yes"; then |
954 |
|
|
ac_cv_f95_mangling="$ac_case case" |
955 |
|
|
if test -z "$ac_underscore"; then |
956 |
|
|
ac_cv_f95_mangling="$ac_cv_f95_mangling, no underscore" |
957 |
|
|
else |
958 |
|
|
ac_cv_f95_mangling="$ac_cv_f95_mangling, underscore" |
959 |
|
|
|
960 |
|
|
fi |
961 |
|
|
if test -z "$ac_extra"; then |
962 |
|
|
ac_cv_f95_mangling="$ac_cv_f95_mangling, no extra underscore" |
963 |
|
|
else |
964 |
|
|
ac_cv_f95_mangling="$ac_cv_f95_mangling, extra underscore" |
965 |
|
|
fi |
966 |
|
|
else |
967 |
|
|
ac_cv_f95_mangling="unknown" |
968 |
|
|
fi |
969 |
|
|
else |
970 |
|
|
ac_cv_f95_mangling="unknown" |
971 |
|
|
|
972 |
|
|
fi |
973 |
|
|
|
974 |
|
|
LIBS=$ac_save_LIBS |
975 |
|
|
AC_LANG_POP(C)dnl |
976 |
|
|
rm -f cf95_test* conftest*]) |
977 |
|
|
AC_LANG_POP(Fortran 95)dnl |
978 |
|
|
]) |
979 |
|
|
])# _AC_F95_NAME_MANGLING |
980 |
|
|
|
981 |
|
|
# The replacement is empty. |
982 |
|
|
AU_DEFUN([AC_F95_NAME_MANGLING], []) |
983 |
|
|
|
984 |
|
|
|
985 |
|
|
# AC_F95_WRAPPERS |
986 |
|
|
# --------------- |
987 |
|
|
# Defines C macros F95_FUNC(name,NAME) and F95_FUNC_(name,NAME) to |
988 |
|
|
# properly mangle the names of C identifiers, and C identifiers with |
989 |
|
|
# underscores, respectively, so that they match the name mangling |
990 |
|
|
# scheme used by the Fortran 95 compiler. |
991 |
|
|
AC_DEFUN([AC_F95_WRAPPERS], |
992 |
|
|
[AC_REQUIRE([_AC_F95_NAME_MANGLING])dnl |
993 |
|
|
AH_TEMPLATE([F95_FUNC], |
994 |
|
|
[Define to a macro mangling the given C identifier (in lower and upper |
995 |
|
|
case), which must not contain underscores, for linking with Fortran 95.])dnl |
996 |
|
|
AH_TEMPLATE([F95_FUNC_], |
997 |
|
|
[As F95_FUNC, but for C identifiers containing underscores.])dnl |
998 |
|
|
case $ac_cv_f95_mangling in |
999 |
|
|
"lower case, no underscore, no extra underscore") |
1000 |
|
|
AC_DEFINE([F95_FUNC(name,NAME)], [name]) |
1001 |
|
|
AC_DEFINE([F95_FUNC_(name,NAME)], [name]) ;; |
1002 |
|
|
"lower case, no underscore, extra underscore") |
1003 |
|
|
AC_DEFINE([F95_FUNC(name,NAME)], [name]) |
1004 |
|
|
AC_DEFINE([F95_FUNC_(name,NAME)], [name ## _]) ;; |
1005 |
|
|
"lower case, underscore, no extra underscore") |
1006 |
|
|
AC_DEFINE([F95_FUNC(name,NAME)], [name ## _]) |
1007 |
|
|
AC_DEFINE([F95_FUNC_(name,NAME)], [name ## _]) ;; |
1008 |
|
|
"lower case, underscore, extra underscore") |
1009 |
|
|
AC_DEFINE([F95_FUNC(name,NAME)], [name ## _]) |
1010 |
|
|
AC_DEFINE([F95_FUNC_(name,NAME)], [name ## __]) ;; |
1011 |
|
|
"upper case, no underscore, no extra underscore") |
1012 |
|
|
AC_DEFINE([F95_FUNC(name,NAME)], [NAME]) |
1013 |
|
|
AC_DEFINE([F95_FUNC_(name,NAME)], [NAME]) ;; |
1014 |
|
|
"upper case, no underscore, extra underscore") |
1015 |
|
|
AC_DEFINE([F95_FUNC(name,NAME)], [NAME]) |
1016 |
|
|
AC_DEFINE([F95_FUNC_(name,NAME)], [NAME ## _]) ;; |
1017 |
|
|
"upper case, underscore, no extra underscore") |
1018 |
|
|
AC_DEFINE([F95_FUNC(name,NAME)], [NAME ## _]) |
1019 |
|
|
AC_DEFINE([F95_FUNC_(name,NAME)], [NAME ## _]) ;; |
1020 |
|
|
"upper case, underscore, extra underscore") |
1021 |
|
|
AC_DEFINE([F95_FUNC(name,NAME)], [NAME ## _]) |
1022 |
|
|
AC_DEFINE([F95_FUNC_(name,NAME)], [NAME ## __]) ;; |
1023 |
|
|
*) |
1024 |
|
|
AC_MSG_WARN([unknown Fortran 95 name-mangling scheme]) |
1025 |
|
|
;; |
1026 |
|
|
esac |
1027 |
|
|
])# AC_F95_WRAPPERS |
1028 |
|
|
|
1029 |
|
|
|
1030 |
|
|
# AC_F95_FUNC(NAME, [SHELLVAR = NAME]) |
1031 |
|
|
# ------------------------------------ |
1032 |
|
|
# For a Fortran subroutine of given NAME, define a shell variable |
1033 |
|
|
# $SHELLVAR to the Fortran 95 mangled name. If the SHELLVAR |
1034 |
|
|
# argument is not supplied, it defaults to NAME. |
1035 |
|
|
AC_DEFUN([AC_F95_FUNC], |
1036 |
|
|
[AC_REQUIRE([_AC_F95_NAME_MANGLING])dnl |
1037 |
|
|
case $ac_cv_f95_mangling in |
1038 |
|
|
upper*) ac_val="m4_toupper([$1])" ;; |
1039 |
|
|
lower*) ac_val="m4_tolower([$1])" ;; |
1040 |
|
|
*) ac_val="unknown" ;; |
1041 |
|
|
esac |
1042 |
|
|
case $ac_cv_f95_mangling in *," underscore"*) ac_val="$ac_val"_ ;; esac |
1043 |
|
|
m4_if(m4_index([$1],[_]),-1,[], |
1044 |
|
|
[case $ac_cv_f95_mangling in *," extra underscore"*) ac_val="$ac_val"_ ;; esac |
1045 |
|
|
]) |
1046 |
|
|
m4_default([$2],[$1])="$ac_val" |
1047 |
|
|
|
1048 |
|
|
])# AC_F95_FUNC |
1049 |
|
|
|
1050 |
|
|
|