b398cd9e7d2087e65428bea77ff9d0245408c8bc
[alexxy/gromacs.git] / acinclude.m4
1  
2 # ACX_CHECK_FFTW()
3 # ----------------
4 # This macro checks for fftw header files and libraries,
5 # including the possible prefixing with s or d to determine precision.
6 # Arg 1 is the fftw header/library name to check for, without 
7 # prefix or anything else (e.g. rfftw_mpi for real MPI transforms)
8 # Arg 2 is the value of $enable_float, i.e. yes/no for precision=4/8.
9 AC_DEFUN(ACX_CHECK_FFTW,
10 [
11 if test -z "$ac_fftw_firstname"; then
12
13 if test "$2" = "no"; then
14   prec="double"
15   realsize=8
16   fftwcheckprefix=d
17 else
18   prec="single"
19   realsize=4
20   fftwcheckprefix=s
21 fi
22
23 usedprefix=""
24 ok="no"
25 # check header doesn't work, since we must use mpicc to get includes, not just /lib/cpp
26 AC_MSG_CHECKING([for $1.h])
27 AC_TRY_COMPILE([#include <$1.h>],,
28 [
29 fftwname=$1 
30 AC_MSG_RESULT(yes)
31 ],
32 AC_MSG_RESULT(no))
33
34
35 if test -n "$fftwname"; then
36 # we cannot run the code since an MPI program might not be allowed on a login node of a supercomputer
37 AC_TRY_COMPILE([#include <$fftwname.h>],
38 [int _array_ [1 - 2 * !((sizeof(fftw_real)) == $realsize)]; ],
39 ok="yes",ok="no")
40 fi
41
42 fftwname=$1
43
44 if test "$ok" != "yes"; then
45   xfftwname=${fftwcheckprefix}${fftwname}
46   AC_MSG_CHECKING([for $xfftwname.h])
47   AC_TRY_COMPILE([#include <$xfftwname.h>],,AC_MSG_RESULT(yes),
48 [
49 AC_MSG_RESULT(no)
50 AC_MSG_ERROR([Cannot find any $prec precision $fftwname.h or $xfftwname.h]
51 [Do you have $prec precision FFTW installed? If you are using packages,]
52 [note that you also need fftw-devel to compile GROMACS. You can find the ]
53 [software at www.fftw.org, and detailed instructions at www.gromacs.org.]
54 [If you compiled FFTW yourself:                                        ]
55 [Note that the default FFTW setup is double precision. Change the FFTW]
56 [configuration to single with --enable-float. If you want MPI support,]
57 [use --enable-mpi. It is a good idea to install both single & double.] 
58 [If your sysadm doesn't want to install it you can do it to a location]
59 [in your home directory and provide the correct paths in the CPPFLAGS]
60 [and LDFLAGS environment variables before running configure.]
61 [That is also necessary to do if your compiler doesn't search]
62 [/usr/local/include and /usr/local/lib by default.]
63 [You can find information at www.gromacs.org, or in the INSTALL file.])
64 ])
65 AC_TRY_COMPILE([#include <$xfftwname.h>],[int _array_ [1 - 2 * !((sizeof(fftw_real)) == $realsize)];],
66 [
67 fftwname=$xfftwname 
68 usedprefix=$fftwcheckprefix
69 ],
70 [
71 AC_MSG_ERROR([Cannot find any $prec precision $fftwname.h or $xfftwname.h]
72 [Do you have $prec precision FFTW installed? If you are using packages,]
73 [note that you also need fftw-devel to compile GROMACS. You can find the ]
74 [software at www.fftw.org, and detailed instructions at www.gromacs.org.]
75 [If you compiled FFTW yourself:                                       ]
76 [Note that the default FFTW setup is double precision. Change the FFTW]
77 [configuration to single with --enable-float. If you want MPI support,]
78 [use --enable-mpi. It is a good idea to install both single & double.] 
79 [If your sysadm doesn't want to install it you can do it to a location]
80 [in your home directory and provide the correct paths in the CPPFLAGS]
81 [and LDFLAGS environment variables before running configure.]
82 [That is also necessary to do if your compiler doesn't search]
83 [/usr/local/include and /usr/local/lib by default.]
84 [You can find information at www.gromacs.org, or in the INSTALL file.])])
85 fi
86
87 AC_CHECK_LIB($fftwname,main,,AC_MSG_ERROR([Can't find a library to match the $fftwname header]))
88 ac_fftw_savedprefix=$usedprefix
89 ac_fftw_firstname=$fftwname
90
91 else
92
93 fftwname=${ac_fftw_savedprefix}$1
94 AC_MSG_CHECKING([for $fftwname.h])
95 AC_TRY_COMPILE(
96 [#include <$fftwname.h>],,AC_MSG_RESULT(yes)
97 AC_CHECK_LIB($fftwname,main,,AC_MSG_ERROR([Can't find a library to match the $fftwname header])),
98 [
99 AC_MSG_RESULT(no)
100 AC_MSG_ERROR([Cant find $fftwname.h header. Make sure all your fftw prefixes match - we already use $ac_fftw_firstname.h])
101 ])
102
103 fi
104
105 ])
106
107
108
109 dnl macro from the fftw distribution (http://www.fftw.org)
110 dnl like AC_SUBST, but replace XXX_variable_XXX instead of @variable@
111 dnl This macro protects VARIABLE from being diverted twice
112 dnl if this macro is called twice for it.
113 dnl AC_SUBST(VARIABLE)
114 define(ACX_SUBST_XXX,
115 [ifdef([ACX_SUBST_XXX_$1], ,
116 [define([ACX_SUBST_XXX_$1], )dnl
117 AC_DIVERT_PUSH(AC_DIVERSION_SED)dnl
118 s=XXX_$1_XXX=[$]$1=g
119 AC_DIVERT_POP()dnl
120 ])])
121
122
123 # ACX_F77_NAME_MANGLING
124 # ---------------------
125 # This is a macro adopted from the fftw distribution (http://www.fftw.org)
126 # to determine how we should call fortran functions from C.
127 AC_DEFUN(ACX_F77_NAME_MANGLING,
128 [
129 AC_REQUIRE([AC_PROG_CC])
130 AC_REQUIRE([AC_PROG_F77])
131 AC_REQUIRE([AC_F77_LIBRARY_LDFLAGS])
132 AC_MSG_CHECKING(fortran name mangling)
133 cat > mangle-func.f <<EOF
134       subroutine foobar()
135       return
136       end
137       subroutine foo_bar()
138       return
139       end
140 EOF
141 ac_try='$F77 -c $FFLAGS mangle-func.f 1>&AC_FD_CC'
142 if AC_TRY_EVAL(ac_try); then
143   ac_try=""
144 else
145   echo "configure: failed program was:" >&AC_FD_CC
146   cat mangle-func.f >&AC_FD_CC
147   rm -f mangle-func*
148   AC_MSG_ERROR(failed to compile fortran test program)
149 fi
150
151 ac_f77_mangle_type=unknown
152 AC_LANG_SAVE
153 AC_LANG_C
154 ac_save_LIBS="$LIBS"
155 LIBS="mangle-func.o $FLIBS $LIBS"
156 AC_TRY_LINK(,foobar();,
157      ac_f77_mangle_type=lowercase,
158      AC_TRY_LINK(,foobar_();,
159           ac_f77_mangle_type=lowercase-underscore,
160           AC_TRY_LINK(,FOOBAR();,
161                ac_f77_mangle_type=uppercase,
162                AC_TRY_LINK(,FOOBAR_();,
163                     ac_f77_mangle_type=uppercase-underscore))))
164 LIBS="$ac_save_LIBS"
165 AC_LANG_RESTORE
166 AC_MSG_RESULT($ac_f77_mangle_type)
167
168 mangle_try=unknown
169 case $ac_f77_mangle_type in
170         lowercase)
171                 AC_DEFINE(F77_NAME_LOWERCASE,,[call f77 with lowercase, no underscore])
172                 mangle_try=foo_bar_
173                 ;;
174         lowercase-underscore)
175                 AC_DEFINE(F77_NAME_LOWERCASE_UNDERSCORE,,[call f77 with lowercase and underscore])
176                 mangle_try=foo_bar__
177                 ;;
178         uppercase)
179                 AC_DEFINE(F77_NAME_UPPERCASE,,[call f77 with uppercase, no underscore])
180                 mangle_try=FOO_BAR_
181                 ;;
182         uppercase-underscore)
183                 AC_DEFINE(F77_NAME_UPPERCASE_UNDERSCORE,,[call f77 with uppercase and underscore])
184                 mangle_try=FOO_BAR__
185                 ;;
186 esac
187
188 AC_MSG_CHECKING(whether f77 functions with underscore get an extra underscore)
189
190 AC_LANG_SAVE
191 AC_LANG_C
192 ac_save_LIBS="$LIBS"
193 LIBS="mangle-func.o $FLIBS $LIBS"
194 AC_TRY_LINK(,$mangle_try();,
195             [ac_f77_mangle_underscore=yes;
196              AC_DEFINE(F77_NAME_EXTRA_UNDERSCORE,,[Append extra underscore to already underscored names])],
197             [ac_f77_mangle_underscore=no])
198 LIBS="$ac_save_LIBS"
199 AC_LANG_RESTORE
200 rm -f mangle-func*
201 AC_MSG_RESULT($ac_f77_mangle_underscore)
202 ])
203
204
205
206
207
208 dnl
209 dnl
210 dnl AC_FIND_MOTIF : find OSF/Motif or LessTif, and provide variables
211 dnl     to easily use them in a Makefile.
212 dnl
213 dnl Adapted from a macro by Andreas Zeller.
214 dnl
215 dnl The variables provided are :
216 dnl     link_motif              (e.g. -L/usr/lesstif/lib -lXm -lXt)
217 dnl     include_motif           (e.g. -I/usr/lesstif/lib)
218 dnl     motif_libraries         (e.g. /usr/lesstif/lib)
219 dnl     motif_includes          (e.g. /usr/lesstif/include)
220 dnl
221 dnl The link_motif and include_motif variables should be fit to put on
222 dnl your application's link line in your Makefile.
223 dnl
224 AC_DEFUN(AC_FIND_MOTIF,
225 [
226 AC_REQUIRE([AC_PATH_XTRA])
227
228 motif_includes=
229 motif_libraries=
230
231 dnl AC_ARG_WITH(motif,
232 dnl [  --without-motif         do not use Motif widgets])
233 dnl Treat --without-motif like
234 dnl --without-motif-includes --without-motif-libraries.
235
236 if test "$no_x" = "yes"
237 then
238   motif_includes=none
239   motif_libraries=none
240 fi
241
242 AC_ARG_WITH(motif-includes,
243 [  --with-motif-includes=DIR     Motif include files are in DIR],
244 motif_includes="$withval")
245
246 AC_ARG_WITH(motif-libraries,
247 [  --with-motif-libraries=DIR    Motif libraries are in DIR],
248 motif_libraries="$withval")
249
250 AC_MSG_CHECKING(for Motif)
251
252
253 #
254 #
255 # Search the include files.
256 #
257 if test "$motif_includes" = ""; then
258 AC_CACHE_VAL(ac_cv_motif_includes,
259 [
260 ac_motif_save_LIBS="$LIBS"
261 ac_motif_save_INCLUDES="$INCLUDES"
262 ac_motif_save_CPPFLAGS="$CPPFLAGS"
263 ac_motif_save_LDFLAGS="$LDFLAGS"
264 #
265 LIBS="$X_PRE_LIBS -lXm -lXt -lX11 $X_EXTRA_LIBS $LIBS"
266 INCLUDES="$X_CFLAGS $INCLUDES"
267 CPPFLAGS="$X_CFLAGS $CPPFLAGS"
268 LDFLAGS="$X_LIBS $LDFLAGS"
269 #
270 ac_cv_motif_includes="none"
271 AC_TRY_COMPILE([#include <Xm/Xm.h>],[int a;],
272 [
273 # Xm/Xm.h is in the standard search path.
274 ac_cv_motif_includes=
275 ],
276 [
277 # Xm/Xm.h is not in the standard search path.
278 # Locate it and put its directory in `motif_includes'
279 #
280 # /usr/include/Motif* are used on HP-UX (Motif).
281 # /usr/include/X11* are used on HP-UX (X and Athena).
282 # /usr/dt is used on Solaris (Motif).
283 # /usr/openwin is used on Solaris (X and Athena).
284 # Other directories are just guesses.
285 for dir in "$x_includes" "${prefix}/include" /usr/include /usr/local/include \
286            /usr/include/Motif2.0 /usr/include/Motif1.2 /usr/include/Motif1.1 \
287            /usr/include/X11R6 /usr/include/X11R5 /usr/include/X11R4 \
288            /usr/dt/include /usr/openwin/include \
289            /usr/dt/*/include /opt/*/include /usr/include/Motif* \
290            "${prefix}"/*/include /usr/*/include /usr/local/*/include \
291            "${prefix}"/include/* /usr/include/* /usr/local/include/*; do
292 if test -f "$dir/Xm/Xm.h"; then
293 ac_cv_motif_includes="$dir"
294 break
295 fi
296 done
297 ])
298 #
299 LIBS="$ac_motif_save_LIBS"
300 INCLUDES="$ac_motif_save_INCLUDES"
301 CPPFLAGS="$ac_motif_save_CPPFLAGS"
302 LDFLAGS="$ac_motif_save_LDFLAGS"
303 ])
304 motif_includes="$ac_cv_motif_includes"
305 fi
306 #
307 #
308 # Now for the libraries.
309 #
310 if test "$motif_libraries" = ""; then
311 AC_CACHE_VAL(ac_cv_motif_libraries,
312 [
313 ac_motif_save_LIBS="$LIBS"
314 ac_motif_save_INCLUDES="$INCLUDES"
315 ac_motif_save_CPPFLAGS="$CPPFLAGS"
316 ac_motif_save_LDFLAGS="$LDFLAGS"
317 #
318 LIBS="$X_PRE_LIBS -lXm -lXt -lX11 $X_EXTRA_LIBS $LIBS"
319 INCLUDES="$X_CFLAGS $INCLUDES"
320 CPPFLAGS="$X_CFLAGS $CPPFLAGS"
321 LDFLAGS="$X_LIBS $LDFLAGS"
322 #
323 ac_cv_motif_libraries="none"
324 AC_TRY_LINK([#include <Xm/Xm.h>],[XtToolkitInitialize();],
325 [
326 # libXm.a is in the standard search path.
327 ac_cv_motif_libraries=
328 ],
329 [
330 # libXm.a is not in the standard search path.
331 # Locate it and put its directory in `motif_libraries'
332 #
333 # /usr/lib/Motif* are used on HP-UX (Motif).
334 # /usr/lib/X11* are used on HP-UX (X and Athena).
335 # /usr/dt is used on Solaris (Motif).
336 # /usr/lesstif is used on Linux (Lesstif).
337 # /usr/openwin is used on Solaris (X and Athena).
338 # Other directories are just guesses.
339 for dir in "$x_libraries" "${prefix}/lib" /usr/lib /usr/local/lib \
340            /usr/lib/Motif2.0 /usr/lib/Motif1.2 /usr/lib/Motif1.1 \
341            /usr/lib/X11R6 /usr/lib/X11R5 /usr/lib/X11R4 /usr/lib/X11 \
342            /usr/dt/lib /usr/openwin/lib \
343            /usr/dt/*/lib /opt/*/lib /usr/lib/Motif* \
344            /usr/lesstif*/lib /usr/lib/Lesstif* \
345            "${prefix}"/*/lib /usr/*/lib /usr/local/*/lib \
346            "${prefix}"/lib/* /usr/lib/* /usr/local/lib/*; do
347 if test -d "$dir" && test "`ls $dir/libXm.* 2> /dev/null`" != ""; then
348 ac_cv_motif_libraries="$dir"
349 break
350 fi
351 done
352 ])
353 #
354 LIBS="$ac_motif_save_LIBS"
355 INCLUDES="$ac_motif_save_INCLUDES"
356 CPPFLAGS="$ac_motif_save_CPPFLAGS"
357 LDFLAGS="$ac_motif_save_LDFLAGS"
358 ])
359 #
360 motif_libraries="$ac_cv_motif_libraries"
361 fi
362 #
363 # Provide an easier way to link
364 #
365 if test "$motif_includes" = "none" -o "$motif_libraries" = "none"; then
366         with_motif="no"
367 else
368         with_motif="yes"
369 fi
370
371 if test "$with_motif" != "no"; then
372         if test "$motif_libraries" = ""; then
373                 link_motif="-lXm -lXt"
374                 MOTIF_LIBS="-lXm -lXt"
375         else
376                 link_motif="-L$motif_libraries -lXm -lXt"
377                 MOTIF_LIBS="-L$motif_libraries -lXm -lXt"
378         fi
379         if test "$motif_includes" != ""; then
380                 include_motif="-I$motif_includes"
381                 MOTIF_INCLUDES="-I$motif_includes"
382         fi
383         LIBS="$LIBS $MOTIF_LIBS"
384         INCLUDES="$INCLUDES $MOTIF_INCLUDES"
385         AC_DEFINE(HAVE_MOTIF,,[Use motif/lesstif libraries])
386 else
387         with_motif="no"
388 fi
389 #
390 #
391 #
392 #
393 motif_libraries_result="$motif_libraries"
394 motif_includes_result="$motif_includes"
395 test "$motif_libraries_result" = "" && motif_libraries_result="in default path"
396 test "$motif_includes_result" = "" && motif_includes_result="in default path"
397 test "$motif_libraries_result" = "none" && motif_libraries_result="(none)"
398 test "$motif_includes_result" = "none" && motif_includes_result="(none)"
399 AC_MSG_RESULT(
400   [libraries $motif_libraries_result, headers $motif_includes_result])
401 ])dnl
402
403
404 dnl macro modified from the fftw distribution (www.fftw.org)
405 AC_DEFUN(ACX_CHECK_CC_FLAGS,
406 [
407 AC_REQUIRE([AC_PROG_CC])
408 AC_CACHE_CHECK(whether $CC accepts $1, ac_$2,
409 [echo 'void f(){}' > conftest.c
410 if test -z "`$CC $1 -c conftest.c 2>&1`"; then
411         ac_$2=yes
412 else
413         ac_$2=no
414 fi
415 rm -f conftest*
416 ])
417 if test "$ac_$2" = yes; then
418         :
419         $3
420 else
421         :
422         $4
423 fi
424 ])
425
426 dnl macro modified from the fftw distribution (www.fftw.org)
427 AC_DEFUN(ACX_CHECK_F77_FLAGS,
428 [
429 AC_REQUIRE([AC_PROG_F77])
430 AC_CACHE_CHECK(whether $F77 accepts $1, ac_$2,
431 [cat > conftest.f << EOF
432       subroutine f
433       return 
434       end
435 EOF
436 if test -z "`$F77 $1 -c conftest.f `"; then
437         ac_$2=yes
438 else
439         ac_$2=no
440 fi
441 rm -f conftest*
442 ])
443 if test "$ac_$2" = yes; then
444         :
445         $3
446 else
447         :
448         $4
449 fi
450 ])
451
452
453 # ACX_DETECT_GMXCPU
454 # ---------------------------
455 # Macro to extend the exact CPU for some hosts
456 AC_DEFUN(ACX_DETECT_GMXCPU,
457 [
458 AC_REQUIRE([AC_CANONICAL_HOST])
459
460 #
461 # Determine the exact cpu type on some common systems where it is 
462 # not visible from the host triplet.
463 # (on e.g. intel and dec/tru64 the host type is enough)
464
465 case "${host_cpu}-${host_os}" in
466
467 rs6000*-aix*)
468   # we need to fool the combination of m4, sh and awk - thus the seemingly unnecessary n
469   IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | head -1 | awk '{ n=1; print $n }'`
470   if /usr/sbin/lsattr -EHl ${IBM_CPU_ID} | grep POWER4 >/dev/null 2>&1; then
471     gmxcpu=power4
472   elif /usr/sbin/lsattr -EHl ${IBM_CPU_ID} | grep POWER3 >/dev/null 2>&1; then
473     gmxcpu=power3
474   elif /usr/sbin/lsattr -EHl ${IBM_CPU_ID} | grep POWER2 >/dev/null 2>&1; then
475     gmxcpu=power2
476   else
477     gmxcpu=""
478   fi
479   ;;
480
481 powerpc*-aix*)
482   if /usr/sbin/lscfg -vp | grep PowerPC | grep 604 >/dev/null 2>&1; then
483     gmxcpu=ppc604
484   elif /usr/sbin/lscfg -vp | grep PowerPC | grep 603 >/dev/null 2>&1; then
485     gmxcpu=ppc603
486   elif /usr/sbin/lscfg -vp | grep PowerPC | grep rs64a >/dev/null 2>&1; then
487     gmxcpu=rs64a
488   elif /usr/sbin/lscfg -vp | grep PowerPC | grep rs64b >/dev/null 2>&1; then
489     gmxcpu=rs64b
490   elif /usr/sbin/lscfg -vp | grep PowerPC | grep rs64c >/dev/null 2>&1; then
491     gmxcpu=rs64c
492   else
493     gmxcpu=""
494   fi
495   ;;
496
497 mips*-irix*)
498   if /sbin/hinv | grep CPU | grep R12000 >/dev/null 2>&1; then
499     gmxcpu=r12000
500   elif /sbin/hinv | grep CPU | grep R10000 >/dev/null 2>&1; then
501     gmxcpu=r10000
502   elif /sbin/hinv | grep CPU | grep R8000 >/dev/null 2>&1; then
503     gmxcpu=r8000
504   elif /sbin/hinv | grep CPU | grep R5000 >/dev/null 2>&1; then
505     gmxcpu=r5000
506   else
507     gmxcpu=""
508   fi
509   ;;
510
511 sparc*-solaris*)
512   if /usr/sbin/prtconf | grep UltraSPARC-III >/dev/null 2>&1; then
513     gmxcpu=ultrasparc3
514   elif /usr/sbin/prtconf | grep UltraSPARC-IIi >/dev/null 2>&1; then
515     gmxcpu=ultrasparc2i
516   elif /usr/sbin/prtconf | grep UltraSPARC-II >/dev/null 2>&1; then
517     gmxcpu=ultrasparc2
518   elif /usr/sbin/prtconf | grep UltraSPARC >/dev/null 2>&1; then
519     gmxcpu=ultrasparc
520   else
521     gmxcpu=""
522   fi
523   ;;
524 *)
525   gmxcpu=""
526   ;;
527
528 esac
529 ])
530
531
532
533 ###############################################################
534 # Macro modified from the fftw distribution (www.fftw.org)
535 # to determine optimization flags.
536 # Note that we have modified config.guess and config.sub
537 # to provide extended information on the detailed type of CPU.
538 # In general we assume you have recent versions of the compilers
539 # that support the highest optimization we know of. If not, you 
540 # can always override these flags, but it's better to upgrade :-)
541 ###############################################################
542 AC_DEFUN(ACX_COMPILER_MAXOPT,
543 [
544 AC_REQUIRE([AC_PROG_CC])
545 AC_REQUIRE([AC_PROG_F77])
546 AC_REQUIRE([AC_CANONICAL_HOST])
547
548 # Try to determine "good" native compiler flags if none specified on command
549 # line. To avoid repeating the entire procedure for fortran flags, we first
550 # determine our suggested choices for both C and fortran, and then possibly
551 # override them with user choices.
552
553 cc_vendor="unknown"
554
555 case "${host_cpu}-${host_os}" in
556
557   *-solaris2*) 
558     case "${gmxcpu}" in
559       ultrasparc3*)
560         xCFLAGS="-fast -xO5 -xtarget=ultra3 -fsimple=2 -fnonstd -dalign"
561         xFFLAGS=$xCFLAGS
562         ;;
563       ultrasparc2i*)
564         xCFLAGS="-fast -xO5 -xtarget=ultra2i -fsimple=2 -fnonstd -dalign"
565         xFFLAGS=$xCFLAGS
566         ;;
567       ultrasparc2*)
568         xCFLAGS="-fast -xO5 -xtarget=ultra2 -fsimple=2 -fnonstd -dalign"
569         xFFLAGS=$xCFLAGS
570         ;;
571       ultrasparc*)
572         xCFLAGS="-fast -xO5 -xtarget=ultra -fsimple=2 -fnonstd -dalign"
573         xFFLAGS=$xCFLAGS
574         ;;
575       *)
576         xCFLAGS="-native -fast -xO5 -fsimple=2 -fnonstd -dalign"
577         xFFLAGS=$xCFLAGS
578         ;;
579     esac
580     ;;
581
582   *-hpux*)  
583     xCFLAGS="-Ae +O3 +Oall"
584     xFFLAGS=$xCFLAGS
585     # If you haven't noticed, we don't like hp very much...
586     # but perhaps that will change if they make something nice out of ia64.
587     ;;
588
589   rs6000*-aix*)
590     # dont use inter-procedure analysis for the innerloops - they take
591     # forever to compile with it, and it doesnt help at all.
592     case "${gmxcpu}" in
593       power4*)
594         xCFLAGS="-O3 -qarch=pwr4 -qtune=pwr4 -qlanglvl=ansi -qmaxmem=16384"
595         xFFLAGS="-O3 -Q -qarch=pwr4 -qtune=pwr4 -qmaxmem=16384 -qhot -qnoipa"
596         ;;
597       power3*)
598         xCFLAGS="-O3 -qarch=pwr3 -qtune=pwr3 -qlanglvl=ansi -qmaxmem=16384"
599         xFFLAGS="-O3 -Q -qarch=pwr3 -qtune=pwr3 -qmaxmem=16384 -qhot -qnoipa"
600         ;;
601       power2*)
602         xCFLAGS="-O3 -qarch=pwr2 -qtune=pwr2 -qlanglvl=ansi -qmaxmem=16384"
603         xFFLAGS="-O3 -Q -qarch=pwr2 -qtune=pwr2 -qmaxmem=16384 -qhot -qnoipa"
604         ;;
605       power)
606         xCFLAGS="-O3 -qarch=pwr -qtune=pwr -qlanglvl=ansi -qmaxmem=16384"
607         xFFLAGS="-O3 -Q -qarch=pwr -qtune=pwr -qmaxmem=16384 -qhot -qnoipa"
608         ;;
609       *)
610         # I don't think people are using anything older than power2, so we tune for
611         # pwr, but dont set the arch since it is nice to have common binaries 
612         # that run also on powerpc.
613         xCFLAGS="-O3 -qlanglvl=ansi -qtune=pwr -qmaxmem=16384"
614         xFFLAGS="-O3 -Q -qtune=pwr -qmaxmem=16384 -qhot"
615         ;;
616     esac
617     ;;
618
619   powerpc*-aix*)
620     case "${gmxcpu}" in
621       ppc604)
622         xCFLAGS="-O3 -qarch=604 -qtune=604 -qlanglvl=ansi -qmaxmem=16384"
623         xFFLAGS="-O3 -Q -qarch=604 -qtune=604 -qmaxmem=16384 -qhot"
624         ;;
625       ppc603)
626         xCFLAGS="-O3 -qarch=603 -qtune=603 -qlanglvl=ansi -qmaxmem=16384"
627         xFFLAGS="-O3 -Q -qarch=603 -qtune=603 -qmaxmem=16384 -qhot"
628         ;;
629       rs64a)
630         xCFLAGS="-O3 -qarch=rs64a -qtune=rs64a -qlanglvl=ansi -qmaxmem=16384"
631         xFFLAGS="-O3 -Q -qarch=rs64a -qtune=rs64a -qmaxmem=16384 -qhot"
632         ;;
633       rs64b)
634         xCFLAGS="-O3 -qarch=rs64b -qtune=rs64b -qlanglvl=ansi -qmaxmem=16384"
635         xFFLAGS="-O3 -Q -qarch=rs64b -qtune=rs64b -qmaxmem=16384 -qhot"
636         ;;
637       rs64c)
638         xCFLAGS="-O3 -qarch=rs64c -qtune=rs64c -qlanglvl=ansi -qmaxmem=16384"
639         xFFLAGS="-O3 -Q -qarch=rs64c -qtune=rs64c -qmaxmem=16384 -qhot"
640         ;;
641       *)
642         xCFLAGS="-O3 -qlanglvl=ansi -qmaxmem=16384"
643         xFFLAGS="-O3 -Q -qmaxmem=16384 -qhot"
644         ;;
645     esac
646     ;;
647
648   mips*-irix*)
649     xCFLAGS="-O3 -OPT:IEEE_arithmetic=3 -OPT:rsqrt=ON -SWP:loop_overhead -INLINE:=ON -LNO:opt=1 -LNO:ou_further=3 -OPT:Olimit=0:roundoff=3:alias=typed -woff 1174 -D__INLINE_INTRINSICS"
650     xFFLAGS="-O3 -OPT:IEEE_arithmetic=3 -OPT:rsqrt=ON -SWP:loop_overhead -INLINE:=ON -LNO:opt=1 -LNO:ou_further=3 -OPT:Olimit=0:roundoff=3:alias=typed -OPT:cray_ivdep=TRUE"
651     
652     if $CC -version | grep "Version 7.1" > /dev/null 2>&1; then
653       xCFLAGS="$xCFLAGS -GCM:aggressive_speculation -GCM:array_speculation" 
654       xFFLAGS="$xFFLAGS -GCM:aggressive_speculation -GCM:array_speculation" 
655     fi
656
657     if $CC -version | grep "Version 7.3" > /dev/null 2>&1; then
658       xCFLAGS="$xCFLAGS -SWP:heur=fdms,nhms,fdnms" 
659       xFFLAGS="$xFFLAGS -SWP:heur=fdms,nhms,fdnms" 
660     fi
661     LDFLAGS="$LDFLAGS -woff 84"
662
663     case "${gmxcpu}" in
664       r12000*)
665         xCFLAGS="-n32 -r12000 -mips4 $xCFLAGS"
666         xFFLAGS="-n32 -r12000 -mips4 $xFFLAGS"
667         xLDFLAGS="-n32 -r12000 -mips4"
668         ;;
669       r10000*)
670         xCFLAGS="-n32 -r10000 -mips4 $xCFLAGS"
671         xFFLAGS="-n32 -r10000 -mips4 $xFFLAGS"
672         xLDFLAGS="-n32 -r10000 -mips4"
673         ;;
674       r8000*)
675         xCFLAGS="-n32 -r8000 -mips4 $xCFLAGS"
676         xFFLAGS="-n32 -r8000 -mips4 $xFFLAGS"
677         xLDFLAGS="-n32 -r8000 -mips4"
678         ;;
679       r5000*)
680         xCFLAGS="-n32 -r5000 -mips4 $xCFLAGS"
681         xFFLAGS="-n32 -r5000 -mips4 $xFFLAGS"
682         xLDFLAGS="-n32 -r5000 -mips4"
683         ;;
684       *)                
685         xCFLAGS="-n32 $xCFLAGS"
686         xFFLAGS="-n32 $xFFLAGS"
687         xLDFLAGS="-n32"
688         ;;
689     esac
690     ;;
691
692   alpha*-osf*) 
693      # NB: -arch implies -tune according to the cc manual.
694      # We dont use -ifo since it conflicts with dependency
695      # generation on old versions of the compiler.
696     case "${host_cpu}" in
697       alphaev*)
698         # extract the processor from cpu type (e.g. alphaev56 -> ev56)
699         evtype=`echo ${host_cpu} | sed 's/alpha//'`
700         xCFLAGS="-std1 -fast -O4 -no_ifo -arch $evtype -unroll 2 -fp_reorder"
701         xFFLAGS="$xCFLAGS -assume noaccuracy_sensitive"
702         xLDFLAGS="-O4"
703         ;;
704       *)
705         xCFLAGS="-std1 -fast -O4 -no_ifo -arch host -unroll 2 -fp_reorder"
706         xFFLAGS="$xCFLAGS -assume noaccuracy_sensitive"
707         xLDFLAGS="-O4"
708         ;;
709     esac
710     ;;
711
712   alpha*-linux*)
713     case "${host_cpu}" in
714       alphaev*)
715         # extract the processor from cpu type (e.g. alphaev56 -> ev56)
716         evtype=`echo ${host_cpu} | sed 's/alpha//'`
717         tmpCFLAGS="-std1 -fast -O4 -no_ifo -arch $evtype -unroll 2 -fp_reorder"
718         tmpFFLAGS="$tmpCFLAGS -assume noaccuracy_sensitive"
719         tmpLDFLAGS="-O4"
720         ;;
721       *)
722         tmpCFLAGS="-std1 -fast -O4 -no_ifo -arch host -unroll 2 -fp_reorder"
723         tmpFFLAGS="$tmpCFLAGS -assume noaccuracy_sensitive"
724         tmpLDFLAGS="-O4"
725         ;;
726     esac
727     if $CC -V 2>  /dev/null | grep Compaq > /dev/null 2>&1; then
728       xCFLAGS="$tmpCFLAGS"
729       cc_vendor="Compaq"
730     fi
731     if test "$enable_fortran" = "yes"; then
732       if $F77 -V 2>  /dev/null | grep Compaq > /dev/null 2>&1; then
733         xFFLAGS="$tmpFFLAGS"
734       fi
735     fi
736     ;;
737
738   *-*)
739     # most of these systems (e.g. linux, FreeBSD) use gcc which is treated
740     # further down, but we can at least check if the Portland compilers are used:
741     if $CC -V 2>  /dev/null | grep Portland > /dev/null 2>&1; then
742       case "${host_cpu}" in
743         i586)
744           pgiopt="-tp p5" 
745           ;;
746         i686)
747           pgiopt="-tp p6" 
748           ;;
749       esac
750       xCFLAGS="$pgiopt -fast -pc 32"
751     fi
752     if test "$enable_fortran" = "yes"; then
753       if $F77 -V 2>  /dev/null | grep Portland > /dev/null 2>&1; then
754         xFFLAGS="$xCFLAGS"
755       fi        
756     fi
757     ;;
758 esac    
759 # Phew, end of all those operating systems and processors!                      
760
761 # use default flags for gcc/g77 on all systems
762 if test $ac_cv_prog_gcc = yes; then
763   xCFLAGS="-O6 -fomit-frame-pointer -finline-functions -funroll-all-loops -Wall -Wno-unused"
764   # -malign-double for x86 systems
765   ACX_CHECK_CC_FLAGS(-malign-double,align_double,xCFLAGS="$xCFLAGS -malign-double")
766 fi
767   
768 if test $enable_fortran = yes; then
769   if test $ac_cv_prog_g77 = yes; then
770     xFFLAGS="-O3 -ffast-math -fomit-frame-pointer -finline-functions -funroll-all-loops -Wall -Wno-unused"
771     # -malign-double for f77 on x86 systems - haven't checked that this works yet.
772     #ACX_CHECK_F77_FLAGS(-malign-double,align_double,xFFLAGS="$xFFLAGS -malign-double")
773   fi
774 fi
775
776 CPU_FLAGS=""
777
778 if test "$GCC" = "yes"; then
779   ASFLAGS="$ASFLAGS -x assembler-with-cpp"
780   # try to guess correct CPU flags, at least for linux
781   case "${host_cpu}" in
782     # i586/i686 cpu flags don't improve speed, thus no need to use them.
783     # don't check f77 separately - we assume f77 and gcc are similar
784           
785     powerpc*)
786       cputype=`(grep cpu /proc/cpuinfo | head -1 | cut -d: -f2 | sed 's/ //g') 2> /dev/null`
787       is60x=`echo $cputype | egrep "^60[0-9]e?$"`
788       if test -n "$is60x"; then
789         ACX_CHECK_CC_FLAGS(-mcpu=$cputype,m_cpu_60x,CPU_FLAGS=-mcpu=$cputype)
790       elif test "$cputype" = 750; then
791         ACX_CHECK_CC_FLAGS(-mcpu=750,m_cpu_750,CPU_FLAGS=-mcpu=750)
792       fi
793       if test -z "$CPU_FLAGS"; then
794         ACX_CHECK_CC_FLAGS(-mcpu=powerpc,m_cpu_powerpc,CPU_FLAGS=-mcpu=powerpc)
795       fi
796       if test -z "$CPU_FLAGS"; then
797         ACX_CHECK_CC_FLAGS(-mpowerpc,m_powerpc,CPU_FLAGS=-mpowerpc)
798       fi
799    esac
800 else
801   AM_CONDITIONAL(GNU_CC,false)
802 fi
803
804 if test -n "$CPU_FLAGS"; then
805   xCFLAGS="$xCFLAGS $CPU_FLAGS"
806   xFFLAGS="$xFFLAGS $CPU_FLAGS"
807 fi
808
809 # Now check if the user provided anything special for C or fortran...
810 # Not nice to have checked everything then, but otherwise we would have
811 # to use entirely separate checks for C and fortran flags, doubling the code.
812 if test "$ac_test_CFLAGS" != "set"; then
813   CFLAGS="$xCFLAGS"
814   # Use the extra link optimization flags on e.g. irix only when
815   # we are using our own C compiler flags
816   LDFLAGS="$LDFLAGS $xLDFLAGS"
817   
818   if test -z "$CFLAGS"; then
819     echo "*******************************************************************"
820     echo "* WARNING: No special optimization settings found for the C       *"
821     echo "* compiler. Use  make CFLAGS=..., or edit the top level Makefile. *"
822     echo "* Reverting to the default setting CFLAGS=-O3. (mail us about it!)*"
823     echo "*******************************************************************"
824     CFLAGS="-O3"
825   fi
826   ACX_CHECK_CC_FLAGS(${CFLAGS}, guessed_cflags, , [
827     echo "*******************************************************************"
828     echo "* Sorry, these optimization settings don't seem to work for       *"
829     echo "* your C compiler. Use make CFLAGS=..., or edit the top Makefile. *"
830     echo "*******************************************************************"
831     CFLAGS=""
832   ])
833 else
834   echo "******************************************"
835   echo "* Using CFLAGS from environment variable *"
836   echo "******************************************"
837 fi
838
839 if test "$enable_fortran" = "yes"; then 
840   if test "$ac_test_FFLAGS" != "set"; then
841     FFLAGS="$xFFLAGS"
842     if test -z "$FFLAGS"; then
843       echo "*******************************************************************"
844       echo "* WARNING: No special optimization settings found for the fortran *"
845       echo "* compiler. Use  make FFLAGS=..., or edit the top level Makefile. *"
846       echo "* Reverting to the default setting FFLAGS=-O3. (mail us about it!)*"
847       echo "*******************************************************************"
848       FFLAGS="-O3"
849     fi
850     ACX_CHECK_F77_FLAGS(${FFLAGS}, guessed_fflags, , [
851       echo "*******************************************************************"
852       echo "* Sorry, these optimization settings don't seem to work for       *"
853       echo "* your f77 compiler. Use make FFLAGS=.., or edit the top Makefile.*"
854       echo "*******************************************************************"
855       FFLAGS=""
856     ])
857   else
858     echo "******************************************"
859     echo "* Using FFLAGS from environment variable *"
860     echo "******************************************"
861   fi
862 fi
863   
864 ])
865
866
867
868
869
870
871 ## libtool.m4 - Configure libtool for the host system. -*-Shell-script-*-
872 ## Copyright 1996, 1997, 1998, 1999, 2000, 2001
873 ## Free Software Foundation, Inc.
874 ## Originally by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996
875 ##
876 ## This program is free software; you can redistribute it and/or modify
877 ## it under the terms of the GNU General Public License as published by
878 ## the Free Software Foundation; either version 2 of the License, or
879 ## (at your option) any later version.
880 ##
881 ## This program is distributed in the hope that it will be useful, but
882 ## WITHOUT ANY WARRANTY; without even the implied warranty of
883 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
884 ## General Public License for more details.
885 ##
886 ## You should have received a copy of the GNU General Public License
887 ## along with this program; if not, write to the Free Software
888 ## Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
889 ##
890 ## As a special exception to the GNU General Public License, if you
891 ## distribute this file as part of a program that contains a
892 ## configuration script generated by Autoconf, you may include it under
893 ## the same distribution terms that you use for the rest of that program.
894
895 # serial 46 AC_PROG_LIBTOOL
896 AC_DEFUN([AC_PROG_LIBTOOL],
897 [AC_REQUIRE([_AC_PROG_LIBTOOL])dnl
898 dnl If AC_PROG_CXX has already been expanded, run AC_LIBTOOL_CXX
899 dnl immediately, otherwise, hook it in at the end of AC_PROG_CXX.
900   AC_PROVIDE_IFELSE([AC_PROG_CXX],
901     [AC_LIBTOOL_CXX],
902     [define([AC_PROG_CXX], defn([AC_PROG_CXX])[AC_LIBTOOL_CXX
903 ])])
904   AC_PROVIDE_IFELSE([AC_PROG_F77],
905     [AC_LIBTOOL_F77],
906     [define([AC_PROG_F77], defn([AC_PROG_F77])[AC_LIBTOOL_F77
907 ])])
908
909 dnl Quote A][M_PROG_GCJ so that aclocal doesn't bring it in needlessly.
910 dnl If either AC_PROG_GCJ or A][M_PROG_GCJ have already been expanded, run
911 dnl AC_LIBTOOL_GCJ immediately, otherwise, hook it in at the end of both.
912   AC_PROVIDE_IFELSE([AC_PROG_GCJ],
913     [AC_LIBTOOL_GCJ],
914     [AC_PROVIDE_IFELSE([A][M_PROG_GCJ],
915         [AC_LIBTOOL_GCJ],
916         [AC_PROVIDE_IFELSE([LT_AC_PROG_GCJ],
917           [AC_LIBTOOL_GCJ],
918         [ifdef([AC_PROG_GCJ],
919                [define([AC_PROG_GCJ], defn([AC_PROG_GCJ])[AC_LIBTOOL_GCJ
920 ])])
921          ifdef([A][M_PROG_GCJ],
922                [define([A][M_PROG_GCJ], defn([A][M_PROG_GCJ])[AC_LIBTOOL_GCJ
923 ])])
924          ifdef([LT_AC_PROG_GCJ],
925                [define([LT_AC_PROG_GCJ], defn([LT_AC_PROG_GCJ])[AC_LIBTOOL_GCJ
926 ])])])])])])
927
928 AC_DEFUN([_AC_PROG_LIBTOOL],
929 [AC_REQUIRE([AC_LIBTOOL_SETUP])dnl
930 AC_BEFORE([$0],[AC_LIBTOOL_CXX])dnl
931 AC_BEFORE([$0],[AC_LIBTOOL_GCJ])dnl
932
933 # Save cache, so that ltconfig can load it
934 AC_CACHE_SAVE
935
936 # Actually configure libtool.  ac_aux_dir is where install-sh is found.
937 AR="$AR" LTCC="$CC" CC="$CC" CFLAGS="$CFLAGS" CPPFLAGS="$CPPFLAGS" \
938 MAGIC_CMD="$MAGIC_CMD" LD="$LD" LDFLAGS="$LDFLAGS" LIBS="$LIBS" \
939 LN_S="$LN_S" NM="$NM" RANLIB="$RANLIB" STRIP="$STRIP" \
940 AS="$AS" DLLTOOL="$DLLTOOL" OBJDUMP="$OBJDUMP" \
941 objext="$OBJEXT" exeext="$EXEEXT" reload_flag="$reload_flag" \
942 deplibs_check_method="$deplibs_check_method" file_magic_cmd="$file_magic_cmd" \
943 ${CONFIG_SHELL-/bin/sh} $ac_aux_dir/ltconfig --no-reexec \
944 $libtool_flags --no-verify --build="$build" $ac_aux_dir/ltmain.sh $host \
945 || AC_MSG_ERROR([libtool configure failed])
946
947 # Reload cache, that may have been modified by ltconfig
948 AC_CACHE_LOAD
949
950 # This can be used to rebuild libtool when needed
951 LIBTOOL_DEPS="$ac_aux_dir/ltconfig $ac_aux_dir/ltmain.sh $ac_aux_dir/ltcf-c.sh"
952
953 # Always use our own libtool.
954 LIBTOOL='$(SHELL) $(top_builddir)/libtool'
955 AC_SUBST(LIBTOOL)dnl
956
957 # Redirect the config.log output again, so that the ltconfig log is not
958 # clobbered by the next message.
959 exec 5>>./config.log
960 ])
961
962 AC_DEFUN([AC_LIBTOOL_SETUP],
963 [AC_PREREQ(2.13)dnl
964 AC_REQUIRE([AC_ENABLE_SHARED])dnl
965 AC_REQUIRE([AC_ENABLE_STATIC])dnl
966 AC_REQUIRE([AC_ENABLE_FAST_INSTALL])dnl
967 AC_REQUIRE([AC_CANONICAL_HOST])dnl
968 AC_REQUIRE([AC_CANONICAL_BUILD])dnl
969 AC_REQUIRE([AC_PROG_CC])dnl
970 AC_REQUIRE([AC_PROG_LD])dnl
971 AC_REQUIRE([AC_PROG_LD_RELOAD_FLAG])dnl
972 AC_REQUIRE([AC_PROG_NM])dnl
973 AC_REQUIRE([AC_PROG_LN_S])dnl
974 AC_REQUIRE([AC_DEPLIBS_CHECK_METHOD])dnl
975 # Autoconf 2.13's AC_OBJEXT and AC_EXEEXT macros only works for C compilers!
976 AC_REQUIRE([AC_OBJEXT])dnl
977 AC_REQUIRE([AC_EXEEXT])dnl
978 dnl
979
980 # Only perform the check for file, if the check method requires it
981 case $deplibs_check_method in
982 file_magic*)
983   if test "$file_magic_cmd" = '$MAGIC_CMD'; then
984     AC_PATH_MAGIC
985   fi
986   ;;
987 esac
988
989 AC_CHECK_TOOL(RANLIB, ranlib, :)
990 AC_CHECK_TOOL(STRIP, strip, :)
991
992 # Check for any special flags to pass to ltconfig.
993 libtool_flags="--cache-file=$cache_file"
994 test "$enable_shared" = no && libtool_flags="$libtool_flags --disable-shared"
995 test "$enable_static" = no && libtool_flags="$libtool_flags --disable-static"
996 test "$enable_fast_install" = no && libtool_flags="$libtool_flags --disable-fast-install"
997 test "$GCC" = yes && libtool_flags="$libtool_flags --with-gcc"
998 test "$lt_cv_prog_gnu_ld" = yes && libtool_flags="$libtool_flags --with-gnu-ld"
999 ifdef([AC_PROVIDE_AC_LIBTOOL_DLOPEN],
1000 [libtool_flags="$libtool_flags --enable-dlopen"])
1001 ifdef([AC_PROVIDE_AC_LIBTOOL_WIN32_DLL],
1002 [libtool_flags="$libtool_flags --enable-win32-dll"])
1003 AC_ARG_ENABLE(libtool-lock,
1004   [  --disable-libtool-lock        avoid locking (might break parallel builds)])
1005 test "x$enable_libtool_lock" = xno && libtool_flags="$libtool_flags --disable-lock"
1006 test x"$silent" = xyes && libtool_flags="$libtool_flags --silent"
1007
1008 AC_ARG_WITH(pic,
1009   [  --with-pic                    try to use only PIC/non-PIC [default=both]],
1010      pic_mode="$withval", pic_mode=default)
1011 test x"$pic_mode" = xyes && libtool_flags="$libtool_flags --prefer-pic"
1012 test x"$pic_mode" = xno && libtool_flags="$libtool_flags --prefer-non-pic"
1013
1014 # Some flags need to be propagated to the compiler or linker for good
1015 # libtool support.
1016 case $host in
1017 *-*-irix6*)
1018   # Find out which ABI we are using.
1019   echo '[#]line __oline__ "configure"' > conftest.$ac_ext
1020   if AC_TRY_EVAL(ac_compile); then
1021     case `/usr/bin/file conftest.$ac_objext` in
1022     *32-bit*)
1023       LD="${LD-ld} -32"
1024       ;;
1025     *N32*)
1026       LD="${LD-ld} -n32"
1027       ;;
1028     *64-bit*)
1029       LD="${LD-ld} -64"
1030       ;;
1031     esac
1032   fi
1033   rm -rf conftest*
1034   ;;
1035
1036 *-*-sco3.2v5*)
1037   # On SCO OpenServer 5, we need -belf to get full-featured binaries.
1038   SAVE_CFLAGS="$CFLAGS"
1039   CFLAGS="$CFLAGS -belf"
1040   AC_CACHE_CHECK([whether the C compiler needs -belf], lt_cv_cc_needs_belf,
1041     [AC_LANG_SAVE
1042      AC_LANG_C
1043      AC_TRY_LINK([],[],[lt_cv_cc_needs_belf=yes],[lt_cv_cc_needs_belf=no])
1044      AC_LANG_RESTORE])
1045   if test x"$lt_cv_cc_needs_belf" != x"yes"; then
1046     # this is probably gcc 2.8.0, egcs 1.0 or newer; no need for -belf
1047     CFLAGS="$SAVE_CFLAGS"
1048   fi
1049   ;;
1050
1051 ifdef([AC_PROVIDE_AC_LIBTOOL_WIN32_DLL],
1052 [*-*-cygwin* | *-*-mingw* | *-*-pw32*)
1053   AC_CHECK_TOOL(DLLTOOL, dlltool, false)
1054   AC_CHECK_TOOL(AS, as, false)
1055   AC_CHECK_TOOL(OBJDUMP, objdump, false)
1056
1057   # recent cygwin and mingw systems supply a stub DllMain which the user
1058   # can override, but on older systems we have to supply one
1059   AC_CACHE_CHECK([if libtool should supply DllMain function], lt_cv_need_dllmain,
1060     [AC_TRY_LINK([],
1061       [extern int __attribute__((__stdcall__)) DllMain(void*, int, void*);
1062       DllMain (0, 0, 0);],
1063       [lt_cv_need_dllmain=no],[lt_cv_need_dllmain=yes])])
1064
1065   case $host/$CC in
1066   *-*-cygwin*/gcc*-mno-cygwin*|*-*-mingw*)
1067     # old mingw systems require "-dll" to link a DLL, while more recent ones
1068     # require "-mdll"
1069     SAVE_CFLAGS="$CFLAGS"
1070     CFLAGS="$CFLAGS -mdll"
1071     AC_CACHE_CHECK([how to link DLLs], lt_cv_cc_dll_switch,
1072       [AC_TRY_LINK([], [], [lt_cv_cc_dll_switch=-mdll],[lt_cv_cc_dll_switch=-dll])])
1073     CFLAGS="$SAVE_CFLAGS" ;;
1074   *-*-cygwin* | *-*-pw32*)
1075     # cygwin systems need to pass --dll to the linker, and not link
1076     # crt.o which will require a WinMain@16 definition.
1077     lt_cv_cc_dll_switch="-Wl,--dll -nostartfiles" ;;
1078   esac
1079   ;;
1080   ])
1081 esac
1082 ])
1083
1084 # AC_LIBTOOL_DLOPEN - enable checks for dlopen support
1085 AC_DEFUN([AC_LIBTOOL_DLOPEN], [AC_BEFORE([$0],[AC_LIBTOOL_SETUP])])
1086
1087 # AC_LIBTOOL_WIN32_DLL - declare package support for building win32 dll's
1088 AC_DEFUN([AC_LIBTOOL_WIN32_DLL], [AC_BEFORE([$0], [AC_LIBTOOL_SETUP])])
1089
1090 # AC_ENABLE_SHARED - implement the --enable-shared flag
1091 # Usage: AC_ENABLE_SHARED[(DEFAULT)]
1092 #   Where DEFAULT is either `yes' or `no'.  If omitted, it defaults to
1093 #   `yes'.
1094 AC_DEFUN([AC_ENABLE_SHARED],
1095 [define([AC_ENABLE_SHARED_DEFAULT], ifelse($1, no, no, yes))dnl
1096 AC_ARG_ENABLE(shared,
1097 changequote(<<, >>)dnl
1098 <<  --enable-shared[=PKGS]        build shared libraries [default=>>AC_ENABLE_SHARED_DEFAULT],
1099 changequote([, ])dnl
1100 [p=${PACKAGE-default}
1101 case $enableval in
1102 yes) enable_shared=yes ;;
1103 no) enable_shared=no ;;
1104 *)
1105   enable_shared=no
1106   # Look at the argument we got.  We use all the common list separators.
1107   IFS="${IFS=   }"; ac_save_ifs="$IFS"; IFS="${IFS}:,"
1108   for pkg in $enableval; do
1109     if test "X$pkg" = "X$p"; then
1110       enable_shared=yes
1111     fi
1112   done
1113   IFS="$ac_save_ifs"
1114   ;;
1115 esac],
1116 enable_shared=AC_ENABLE_SHARED_DEFAULT)dnl
1117 ])
1118
1119 # AC_DISABLE_SHARED - set the default shared flag to --disable-shared
1120 AC_DEFUN([AC_DISABLE_SHARED], [AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl
1121 AC_ENABLE_SHARED(no)])
1122
1123 # AC_ENABLE_STATIC - implement the --enable-static flag
1124 # Usage: AC_ENABLE_STATIC[(DEFAULT)]
1125 #   Where DEFAULT is either `yes' or `no'.  If omitted, it defaults to
1126 #   `yes'.
1127 AC_DEFUN([AC_ENABLE_STATIC],
1128 [define([AC_ENABLE_STATIC_DEFAULT], ifelse($1, no, no, yes))dnl
1129 AC_ARG_ENABLE(static,
1130 changequote(<<, >>)dnl
1131 <<  --enable-static[=PKGS]        build static libraries [default=>>AC_ENABLE_STATIC_DEFAULT],
1132 changequote([, ])dnl
1133 [p=${PACKAGE-default}
1134 case $enableval in
1135 yes) enable_static=yes ;;
1136 no) enable_static=no ;;
1137 *)
1138   enable_static=no
1139   # Look at the argument we got.  We use all the common list separators.
1140   IFS="${IFS=   }"; ac_save_ifs="$IFS"; IFS="${IFS}:,"
1141   for pkg in $enableval; do
1142     if test "X$pkg" = "X$p"; then
1143       enable_static=yes
1144     fi
1145   done
1146   IFS="$ac_save_ifs"
1147   ;;
1148 esac],
1149 enable_static=AC_ENABLE_STATIC_DEFAULT)dnl
1150 ])
1151
1152 # AC_DISABLE_STATIC - set the default static flag to --disable-static
1153 AC_DEFUN([AC_DISABLE_STATIC],
1154 [AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl
1155 AC_ENABLE_STATIC(no)])
1156
1157
1158 # AC_ENABLE_FAST_INSTALL - implement the --enable-fast-install flag
1159 # Usage: AC_ENABLE_FAST_INSTALL[(DEFAULT)]
1160 #   Where DEFAULT is either `yes' or `no'.  If omitted, it defaults to
1161 #   `yes'.
1162 AC_DEFUN([AC_ENABLE_FAST_INSTALL],
1163 [define([AC_ENABLE_FAST_INSTALL_DEFAULT], ifelse($1, no, no, yes))dnl
1164 AC_ARG_ENABLE(fast-install,
1165 changequote(<<, >>)dnl
1166 <<  --enable-fast-install[=PKGS]  optimize for fast installation [default=>>AC_ENABLE_FAST_INSTALL_DEFAULT],
1167 changequote([, ])dnl
1168 [p=${PACKAGE-default}
1169 case $enableval in
1170 yes) enable_fast_install=yes ;;
1171 no) enable_fast_install=no ;;
1172 *)
1173   enable_fast_install=no
1174   # Look at the argument we got.  We use all the common list separators.
1175   IFS="${IFS=   }"; ac_save_ifs="$IFS"; IFS="${IFS}:,"
1176   for pkg in $enableval; do
1177     if test "X$pkg" = "X$p"; then
1178       enable_fast_install=yes
1179     fi
1180   done
1181   IFS="$ac_save_ifs"
1182   ;;
1183 esac],
1184 enable_fast_install=AC_ENABLE_FAST_INSTALL_DEFAULT)dnl
1185 ])
1186
1187 # AC_DISABLE_FAST_INSTALL - set the default to --disable-fast-install
1188 AC_DEFUN([AC_DISABLE_FAST_INSTALL],
1189 [AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl
1190 AC_ENABLE_FAST_INSTALL(no)])
1191
1192 # AC_LIBTOOL_PICMODE - implement the --with-pic flag
1193 # Usage: AC_LIBTOOL_PICMODE[(MODE)]
1194 #   Where MODE is either `yes' or `no'.  If omitted, it defaults to
1195 #   `both'.
1196 AC_DEFUN([AC_LIBTOOL_PICMODE],
1197 [AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl
1198 pic_mode=ifelse($#,1,$1,default)])
1199
1200
1201 # AC_PATH_TOOL_PREFIX - find a file program which can recognise shared library
1202 AC_DEFUN([AC_PATH_TOOL_PREFIX],
1203 [AC_MSG_CHECKING([for $1])
1204 AC_CACHE_VAL(lt_cv_path_MAGIC_CMD,
1205 [case $MAGIC_CMD in
1206   /*)
1207   lt_cv_path_MAGIC_CMD="$MAGIC_CMD" # Let the user override the test with a path.
1208   ;;
1209   ?:/*)
1210   lt_cv_path_MAGIC_CMD="$MAGIC_CMD" # Let the user override the test with a dos path.
1211   ;;
1212   *)
1213   ac_save_MAGIC_CMD="$MAGIC_CMD"
1214   IFS="${IFS=   }"; ac_save_ifs="$IFS"; IFS=":"
1215 dnl $ac_dummy forces splitting on constant user-supplied paths.
1216 dnl POSIX.2 word splitting is done only on the output of word expansions,
1217 dnl not every word.  This closes a longstanding sh security hole.
1218   ac_dummy="ifelse([$2], , $PATH, [$2])"
1219   for ac_dir in $ac_dummy; do
1220     test -z "$ac_dir" && ac_dir=.
1221     if test -f $ac_dir/$1; then
1222       lt_cv_path_MAGIC_CMD="$ac_dir/$1"
1223       if test -n "$file_magic_test_file"; then
1224         case $deplibs_check_method in
1225         "file_magic "*)
1226           file_magic_regex="`expr \"$deplibs_check_method\" : \"file_magic \(.*\)\"`"
1227           MAGIC_CMD="$lt_cv_path_MAGIC_CMD"
1228           if eval $file_magic_cmd \$file_magic_test_file 2> /dev/null |
1229             egrep "$file_magic_regex" > /dev/null; then
1230             :
1231           else
1232             cat <<EOF 1>&2
1233
1234 *** Warning: the command libtool uses to detect shared libraries,
1235 *** $file_magic_cmd, produces output that libtool cannot recognize.
1236 *** The result is that libtool may fail to recognize shared libraries
1237 *** as such.  This will affect the creation of libtool libraries that
1238 *** depend on shared libraries, but programs linked with such libtool
1239 *** libraries will work regardless of this problem.  Nevertheless, you
1240 *** may want to report the problem to your system manager and/or to
1241 *** bug-libtool@gnu.org
1242
1243 EOF
1244           fi ;;
1245         esac
1246       fi
1247       break
1248     fi
1249   done
1250   IFS="$ac_save_ifs"
1251   MAGIC_CMD="$ac_save_MAGIC_CMD"
1252   ;;
1253 esac])
1254 MAGIC_CMD="$lt_cv_path_MAGIC_CMD"
1255 if test -n "$MAGIC_CMD"; then
1256   AC_MSG_RESULT($MAGIC_CMD)
1257 else
1258   AC_MSG_RESULT(no)
1259 fi
1260 ])
1261
1262
1263 # AC_PATH_MAGIC - find a file program which can recognise a shared library
1264 AC_DEFUN([AC_PATH_MAGIC],
1265 [AC_REQUIRE([AC_CHECK_TOOL_PREFIX])dnl
1266 AC_PATH_TOOL_PREFIX(${ac_tool_prefix}file, /usr/bin:$PATH)
1267 if test -z "$lt_cv_path_MAGIC_CMD"; then
1268   if test -n "$ac_tool_prefix"; then
1269     AC_PATH_TOOL_PREFIX(file, /usr/bin:$PATH)
1270   else
1271     MAGIC_CMD=:
1272   fi
1273 fi
1274 ])
1275
1276
1277 # AC_PROG_LD - find the path to the GNU or non-GNU linker
1278 AC_DEFUN([AC_PROG_LD],
1279 [AC_ARG_WITH(gnu-ld,
1280 [  --with-gnu-ld                 assume the C compiler uses GNU ld [default=no]],
1281 test "$withval" = no || with_gnu_ld=yes, with_gnu_ld=no)
1282 AC_REQUIRE([AC_PROG_CC])dnl
1283 AC_REQUIRE([AC_CANONICAL_HOST])dnl
1284 AC_REQUIRE([AC_CANONICAL_BUILD])dnl
1285 ac_prog=ld
1286 if test "$GCC" = yes; then
1287   # Check if gcc -print-prog-name=ld gives a path.
1288   AC_MSG_CHECKING([for ld used by GCC])
1289   case $host in
1290   *-*-mingw*)
1291     # gcc leaves a trailing carriage return which upsets mingw
1292     ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;;
1293   *)
1294     ac_prog=`($CC -print-prog-name=ld) 2>&5` ;;
1295   esac
1296   case $ac_prog in
1297     # Accept absolute paths.
1298     [[\\/]* | [A-Za-z]:[\\/]*)]
1299       re_direlt=['/[^/][^/]*/\.\./']
1300       # Canonicalize the path of ld
1301       ac_prog=`echo $ac_prog| sed 's%\\\\%/%g'`
1302       while echo $ac_prog | grep "$re_direlt" > /dev/null 2>&1; do
1303         ac_prog=`echo $ac_prog| sed "s%$re_direlt%/%"`
1304       done
1305       test -z "$LD" && LD="$ac_prog"
1306       ;;
1307   "")
1308     # If it fails, then pretend we aren't using GCC.
1309     ac_prog=ld
1310     ;;
1311   *)
1312     # If it is relative, then search for the first ld in PATH.
1313     with_gnu_ld=unknown
1314     ;;
1315   esac
1316 elif test "$with_gnu_ld" = yes; then
1317   AC_MSG_CHECKING([for GNU ld])
1318 else
1319   AC_MSG_CHECKING([for non-GNU ld])
1320 fi
1321 AC_CACHE_VAL(lt_cv_path_LD,
1322 [if test -z "$LD"; then
1323   IFS="${IFS=   }"; ac_save_ifs="$IFS"; IFS="${IFS}${PATH_SEPARATOR-:}"
1324   for ac_dir in $PATH; do
1325     test -z "$ac_dir" && ac_dir=.
1326     if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then
1327       lt_cv_path_LD="$ac_dir/$ac_prog"
1328       # Check to see if the program is GNU ld.  I'd rather use --version,
1329       # but apparently some GNU ld's only accept -v.
1330       # Break only if it was the GNU/non-GNU ld that we prefer.
1331       if "$lt_cv_path_LD" -v 2>&1 < /dev/null | egrep '(GNU|with BFD)' > /dev/null; then
1332         test "$with_gnu_ld" != no && break
1333       else
1334         test "$with_gnu_ld" != yes && break
1335       fi
1336     fi
1337   done
1338   IFS="$ac_save_ifs"
1339 else
1340   lt_cv_path_LD="$LD" # Let the user override the test with a path.
1341 fi])
1342 LD="$lt_cv_path_LD"
1343 if test -n "$LD"; then
1344   AC_MSG_RESULT($LD)
1345 else
1346   AC_MSG_RESULT(no)
1347 fi
1348 test -z "$LD" && AC_MSG_ERROR([no acceptable ld found in \$PATH])
1349 AC_PROG_LD_GNU
1350 ])
1351
1352 AC_DEFUN([AC_PROG_LD_GNU],
1353 [AC_CACHE_CHECK([if the linker ($LD) is GNU ld], lt_cv_prog_gnu_ld,
1354 [# I'd rather use --version here, but apparently some GNU ld's only accept -v.
1355 if $LD -v 2>&1 </dev/null | egrep '(GNU|with BFD)' 1>&5; then
1356   lt_cv_prog_gnu_ld=yes
1357 else
1358   lt_cv_prog_gnu_ld=no
1359 fi])
1360 with_gnu_ld=$lt_cv_prog_gnu_ld
1361 ])
1362
1363 # AC_PROG_LD_RELOAD_FLAG - find reload flag for linker
1364 #   -- PORTME Some linkers may need a different reload flag.
1365 AC_DEFUN([AC_PROG_LD_RELOAD_FLAG],
1366 [AC_CACHE_CHECK([for $LD option to reload object files], lt_cv_ld_reload_flag,
1367 [lt_cv_ld_reload_flag='-r'])
1368 reload_flag=$lt_cv_ld_reload_flag
1369 test -n "$reload_flag" && reload_flag=" $reload_flag"
1370 ])
1371
1372 # AC_DEPLIBS_CHECK_METHOD - how to check for library dependencies
1373 #  -- PORTME fill in with the dynamic library characteristics
1374 AC_DEFUN([AC_DEPLIBS_CHECK_METHOD],
1375 [AC_CACHE_CHECK([how to recognise dependant libraries],
1376 lt_cv_deplibs_check_method,
1377 [lt_cv_file_magic_cmd='$MAGIC_CMD'
1378 lt_cv_file_magic_test_file=
1379 lt_cv_deplibs_check_method='unknown'
1380 # Need to set the preceding variable on all platforms that support
1381 # interlibrary dependencies.
1382 # 'none' -- dependencies not supported.
1383 # `unknown' -- same as none, but documents that we really don't know.
1384 # 'pass_all' -- all dependencies passed with no checks.
1385 # 'test_compile' -- check by making test program.
1386 # 'file_magic [regex]' -- check by looking for files in library path
1387 # which responds to the $file_magic_cmd with a given egrep regex.
1388 # If you have `file' or equivalent on your system and you're not sure
1389 # whether `pass_all' will *always* work, you probably want this one.
1390
1391 case $host_os in
1392 aix*)
1393   lt_cv_deplibs_check_method=pass_all
1394   ;;
1395
1396 beos*)
1397   lt_cv_deplibs_check_method=pass_all
1398   ;;
1399
1400 bsdi4*)
1401   lt_cv_deplibs_check_method=['file_magic ELF [0-9][0-9]*-bit [ML]SB (shared object|dynamic lib)']
1402   lt_cv_file_magic_cmd='/usr/bin/file -L'
1403   lt_cv_file_magic_test_file=/shlib/libc.so
1404   ;;
1405
1406 cygwin* | mingw* |pw32*)
1407   lt_cv_deplibs_check_method='file_magic file format pei*-i386(.*architecture: i386)?'
1408   lt_cv_file_magic_cmd='$OBJDUMP -f'
1409   ;;
1410
1411 darwin* | rhapsody*)
1412   lt_cv_deplibs_check_method='file_magic Mach-O dynamically linked shared library'
1413   lt_cv_file_magic_cmd='/usr/bin/file -L'
1414   case "$host_os" in
1415   rhapsody* | darwin1.[012])
1416     lt_cv_file_magic_test_file='/System/Library/Frameworks/System.framework/System'
1417     ;;
1418   *) # Darwin 1.3 on
1419     lt_cv_file_magic_test_file='/usr/lib/libSystem.dylib'
1420     ;;
1421   esac
1422   ;;
1423
1424 freebsd* )
1425   if echo __ELF__ | $CC -E - | grep __ELF__ > /dev/null; then
1426     case $host_cpu in
1427     i*86 )
1428       # Not sure whether the presence of OpenBSD here was a mistake.
1429       # Let's accept both of them until this is cleared up.
1430       lt_cv_deplibs_check_method=['file_magic (FreeBSD|OpenBSD)/i[3-9]86 (compact )?demand paged shared library']
1431       lt_cv_file_magic_cmd=/usr/bin/file
1432       lt_cv_file_magic_test_file=`echo /usr/lib/libc.so.*`
1433       ;;
1434     esac
1435   else
1436     lt_cv_deplibs_check_method=pass_all
1437   fi
1438   ;;
1439
1440 gnu*)
1441   lt_cv_deplibs_check_method=pass_all
1442   ;;
1443
1444 hpux10.20*|hpux11*)
1445   lt_cv_deplibs_check_method=['file_magic (s[0-9][0-9][0-9]|PA-RISC[0-9].[0-9]) shared library']
1446   lt_cv_file_magic_cmd=/usr/bin/file
1447   lt_cv_file_magic_test_file=/usr/lib/libc.sl
1448   ;;
1449
1450 irix5* | irix6*)
1451   case $host_os in
1452   irix5*)
1453     # this will be overridden with pass_all, but let us keep it just in case
1454     lt_cv_deplibs_check_method="file_magic ELF 32-bit MSB dynamic lib MIPS - version 1"
1455     ;;
1456   *)
1457     case $LD in
1458     *-32|*"-32 ") libmagic=32-bit;;
1459     *-n32|*"-n32 ") libmagic=N32;;
1460     *-64|*"-64 ") libmagic=64-bit;;
1461     *) libmagic=never-match;;
1462     esac
1463     # this will be overridden with pass_all, but let us keep it just in case
1464     lt_cv_deplibs_check_method=["file_magic ELF ${libmagic} MSB mips-[1234] dynamic lib MIPS - version 1"]
1465     ;;
1466   esac
1467   lt_cv_file_magic_test_file=`echo /lib${libsuff}/libc.so*`
1468   lt_cv_deplibs_check_method=pass_all
1469   ;;
1470
1471 # This must be Linux ELF.
1472 linux-gnu*)
1473   case $host_cpu in
1474   alpha* | hppa* | i*86 | powerpc* | sparc* | ia64* )
1475     lt_cv_deplibs_check_method=pass_all ;;
1476   *)
1477     # glibc up to 2.1.1 does not perform some relocations on ARM
1478     lt_cv_deplibs_check_method=['file_magic ELF [0-9][0-9]*-bit [LM]SB (shared object|dynamic lib )'] ;;
1479   esac
1480   lt_cv_file_magic_test_file=`echo /lib/libc.so* /lib/libc-*.so`
1481   ;;
1482
1483 netbsd*)
1484   if echo __ELF__ | $CC -E - | grep __ELF__ > /dev/null; then
1485     [lt_cv_deplibs_check_method='match_pattern /lib[^/\.]+\.so\.[0-9]+\.[0-9]+$']
1486   else
1487     [lt_cv_deplibs_check_method='match_pattern /lib[^/\.]+\.so$']
1488   fi
1489   ;;
1490
1491 newsos6)
1492   [lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [ML]SB (executable|dynamic lib)']
1493   lt_cv_file_magic_cmd=/usr/bin/file
1494   lt_cv_file_magic_test_file=/usr/lib/libnls.so
1495   ;;
1496
1497 osf3* | osf4* | osf5*)
1498   # this will be overridden with pass_all, but let us keep it just in case
1499   lt_cv_deplibs_check_method='file_magic COFF format alpha shared library'
1500   lt_cv_file_magic_test_file=/shlib/libc.so
1501   lt_cv_deplibs_check_method=pass_all
1502   ;;
1503
1504 sco3.2v5*)
1505   lt_cv_deplibs_check_method=pass_all
1506   ;;
1507
1508 solaris*)
1509   lt_cv_deplibs_check_method=pass_all
1510   lt_cv_file_magic_test_file=/lib/libc.so
1511   ;;
1512
1513 [sysv5uw[78]* | sysv4*uw2*)]
1514   lt_cv_deplibs_check_method=pass_all
1515   ;;
1516
1517 sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*)
1518   case $host_vendor in
1519   ncr)
1520     lt_cv_deplibs_check_method=pass_all
1521     ;;
1522   motorola)
1523     lt_cv_deplibs_check_method=['file_magic ELF [0-9][0-9]*-bit [ML]SB (shared object|dynamic lib) M[0-9][0-9]* Version [0-9]']
1524     lt_cv_file_magic_test_file=`echo /usr/lib/libc.so*`
1525     ;;
1526   esac
1527   ;;
1528 esac
1529 ])
1530 file_magic_cmd=$lt_cv_file_magic_cmd
1531 deplibs_check_method=$lt_cv_deplibs_check_method
1532 ])
1533
1534
1535 # AC_PROG_NM - find the path to a BSD-compatible name lister
1536 AC_DEFUN([AC_PROG_NM],
1537 [AC_MSG_CHECKING([for BSD-compatible nm])
1538 AC_CACHE_VAL(lt_cv_path_NM,
1539 [if test -n "$NM"; then
1540   # Let the user override the test.
1541   lt_cv_path_NM="$NM"
1542 else
1543   IFS="${IFS=   }"; ac_save_ifs="$IFS"; IFS="${IFS}${PATH_SEPARATOR-:}"
1544   for ac_dir in $PATH /usr/ccs/bin /usr/ucb /bin; do
1545     test -z "$ac_dir" && ac_dir=.
1546     tmp_nm=$ac_dir/${ac_tool_prefix}nm
1547     if test -f $tmp_nm || test -f $tmp_nm$ac_exeext ; then
1548       # Check to see if the nm accepts a BSD-compat flag.
1549       # Adding the `sed 1q' prevents false positives on HP-UX, which says:
1550       #   nm: unknown option "B" ignored
1551       # Tru64's nm complains that /dev/null is an invalid object file
1552       if ($tmp_nm -B /dev/null 2>&1 | sed '1q'; exit 0) | egrep '(/dev/null|Invalid file or object type)' >/dev/null; then
1553         lt_cv_path_NM="$tmp_nm -B"
1554         break
1555       elif ($tmp_nm -p /dev/null 2>&1 | sed '1q'; exit 0) | egrep /dev/null >/dev/null; then
1556         lt_cv_path_NM="$tmp_nm -p"
1557         break
1558       else
1559         lt_cv_path_NM=${lt_cv_path_NM="$tmp_nm"} # keep the first match, but
1560         continue # so that we can try to find one that supports BSD flags
1561       fi
1562     fi
1563   done
1564   IFS="$ac_save_ifs"
1565   test -z "$lt_cv_path_NM" && lt_cv_path_NM=nm
1566 fi])
1567 NM="$lt_cv_path_NM"
1568 AC_MSG_RESULT([$NM])
1569 ])
1570
1571 # AC_CHECK_LIBM - check for math library
1572 AC_DEFUN([AC_CHECK_LIBM],
1573 [AC_REQUIRE([AC_CANONICAL_HOST])dnl
1574 LIBM=
1575 case $host in
1576 *-*-beos* | *-*-cygwin* | *-*-pw32*)
1577   # These system don't have libm
1578   ;;
1579 *-ncr-sysv4.3*)
1580   AC_CHECK_LIB(mw, _mwvalidcheckl, LIBM="-lmw")
1581   AC_CHECK_LIB(m, main, LIBM="$LIBM -lm")
1582   ;;
1583 *)
1584   AC_CHECK_LIB(m, main, LIBM="-lm")
1585   ;;
1586 esac
1587 ])
1588
1589 # AC_LIBLTDL_CONVENIENCE[(dir)] - sets LIBLTDL to the link flags for
1590 # the libltdl convenience library and INCLTDL to the include flags for
1591 # the libltdl header and adds --enable-ltdl-convenience to the
1592 # configure arguments.  Note that LIBLTDL and INCLTDL are not
1593 # AC_SUBSTed, nor is AC_CONFIG_SUBDIRS called.  If DIR is not
1594 # provided, it is assumed to be `libltdl'.  LIBLTDL will be prefixed
1595 # with '${top_builddir}/' and INCLTDL will be prefixed with
1596 # '${top_srcdir}/' (note the single quotes!).  If your package is not
1597 # flat and you're not using automake, define top_builddir and
1598 # top_srcdir appropriately in the Makefiles.
1599 AC_DEFUN([AC_LIBLTDL_CONVENIENCE],
1600 [AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl
1601   case $enable_ltdl_convenience in
1602   no) AC_MSG_ERROR([this package needs a convenience libltdl]) ;;
1603   "") enable_ltdl_convenience=yes
1604       ac_configure_args="$ac_configure_args --enable-ltdl-convenience" ;;
1605   esac
1606   LIBLTDL='${top_builddir}/'ifelse($#,1,[$1],['libltdl'])/libltdlc.la
1607   INCLTDL='-I${top_srcdir}/'ifelse($#,1,[$1],['libltdl'])
1608 ])
1609
1610 # AC_LIBLTDL_INSTALLABLE[(dir)] - sets LIBLTDL to the link flags for
1611 # the libltdl installable library and INCLTDL to the include flags for
1612 # the libltdl header and adds --enable-ltdl-install to the configure
1613 # arguments.  Note that LIBLTDL and INCLTDL are not AC_SUBSTed, nor is
1614 # AC_CONFIG_SUBDIRS called.  If DIR is not provided and an installed
1615 # libltdl is not found, it is assumed to be `libltdl'.  LIBLTDL will
1616 # be prefixed with '${top_builddir}/' and INCLTDL will be prefixed
1617 # with '${top_srcdir}/' (note the single quotes!).  If your package is
1618 # not flat and you're not using automake, define top_builddir and
1619 # top_srcdir appropriately in the Makefiles.
1620 # In the future, this macro may have to be called after AC_PROG_LIBTOOL.
1621 AC_DEFUN([AC_LIBLTDL_INSTALLABLE],
1622 [AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl
1623   AC_CHECK_LIB(ltdl, main,
1624   [test x"$enable_ltdl_install" != xyes && enable_ltdl_install=no],
1625   [if test x"$enable_ltdl_install" = xno; then
1626      AC_MSG_WARN([libltdl not installed, but installation disabled])
1627    else
1628      enable_ltdl_install=yes
1629    fi
1630   ])
1631   if test x"$enable_ltdl_install" = x"yes"; then
1632     ac_configure_args="$ac_configure_args --enable-ltdl-install"
1633     LIBLTDL='${top_builddir}/'ifelse($#,1,[$1],['libltdl'])/libltdl.la
1634     INCLTDL='-I${top_srcdir}/'ifelse($#,1,[$1],['libltdl'])
1635   else
1636     ac_configure_args="$ac_configure_args --enable-ltdl-install=no"
1637     LIBLTDL="-lltdl"
1638     INCLTDL=
1639   fi
1640 ])
1641
1642 # If this macro is not defined by Autoconf, define it here.
1643 ifdef([AC_PROVIDE_IFELSE],
1644       [],
1645       [define([AC_PROVIDE_IFELSE],
1646               [ifdef([AC_PROVIDE_$1],
1647                      [$2], [$3])])])
1648
1649 # AC_LIBTOOL_F77 - enable support for fortran libraries
1650 AC_DEFUN([AC_LIBTOOL_F77], [AC_REQUIRE([_AC_LIBTOOL_F77])])
1651
1652 AC_DEFUN([_AC_LIBTOOL_F77],
1653 [
1654 if test "$ac_cv_prog_f77_works" = "yes"; then
1655 AC_REQUIRE([AC_PROG_F77])
1656 LIBTOOL_DEPS=$LIBTOOL_DEPS" $ac_aux_dir/ltcf-f77.sh"
1657 lt_save_CC="$CC"
1658 lt_save_CFLAGS="$CFLAGS"
1659 dnl Make sure LTCC is set to the C compiler, i.e. set LTCC before CC
1660 dnl is set to the fortran compiler.
1661 AR="$AR" LTCC="$CC" CC="$F77" F77="$F77" CFLAGS="$FFLAGS" CPPFLAGS="" \
1662 MAGIC_CMD="$MAGIC_CMD" LD="$LD" LDFLAGS="$LDFLAGS" LIBS="$LIBS" \
1663 LN_S="$LN_S" NM="$NM" RANLIB="$RANLIB" STRIP="$STRIP" \
1664 AS="$AS" DLLTOOL="$DLLTOOL" OBJDUMP="$OBJDUMP" \
1665 objext="$OBJEXT" exeext="$EXEEXT" reload_flag="$reload_flag" \
1666 deplibs_check_method="$deplibs_check_method" \
1667 file_magic_cmd="$file_magic_cmd" \
1668 ${CONFIG_SHELL-/bin/sh} $ac_aux_dir/ltconfig -o libtool $libtool_flags \
1669 --build="$build" --add-tag=F77 $ac_aux_dir/ltcf-f77.sh $host \
1670 || AC_MSG_ERROR([libtool tag configuration failed])
1671 CC="$lt_save_CC"
1672 CFLAGS="$lt_save_CFLAGS"
1673
1674 # Redirect the config.log output again, so that the ltconfig log is not
1675 # clobbered by the next message.
1676 exec 5>>./config.log
1677 fi
1678 ])
1679
1680 # AC_LIBTOOL_CXX - enable support for C++ libraries
1681 AC_DEFUN([AC_LIBTOOL_CXX], [AC_REQUIRE([_AC_LIBTOOL_CXX])])
1682
1683 AC_DEFUN([_AC_LIBTOOL_CXX],
1684 [AC_REQUIRE([AC_PROG_CXX])
1685 AC_REQUIRE([AC_PROG_CXXCPP])
1686 LIBTOOL_DEPS=$LIBTOOL_DEPS" $ac_aux_dir/ltcf-cxx.sh"
1687 lt_save_CC="$CC"
1688 lt_save_CFLAGS="$CFLAGS"
1689 dnl Make sure LTCC is set to the C compiler, i.e. set LTCC before CC
1690 dnl is set to the C++ compiler.
1691 AR="$AR" LTCC="$CC" CC="$CXX" CXX="$CXX" CFLAGS="$CXXFLAGS" CPPFLAGS="$CPPFLAGS" \
1692 MAGIC_CMD="$MAGIC_CMD" LD="$LD" LDFLAGS="$LDFLAGS" LIBS="$LIBS" \
1693 LN_S="$LN_S" NM="$NM" RANLIB="$RANLIB" STRIP="$STRIP" \
1694 AS="$AS" DLLTOOL="$DLLTOOL" OBJDUMP="$OBJDUMP" \
1695 objext="$OBJEXT" exeext="$EXEEXT" reload_flag="$reload_flag" \
1696 deplibs_check_method="$deplibs_check_method" \
1697 file_magic_cmd="$file_magic_cmd" \
1698 ${CONFIG_SHELL-/bin/sh} $ac_aux_dir/ltconfig -o libtool $libtool_flags \
1699 --build="$build" --add-tag=CXX $ac_aux_dir/ltcf-cxx.sh $host \
1700 || AC_MSG_ERROR([libtool tag configuration failed])
1701 CC="$lt_save_CC"
1702 CFLAGS="$lt_save_CFLAGS"
1703
1704 # Redirect the config.log output again, so that the ltconfig log is not
1705 # clobbered by the next message.
1706 exec 5>>./config.log
1707 ])
1708
1709 # AC_LIBTOOL_GCJ - enable support for GCJ libraries
1710 AC_DEFUN([AC_LIBTOOL_GCJ],[AC_REQUIRE([_AC_LIBTOOL_GCJ])])
1711
1712 AC_DEFUN([_AC_LIBTOOL_GCJ],
1713 [AC_REQUIRE([AC_PROG_LIBTOOL])
1714 AC_PROVIDE_IFELSE([AC_PROG_GCJ],[],
1715   [AC_PROVIDE_IFELSE([A][M_PROG_GCJ],[],
1716     [AC_PROVIDE_IFELSE([LT_AC_PROG_GCJ],[],
1717       [ifdef([AC_PROG_GCJ],[AC_REQUIRE([AC_PROG_GCJ])],
1718          [ifdef([A][M_PROG_GCJ],[AC_REQUIRE([A][M_PROG_GCJ])],
1719            [AC_REQUIRE([A][C_PROG_GCJ_OR_A][M_PROG_GCJ])])])])])])
1720 LIBTOOL_DEPS=$LIBTOOL_DEPS" $ac_aux_dir/ltcf-gcj.sh"
1721 lt_save_CC="$CC"
1722 lt_save_CFLAGS="$CFLAGS"
1723 dnl Make sure LTCC is set to the C compiler, i.e. set LTCC before CC
1724 dnl is set to the C++ compiler.
1725 AR="$AR" LTCC="$CC" CC="$GCJ" CFLAGS="$GCJFLAGS" CPPFLAGS="$CPPFLAGS" \
1726 MAGIC_CMD="$MAGIC_CMD" LD="$LD" LDFLAGS="$LDFLAGS" LIBS="$LIBS" \
1727 LN_S="$LN_S" NM="$NM" RANLIB="$RANLIB" STRIP="$STRIP" \
1728 AS="$AS" DLLTOOL="$DLLTOOL" OBJDUMP="$OBJDUMP" \
1729 objext="$OBJEXT" exeext="$EXEEXT" reload_flag="$reload_flag" \
1730 deplibs_check_method="$deplibs_check_method" \
1731 file_magic_cmd="$file_magic_cmd" \
1732 ${CONFIG_SHELL-/bin/sh} $ac_aux_dir/ltconfig -o libtool $libtool_flags \
1733 --build="$build" --add-tag=GCJ $ac_aux_dir/ltcf-gcj.sh $host \
1734 || AC_MSG_ERROR([libtool tag configuration failed])
1735 CC="$lt_save_CC"
1736 CFLAGS="$lt_save_CFLAGS"
1737
1738 # Redirect the config.log output again, so that the ltconfig log is not
1739 # clobbered by the next message.
1740 exec 5>>./config.log
1741 ])
1742
1743 dnl old names
1744 AC_DEFUN([AM_PROG_LIBTOOL],   [AC_PROG_LIBTOOL])
1745 AC_DEFUN([AM_ENABLE_SHARED],  [AC_ENABLE_SHARED($@)])
1746 AC_DEFUN([AM_ENABLE_STATIC],  [AC_ENABLE_STATIC($@)])
1747 AC_DEFUN([AM_DISABLE_SHARED], [AC_DISABLE_SHARED($@)])
1748 AC_DEFUN([AM_DISABLE_STATIC], [AC_DISABLE_STATIC($@)])
1749 AC_DEFUN([AM_PROG_LD],        [AC_PROG_LD])
1750 AC_DEFUN([AM_PROG_NM],        [AC_PROG_NM])
1751
1752 dnl This is just to silence aclocal about the macro not being used
1753 ifelse([AC_DISABLE_FAST_INSTALL])dnl
1754 ifelse([AC_DISABLE_SHARED])dnl
1755
1756 AC_DEFUN([LT_AC_PROG_GCJ],
1757 [AC_CHECK_TOOL(GCJ, gcj, no)
1758   test "x${GCJFLAGS+set}" = xset || GCJFLAGS="-g -O2"
1759   AC_SUBST(GCJFLAGS)
1760 ])