|
1 |
# AC_FC_MODULE_OUTPUT_FLAG([ACTION-IF-SUCCESS], [ACTION-IF-FAILURE = FAILURE])
|
|
2 |
# ----------------------------------------------------------------------------
|
|
3 |
# Find a flag to write Fortran 90 module information to another directory.
|
|
4 |
# If successful, run ACTION-IF-SUCCESS (defaults to nothing), otherwise
|
|
5 |
# run ACTION-IF-FAILURE (defaults to failing with an error message).
|
|
6 |
# The module flag is cached in the ac_cv_fc_module_output_flag variable.
|
|
7 |
# It may contain significant trailing whitespace.
|
|
8 |
#
|
|
9 |
# For known flags, see the documentation of AC_FC_MODULE_FLAG above.
|
|
10 |
AC_DEFUN([AC_FC_MODULE_OUTPUT_FLAG],[
|
|
11 |
AC_CACHE_CHECK([Fortran 90 module output flag], [ac_cv_fc_module_output_flag],
|
|
12 |
[AC_LANG_PUSH([Fortran])
|
|
13 |
mkdir conftest.dir conftest.dir/sub
|
|
14 |
cd conftest.dir
|
|
15 |
ac_cv_fc_module_output_flag=unknown
|
|
16 |
ac_fc_module_output_flag_FCFLAGS_save=$FCFLAGS
|
|
17 |
# Flag ordering is significant: put flags late which some compilers use
|
|
18 |
# for the search path.
|
|
19 |
for ac_flag in -J '-J ' -fmod= -moddir= +moddir= -qmoddir= '-mod ' \
|
|
20 |
'-module ' -M '-Am -M' '-e m -J '; do
|
|
21 |
FCFLAGS="$ac_fc_module_output_flag_FCFLAGS_save ${ac_flag}sub"
|
|
22 |
AC_COMPILE_IFELSE([[
|
|
23 |
module conftest_module
|
|
24 |
contains
|
|
25 |
subroutine conftest_routine
|
|
26 |
write(*,'(a)') 'gotcha!'
|
|
27 |
end subroutine
|
|
28 |
end module]],
|
|
29 |
[cd sub
|
|
30 |
AC_COMPILE_IFELSE([[
|
|
31 |
program main
|
|
32 |
use conftest_module
|
|
33 |
call conftest_routine
|
|
34 |
end program]],
|
|
35 |
[ac_cv_fc_module_output_flag="$ac_flag"])
|
|
36 |
cd ..
|
|
37 |
if test "$ac_cv_fc_module_output_flag" != unknown; then
|
|
38 |
break
|
|
39 |
fi])
|
|
40 |
done
|
|
41 |
FCFLAGS=$ac_fc_module_output_flag_FCFLAGS_save
|
|
42 |
cd ..
|
|
43 |
rm -rf conftest.dir
|
|
44 |
AC_LANG_POP([Fortran])
|
|
45 |
])
|
|
46 |
if test "$ac_cv_fc_module_output_flag" != unknown; then
|
|
47 |
FC_MODOUT=$ac_cv_fc_module_output_flag
|
|
48 |
$1
|
|
49 |
else
|
|
50 |
FC_MODOUT=
|
|
51 |
m4_default([$2],
|
|
52 |
[AC_MSG_ERROR([unable to find compiler flag to write module information to])])
|
|
53 |
fi
|
|
54 |
AC_SUBST([FC_MODOUT])
|
|
55 |
# Ensure trailing whitespace is preserved in a Makefile.
|
|
56 |
AC_SUBST([ac_empty], [""])
|
|
57 |
AC_CONFIG_COMMANDS_PRE([case $FC_MODOUT in #(
|
|
58 |
*\ ) FC_MODOUT=$FC_MODOUT'${ac_empty}' ;;
|
|
59 |
esac])dnl
|
|
60 |
])
|