ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/OpenMD/trunk/ac-tools/OOPSE.m4
Revision: 1201
Committed: Fri Dec 7 00:48:28 2007 UTC (17 years, 8 months ago) by chuckv
File size: 48285 byte(s)
Log Message:
Define USE_QHULL.

File Contents

# Content
1 dnl We need a function similar to AC_CHECK_LIB to check for C++ libraries.
2 dnl AC_CHECK_CXX_LIB provides a similar interface like AC_CHECK_LIB
3 dnl and uses AC_TRY_LINK.
4 dnl
5 dnl $1 library name (without "-l")
6 dnl $2 object name to check for
7 dnl $3 neccessary include directive(s)
8 dnl $4 command to create object $2
9 dnl $5 yes-action
10 dnl $6 no-action
11 dnl $7 include dir for $3 (with -I)
12 dnl $8 additional libraries to link with
13
14 AC_DEFUN(AC_CHECK_CXX_LIB, AC_MSG_CHECKING([for $2 in -l$1])
15 save_CXXFLAGS_CHECK_CXX_LIB="$CXXFLAGS"
16 CXXFLAGS="$CXXFLAGS $7"
17 save_LIBS_CHECK_CXX_LIB="$LIBS"
18 LIBS="-l$1 $8 $LIBS"
19 [AC_TRY_LINK([$3], [$4], [AC_MSG_RESULT([yes])
20 $5], [AC_MSG_RESULT([no])
21 $6])]
22 CXXFLAGS="$save_CXXFLAGS_CHECK_CXX_LIB"
23 LIBS="$save_LIBS_CHECK_CXX_LIB")dnl
24
25 dnl
26 dnl AC_CHECK_MODSUFFIX
27 dnl
28 AC_DEFUN([AC_CHECK_MODSUFFIX],[
29
30 AC_MSG_CHECKING(for module suffix)
31 rm -f conftest*
32 # Intel ifc compiler generates files by the name of work.pc and work.pcl (!)
33 rm -f work*
34 cat >conftest.$ac_ext <<EOF
35 module conftest
36 integer n
37 parameter (n=1)
38 end module conftest
39 EOF
40 # SGI and absoft compilers generates module name in upper case!
41 testname="conftest"
42 modcase="lower"
43 if (eval $ac_compile) 2>/dev/null ; then
44 MOD=`ls conftest* | grep -v conftest.$ac_ext | grep -v conftest.o`
45 MOD=`echo "$MOD" | sed -e 's/conftest\.//g'`
46 if test -z "$MOD" ; then
47 MOD=`ls CONFTEST* 2>/dev/null \
48 | grep -v CONFTEST.$ac_ext | grep -v CONFTEST.o`
49 MOD=`echo "$MOD" | sed -e 's/CONFTEST\.//g'`
50 if test -n "$MOD" ; then
51 testname="CONFTEST"
52 modcase="upper"
53 fi
54 fi
55 if test -z "$MOD" ; then
56 AC_MSG_RESULT(unknown)
57 # Use mod if we can't figure it out
58 MOD="mod"
59 else
60 AC_MSG_RESULT($MOD)
61 fi
62 if test -s work.pcl ; then
63 AC_MSG_WARN([Compiler generates auxillery files!])
64 fi
65 else
66 AC_MSG_RESULT(unknown)
67 fi
68 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
154 AC_DEFUN(ACX_CHECK_CC_FLAGS,
155 [
156 AC_REQUIRE([AC_PROG_CC])
157 AC_CACHE_CHECK(whether ${CC} accepts $1, ac_$2,
158 [echo 'void f(){}' > conftest.c
159 if test -z "`${CC} $1 -c conftest.c 2>&1`"; then
160 ac_$2=yes
161 else
162 ac_$2=no
163 fi
164 rm -f conftest*
165 ])
166 if test "$ac_$2" = yes; then
167 :
168 $3
169 else
170 :
171 $4
172 fi
173 ])
174
175 AC_DEFUN(ACX_CHECK_CXX_FLAGS,
176 [
177 AC_REQUIRE([AC_PROG_CXX])
178 AC_CACHE_CHECK(whether ${CXX} accepts $1, ac_$2,
179 [echo 'void f(){}' > conftest.cpp
180 if test -z "`${CXX} $1 -c conftest.cpp 2>&1`"; then
181 ac_$2=yes
182 else
183 ac_$2=no
184 fi
185 rm -f conftest*
186 ])
187 if test "$ac_$2" = yes; then
188 :
189 $3
190 else
191 :
192 $4
193 fi
194 ])
195
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_$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_$2=yes
212 else
213 ac_$2=no
214 fi
215 rm -f conftest*
216 AC_LANG_RESTORE()
217 ])
218 if test "$ac_$2" = yes; then
219 :
220 $3
221 else
222 :
223 $4
224 fi
225 ])
226
227 AC_DEFUN(ACX_PROG_GCC_VERSION,
228 [
229 AC_REQUIRE([AC_PROG_CC])
230 AC_CACHE_CHECK(whether we are using gcc $1.$2 or later, ac_cv_prog_gcc_$1_$2,
231 [
232 dnl The semicolon after "yes" below is to pacify NeXT's syntax-checking cpp.
233 cat > conftest.c <<EOF
234 #ifdef __GNUC__ && !defined (__INTEL_COMPILER)
235 # if (__GNUC__ > $1) || (__GNUC__ == $1 && __GNUC_MINOR__ >= $2)
236 yes;
237 # endif
238 #endif
239 EOF
240 if AC_TRY_COMMAND(${CC-cc} -E conftest.c) | egrep yes >/dev/null 2>&1; then
241 ac_cv_prog_gcc_$1_$2=yes
242 else
243 ac_cv_prog_gcc_$1_$2=no
244 fi
245 ])
246 if test "$ac_cv_prog_gcc_$1_$2" = yes; then
247 :
248 $3
249 else
250 :
251 $4
252 fi
253 ])
254
255 AC_DEFUN(ACX_PROG_GXX_VERSION,
256 [
257 AC_REQUIRE([AC_PROG_CXX])
258 AC_CACHE_CHECK(whether we are using g++ $1.$2 or later, ac_cv_prog_gxx_$1_$2,
259 [
260 dnl The semicolon after "yes" below is to pacify NeXT's syntax-checking cpp.
261 cat > conftest.cpp <<EOF
262 #ifdef __GNUC__ && !defined (__INTEL_COMPILER)
263 # if (__GNUC__ > $1) || (__GNUC__ == $1 && __GNUC_MINOR__ >= $2)
264 yes;
265 # endif
266 #endif
267 EOF
268 if AC_TRY_COMMAND(${CXX-c++} -E conftest.cpp) | egrep yes >/dev/null 2>&1; then
269 ac_cv_prog_gxx_$1_$2=yes
270 else
271 ac_cv_prog_gxx_$1_$2=no
272 fi
273 ])
274 if test "$ac_cv_prog_gxx_$1_$2" = yes; then
275 :
276 $3
277 else
278 :
279 $4
280 fi
281 ])
282
283 AC_DEFUN(ACX_PROG_REALLY_GCC,
284 [
285 AC_REQUIRE([AC_PROG_CC])
286 AC_CACHE_CHECK(whether we are *really* using GNU cc, ac_cv_prog_really_gcc,
287 [
288 dnl The semicolon after "yes" below is to pacify NeXT's syntax-checking cpp.
289 cat > conftest.c <<EOF
290 #ifdef __GNUC__
291 #if defined(__INTEL_COMPILER) || defined(__PATHCC__)
292 no;
293 #else
294 yes;
295 #endif
296 #endif
297 EOF
298 if AC_TRY_COMMAND(${CC-cc} -E conftest.c) | egrep yes >/dev/null 2>&1; then
299 ac_cv_prog_really_gcc=yes
300 else
301 ac_cv_prog_really_gcc=no
302 fi
303 ])
304 if test "$ac_cv_prog_really_gcc" = yes; then
305 :
306 $1
307 else
308 :
309 $2
310 fi
311 ])
312
313 AC_DEFUN(ACX_PROG_REALLY_GXX,
314 [
315 AC_REQUIRE([AC_PROG_CXX])
316 AC_CACHE_CHECK(whether we are *really* using GNU c++, ac_cv_prog_really_gxx,
317 [
318 dnl The semicolon after "yes" below is to pacify NeXT's syntax-checking cpp.
319 cat > conftest.cpp <<EOF
320 #ifdef __GNUC__
321 #if defined(__INTEL_COMPILER) || defined(__PATHCC__)
322 no;
323 #else
324 yes;
325 #endif
326 #endif
327 EOF
328 if AC_TRY_COMMAND(${CXX-c++} -E conftest.cpp) | egrep yes >/dev/null 2>&1; then
329 ac_cv_prog_really_gxx=yes
330 else
331 ac_cv_prog_really_gxx=no
332 fi
333 ])
334 if test "$ac_cv_prog_really_gxx" = yes; then
335 :
336 $1
337 else
338 :
339 $2
340 fi
341 ])
342
343
344 AC_DEFUN(ACX_PROG_CC_MAXOPT,
345 [
346 AC_REQUIRE([AC_PROG_CC])
347 AC_REQUIRE([AC_CANONICAL_HOST])
348
349 ACX_PROG_REALLY_GCC
350
351 # Try to determine "good" native compiler flags if none specified on command
352 # line
353 if test "$ac_test_CFLAGS" != "set"; then
354 CFLAGS=""
355 case "${host_cpu}-${host_os}" in
356
357 *linux*) if test "$CC" = icc; then
358 CFLAGS="-O"
359 fi;;
360 sparc-solaris2*) if test "$CC" = cc; then
361 CFLAGS="-O -dalign"
362 fi;;
363
364 alpha*-osf*) if test "$CC" = cc; then
365 CFLAGS="-newc -w0 -O5 -ansi_alias -ansi_args -fp_reorder -tune host -arch host -std1"
366 fi;;
367
368 hppa*-hpux*) if test "$CC" = cc; then
369 CFLAGS="-Ae +O3 +Oall"
370 fi;;
371
372 rs6000*-aix*) if test "$CC" = cc -o "$CC" = xlc; then
373 CFLAGS="-O3 -qtune=auto -qansialias -w"
374 fi;;
375 powerpc*-aix*)
376 if test "$CC" = cc -o "$CC" = xlc; then
377 CFLAGS="-O3 -qtune=auto -qansialias -w"
378 echo "*******************************************************"
379 echo "* You have AIX on an unknown powerpc system. It is *"
380 echo "* recommended that you use *"
381 echo "* *"
382 echo "* CFLAGS=-O3 -qarch=ppc -qtune=xxx -qansialias -w *"
383 echo "* ^^^ *"
384 echo "* where xxx is 601, 603, 604, or whatever kind of *"
385 echo "* PowerPC CPU you have. For more info, man cc. *"
386 echo "*******************************************************"
387 fi;;
388 *darwin*)
389 if test "$CC" = xlc -o "$CC" = cc; then
390 CFLAGS="-qthreaded -O -qtune=auto -qarch=auto -qunroll=auto -qaltivec"
391 fi
392 if test "$CC" = icc; then
393 CFLAGS="-O3 -ip -no-prec-div -mdynamic-no-pic"
394 fi;;
395 esac
396
397 # use default flags for gcc on all systems
398 if test $ac_cv_prog_really_gcc = yes; then
399 CFLAGS="-O6 -fomit-frame-pointer -Wall -W -Wcast-qual -Wpointer-arith -Wcast-align -pedantic"
400 fi
401
402 # test for gcc-specific flags:
403 if test $ac_cv_prog_really_gcc = yes; then
404 # -malign-double for x86 systems
405 ACX_CHECK_CC_FLAGS(-malign-double,align_double, CFLAGS="$CFLAGS -malign-double")
406 # -fstrict-aliasing for gcc-2.95+
407 ACX_CHECK_CC_FLAGS(-fstrict-aliasing,fstrict_aliasing, CFLAGS="$CFLAGS -fstrict-aliasing")
408 fi
409
410 CPU_FLAGS=""
411 if test $ac_cv_prog_really_gcc = yes; then
412 dnl try to guess correct CPU flags, at least for linux
413 case "${host_cpu}" in
414 i586*) ACX_CHECK_CC_FLAGS(-mcpu=pentium,cpu_pentium,
415 [CPU_FLAGS=-mcpu=pentium],
416 [ACX_CHECK_CC_FLAGS(-mpentium,pentium,
417 [CPU_FLAGS=-mpentium])])
418 ;;
419 i686*) ACX_CHECK_CC_FLAGS(-mcpu=pentiumpro,cpu_pentiumpro,
420 [CPU_FLAGS=-mcpu=pentiumpro],
421 [ACX_CHECK_CC_FLAGS(-mpentiumpro,pentiumpro,
422 [CPU_FLAGS=-mpentiumpro])])
423 ;;
424 powerpc*)
425 cputype=`(grep cpu /proc/cpuinfo | head -1 | cut -d: -f2 | sed 's/ //g') 2> /dev/null`
426 is60x=`echo $cputype | egrep "^60[0-9]e?$"`
427 if test -n "$is60x"; then
428 ACX_CHECK_CC_FLAGS(-mcpu=$cputype,m_cpu_60x,
429 CPU_FLAGS=-mcpu=$cputype)
430 elif test "$cputype" = 750; then
431 ACX_PROG_GCC_VERSION(2,95,
432 ACX_CHECK_CC_FLAGS(-mcpu=750,m_cpu_750,
433 CPU_FLAGS=-mcpu=750))
434 fi
435 if test -z "$CPU_FLAGS"; then
436 ACX_CHECK_CC_FLAGS(-mcpu=powerpc,m_cpu_powerpc,
437 CPU_FLAGS=-mcpu=powerpc)
438 fi
439 if test -z "$CPU_FLAGS"; then
440 ACX_CHECK_CC_FLAGS(-mpowerpc,m_powerpc,
441 CPU_FLAGS=-mpowerpc)
442 fi
443 esac
444 fi
445
446 if test -n "$CPU_FLAGS"; then
447 CFLAGS="$CFLAGS $CPU_FLAGS"
448 fi
449
450 if test -z "$CFLAGS"; then
451 echo ""
452 echo "********************************************************"
453 echo "* WARNING: Don't know the best CFLAGS for this system *"
454 echo "* Use make CFLAGS=..., or edit the top level Makefile *"
455 echo "* (otherwise, a default of CFLAGS=-O3 will be used) *"
456 echo "********************************************************"
457 echo ""
458 CFLAGS="-O3"
459 fi
460
461 ACX_CHECK_CC_FLAGS(${CFLAGS}, guessed_cflags, , [
462 echo ""
463 echo "********************************************************"
464 echo "* WARNING: The guessed CFLAGS don't seem to work with *"
465 echo "* your compiler. *"
466 echo "* Use make CFLAGS=..., or edit the top level Makefile *"
467 echo "********************************************************"
468 echo ""
469 CFLAGS=""
470 ])
471
472 fi
473 ])
474
475 AC_DEFUN(ACX_PROG_CXX_MAXOPT,
476 [
477 AC_REQUIRE([AC_PROG_CXX])
478 AC_REQUIRE([AC_CANONICAL_HOST])
479
480 ACX_PROG_REALLY_GXX
481
482 # Try to determine "good" native compiler flags if none specified on command
483 # line
484 if test "$ac_test_CXXFLAGS" != "set"; then
485 CXXFLAGS=""
486 case "${host_cpu}-${host_os}" in
487
488 *linux*) if test "$CXX" = icc -o "$CXX" = icpc; then
489 CXXFLAGS="-O"
490 fi;;
491 sparc-solaris2*) if test "$CXX" = CC; then
492 CXXFLAGS="-features=extensions -O -dalign"
493 fi;;
494 rs6000*-aix*) if test "$CXX" = xlC; then
495 CXXFLAGS="-O3 -qarch=pwrx -qtune=pwrx -qansialias -w"
496 fi;;
497 powerpc*-aix*)
498 if test "$CXX" = xlC; then
499 CXXFLAGS="-O3 -qarch=ppc -qansialias -w"
500 echo "*******************************************************"
501 echo "* You have AIX on an unknown powerpc system. It is *"
502 echo "* recommended that you use *"
503 echo "* *"
504 echo "* CXXFLAGS=-O3 -qarch=ppc -qtune=xxx -qansialias -w *"
505 echo "* ^^^ *"
506 echo "* where xxx is 601, 603, 604, or whatever kind of *"
507 echo "* PowerPC CPU you have. For more info, man cc. *"
508 echo "*******************************************************"
509 fi;;
510 *darwin*)
511 if test "$CXX" = xlc++ -o "$CXX" = xlC ; then
512 CXXFLAGS="-qthreaded -O -qtune=auto -qarch=auto -qunroll=auto -qaltivec"
513 fi
514 if test "$CXX" = icpc; then
515 CXXFLAGS="-O3 -ip -no-prec-div -mdynamic-no-pic"
516 fi;;
517 esac
518
519 # use default flags for gcc on all systems
520 if test $ac_cv_prog_really_gxx = yes; then
521 CXXFLAGS="-O6 -fomit-frame-pointer -Wall -W -Wcast-qual -Wpointer-arith -Wcast-align -pedantic"
522 fi
523
524 # test for gcc-specific flags:
525 if test $ac_cv_prog_really_gxx = yes; then
526 # -malign-double for x86 systems
527 ACX_CHECK_CXX_FLAGS(-malign-double,align_double, CXXFLAGS="$CXXFLAGS -malign-double")
528 # -fstrict-aliasing for gcc-2.95+
529 ACX_CHECK_CXX_FLAGS(-fstrict-aliasing,fstrict_aliasing, CXXFLAGS="$CXXFLAGS -fstrict-aliasing")
530 fi
531
532 CPU_FLAGS=""
533 if test $ac_cv_prog_really_gxx = yes; then
534 dnl try to guess correct CPU flags, at least for linux
535 case "${host_cpu}" in
536 i586*) ACX_CHECK_CXX_FLAGS(-mcpu=pentium,cpu_pentium,
537 [CPU_FLAGS=-mcpu=pentium],
538 [ACX_CHECK_CXX_FLAGS(-mpentium,pentium,
539 [CPU_FLAGS=-mpentium])])
540 ;;
541 i686*) ACX_CHECK_CXX_FLAGS(-mcpu=pentiumpro,cpu_pentiumpro,
542 [CPU_FLAGS=-mcpu=pentiumpro],
543 [ACX_CHECK_CXX_FLAGS(-mpentiumpro,pentiumpro,
544 [CPU_FLAGS=-mpentiumpro])])
545 ;;
546 powerpc*)
547 cputype=`(grep cpu /proc/cpuinfo | head -1 | cut -d: -f2 | sed 's/ //g') 2> /dev/null`
548 is60x=`echo $cputype | egrep "^60[0-9]e?$"`
549 if test -n "$is60x"; then
550 ACX_CHECK_CXX_FLAGS(-mcpu=$cputype,m_cpu_60x,
551 CPU_FLAGS=-mcpu=$cputype)
552 elif test "$cputype" = 750; then
553 ACX_PROG_GXX_VERSION(2,95,
554 ACX_CHECK_CXX_FLAGS(-mcpu=750,m_cpu_750,
555 CPU_FLAGS=-mcpu=750))
556 fi
557 if test -z "$CPU_FLAGS"; then
558 ACX_CHECK_CXX_FLAGS(-mcpu=powerpc,m_cpu_powerpc,
559 CPU_FLAGS=-mcpu=powerpc)
560 fi
561 if test -z "$CPU_FLAGS"; then
562 ACX_CHECK_CXX_FLAGS(-mpowerpc,m_powerpc,
563 CPU_FLAGS=-mpowerpc)
564 fi
565 esac
566 fi
567
568 if test -n "$CPU_FLAGS"; then
569 CXXFLAGS="$CXXFLAGS $CPU_FLAGS"
570 fi
571
572 if test -z "$CXXFLAGS"; then
573 echo ""
574 echo "**********************************************************"
575 echo "* WARNING: Don't know the best CXXFLAGS for this system *"
576 echo "* Use make CXXFLAGS=..., or edit the top level Makefile *"
577 echo "* (otherwise, a default of CXXFLAGS=-O3 will be used) *"
578 echo "**********************************************************"
579 echo ""
580 CXXFLAGS="-O3"
581 fi
582
583 ACX_CHECK_CXX_FLAGS(${CXXFLAGS}, guessed_cxxflags, , [
584 echo ""
585 echo "**********************************************************"
586 echo "* WARNING: The guessed CXXFLAGS don't seem to work with *"
587 echo "* your compiler. *"
588 echo "* Use make CXXFLAGS=..., or edit the top level Makefile *"
589 echo "**********************************************************"
590 echo ""
591 CXXFLAGS=""
592 ])
593
594 fi
595 ])
596
597 AC_DEFUN(ACX_PROG_FC_MAXOPT,
598 [
599 AC_REQUIRE([AC_PROG_FC])
600 AC_REQUIRE([AC_CANONICAL_HOST])
601
602 # Try to determine "good" native compiler flags if none specified on command
603 # line
604
605 if test "$ac_test_FFLAGS" != "set"; then
606 FCFLAGS=""
607 case "${host_cpu}-${host_os}" in
608
609 *linux*) if test "$FC" = ifc -o "$FC" = ifort; then
610 FCFLAGS="-O3 -ip -no-prec-div"
611 fi;;
612 rs6000*-aix*) if test "$FC" = xlf90 -o "$FC" = f90 -o "$FC" = xlf95; then
613 FCFLAGS="-O3 -qarch=pwrx -qtune=pwrx -qansialias -w"
614 fi;;
615 powerpc*-aix*)
616 if test "$FC" = f90 -o "$FC" = xlf90 -o "$FC" = xlf95; then
617 FCFLAGS="-O3 -qarch=ppc -qansialias -w"
618 echo "*******************************************************"
619 echo "* You have AIX on an unknown powerpc system. It is *"
620 echo "* recommended that you use *"
621 echo "* *"
622 echo "* FCFLAGS=-O3 -qarch=ppc -qtune=xxx -qansialias -w *"
623 echo "* ^^^ *"
624 echo "* where xxx is 601, 603, 604, or whatever kind of *"
625 echo "* PowerPC CPU you have. For more info, man xlf. *"
626 echo "*******************************************************"
627 fi;;
628 *darwin*)
629 if test "$FC" = f90 -o "$FC" = xlf90 -o "$FC" = xlf95; then
630 FCFLAGS="-qthreaded -O -qtune=auto -qarch=auto -qunroll=auto"
631 fi
632 if test "$FC" = ifort; then
633 FCFLAGS="-O3 -ip -no-prec-dev -mdynamic-no-pic"
634 fi;;
635 esac
636
637 if test -n "$CPU_FLAGS"; then
638 FCFLAGS="$FCFLAGS $CPU_FLAGS"
639 fi
640
641 if test -z "$FCFLAGS"; then
642 echo ""
643 echo "*********************************************************"
644 echo "* WARNING: Don't know the best FCFLAGS for this system *"
645 echo "* Use make FCFLAGS=..., or edit the top level Makefile *"
646 echo "* (otherwise, a default of FCFLAGS=-O3 will be used) *"
647 echo "*********************************************************"
648 echo ""
649 FCFLAGS="-O3"
650 fi
651
652 ACX_CHECK_FC_FLAGS(${FCFLAGS}, guessed_f90flags, , [
653 echo ""
654 echo "**********************************************************"
655 echo "* WARNING: The guessed FCFLAGS don't seem to work with *"
656 echo "* your compiler. *"
657 echo "* Use make FCFLAGS=..., or edit the top level Makefile *"
658 echo "*********************************************************"
659 echo ""
660 FCFLAGS=""
661 ])
662
663 fi
664 ])
665
666 AC_DEFUN(ACX_PROG_F90_PREPFLAG,
667 [
668 AC_REQUIRE([AC_PROG_FC])
669 AC_REQUIRE([AC_CANONICAL_HOST])
670
671 # Try to determine native compiler flags that allow us to use F90 suffix
672 # for preprocessed f90 source.
673
674 if test "$ac_test_PREPFLAG" != "set"; then
675 PREPFLAG=""
676 case "${host_cpu}-${host_os}" in
677
678 *linux*) if test "$FC" = ifc -o "$FC" = ifort; then
679 PREPFLAG="-fpp1 "
680 fi;;
681 *aix*) if test "$FC" = xlf90 -o "$FC" = f90 -o "$FC" = xlf95; then
682 PREPFLAG="-qsuffix=cpp=F90 "
683 fi;;
684 *darwin*)
685 if test "$FC" = f90 -o "$FC" = xlf90 -o "$FC" = xlf95; then
686 PREPFLAG="-qsuffix=cpp=F90 "
687 fi;;
688 esac
689
690 if test -z "$PREPFLAG"; then
691 AC_MSG_WARN("Using empty PREPFLAG")
692 PREPFLAG=""
693 fi
694
695 AC_MSG_CHECKING(to make sure F90 preprocessor flag works)
696 AC_LANG_SAVE()
697 AC_LANG(Fortran)
698 ac_save_ext=$ac_ext
699 ac_ext=F90
700 ac_save_FCFLAGS_SRCEXT=$FCFLAGS_SRCEXT
701
702 AS_IF([test "$PREPFLAG"], [FCFLAGS_SRCEXT="${PREPFLAG}"])
703 _AC_COMPILE_IFELSE([
704 AC_LANG_SOURCE([
705 program conftest
706 integer :: i
707 i = 1
708 end program conftest
709 ])], [prepflagworks=1], [prepflagworks=0])
710
711 FCFLAGS_SRCEXT=$ac_save_FCFLAGS_SRCEXT
712 ac_ext=$ac_save_ext
713 AC_LANG_RESTORE()
714
715 if test "$prepflagworks" = 1; then
716 AC_MSG_RESULT(yes)
717 FCFLAGS_SRCEXT="${PREPFLAG}"
718 AC_SUBST(FCFLAGS_SRCEXT)
719 else
720 AC_MSG_RESULT(no)
721 AC_MSG_ERROR([Can't figure out working Fortran90 preprocessor flag])
722 fi
723 fi
724 ])
725
726
727 AC_DEFUN(ACX_PROG_F90_PREPDEFFLAG,
728 [
729 AC_REQUIRE([AC_PROG_FC])
730 AC_REQUIRE([AC_CANONICAL_HOST])
731
732 # Try to determine native compiler flags that allow us to use F90 suffix
733 # for preprocessed f90 source with -D type defines
734
735 if test "$ac_test_PREPDEFFLAG" != "set"; then
736 PREPDEFFLAG=""
737 case "${host_cpu}-${host_os}" in
738
739 *linux*) if test "$FC" = ifc -o "$FC" = ifort; then
740 PREPDEFFLAG=" "
741 fi;;
742 *aix*) if test "$FC" = xlf90 -o "$FC" = f90 -o "$FC" = xlf95; then
743 PREPDEFFLAG="-WF,"
744 fi;;
745 *darwin*)
746 if test "$FC" = f90 -o "$FC" = xlf90 -o "$FC" = xlf95; then
747 PREPDEFFLAG="-WF,"
748 fi;;
749 esac
750
751 if test -z "$PREPDEFFLAG"; then
752 AC_MSG_WARN("Using empty PREPDEFFLAG")
753 PREPDEFFLAG=" "
754 fi
755
756 AC_MSG_CHECKING(to make sure F90 preprocessor define flag works)
757 AC_LANG_SAVE()
758 AC_LANG(Fortran)
759 ac_save_ext=$ac_ext
760 ac_ext=F90
761 ac_save_FCFLAGS=$FCFLAGS
762
763 AS_IF([test "$PREPDEFFLAG"], [FCFLAGS="${FCFLAGS} ${PREPDEFFLAG}-DTEST"])
764 _AC_COMPILE_IFELSE([
765 AC_LANG_SOURCE([
766 program conftest
767 integer :: i
768 #ifdef TEST
769 i = 1
770 #else
771 choke me
772 #endif
773 end program conftest
774 ])], [prepdefflagworks=1], [prepdefflagworks=0])
775
776 FCFLAGS=$ac_save_FCFLAGS
777 ac_ext=$ac_save_ext
778 AC_LANG_RESTORE()
779
780 if test "$prepdefflagworks" = 1; then
781 AC_MSG_RESULT(yes)
782 AC_SUBST(PREPDEFFLAG)
783 else
784 AC_MSG_RESULT(no)
785 AC_MSG_ERROR([Can't figure out working Fortran90 preprocessor define flag])
786 fi
787 fi
788 ])
789
790 dnl check for the required MPI library
791 AC_DEFUN([ACX_MPI], [
792
793 # Set variables...
794 MPI_LIB_DIR="$MPI/lib"
795 MPI_INC_DIR="$MPI/include"
796 AC_SUBST([MPI_LIB_DIR])
797 AC_SUBST([MPI_INC_DIR])
798
799 AC_LANG(C)
800 AC_MSG_CHECKING([for mpi.h])
801 have_mpi_h=0
802 rm -f conftest*
803 echo '#include <mpi.h>' > conftest.c
804 if ${CC} -I${MPI_INC_DIR} -c conftest.c 2>&1 ; then
805 AC_MSG_RESULT(yes)
806 have_mpi_h=1
807 else
808 if test -s conftest.out ; then
809 cat conftest.out >> config.log
810 fi
811 AC_MSG_RESULT(no! Check MPI include paths)
812 USE_MPI="no"
813 fi
814 rm -f conftest*
815 if test "$have_mpi_h" = 1; then
816 AC_DEFINE(HAVE_MPI_H, 1, [have mpi.h])
817 fi
818
819 AC_MSG_CHECKING([whether mpif.h is usable])
820 AC_LANG_SAVE()
821 AC_LANG(Fortran)
822 ac_save_ext=$ac_ext
823 ac_ext=F90
824 ac_save_FCFLAGS=$FCFLAGS
825 have_mpif_h=0
826 rm -f conftest*
827 cat >conftest.$ac_ext <<EOF
828 program main
829 include 'mpif.h'
830 end
831 EOF
832 if $FC -I$MPI_INC_DIR -c $FCFLAGS $FCFLAGS_SRCEXT conftest.$ac_ext > conftest.out 2>&1 ; then
833 AC_MSG_RESULT(yes)
834 MPI_F90_INC="$MPI_INC_DIR"
835 have_mpif_h=1
836 else
837 if test -s conftest.out ; then
838 cat conftest.out >> config.log
839 fi
840 AC_MSG_RESULT([no! Check MPI include paths])
841 USE_MPI="no"
842 fi
843 rm -f conftest*
844 AC_SUBST(MPI_F90_INC)
845 if test "$have_mpif_h" = 1; then
846 AC_DEFINE(HAVE_MPIF_H, 1, [have mpif.h])
847 fi
848 FCFLAGS=$ac_save_FCFLAGS
849 ac_ext=$ac_save_ext
850 AC_LANG_RESTORE()
851
852 AC_LANG_PUSH(C)
853 ac_save_LDFLAGS=$LDFLAGS
854 LDFLAGS="-L${MPI_LIB_DIR} ${LDFLAGS} "
855
856 if test x = x"$MPI_LIB"; then
857 AC_CHECK_LIB(mpich, MPI_Init, [MPI_LIB="-lmpich"])
858 fi
859 $as_unset ac_cv_lib_mpich_MPI_Init
860 if test x = x"$MPI_LIB"; then
861 AC_CHECK_LIB(pmpich, MPI_Init, [MPI_LIB="-lpmpich -lmpich -lpmpich -lmpich"], [],
862 [-lmpich -lpmpich -lmpich])
863 fi
864 if test x = x"$MPI_LIB"; then
865 AC_CHECK_LIB(mpi, MPI_Init, [MPI_LIB="-lmpi"])
866 fi
867 $as_unset ac_cv_lib_mpi_MPI_Init
868 if test x = x"$MPI_LIB"; then
869 AC_CHECK_LIB(mpi, MPI_Init, [MPI_LIB="-lmpi -llam"], [],
870 [-llam])
871 fi
872 $as_unset ac_cv_lib_mpi_MPI_Init
873 if test x = x"$MPI_LIB"; then
874 AC_CHECK_LIB(mpi, MPI_Init, [MPI_LIB="-lmpi -llam -lpthread"],[
875 AC_MSG_ERROR([Didn't find liblam, libmpi, or libmpich; check path for MPI package first...])
876 USE_MPI="no"
877 ],
878 [-llam -lpthread])
879 fi
880
881 AC_SUBST(MPI_LIB)
882
883 AC_MSG_CHECKING([for MPI Fortran library])
884 MPI_F90_LIB=""
885 if test -f "$MPI_LIB_DIR/libfmpich.a" ; then
886 MPI_F90_LIB="-lfmpich"
887 elif test -f "$MPI_LIB_DIR/liblamf77mpi.a" ; then
888 MPI_F90_LIB="-llamf77mpi"
889 else
890 dnl nothing special found, we'll assume that the C
891 dnl library is all we need
892 MPI_F90_LIB=" "
893 fi
894 AC_MSG_RESULT([found $MPI_F90_LIB])
895 AC_SUBST(MPI_F90_LIB)
896 ])dnl ACX_MPI
897
898
899
900 AC_DEFUN([adl_FUNC_GETOPT_LONG],
901 [AC_PREREQ(2.49)dnl
902 # clean out junk possibly left behind by a previous configuration
903 rm -f src/getopt.h
904 # Check for getopt_long support
905 AC_CHECK_HEADERS([getopt.h])
906 AC_CHECK_FUNCS([getopt_long],,
907 [# FreeBSD has a gnugetopt library for this
908 AC_CHECK_LIB([gnugetopt],[getopt_long],[AC_DEFINE([HAVE_GETOPT_LONG])],
909 [# use the GNU replacement
910 AC_LIBOBJ(getopt)
911 AC_LIBOBJ(getopt1)
912 AC_CONFIG_LINKS([src/getopt.h:src/utils/gnugetopt.h])])])])
913
914
915 AC_DEFUN([ACX_CONFIG_HOME], [
916 myDir=${0%/*}
917 if [ "$myDir" = "$0" ]; then
918 # Ran from local directory
919 myDir=$PWD
920 fi
921 # Resolve symlinks.
922 myProgram="$0"
923 while [ -L "$myProgram" ]; do
924 ls=`/bin/ls -ld "$myProgram"`
925 link=`/usr/bin/expr "$ls" : '.*-> \(.*\)$'`
926 if /usr/bin/expr "$link" : '.*/.*' > /dev/null; then
927 myProgram="$link"
928 else
929 myProgram="`AS_DIRNAME([$myProgram])`/$link"
930 fi
931 done
932 myDir=`AS_DIRNAME([$myProgram])`
933 fi
934 CONFIG_HOME=$myDir
935 ])
936
937 AC_DEFUN(BB_ENABLE_DOXYGEN,
938 [
939 AC_ARG_ENABLE(doxygen, [ --enable-doxygen enable documentation generation with doxygen (auto)])
940 AC_ARG_ENABLE(dot, [ --enable-dot use 'dot' to generate graphs in doxygen (auto)])
941 AC_ARG_ENABLE(html-docs, [ --enable-html-docs enable HTML generation with doxygen (yes)], [], [ enable_html_docs=yes])
942 AC_ARG_ENABLE(latex-docs, [ --enable-latex-docs enable LaTeX documentation generation with doxygen (no)], [], [ enable_latex_docs=no])
943 if test "x$enable_doxygen" = xno; then
944 enable_doc=no
945 else
946 AC_PATH_PROG(DOXYGEN, doxygen, , $PATH)
947 if test "x$DOXYGEN" = x; then
948 if test "x$enable_doxygen" = xyes; then
949 AC_MSG_ERROR([could not find doxygen])
950 fi
951 enable_doc=no
952 else
953 enable_doc=yes
954 AC_PATH_PROG(DOT, dot, , $PATH)
955 fi
956 fi
957
958 if test "x$enable_doc" = xyes; then
959 DOC=1
960 else
961 DOC=0
962 fi
963 AC_SUBST(DOC)
964
965 if test x$DOT = x; then
966 if test "x$enable_dot" = xyes; then
967 AC_MSG_ERROR([could not find dot])
968 fi
969 enable_dot=no
970 else
971 enable_dot=yes
972 fi
973 AC_SUBST(enable_dot)
974 AC_SUBST(enable_html_docs)
975 AC_SUBST(enable_latex_docs)
976 ])
977 #
978 #
979 #
980 AC_DEFUN([AX_SYS_PERLSHARPBANG],[dnl
981
982 AC_PATH_PROG(PERLINTERP,perl,perl)
983 ac_cv_path_perlinterp="$PERLINTERP"
984 _sHpB='#!'
985
986 AC_ARG_WITH(perl-shebang,
987 AC_HELP_STRING([--with-perl-shebang],
988 [override what perl thinks is the way for the kernel to start it (seldom needed)]dnl
989 ),
990 [opt_perl_shebang="$withval"]dnl
991 ,dnl
992 [opt_perl_shebang="not_set"]dnl
993 )dnl
994
995 AC_CACHE_CHECK([whether explicit instead of detected sharpbang is to be used],
996 ax_cv_opt_perl_shebang,
997 [ case "$opt_perl_shebang" in
998 not_set ) ax_cv_opt_perl_shebang=''
999 ;;
1000 * )
1001 ax_cv_opt_perl_shebang=`echo "$opt_perl_shebang" | sed -e's|^#!\s*\(.*\)$|\1|'`
1002 esac
1003 ]dnl
1004 )dnl
1005
1006 if test "A$ax_cv_opt_perl_shebang" != "A"
1007 then
1008 ac_cv_sys_kernshrpbang_perl="$ax_cv_opt_perl_shebang"
1009 PERL_SHEBANG="$ac_cv_sys_kernshrpbang_perl"
1010 AC_SUBST(PERL_SHEBANG)dnl
1011 AC_MSG_NOTICE([OK - PERL_SHEBANG is $_sHpB$PERL_SHEBANG.])
1012
1013 # Automatic detection of sharpbang formula starts here
1014 else dnl
1015
1016 _somian_shbangperl=`$PERLINTERP -V:startperl`
1017 negclass="[[^']]"; dnl
1018 # must leave this comment: m4 will remove the outer brackets for us, heheh
1019 AC_CACHE_CHECK([for kernel sharpbang invocation to start perl],
1020 ac_cv_sys_kernshrpbang_perl,
1021 [_somian_kspb_perl=`echo "$_somian_shbangperl" | sed -ne"s|.*='\($negclass*\)';$|\1|p"`
1022 if test "x$_somian_kspb_perl" == x
1023 then _somian_ksbp_warn_empty='durnit'
1024 else
1025 case "A$_somian_kspb_perl" in
1026 A#!*perl* )
1027 ac_cv_sys_kernshrpbang_perl=`echo "$_somian_kspb_perl" | sed -e's|#!\(.*\)$|\1|'`
1028 ;;
1029 A* ) _somian_ksbp_warn_defau='trouble'
1030 ac_cv_sys_kernshrpbang_perl="$PERLINTERP"
1031 esac
1032 fi
1033 ])dnl Done with testing sharpbang
1034
1035 # The above prints Checking ... result message to user.
1036 PERL_SHEBANG="$ac_cv_sys_kernshrpbang_perl"
1037 AC_SUBST(PERL_SHEBANG)
1038 if test A${_somian_ksbp_warn_empty+set} == Aset
1039 then AC_MSG_WARN([dnl
1040 In last check, doing $PERLINTERP -V:startperl yielded empty result! That should not happen.])
1041 fi
1042 # Inform user after printing result value
1043 if test A${_somian_ksbp_warn_defau+set} == Aset
1044 then AC_MSG_NOTICE([Maybe Not good -])
1045 AC_MSG_WARN([dnl
1046 In last check perl's Config query did not work so we bunted: $_sHpB$PERLINTERP])
1047 else AC_MSG_NOTICE([OK Good result - ])
1048 AC_MSG_NOTICE([dnl
1049 In last check we got a proper-looking answer from perl's Config: $_somian_shbangperl])
1050 dnl Done with user info messages
1051 fi
1052 dnl Outer loop checked for user override term here
1053 fi dnl
1054
1055 ])dnl EOMACRO DEF
1056
1057 AC_DEFUN([ACX_CHECK_ZLIB],
1058 #
1059 # Handle user hints
1060 #
1061 [AC_ARG_WITH(zlib,
1062 AC_HELP_STRING([--with-zlib=DIR],
1063 [root directory path of zlib installation (defaults to /usr/local or /usr if not found in /usr/local)]dnl
1064 ),
1065 [zlib_dir="$withval"]dnl
1066 ,dnl
1067 [zlib_dir="not_set"]dnl
1068 )dnl
1069
1070 if test "$zlib_dir" != "no"; then
1071
1072 if test "$zlib_dir" != "not_set" ; then
1073 if test -d "$zlib_dir"
1074 then
1075 ZLIB_HOME="$zlib_dir"
1076 else
1077 AC_MSG_WARN([Sorry, $zlib_dir does not exist, checking usual places])
1078 ZLIB_HOME=/usr/local
1079 if test ! -f "${ZLIB_HOME}/include/zlib.h"
1080 then
1081 ZLIB_HOME=/usr
1082 fi
1083 fi
1084 fi
1085 #
1086 # Locate zlib, if wanted
1087 #
1088 if test -n "${ZLIB_HOME}"
1089 then
1090 ZLIB_OLD_LDFLAGS=$LDFLAGS
1091 ZLIB_OLD_CFLAGS=$CFLAGS
1092 LDFLAGS="$LDFLAGS -L${ZLIB_HOME}/lib"
1093 CFLAGS="$CFLAGS -I${ZLIB_HOME}/include"
1094 AC_LANG_SAVE
1095 AC_LANG_C
1096 AC_CHECK_LIB(z, inflateEnd, [zlib_cv_libz=yes], [zlib_cv_libz=no])
1097 AC_CHECK_HEADER(zlib.h, [zlib_cv_zlib_h=yes], [zlib_cv_zlib_h=no])
1098 AC_LANG_RESTORE
1099
1100 if test "$zlib_cv_libz" = "yes" -a "$zlib_cv_zlib_h" = "yes"; then
1101 AC_DEFINE(HAVE_ZLIB_H, 1, [have zlib.h])
1102 AC_DEFINE(HAVE_LIBZ, 1, [have libz.a])
1103 ZLIB_INC_DIR="${ZLIB_HOME}/include"
1104 ZLIB_LIB_DIR="${ZLIB_HOME}/lib"
1105 ZLIB="-lz"
1106 else
1107 AC_MSG_CHECKING(zlib in ${ZLIB_HOME})
1108 ZLIB_INC_DIR=
1109 ZLIB_LIB_DIR=
1110 ZLIB=
1111 LDFLAGS="$ZLIB_OLD_LDFLAGS"
1112 CFLAGS="$ZLIB_OLD_CFLAGS"
1113 AC_MSG_RESULT(failed)
1114 echo ""
1115 echo "*********************************************************"
1116 echo "* WARNING: Could not find a working zlib installation *"
1117 echo "* If you need OOPSE to be able to deal with compressed *"
1118 echo "* trajectory dump files be sure to specify a valid zlib *"
1119 echo "* installation with --with-zlib=DIR *"
1120 echo "* *"
1121 echo "* OOPSE will still work without zlib installed. *"
1122 echo "*********************************************************"
1123 echo ""
1124 fi
1125 AC_SUBST(ZLIB_INC_DIR)
1126 AC_SUBST(ZLIB_LIB_DIR)
1127 AC_SUBST(ZLIB)
1128 fi
1129 fi
1130 ])
1131
1132 AC_DEFUN([ACX_CHECK_QHULL],
1133 #
1134 # Handle user hints
1135 #
1136 [AC_ARG_WITH(qhull,
1137 AC_HELP_STRING([--with-qhull=DIR],
1138 [root directory path of qhull installation (defaults to /usr/local or /usr if not found in /usr/local)]dnl
1139 ),
1140 [qhull_dir="$withval"]dnl
1141 ,dnl
1142 [qhull_dir="not_set"]dnl
1143 )dnl
1144
1145 if test "$qhull_dir" != "no"; then
1146
1147 if test "$qhull_dir" != "not_set" ; then
1148 if test -d "$qhull_dir"
1149 then
1150 QHULL_HOME="$qhull_dir"
1151 else
1152 AC_MSG_WARN([Sorry, $qhull_dir does not exist, checking usual places])
1153 QHULL_HOME=/usr/local
1154 if test ! -f "${QHULL_HOME}/include/qhull/qhull.h"
1155 then
1156 QHULL_HOME=/usr
1157 fi
1158 fi
1159 fi
1160 #
1161 # Locate qhull, if wanted
1162 #
1163 if test -n "${QHULL_HOME}"
1164 then
1165 QHULL_OLD_LDFLAGS=$LDFLAGS
1166 QHULL_OLD_CFLAGS=$CFLAGS
1167 LDFLAGS="$LDFLAGS -L${QHULL_HOME}/lib"
1168 CFLAGS="$CFLAGS -I${QHULL_HOME}/include"
1169 AC_LANG_SAVE
1170 AC_LANG_C
1171 AC_CHECK_LIB(qhull, qh_qhull, [qhull_cv_libqhull=yes], [qhull_cv_libqhull=no])
1172 AC_CHECK_HEADER(qhull/qhull.h, [qhull_cv_qhull_h=yes], [qhull_cv_qhull_h=no])
1173 AC_LANG_RESTORE
1174
1175 if test "$qhull_cv_libqhull" = "yes" -a "$qhull_cv_qhull_h" = "yes"; then
1176 AC_DEFINE(HAVE_QHULL_H, 1, [have qhull.h])
1177 AC_DEFINE(HAVE_QHULL, 1, [have libqhull.a])
1178 USE_QHULL=yes
1179 QHULL_INC_DIR="${QHULL_HOME}/include"
1180 QHULL_LIB_DIR="${QHULL_HOME}/lib"
1181 QHULL="-lqhull"
1182 else
1183 AC_MSG_CHECKING(qhull in ${QHULL_HOME})
1184 QHULL_INC_DIR=
1185 QHULL_LIB_DIR=
1186 QHULL=
1187 USE_QHULL=no
1188 LDFLAGS="$QHULL_OLD_LDFLAGS"
1189 CFLAGS="$QHULL_OLD_CFLAGS"
1190 AC_MSG_RESULT(failed)
1191 echo ""
1192 echo "*********************************************************"
1193 echo "* WARNING: Could not find a working qhull installation *"
1194 echo "* If you need OOPSE to be able to deal with convex *"
1195 echo "* hulls be sure to specify a valid qhull installation *"
1196 echo "* with --with-qhull=DIR *"
1197 echo "* *"
1198 echo "* OOPSE will still work without qhull installed. *"
1199 echo "*********************************************************"
1200 echo ""
1201 fi
1202 AC_SUBST(QHULL_INC_DIR)
1203 AC_SUBST(QHULL_LIB_DIR)
1204 AC_SUBST(QHULL)
1205 AC_SUBST(USE_QHULL)
1206 fi
1207 fi
1208 ])
1209
1210
1211 AC_DEFUN([ACX_CHECK_FFTW],
1212 #
1213 # Handle user hints
1214 #
1215 [AC_ARG_WITH(fftw,
1216 AC_HELP_STRING([--with-fftw=DIR],
1217 [root directory path of fftw installation (defaults to /usr/local or /usr if not found in /usr/local)]dnl
1218 ),
1219 [fftw_dir="$withval"]dnl
1220 ,dnl
1221 [fftw_dir="not_set"]dnl
1222 )dnl
1223
1224 if test "$fftw_dir" != "no"; then
1225 if test "$fftw_dir" != "not_set" ; then
1226 if test -d "$fftw_dir"; then
1227 FFTW_HOME="$fftw_dir"
1228 else
1229 AC_MSG_WARN([Sorry, $fftw_dir does not exist, checking usual places])
1230 FFTW_HOME=/usr/local
1231 if test ! -f "${FFTW_HOME}/include/fftw3.h" -o -f "${FFTW_HOME}/include/fftw.h" -o -f "${FFTW_HOME}/include/dfftw.h"; then
1232 FFTW_HOME=/usr
1233 fi
1234 fi
1235 #
1236 # Locate fftw, if wanted
1237 #
1238 if test -n "${FFTW_HOME}"; then
1239 FFTW_OLD_LDFLAGS=$LDFLAGS
1240 FFTW_OLD_CFLAGS=$CFLAGS
1241 LDFLAGS="$LDFLAGS -L${FFTW_HOME}/lib"
1242 CFLAGS="$CFLAGS -I${FFTW_HOME}/include"
1243 AC_LANG_SAVE
1244 AC_LANG_C
1245 AC_CHECK_LIB(fftw3, fftw_execute, [fftw_cv_libfftw3=yes], [fftw_cv_libfftw3=no])
1246 AC_CHECK_HEADER(fftw3.h, [fftw_cv_fftw3_h=yes], [fftw_cv_fftw3_h=no])
1247 if test "$fftw_cv_libfftw3" = "no" -o "$fftw_cv_fftw3_h" = "no"; then
1248 AC_CHECK_LIB(fftw, fftwnd_one, [fftw_cv_libfftw=yes], [fftw_cv_libfftw=no])
1249 AC_CHECK_HEADER(fftw.h, [fftw_cv_fftw_h=yes], [fftw_cv_fftw_h=no])
1250 if test "$fftw_cv_libfftw" = "no" -o "$fftw_cv_fftw_h" = "no"; then
1251 AC_CHECK_LIB(dfftw, fftwnd_one, [fftw_cv_libdfftw=yes], [fftw_cv_libdfftw=no])
1252 AC_CHECK_HEADER(dfftw.h, [fftw_cv_dfftw_h=yes], [fftw_cv_dfftw_h=no])
1253 fi
1254 fi
1255 AC_LANG_RESTORE
1256 if test "$fftw_cv_libfftw3" = "yes" -a "$fftw_cv_fftw3_h" = "yes"; then
1257 AC_DEFINE(HAVE_FFTW3_H, 1, [have fftw3.h])
1258 FFTW_INC_DIR="${FFTW_HOME}/include"
1259 FFTW_LIB_DIR="${FFTW_HOME}/lib"
1260 FFTW_LIBS="-lfftw3"
1261 else
1262 if test "$fftw_cv_libfftw" = "yes" -a "$fftw_cv_fftw_h" = "yes"; then
1263 AC_DEFINE(HAVE_FFTW_H, 1, [have fftw.h])
1264 FFTW_INC_DIR="${FFTW_HOME}/include"
1265 FFTW_LIB_DIR="${FFTW_HOME}/lib"
1266 FFTW_LIBS="-lfftw"
1267 else
1268 if test "$fftw_cv_libdfftw" = "yes" -a "$fftw_cv_dfftw_h" = "yes"; then
1269 AC_DEFINE(HAVE_DFFTW_H, 1, [have dfftw.h])
1270 FFTW_INC_DIR="${FFTW_HOME}/include"
1271 FFTW_LIB_DIR="${FFTW_HOME}/lib"
1272 FFTW_LIBS="-ldfftw"
1273 else
1274 AC_MSG_CHECKING(fftw in ${FFTW_HOME})
1275 FFTW_INC_DIR=
1276 FFTW_LIB_DIR=
1277 FFTW_LIBS=
1278 LDFLAGS="$FFTW_OLD_LDFLAGS"
1279 CFLAGS="$FFTW_OLD_CFLAGS"
1280 AC_MSG_RESULT(failed)
1281 echo ""
1282 echo "*********************************************************"
1283 echo "* WARNING: Could not find a working FFTW installation *"
1284 echo "* If you need the staticProps program to be able to *"
1285 echo "* compute undulation spectra, be sure to specify a *"
1286 echo "* valid fftw installation with --with-fftw=DIR *"
1287 echo "* *"
1288 echo "* OOPSE will still work without fftw installed. *"
1289 echo "*********************************************************"
1290 echo ""
1291 fi
1292 fi
1293 fi
1294 AC_SUBST(FFTW_INC_DIR)
1295 AC_SUBST(FFTW_LIB_DIR)
1296 AC_SUBST(FFTW_LIBS)
1297 fi
1298 fi
1299 fi
1300 ])
1301
1302 # AC_F90_MODULE_NAMES
1303 # -------------------
1304 #
1305 # Figure out how the Fortran 90 compiler constructs module file names
1306 #
1307 AC_DEFUN([AC_F90_MODULE_NAMES],
1308 [AC_REQUIRE([AC_PROG_FC])dnl
1309 AC_CACHE_CHECK([for Fortran 90 module file names],
1310 ac_cv_f90_module_names,
1311 [AC_LANG_PUSH(Fortran)
1312 # carry out the test in a new directory, so that we don't miss anything
1313 mkdir conftest
1314 cd conftest
1315 AC_COMPILE_IFELSE(
1316 [MODULE Bar
1317 END MODULE Bar],
1318 ac_cv_f90_module_names=
1319 [ac_file_list=*
1320 for ac_file in $ac_file_list; do
1321 case $ac_file in
1322 # don't care for original source and object files
1323 conftest.$ac_ext | conftest.$ac_objext | conftest.err )
1324 :
1325 ;;
1326 # look for new files derived from the file name
1327 *conftest*)
1328 ac_pat=`echo $ac_file | sed s/conftest/%FILE%/`
1329 _AC_LIST_MEMBER_IF($ac_pat, $ac_cv_f90_module_names,,
1330 ac_cv_f90_module_names="$ac_cv_f90_module_names $ac_pat")
1331 ;;
1332 # look for new files derived from the module name,
1333 # with different case translation schemes
1334 *Bar*)
1335 ac_pat=`echo $ac_file | sed s/Bar/%Module%/`
1336 _AC_LIST_MEMBER_IF($ac_pat, $ac_cv_f90_module_names,,
1337 ac_cv_f90_module_names="$ac_cv_f90_module_names $ac_pat")
1338 ;;
1339 *bar*)
1340 ac_pat=`echo $ac_file | sed s/bar/%module%/`
1341 _AC_LIST_MEMBER_IF($ac_pat, $ac_cv_f90_module_names,,
1342 ac_cv_f90_module_names="$ac_cv_f90_module_names $ac_pat")
1343 ;;
1344 *BAR*)
1345 ac_pat=`echo $ac_file | sed s/BAR/%MODULE%/`
1346 _AC_LIST_MEMBER_IF($ac_pat, $ac_cv_f90_module_names,,
1347 ac_cv_f90_module_names="$ac_cv_f90_module_names $ac_pat")
1348 ;;
1349 # Other files - we have no idea how they are generated
1350 *)
1351 AC_MSG_WARN([Bogus file found: $ac_file])
1352 ;;
1353 esac
1354 done
1355 if test "x$ac_cv_f90_module_names" = "x"; then
1356 AC_MSG_WARN([Couldn't determine module file names])
1357 fi
1358 ],
1359 [ac_cv_f90_module_names=
1360 AC_MSG_WARN([Couldn't determine module file names])])
1361 cd ..
1362 # cleanup
1363 rm -rf conftest
1364 AC_LANG_POP()dnl
1365 ]) # AC_CACHE_CHECK
1366
1367 # We now generate a shell script that will help us to figure out the correct
1368 # module file names, using the value of ac_cv_f90_module_names
1369
1370 echo "Generating shell script modnam"
1371
1372 cat > scripts/modnam << EOF
1373 #! /bin/sh
1374 # This script is auto-generated by configure
1375 #
1376 usage="\\
1377 Usage: \$[0] [[FILES]]
1378
1379 [[FILES]] are Fortran 90 source files.
1380 The output is a list of module file names that the Fortran 90 compiler
1381 generates when compiling [[FILES]]."
1382
1383 list=
1384 empty=
1385
1386 if test \$[@%:@] -eq 0; then
1387 echo "\$usage"; exit 0
1388 fi
1389
1390 while test \$[@%:@] != 0; do
1391
1392 file=\$[1]
1393 shift
1394
1395 # strip suffix
1396 base=\`echo \$file | sed 's/[[.]][[^.]]*$//'\`
1397
1398 test ! -f \$file && continue
1399
1400 # Look for module definitions and transform them to upper / lower case
1401 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/'\`
1402 upper=\`echo \$mods | tr a-z A-Z\`
1403 lower=\`echo \$mods | tr A-Z a-z\`
1404
1405 # Here, the patterns for generating module file names were inserted by configure
1406 for trans in $ac_cv_f90_module_names; do
1407
1408 pat=\`echo \$trans | sed 's/.*\(%.*%\).*/\1/'\`
1409 var=empty
1410 case \$pat in
1411 %MODULE%)
1412 var=upper ;;
1413 %Module%)
1414 var=mods ;;
1415 %module%)
1416 var=lower ;;
1417 %FILE%)
1418 test -n "\$mods" && var=base ;;
1419 esac
1420 new=\`eval '(for i in \$'\$var '; do echo \$trans | sed s/\$pat/\$i/; done)'\`
1421 list="\$list \$new"
1422 done
1423 done
1424
1425 echo \$list
1426 # end of configure-generated script
1427 EOF
1428 chmod 755 scripts/modnam
1429 ]) # AC_F90_MODULE_NAMES
1430
1431 dnl
1432 dnl These functions were taken from the GRASS GIS toolkit:
1433 dnl
1434 dnl autoconf undefines "eval", so use "builtin([eval], ...)"
1435 dnl
1436
1437 AC_DEFUN(LOC_CHECK_USE,[
1438 AC_MSG_CHECKING(whether to use $2)
1439 AC_MSG_RESULT("$with_$1")
1440 case "$with_$1" in
1441 "no") $3= ;;
1442 "yes") $3="1" ;;
1443 *) AC_MSG_ERROR([*** You must answer yes or no.]) ;;
1444 esac
1445
1446 ])
1447
1448 AC_DEFUN(LOC_CHECK_INC_PATH,[
1449 AC_MSG_CHECKING(for location of $2 includes)
1450 case "$with_$1_includes" in
1451 y | ye | yes | n | no)
1452 AC_MSG_ERROR([*** You must supply a directory to --with-$1-includes.])
1453 ;;
1454 esac
1455 AC_MSG_RESULT($with_$1_includes)
1456
1457 if test -n "$with_$1_includes" ; then
1458 for dir in $with_$1_includes; do
1459 if test -d "$dir"; then
1460 $3="$$3 -I$dir"
1461 else
1462 AC_MSG_ERROR([*** $2 includes directory $dir does not exist.])
1463 fi
1464 done
1465 fi
1466 ])
1467
1468 AC_DEFUN(LOC_CHECK_LIB_PATH,[
1469 AC_MSG_CHECKING(for location of $2 library)
1470 case "$with_$1_libs" in
1471 y | ye | yes | n | no)
1472 AC_MSG_ERROR([*** You must supply a directory to --with-$1-libs.])
1473 ;;
1474 esac
1475 AC_MSG_RESULT($with_$1_libs)
1476
1477 if test -n "$with_$1_libs"; then
1478 for dir in $with_$1_libs; do
1479 if test -d "$dir"; then
1480 $3="$$3 -L$dir"
1481 else
1482 AC_MSG_ERROR([*** $2 library directory $dir does not exist.])
1483 fi
1484 done
1485 fi
1486 ])
1487
1488 AC_DEFUN(LOC_CHECK_SHARE_PATH,[
1489 AC_MSG_CHECKING(for location of $2 data files)
1490 case "$with_$1_share" in
1491 y | ye | yes | n | no)
1492 AC_MSG_ERROR([*** You must supply a directory to --with-$1-share.])
1493 ;;
1494 esac
1495 AC_MSG_RESULT($with_$1_share)
1496
1497 if test -n "$with_$1_share" ; then
1498 if test -d "$with_$1_share"; then
1499 $3="$with_$1_share"
1500 else
1501 AC_MSG_ERROR([*** $2 data directory $dir does not exist.])
1502 fi
1503 fi
1504 ])
1505
1506 AC_DEFUN(LOC_CHECK_INCLUDES,[
1507 ac_save_cppflags="$CPPFLAGS"
1508 CPPFLAGS="$3 $CPPFLAGS"
1509 AC_CHECK_HEADERS($1, [], ifelse($4,[],[
1510 AC_MSG_ERROR([*** Unable to locate $2 includes.])
1511 ], $4))
1512 CPPFLAGS=$ac_save_cppflags
1513 ])
1514
1515 dnl autoconf undefines "shift", so use "builtin([shift], ...)"
1516
1517 define(LOC_SHIFT1,[builtin([shift],$*)])
1518 define(LOC_SHIFT2,[LOC_SHIFT1(LOC_SHIFT1($*))])
1519 define(LOC_SHIFT4,[LOC_SHIFT2(LOC_SHIFT2($*))])
1520 define(LOC_SHIFT8,[LOC_SHIFT4(LOC_SHIFT4($*))])
1521 define(LOC_SHIFT9,[LOC_SHIFT1(LOC_SHIFT8($*))])
1522
1523 dnl $1 = library
1524 dnl $2 = function
1525 dnl $3 = descriptive name
1526 dnl $4 = LDFLAGS initialiser
1527 dnl $5 = result variable
1528 dnl $6 = mandatory dependencies (not added to $5)
1529 dnl $7 = mandatory dependencies (added to $5)
1530 dnl $8 = ACTION-IF-NOT-FOUND
1531 dnl $9+ = optional dependencies
1532
1533 define(LOC_CHECK_LIBS_0,[
1534 AC_CHECK_LIB($1, $2, $5="$$5 -l$1 $7",[
1535 [$8]
1536 ],$6 $7)
1537 ])
1538
1539 define(LOC_CHECK_LIBS_1,[
1540 ifelse($9,[],
1541 LOC_CHECK_LIBS_0($1,$2,,,$5,$6,$7,$8),
1542 [
1543 LOC_CHECK_LIBS_1($1,$2,,,$5,$6,$7,
1544 LOC_CHECK_LIBS_1($1,$2,,,$5,$6,$7 $9,$8,LOC_SHIFT9($*)),
1545 LOC_SHIFT9($*))
1546 ]
1547 )
1548 ])
1549
1550 define(LOC_CHECK_LIBS,[
1551 ac_save_ldflags="$LDFLAGS"
1552 LDFLAGS="$4 $LDFLAGS"
1553 LOC_CHECK_LIBS_1($1,$2,,,$5,$6,$7,
1554 LDFLAGS=${ac_save_ldflags}
1555 ifelse($8,[],[
1556 AC_MSG_ERROR([*** Unable to locate $3 library.])
1557 ],$8),LOC_SHIFT8($*))
1558 LDFLAGS=${ac_save_ldflags}
1559 ])
1560
1561 AC_DEFUN(LOC_CHECK_VERSION_STRING,[
1562 AC_MSG_CHECKING($3 version)
1563 ac_save_cppflags="$CPPFLAGS"
1564 CPPFLAGS="$5 $CPPFLAGS"
1565 AC_TRY_RUN([
1566 #include <stdio.h>
1567 #include <$1>
1568 int main(void) {
1569 FILE *fp = fopen("conftestdata","w");
1570 fputs($2, fp);
1571 return 0;
1572 }
1573 ],
1574 [ $4=`cat conftestdata`
1575 AC_MSG_RESULT($$4)],
1576 [ AC_MSG_ERROR([*** Could not determine $3 version.]) ],
1577 [ $4=$6
1578 AC_MSG_RESULT([unknown (cross-compiling)]) ])
1579 CPPFLAGS=$ac_save_cppflags
1580 ])
1581
1582 AC_DEFUN(LOC_CHECK_SHARE,[
1583 AC_CHECK_FILE($3/$1, [], ifelse($4,[],[
1584 AC_MSG_ERROR([*** Unable to locate $2 data files.])
1585 ], $4))
1586 ])
1587
1588 AC_DEFUN(LOC_CHECK_VERSION_INT,[
1589 AC_MSG_CHECKING($3 version)
1590 ac_save_cppflags="$CPPFLAGS"
1591 CPPFLAGS="$5 $CPPFLAGS"
1592 AC_TRY_RUN([
1593 #include <stdio.h>
1594 #include <$1>
1595 int main(void) {
1596 FILE *fp = fopen("conftestdata","w");
1597 fprintf(fp, "%d", $2);
1598 return 0;
1599 }
1600 ],
1601 [ $4=`cat conftestdata`
1602 AC_MSG_RESULT($$4)],
1603 [ AC_MSG_ERROR([*** Could not determine $3 version.]) ],
1604 [ $4=$6
1605 AC_MSG_RESULT([unknown (cross-compiling)]) ])
1606 CPPFLAGS=$ac_save_cppflags
1607 ])
1608
1609 dnl autoconf undefines "eval", so use "builtin([eval], ...)"
1610
1611 AC_DEFUN(LOC_PAD,[$1[]ifelse(builtin([eval],len($1) > 23),1,[
1612 ],substr([ ],len($1)))])
1613
1614 AC_DEFUN(LOC_ARG_WITH,[
1615 AC_ARG_WITH($1,
1616 LOC_PAD([ --with-$1])[support $2 functionality (default: ]ifelse([$3],,yes,[$3])[)],,
1617 [with_$1=]ifelse([$3],,yes,[$3]))
1618 ])
1619
1620 AC_DEFUN(LOC_ARG_WITH_INC,[
1621 AC_ARG_WITH($1-includes,
1622 LOC_PAD([ --with-$1-includes=DIRS])[$2 include files are in DIRS])
1623 ])
1624
1625 AC_DEFUN(LOC_ARG_WITH_LIB,[
1626 AC_ARG_WITH($1-libs,
1627 LOC_PAD([ --with-$1-libs=DIRS])[$2 library files are in DIRS])
1628 ])
1629
1630 AC_DEFUN(LOC_ARG_WITH_SHARE,[
1631 AC_ARG_WITH($1-share,
1632 LOC_PAD([ --with-$1-share=DIR])[$2 data files are in DIR])
1633 ])
1634
1635 AC_DEFUN(LOC_OPTIONAL,[
1636 AC_MSG_CHECKING(whether to build $1)
1637 if test -n "$USE_$2" ; then
1638 AC_MSG_RESULT(yes)
1639 BUILD_$3="$4"
1640 else
1641 AC_MSG_RESULT(no)
1642 BUILD_$3=
1643 fi
1644 AC_SUBST(BUILD_$3)
1645 ])
1646
1647 AC_DEFUN(LOC_MSG,[
1648 echo "$1"
1649 ])
1650
1651 AC_DEFUN(LOC_PAD_26,[substr([ ],len($1))])
1652
1653 AC_DEFUN(LOC_YES_NO,[if test -n "${$1}" ; then echo yes ; else echo no ; fi])
1654
1655 AC_DEFUN(LOC_MSG_USE,[
1656 [echo " $1:]LOC_PAD_26($1)`LOC_YES_NO($2)`"])