1047 |
|
|
1048 |
|
])# AC_F95_FUNC |
1049 |
|
|
1050 |
+ |
# AC_F90_MODULE_NAMES |
1051 |
+ |
# ------------------- |
1052 |
+ |
# |
1053 |
+ |
# Figure out how the Fortran 90 compiler constructs module file names |
1054 |
+ |
# |
1055 |
+ |
AC_DEFUN([AC_F90_MODULE_NAMES], |
1056 |
+ |
[AC_REQUIRE([AC_PROG_F90])dnl |
1057 |
+ |
AC_CACHE_CHECK([for Fortran 90 module file names], |
1058 |
+ |
ac_cv_f90_module_names, |
1059 |
+ |
[AC_LANG_PUSH(Fortran 90) |
1060 |
+ |
# carry out the test in a new directory, so that we don't miss anything |
1061 |
+ |
mkdir conftest |
1062 |
+ |
cd conftest |
1063 |
+ |
AC_COMPILE_IFELSE( |
1064 |
+ |
[MODULE Bar |
1065 |
+ |
END MODULE Bar], |
1066 |
+ |
ac_cv_f90_module_names= |
1067 |
+ |
[ac_file_list=* |
1068 |
+ |
for ac_file in $ac_file_list; do |
1069 |
+ |
case $ac_file in |
1070 |
+ |
# don't care for original source and object files |
1071 |
+ |
conftest.$ac_ext | conftest.$ac_objext | conftest.err ) |
1072 |
+ |
: |
1073 |
+ |
;; |
1074 |
+ |
# look for new files derived from the file name |
1075 |
+ |
*conftest*) |
1076 |
+ |
ac_pat=`echo $ac_file | sed s/conftest/%FILE%/` |
1077 |
+ |
_AC_LIST_MEMBER_IF($ac_pat, $ac_cv_f90_module_names,, |
1078 |
+ |
ac_cv_f90_module_names="$ac_cv_f90_module_names $ac_pat") |
1079 |
+ |
;; |
1080 |
+ |
# look for new files derived from the module name, |
1081 |
+ |
# with different case translation schemes |
1082 |
+ |
*Bar*) |
1083 |
+ |
ac_pat=`echo $ac_file | sed s/Bar/%Module%/` |
1084 |
+ |
_AC_LIST_MEMBER_IF($ac_pat, $ac_cv_f90_module_names,, |
1085 |
+ |
ac_cv_f90_module_names="$ac_cv_f90_module_names $ac_pat") |
1086 |
+ |
;; |
1087 |
+ |
*bar*) |
1088 |
+ |
ac_pat=`echo $ac_file | sed s/bar/%module%/` |
1089 |
+ |
_AC_LIST_MEMBER_IF($ac_pat, $ac_cv_f90_module_names,, |
1090 |
+ |
ac_cv_f90_module_names="$ac_cv_f90_module_names $ac_pat") |
1091 |
+ |
;; |
1092 |
+ |
*BAR*) |
1093 |
+ |
ac_pat=`echo $ac_file | sed s/BAR/%MODULE%/` |
1094 |
+ |
_AC_LIST_MEMBER_IF($ac_pat, $ac_cv_f90_module_names,, |
1095 |
+ |
ac_cv_f90_module_names="$ac_cv_f90_module_names $ac_pat") |
1096 |
+ |
;; |
1097 |
+ |
# Other files - we have no idea how they are generated |
1098 |
+ |
*) |
1099 |
+ |
AC_MSG_WARN([Bogus file found: $ac_file]) |
1100 |
+ |
;; |
1101 |
+ |
esac |
1102 |
+ |
done |
1103 |
+ |
if test "x$ac_cv_f90_module_names" = "x"; then |
1104 |
+ |
AC_MSG_WARN([Couldn't determine module file names]) |
1105 |
+ |
fi |
1106 |
+ |
], |
1107 |
+ |
[ac_cv_f90_module_names= |
1108 |
+ |
AC_MSG_WARN([Couldn't determine module file names])]) |
1109 |
+ |
cd .. |
1110 |
+ |
# cleanup |
1111 |
+ |
rm -rf conftest |
1112 |
+ |
AC_LANG_POP()dnl |
1113 |
+ |
]) # AC_CACHE_CHECK |
1114 |
|
|
1115 |
+ |
# We now generate a shell script that will help us to figure out the correct |
1116 |
+ |
# module file names, using the value of ac_cv_f90_module_names |
1117 |
+ |
|
1118 |
+ |
echo "Generating shell script modnam" |
1119 |
+ |
|
1120 |
+ |
cat > scripts/modnam << EOF |
1121 |
+ |
#! /bin/sh |
1122 |
+ |
# This script is auto-generated by configure |
1123 |
+ |
# |
1124 |
+ |
usage="\\ |
1125 |
+ |
Usage: \$[0] [[FILES]] |
1126 |
+ |
|
1127 |
+ |
[[FILES]] are Fortran 90 source files. |
1128 |
+ |
The output is a list of module file names that the Fortran 90 compiler |
1129 |
+ |
generates when compiling [[FILES]]." |
1130 |
+ |
|
1131 |
+ |
list= |
1132 |
+ |
empty= |
1133 |
+ |
|
1134 |
+ |
if test \$[@%:@] -eq 0; then |
1135 |
+ |
echo "\$usage"; exit 0 |
1136 |
+ |
fi |
1137 |
+ |
|
1138 |
+ |
while test \$[@%:@] != 0; do |
1139 |
+ |
|
1140 |
+ |
file=\$[1] |
1141 |
+ |
shift |
1142 |
+ |
|
1143 |
+ |
# strip suffix |
1144 |
+ |
base=\`echo \$file | sed 's/[[.]][[^.]]*$//'\` |
1145 |
+ |
|
1146 |
+ |
test ! -f \$file && continue |
1147 |
+ |
|
1148 |
+ |
# Look for module definitions and transform them to upper / lower case |
1149 |
+ |
mods=\`cat \$file | sed '/^ *[[mM][oO][dD][uU][lL][eE]]/!d;s/^ *[[mM][oO][dD][uU][lL][eE]] *\([[A-Za-z_][A-Za-z0-9_]]*\).*\$/\1/'\` |
1150 |
+ |
upper=\`echo \$mods | tr a-z A-Z\` |
1151 |
+ |
lower=\`echo \$mods | tr A-Z a-z\` |
1152 |
+ |
|
1153 |
+ |
# Here, the patterns for generating module file names were inserted by configure |
1154 |
+ |
for trans in $ac_cv_f90_module_names; do |
1155 |
+ |
|
1156 |
+ |
pat=\`echo \$trans | sed 's/.*\(%.*%\).*/\1/'\` |
1157 |
+ |
var=empty |
1158 |
+ |
case \$pat in |
1159 |
+ |
%MODULE%) |
1160 |
+ |
var=upper ;; |
1161 |
+ |
%Module%) |
1162 |
+ |
var=mods ;; |
1163 |
+ |
%module%) |
1164 |
+ |
var=lower ;; |
1165 |
+ |
%FILE%) |
1166 |
+ |
test -n "\$mods" && var=base ;; |
1167 |
+ |
esac |
1168 |
+ |
new=\`eval '(for i in \$'\$var '; do echo \$trans | sed s/\$pat/\$i/; done)'\` |
1169 |
+ |
list="\$list \$new" |
1170 |
+ |
done |
1171 |
+ |
done |
1172 |
+ |
|
1173 |
+ |
echo \$list |
1174 |
+ |
# end of configure-generated script |
1175 |
+ |
EOF |
1176 |
+ |
chmod 755 scripts/modnam |
1177 |
+ |
]) # AC_F90_MODULE_NAMES |