ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/OpenMD/branches/development/ac-tools/OpenMD.m4
(Generate patch)

Comparing branches/development/ac-tools/OpenMD.m4 (file contents):
Revision 1465 by chuckv, Fri Jul 9 23:08:25 2010 UTC vs.
Revision 1603 by gezelter, Thu Aug 4 21:02:06 2011 UTC

# Line 69 | Line 69 | AC_SUBST(MOD)
69  
70   ])
71  
72
73 dnl
74 dnl AC_CHECK_MODDIRFLAG
75 dnl
76 AC_DEFUN([AC_CHECK_MODDIRFLAG],[
77
78 # Check for module include path (some use -I, some (Solaris) use -M, some
79 # (absoft) use -p).
80 # Intel compilers use a wierd system: -cl,filename.pcl .  If no file is
81 # specified, work.pcl and work.pc are created.  However, if you specify
82 # a file, it must contain a the name of a file ending in .pc .  Ugh!
83 # Use the module made above
84 AC_MSG_CHECKING(for module directory path flag)
85 rm -f conftest*
86 # Intel ifc compiler generates files by the name of work.pc and work.pcl (!)
87 rm -f work*
88 cat >conftest.$ac_ext <<EOF
89        module conftest
90        integer n
91        parameter (n=1)
92        end module conftest
93 EOF
94 # SGI and absoft compilers generates module name in upper case!
95 testname="conftest"
96 if (eval $ac_compile) 2>/dev/null ; then
97   mod=`ls CONFTEST* 2>/dev/null | grep -v CONFTEST.$ac_ext | grep -v CONFTEST.o`
98   mod=`echo "$mod" | sed -e 's/CONFTEST\.//g'`
99   if test -n "$mod" ; then
100      testname="CONFTEST"
101   fi
102   madedir=0
103   if test ! -d conf ; then mkdir conf ; madedir=1; fi
104   cp $testname.$MOD conf
105   rm -f conftest* CONFTEST*
106   cat >conftest1.$ac_ext <<EOF
107        program main
108        use conftest
109        print *, n
110        end
111 EOF
112   F90_WORK_FILES_ARG=""
113   F90MODINCSPEC=""
114   if $FC -c -Iconf $FCFLAGS $FCFLAGS_SRCEXT conftest1.$ac_ext > conftest.out 2>&1 ; then
115       MODDIRFLAG="-I"
116       F90MODINCSPEC="-I<dir>"
117       AC_MSG_RESULT(-I)
118   elif $FC -c -Mconf $FCFLAGS $FCFLAGS_SRCEXT conftest1.$ac_ext >> conftest.out 2>&1 ; then
119       MODDIRFLAG="-M"
120       F90MODINCSPEC="-M<dir>"
121       AC_MSG_RESULT(-M)
122   elif $FC -c -pconf $FCFLAGS $FCFLAGS_SRCEXT conftest1.$ac_ext >> conftest.out 2>&1 ; then
123       MODDIRFLAG="-p"
124       F90MODINCSPEC="-p<dir>"
125       AC_MSG_RESULT(-p)
126   elif test -s work.pc ; then
127        cp work.pc conf/mpimod.pc
128        echo "mpimod.pc" > conf/mpimod.pcl
129        echo "`pwd`/conf/mpimod.pc" >> conf/mpimod.pcl
130        if $FC -c -cl,conf/mpimod.pcl $FCFLAGS $FCFLAGS_SRCEXT conftest1.$ac_ext >>conftest.out 2>&1 ; then
131            MODDIRFLAG='-cl,mpimod.pcl'
132            AC_MSG_RESULT([-cl,filename where filename contains a list of files and directories])
133            F90_WORK_FILES_ARG="-cl,mpimod.pcl"
134            F90MODINCSPEC="-cl,<dir>/<file>mod.pcl"
135            AC_SUBST(F90_WORK_FILES_ARG)
136        else
137            # The version of the Intel compiler that I have refuses to let
138            # you put the "work catalog" list anywhere but the current
139            # directory. For example, you cannot in
140         :
141        fi
142   fi
143   if test -z "MODDIRFLAG" ; then
144       AC_MSG_RESULT(unknown)
145   fi
146   AC_SUBST(MODDIRFLAG)
147   AC_SUBST(F90MODINCSPEC)
148   rm -f conftest* conf/conftest* conf/CONFTEST* CONFTEST* conf/mpimod*
149   if test $madedir = 1 ; then rmdir conf ; fi
150 fi
151
152 ])
153
72   AC_DEFUN(ACX_CHECK_CC_FLAGS,
73   [
74   AC_REQUIRE([AC_PROG_CC])
# Line 193 | Line 111 | fi
111   fi
112   ])
113  
196 dnl -------------------------------------------------------------------------
197 dnl ACX_CHECK_FC_FLAGS()
198 dnl
199 dnl     Check for optimizer flags the Fortran compiler can use.
200 dnl
201 AC_DEFUN(ACX_CHECK_FC_FLAGS,
202 [
203 AC_CACHE_CHECK(whether ${FC} accepts $1, ac_cv_$2,
204 [
205 AC_LANG_SAVE
206 AC_LANG(Fortran)
207 echo 'program main' > conftest.$ac_ext
208 echo 'end program main' >> conftest.$ac_ext
209 ac_compile='${FC} -c $1 $FCFLAGS $FCFLAGS_SRCEXT conftest.$ac_ext 1>&AC_FD_CC'
210 if AC_TRY_EVAL(ac_compile); then
211        ac_cv_$2=yes
212 else
213        ac_cv_$2=no
214 fi
215 rm -f conftest*
216 AC_LANG_RESTORE()
217 ])
218 if test "$ac_cv_$2" = yes; then
219        :
220        $3
221 else
222        :
223        $4
224 fi
225 ])
226
114   AC_DEFUN(ACX_PROG_GCC_VERSION,
115   [
116   AC_REQUIRE([AC_PROG_CC])
# Line 499 | Line 386 | if test "$ac_test_CXXFLAGS" != "set"; then
386          echo "**********************************************************"
387          echo ""
388          CXXFLAGS=""
502  ])
503
504 fi
505 ])
506
507 AC_DEFUN(ACX_PROG_FC_MAXOPT,
508 [
509 AC_REQUIRE([AC_PROG_FC])
510 AC_REQUIRE([AC_CANONICAL_HOST])
511
512
513 # Try to determine "good" native compiler flags if none specified on command
514 # line
515
516 if test "$ac_test_FFLAGS" != "set"; then
517  FCFLAGS=""
518  case "${host_cpu}-${host_os}" in
519
520  *linux*) if test "$FC" = ifc -o "$FC" = ifort; then
521                    FCFLAGS="-O2"
522                fi;;
523   rs6000*-aix*)  if test "$FC" = xlf90 -o "$FC" = f90 -o "$FC" = xlf95; then
524                    FCFLAGS="-O3 -qarch=pwrx -qtune=pwrx -qansialias -w"
525                fi;;
526   powerpc*-aix*)
527        if test "$FC" = f90 -o "$FC" = xlf90 -o "$FC" = xlf95; then
528                FCFLAGS="-O3 -qarch=ppc -qansialias -w"
529                echo "*******************************************************"
530                echo "*  You have AIX on an unknown powerpc system.  It is  *"
531                echo "*  recommended that you use                           *"
532                echo "*                                                     *"
533                echo "*   FCFLAGS=-O3 -qarch=ppc -qtune=xxx -qansialias -w  *"
534                echo "*                                 ^^^                 *"
535                echo "*  where xxx is 601, 603, 604, or whatever kind of    *"
536                echo "*  PowerPC CPU you have.   For more info, man xlf.    *"
537                echo "*******************************************************"
538        fi;;
539   *darwin*)
540        if test "$FC" = f90 -o "$FC" = xlf90 -o "$FC" = xlf95; then
541                FCFLAGS="-qthreaded -O -qtune=auto -qarch=auto -qunroll=auto"
542        fi
543        if test "$FC" = ifort; then
544                FCFLAGS="-O2"
545        fi
546        if test "$FC" = gfortran; then
547                FCFLAGS="-Os"
548        fi;;
549  esac
550
551  if test -z "$FCFLAGS"; then
552        echo ""
553        echo "*********************************************************"
554        echo "* WARNING: Don't know the best FCFLAGS for this system  *"
555        echo "* Use  make FCFLAGS=..., or edit the top level Makefile *"
556        echo "* (otherwise, a default of FCFLAGS=-O will be used)     *"
557        echo "*********************************************************"
558        echo ""
559        FCFLAGS="-O"
560  fi
561
562  ACX_CHECK_FC_FLAGS(${FCFLAGS}, ac_cv_guessed_f90flags, , [
563        echo ""
564        echo "**********************************************************"
565        echo "* WARNING: The guessed FCFLAGS don't seem to work with  *"
566        echo "* your compiler.                                        *"
567        echo "* Use  make FCFLAGS=..., or edit the top level Makefile *"
568        echo "*********************************************************"
569        echo ""
570        FCFLAGS=""
389    ])
390  
391   fi
392   ])
393  
576 AC_DEFUN(ACX_PROG_F90_PREPFLAG,
577 [
578 AC_REQUIRE([AC_PROG_FC])
579 AC_REQUIRE([AC_CANONICAL_HOST])
580
581 # Try to determine native compiler flags that allow us to use F90 suffix
582 # for preprocessed f90 source.
583
584 if test "$ac_test_PREPFLAG" != "set"; then
585  PREPFLAG=""
586  case "${host_cpu}-${host_os}" in
587
588  *linux*) if test "$FC" = ifc -o "$FC" = ifort; then
589                    PREPFLAG="-fpp1 "
590                fi;;
591  *aix*)  if test "$FC" = xlf90 -o "$FC" = f90 -o "$FC" = xlf95; then
592                    PREPFLAG="-qsuffix=cpp=F90 "
593                fi;;
594  *darwin*)
595        if test "$FC" = f90 -o "$FC" = xlf90 -o "$FC" = xlf95; then
596                PREPFLAG="-qsuffix=cpp=F90 "
597        fi;;
598  esac
599
600  if test -z "$PREPFLAG"; then
601        AC_MSG_WARN("Using empty PREPFLAG")
602        PREPFLAG=""
603  fi
604
605  AC_MSG_CHECKING(to make sure F90 preprocessor flag works)
606  AC_LANG_SAVE()
607  AC_LANG(Fortran)
608  ac_save_ext=$ac_ext
609  ac_ext=F90
610  ac_save_FCFLAGS_SRCEXT=$FCFLAGS_SRCEXT
611
612  AS_IF([test "$PREPFLAG"], [FCFLAGS_SRCEXT="${PREPFLAG}"])
613    _AC_COMPILE_IFELSE([
614      AC_LANG_SOURCE([
615 program conftest
616  integer :: i
617  i = 1
618 end program conftest
619 ])], [prepflagworks=1], [prepflagworks=0])
620
621  FCFLAGS_SRCEXT=$ac_save_FCFLAGS_SRCEXT
622  ac_ext=$ac_save_ext
623  AC_LANG_RESTORE()
624
625  if test "$prepflagworks" = 1; then
626    AC_MSG_RESULT(yes)
627    FCFLAGS_SRCEXT="${PREPFLAG}"
628    AC_SUBST(FCFLAGS_SRCEXT)
629  else
630    AC_MSG_RESULT(no)
631    AC_MSG_ERROR([Can't figure out working Fortran90 preprocessor flag])
632  fi
633 fi
634 ])
635
636
637 AC_DEFUN(ACX_PROG_F90_PREPDEFFLAG,
638 [
639 AC_REQUIRE([AC_PROG_FC])
640 AC_REQUIRE([AC_CANONICAL_HOST])
641
642 # Try to determine native compiler flags that allow us to use F90 suffix
643 # for preprocessed f90 source with -D type defines
644
645 if test "$ac_test_PREPDEFFLAG" != "set"; then
646  PREPDEFFLAG=""
647  case "${host_cpu}-${host_os}" in
648
649  *linux*) if test "$FC" = ifc -o "$FC" = ifort; then
650                    PREPDEFFLAG=" "
651                fi;;
652  *aix*)  if test "$FC" = xlf90 -o "$FC" = f90 -o "$FC" = xlf95; then
653                    PREPDEFFLAG="-WF,"
654                fi;;
655  *darwin*)
656        if test "$FC" = f90 -o "$FC" = xlf90 -o "$FC" = xlf95; then
657                PREPDEFFLAG="-WF,"
658        fi;;
659  esac
660
661  if test -z "$PREPDEFFLAG"; then
662        AC_MSG_WARN("Using empty PREPDEFFLAG")
663        PREPDEFFLAG=" "
664  fi
665
666  AC_MSG_CHECKING(to make sure F90 preprocessor define flag works)
667  AC_LANG_SAVE()
668  AC_LANG(Fortran)
669  ac_save_ext=$ac_ext
670  ac_ext=F90
671  ac_save_FCFLAGS=$FCFLAGS
672
673  AS_IF([test "$PREPDEFFLAG"], [FCFLAGS="${FCFLAGS} ${PREPDEFFLAG}-DTEST"])
674    _AC_COMPILE_IFELSE([
675      AC_LANG_SOURCE([
676 program conftest
677  integer :: i
678 #ifdef TEST
679  i = 1
680 #else
681  choke me
682 #endif
683 end program conftest
684 ])], [prepdefflagworks=1], [prepdefflagworks=0])
685
686  FCFLAGS=$ac_save_FCFLAGS
687  ac_ext=$ac_save_ext
688  AC_LANG_RESTORE()
689
690  if test "$prepdefflagworks" = 1; then
691    AC_MSG_RESULT(yes)
692    AC_SUBST(PREPDEFFLAG)
693  else
694    AC_MSG_RESULT(no)
695    AC_MSG_ERROR([Can't figure out working Fortran90 preprocessor define flag])
696  fi
697 fi
698 ])
699
700
701
702
394   AC_DEFUN([adl_FUNC_GETOPT_LONG],
395   [AC_PREREQ(2.49)dnl
396    # clean out junk possibly left behind by a previous configuration
# Line 1195 | Line 886 | fi
886    fi
887   fi
888   ])
1198
1199 # AC_F90_MODULE_NAMES
1200 # -------------------
1201 #
1202 # Figure out how the Fortran 90 compiler constructs module file names
1203 #
1204 AC_DEFUN([AC_F90_MODULE_NAMES],
1205 [AC_REQUIRE([AC_PROG_FC])dnl
1206 AC_CACHE_CHECK([for Fortran 90 module file names],
1207               ac_cv_f90_module_names,
1208 [AC_LANG_PUSH(Fortran)
1209 # carry out the test in a new directory, so that we don't miss anything
1210 mkdir conftest
1211 cd conftest
1212 AC_COMPILE_IFELSE(
1213 [MODULE Bar
1214 END MODULE Bar],
1215 ac_cv_f90_module_names=
1216 [ac_file_list=*
1217 for ac_file in $ac_file_list; do
1218   case $ac_file in
1219      # don't care for original source and object files
1220      conftest.$ac_ext | conftest.$ac_objext | conftest.err )
1221          :
1222          ;;
1223      # look for new files derived from the file name
1224      *conftest*)
1225          ac_pat=`echo $ac_file | sed s/conftest/%FILE%/`
1226          _AC_LIST_MEMBER_IF($ac_pat, $ac_cv_f90_module_names,,
1227              ac_cv_f90_module_names="$ac_cv_f90_module_names $ac_pat")
1228          ;;
1229      # look for new files derived from the module name,
1230      # with different case translation schemes
1231      *Bar*)
1232          ac_pat=`echo $ac_file | sed s/Bar/%Module%/`
1233          _AC_LIST_MEMBER_IF($ac_pat, $ac_cv_f90_module_names,,
1234              ac_cv_f90_module_names="$ac_cv_f90_module_names $ac_pat")
1235          ;;
1236      *bar*)
1237          ac_pat=`echo $ac_file | sed s/bar/%module%/`
1238          _AC_LIST_MEMBER_IF($ac_pat, $ac_cv_f90_module_names,,
1239              ac_cv_f90_module_names="$ac_cv_f90_module_names $ac_pat")
1240          ;;
1241      *BAR*)
1242          ac_pat=`echo $ac_file | sed s/BAR/%MODULE%/`
1243          _AC_LIST_MEMBER_IF($ac_pat, $ac_cv_f90_module_names,,
1244              ac_cv_f90_module_names="$ac_cv_f90_module_names $ac_pat")
1245          ;;
1246       # Other files - we have no idea how they are generated
1247       *)
1248          AC_MSG_WARN([Bogus file found: $ac_file])
1249          ;;
1250   esac
1251 done
1252 if test "x$ac_cv_f90_module_names" = "x"; then
1253  AC_MSG_WARN([Couldn't determine module file names])
1254 fi
1255 ],
1256 [ac_cv_f90_module_names=
1257 AC_MSG_WARN([Couldn't determine module file names])])
1258 cd ..
1259 # cleanup
1260 rm -rf conftest
1261 AC_LANG_POP()dnl
1262 ]) # AC_CACHE_CHECK
1263
1264 # We now generate a shell script that will help us to figure out the correct
1265 # module file names, using the value of ac_cv_f90_module_names
1266
1267 echo "Generating shell script modnam"
1268
1269 cat > scripts/modnam << EOF
1270 #! /bin/sh
1271 # This script is auto-generated by configure
1272 #
1273 usage="\\
1274 Usage: \$[0] [[FILES]]
889  
1276 [[FILES]] are Fortran 90 source files.
1277 The output is a list of module file names that the Fortran 90 compiler
1278 generates when compiling [[FILES]]."
890  
1280 list=
1281 empty=
1282
1283 if test \$[@%:@] -eq 0; then
1284   echo "\$usage"; exit 0
1285 fi
1286
1287 while test \$[@%:@] != 0; do
1288
1289  file=\$[1]
1290  shift
1291
1292 # strip suffix
1293  base=\`echo \$file | sed 's/[[.]][[^.]]*$//'\`
1294
1295  test ! -f \$file && continue
1296
1297 # Look for module definitions and transform them to upper / lower case
1298  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/'\`
1299  upper=\`echo \$mods | tr a-z A-Z\`
1300  lower=\`echo \$mods | tr A-Z a-z\`
1301
1302 # Here, the patterns for generating module file names were inserted by configure
1303  for trans in $ac_cv_f90_module_names; do
1304
1305    pat=\`echo \$trans | sed 's/.*\(%.*%\).*/\1/'\`
1306    var=empty
1307    case \$pat in
1308       %MODULE%)
1309          var=upper ;;
1310       %Module%)
1311          var=mods ;;
1312       %module%)
1313          var=lower ;;
1314       %FILE%)
1315          test -n "\$mods" && var=base ;;
1316    esac
1317    new=\`eval '(for i in \$'\$var '; do echo \$trans | sed s/\$pat/\$i/; done)'\`
1318    list="\$list \$new"
1319  done
1320 done
1321
1322 echo \$list
1323 # end of configure-generated script
1324 EOF
1325 chmod 755 scripts/modnam
1326 ]) # AC_F90_MODULE_NAMES
1327
891   dnl
892   dnl These functions were taken from the GRASS GIS toolkit:
893   dnl

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines