1 dnl local autoconf macros
2 dnl Bruno Haible 21.9.1997
3 dnl Marcus Daniels 10.4.1997
7 dnl without AC_MSG_...: with AC_MSG_... and caching:
8 dnl AC_TRY_CPP CL_CPP_CHECK
9 dnl AC_TRY_COMPILE CL_COMPILE_CHECK
10 dnl AC_TRY_LINK CL_LINK_CHECK
11 dnl AC_TRY_RUN CL_RUN_CHECK - would require cross-compiling support
13 dnl AC_TRY_CPP(INCLUDES,
14 dnl ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND])
15 dnl CL_CPP_CHECK(ECHO-TEXT, CACHE-ID,
17 dnl ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND])
18 dnl AC_TRY_xxx(INCLUDES, FUNCTION-BODY,
19 dnl ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND])
20 dnl CL_xxx_CHECK(ECHO-TEXT, CACHE-ID,
21 dnl INCLUDES, FUNCTION-BODY,
22 dnl ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND])
25 [AC_MSG_CHECKING(for $1)
27 AC_TRY_CPP([$3], $2=yes, $2=no)
30 if test [$]$2 = yes; then
31 ifelse([$4], , :, [$4])
32 ifelse([$5], , , [else
38 define(CL_COMPILE_CHECK,
39 [AC_MSG_CHECKING(for $1)
41 AC_TRY_COMPILE([$3],[$4], $2=yes, $2=no)
44 if test [$]$2 = yes; then
45 ifelse([$5], , :, [$5])
46 ifelse([$6], , , [else
53 [AC_MSG_CHECKING(for $1)
55 AC_TRY_LINK([$3],[$4], $2=yes, $2=no)
58 if test [$]$2 = yes; then
59 ifelse([$5], , :, [$5])
60 ifelse([$6], , , [else
66 dnl CL_PROTO(IDENTIFIER, ACTION-IF-NOT-FOUND, FINAL-PROTOTYPE)
68 [AC_MSG_CHECKING([for $1 declaration])
69 AC_CACHE_VAL(cl_cv_proto_[$1], [$2
71 cl_cv_proto_$1=`echo "[$]cl_cv_proto_$1" | tr -s ' ' | sed -e 's/( /(/'`
72 AC_MSG_RESULTPROTO([$]cl_cv_proto_$1)
75 dnl CL_PROTO_RET(INCLUDES, DECL, CACHE-ID, TYPE-IF-OK, TYPE-IF-FAILS)
79 ], [], $3="$4", $3="$5")
82 dnl CL_PROTO_TRY(INCLUDES, ANSI-DECL, TRAD-DECL, ACTION-IF-OK, ACTION-IF-FAILS)
86 [#if defined(__STDC__) || defined(__cplusplus)
94 dnl CL_PROTO_CONST(INCLUDES, ANSI-DECL, TRAD-DECL, CACHE-ID)
95 define(CL_PROTO_CONST,
96 [CL_PROTO_TRY([$1], [$2], [$3], $4="", $4="const")]
100 dnl performs ACTION, with AC_MSG_CHECKING and AC_MSG_RESULT being defined away.
102 [pushdef([AC_MSG_CHECKING],[:])dnl
103 pushdef([AC_CHECKING],[:])dnl
104 pushdef([AC_MSG_RESULT],[:])dnl
105 pushdef([AC_MSG_RESULTPROTO],[:])dnl
107 popdef([AC_MSG_RESULTPROTO])dnl
108 popdef([AC_MSG_RESULT])dnl
109 popdef([AC_CHECKING])dnl
110 popdef([AC_MSG_CHECKING])dnl
113 AC_DEFUN(CL_AS_UNDERSCORE,
114 [AC_BEFORE([$0], [CL_GLOBAL_CONSTRUCTORS])
115 AC_CACHE_CHECK(for underscore in external names, cl_cv_prog_as_underscore, [
116 cat > conftest.c <<EOF
117 int foo() { return 0; }
119 # look for the assembly language name in the .s file
120 AC_TRY_COMMAND(${CC-cc} -S conftest.c) >/dev/null 2>&1
121 if grep _foo conftest.s >/dev/null ; then
122 cl_cv_prog_as_underscore=yes
124 cl_cv_prog_as_underscore=no
128 if test $cl_cv_prog_as_underscore = yes; then
130 AC_DEFINE(ASM_UNDERSCORE)
134 AC_SUBST(AS_UNDERSCORE)dnl
137 AC_DEFUN(CL_PROG_RANLIB, [AC_CHECK_PROG(RANLIB, ranlib, ranlib, true)])dnl
139 AC_DEFUN(CL_PROG_INSTALL,
140 [dnl This is mostly copied from AC_PROG_INSTALL.
141 # Find a good install program. We prefer a C program (faster),
142 # so one script is as good as another. But avoid the broken or
143 # incompatible versions:
144 # SysV /etc/install, /usr/sbin/install
145 # SunOS /usr/etc/install
148 # AFS /usr/afsws/bin/install, which mishandles nonexistent args
149 # SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff"
150 # ./install, which can be erroneously created by make from ./install.sh.
151 AC_MSG_CHECKING(for a BSD compatible install)
152 if test -z "$INSTALL"; then
153 AC_CACHE_VAL(cl_cv_path_install,
154 [ IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:"
155 for ac_dir in $PATH; do
156 # Account for people who put trailing slashes in PATH elements.
158 /|./|.//|/etc/*|/usr/sbin/*|/usr/etc/*|/sbin/*|/usr/afsws/bin/*|/usr/ucb/*) ;;
160 # OSF1 and SCO ODT 3.0 have their own names for install.
161 for ac_prog in ginstall installbsd scoinst install; do
162 if test -f $ac_dir/$ac_prog; then
163 if test $ac_prog = install &&
164 grep dspmsg $ac_dir/$ac_prog >/dev/null 2>&1; then
165 # AIX install. It has an incompatible calling convention.
166 # OSF/1 installbsd also uses dspmsg, but is usable.
169 if test $ac_prog = installbsd &&
170 grep src/bos $ac_dir/$ac_prog >/dev/null 2>&1; then
171 # AIX installbsd doesn't work without option "-g".
174 cl_cv_path_install="$ac_dir/$ac_prog -c"
184 # As a last resort, use cp.
185 test -z "$cl_cv_path_install" && cl_cv_path_install="cp"
187 INSTALL="$cl_cv_path_install"
189 dnl We do special magic for INSTALL instead of AC_SUBST, to get
190 dnl relative paths right.
191 AC_MSG_RESULT($INSTALL)
193 # Use test -z because SunOS4 sh mishandles braces in ${var-val}.
194 # It thinks the first close brace ends the variable substitution.
195 test -z "$INSTALL_PROGRAM" && INSTALL_PROGRAM='$(INSTALL)'
196 AC_SUBST(INSTALL_PROGRAM)dnl
197 if test -z "$INSTALL_DATA"; then
199 cp | */cp ) INSTALL_DATA='$(INSTALL)' ;;
200 * ) INSTALL_DATA='$(INSTALL) -m 644' ;;
203 AC_SUBST(INSTALL_DATA)dnl
206 AC_DEFUN(CL_CANONICAL_HOST,
207 [AC_REQUIRE([AC_PROG_CC]) dnl Actually: AC_REQUIRE([CL_CC_WORKS])
208 dnl Set ac_aux_dir before the cache check, because AM_PROG_LIBTOOL needs it.
209 ac_aux_dir=${srcdir}/$1
210 AC_CACHE_CHECK(host system type, cl_cv_host, [
211 dnl A substitute for AC_CONFIG_AUX_DIR_DEFAULT, so we don't need install.sh.
212 ac_config_guess=$ac_aux_dir/config.guess
213 ac_config_sub=$ac_aux_dir/config.sub
214 dnl Mostly copied from AC_CANONICAL_HOST.
215 # Make sure we can run config.sub.
216 if $ac_config_sub sun4 >/dev/null 2>&1; then :
217 else AC_MSG_ERROR(can not run $ac_config_sub)
220 case "$host_alias" in
223 NONE) dnl config.guess needs to compile things
224 host_alias=`export CC; $ac_config_guess` ;;
225 *) host_alias=$nonopt ;;
228 # Don't fail just because the system is not listed in GNU's database.
229 if test -n "$host_alias"; then
230 host=`$ac_config_sub $host_alias`
232 host=unknown-unknown-unknown
238 host_cpu=`echo $host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'`
239 host_vendor=`echo $host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'`
240 host_os=`echo $host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'`
243 AC_SUBST(host_cpu)dnl
244 AC_SUBST(host_vendor)dnl
248 AC_DEFUN(CL_CANONICAL_HOST_CPU,
249 [AC_REQUIRE([CL_CANONICAL_HOST])AC_REQUIRE([AC_PROG_CC])
255 alphaev[4-7] | alphaev56 | alphapca5[67] )
258 hppa1.0 | hppa1.1 | hppa2.0 )
264 c1 | c2 | c32 | c34 | c38 | c4 )
269 AC_CACHE_CHECK([for 64-bit MIPS], cl_cv_host_mips64, [
271 [#if defined(_MIPS_SZLONG)
272 #if (_MIPS_SZLONG == 64)
273 /* We should also check for (_MIPS_SZPTR == 64), but gcc keeps this at 32. */
277 ], cl_cv_host_mips64=yes, cl_cv_host_mips64=no)
279 if test $cl_cv_host_mips64 = yes; then
283 dnl UltraSPARCs running Linux have `uname -m` = "sparc64", but the C compiler
284 dnl still generates 32-bit code.
286 AC_CACHE_CHECK([for 64-bit SPARC], cl_cv_host_sparc64, [
288 [#if defined(__sparcv9) || defined(__arch64__)
291 ], cl_cv_host_sparc64=yes, cl_cv_host_sparc64=no)
293 if test $cl_cv_host_sparc64 = yes; then
300 dnl was AC_DEFINE_UNQUOTED(__${host_cpu}__) but KAI C++ 3.2d doesn't like this
301 cat >> confdefs.h <<EOF
302 #ifndef __${host_cpu}__
303 #define __${host_cpu}__ 1
308 AC_DEFUN(CL_LONGLONG,
309 [AC_CACHE_CHECK(for long long type, cl_cv_c_longlong, [
310 AC_TRY_RUN([int main()
312 /* long longs don't work right with gcc-2.7.2 on m68k */
313 /* long longs don't work right with gcc-2.7.2 on rs6000: avcall/tests.c gets
316 #if defined(__m68k__) || (defined(_IBMR2) || defined(__powerpc))
318 #if (__GNUC_MINOR__ <= 7)
324 { long x = 944938507; long y = 737962842; long z = 162359677;
325 exit(!(((long long) x)*((long long) y)>>32 == z));
328 cl_cv_c_longlong=yes, cl_cv_c_longlong=no,
329 dnl When cross-compiling, don't assume anything.
330 cl_cv_c_longlong="guessing no")
332 case "$cl_cv_c_longlong" in
333 *yes) AC_DEFINE(HAVE_LONGLONG) ;;
338 AC_DEFUN(CL_LONGDOUBLE,
339 [AC_CACHE_CHECK(for long double type, cl_cv_c_longdouble, [
340 AC_TRY_RUN([int main()
341 { long double x = 2.7182818284590452354L; x = x*x; exit (x==0.0L); }],
342 cl_cv_c_longdouble=yes, cl_cv_c_longdouble=no,
343 dnl When cross-compiling, don't assume anything.
344 cl_cv_c_longdouble="guessing no")
346 case "$cl_cv_c_longdouble" in
347 *yes) AC_DEFINE(HAVE_LONGDOUBLE) ;;
352 AC_DEFUN(CL_TEMPLATE_NULL,
353 [CL_COMPILE_CHECK([working template<>], cl_cv_c_templatenull,
354 [template <class T> class c {}; template <> class c<int> { int x; };], ,
355 AC_DEFINE(HAVE_TEMPLATE_NULL))
358 AC_DEFUN(CL_UNISTD_H,
359 [AC_CHECK_HEADERS(unistd.h)]
363 [# The Ultrix 4.2 mips builtin alloca declared by alloca.h only works
364 # for constant arguments. Useless!
365 CL_LINK_CHECK(working alloca.h, cl_cv_header_alloca_h,
366 [#include <alloca.h>], [char *p = (char *) alloca(2 * sizeof(int));],
367 AC_DEFINE(HAVE_ALLOCA_H))dnl
368 decl="#ifdef __GNUC__
369 #define alloca __builtin_alloca
373 #define alloca _alloca
389 CL_LINK_CHECK([alloca], cl_cv_func_alloca,
390 $decl, [char *p = (char *) alloca(1);],
391 , [alloca_missing=1])dnl
392 if test -n "$alloca_missing"; then
393 # The SVR3 libPW and SVR4 libucb both contain incompatible functions
394 # that cause trouble. Some versions do not even contain alloca or
395 # contain a buggy version. If you still want to use their alloca,
396 # use ar to extract alloca.o from them instead of compiling alloca.c.
397 ALLOCA=alloca.${ac_objext}
403 AC_DEFUN(CL_FPU_CONTROL,
404 [dnl Check for Linux with <fpu_control.h> and fpu_control_t or __setfpucw().
405 dnl glibc versions since October 1998 define fpu_control_t. Earlier versions
406 dnl define and declare __setfpucw(). Very early Linux libc versions have none,
407 dnl and __fpu_control is of type `unsigned short'.
408 CL_COMPILE_CHECK([fpu_control_t], cl_cv_type_fpu_control_t,
409 [#include <fpu_control.h>], [fpu_control_t x;],
410 AC_DEFINE(HAVE_FPU_CONTROL_T))
411 CL_COMPILE_CHECK([__setfpucw], cl_cv_func_setfpucw,
412 [#include <fpu_control.h>], [__setfpucw(_FPU_IEEE);],
413 AC_DEFINE(HAVE_SETFPUCW))
417 [AC_MSG_CHECKING(for perror declaration)
418 AC_CACHE_VAL(cl_cv_proto_perror, [
420 /* Some systems declare perror() in <errno.h>, some in <stdio.h>, some don't
421 declare it at all. */
424 ]AC_LANG_EXTERN[double perror ();], [],
425 cl_cv_proto_perror=no, cl_cv_proto_perror=yes)
427 AC_MSG_RESULT([$cl_cv_proto_perror])
428 if test $cl_cv_proto_perror = yes; then
429 AC_DEFINE(HAVE_PERROR_DECL)
434 [AC_CHECK_HEADERS(sys/resource.h sys/times.h)dnl
435 if test $ac_cv_header_sys_resource_h = yes; then
436 dnl HAVE_SYS_RESOURCE_H defined
437 CL_LINK_CHECK([getrusage], cl_cv_func_getrusage,
438 [#include <sys/types.h> /* NetBSD 1.0 needs this */
439 #include <sys/time.h>
440 #include <sys/resource.h>],
441 [struct rusage x; int y = RUSAGE_SELF; getrusage(y,&x); x.ru_utime.tv_sec;],
442 AC_DEFINE(HAVE_GETRUSAGE))dnl
443 if test $cl_cv_func_getrusage = yes; then
444 CL_PROTO([getrusage], [
450 #include <sys/types.h> /* NetBSD 1.0 needs this */
451 #include <sys/time.h>
452 #include <sys/resource.h>
454 [int getrusage (int who, struct rusage * rusage);],
456 [cl_cv_proto_getrusage_arg1="int"],
457 [cl_cv_proto_getrusage_arg1="enum __rusage_who"])
458 ], [extern int getrusage ($cl_cv_proto_getrusage_arg1, struct rusage *);])
459 AC_DEFINE_UNQUOTED(RUSAGE_WHO_T,$cl_cv_proto_getrusage_arg1)
464 AC_DEFUN(CL_GETTIMEOFDAY,
465 [AC_BEFORE([$0], [CL_TIMES_CLOCK])
466 AC_CHECK_FUNCS(gettimeofday)dnl
467 if test $ac_cv_func_gettimeofday = yes; then
468 dnl HAVE_GETTIMEOFDAY is defined
469 CL_PROTO([gettimeofday], [
471 #include <sys/types.h>
472 #include <sys/time.h>
473 ], [int gettimeofday (struct timeval * tp, struct timezone * tzp);],
474 [int gettimeofday();],
475 cl_cv_proto_gettimeofday_dots=no
476 cl_cv_proto_gettimeofday_arg2="struct timezone *",
478 #include <sys/types.h>
479 #include <sys/time.h>
480 ], [int gettimeofday (struct timeval * tp, void * tzp);],
481 [int gettimeofday();],
482 cl_cv_proto_gettimeofday_dots=no
483 cl_cv_proto_gettimeofday_arg2="void *",
484 cl_cv_proto_gettimeofday_dots=yes
485 cl_cv_proto_gettimeofday_arg2="..."))
486 ], [extern int gettimeofday (struct timeval *, $cl_cv_proto_gettimeofday_arg2);])
487 if test $cl_cv_proto_gettimeofday_dots = yes; then
488 AC_DEFINE(GETTIMEOFDAY_DOTS)
490 AC_DEFINE_UNQUOTED(GETTIMEOFDAY_TZP_T,$cl_cv_proto_gettimeofday_arg2)
496 [AC_BEFORE([$0], [CL_TIMES_CLOCK])
497 AC_CHECK_FUNCS(ftime)])dnl
499 AC_DEFUN(CL_TIMES_CLOCK,
500 [AC_REQUIRE([CL_GETTIMEOFDAY])dnl
501 AC_REQUIRE([CL_FTIME])dnl
502 if test $ac_cv_func_gettimeofday = no -a $ac_cv_func_ftime = no; then
503 AC_CHECK_FUNC(times, , no_times=1)dnl
504 if test -z "$no_times"; then
505 AC_CACHE_CHECK(for times return value, cl_cv_func_times_return, [
507 #include <sys/types.h>
508 #include <time.h> /* needed for CLK_TCK */
510 #include <sys/time.h> /* needed for CLK_TCK on SYSV PTX */
512 #include <sys/times.h>
518 result1 = times(&buffer);
519 if ((result1 == (clock_t)0) || (result1 == (clock_t)(-1))) exit(1);
521 result2 = times(&buffer);
522 if ((result2 == (clock_t)0) || (result2 == (clock_t)(-1))) exit(1);
523 ticks = result2 - result1;
524 exit(!((ticks >= CLK_TCK/2) && (ticks <= 3*CLK_TCK/2)));
525 }], cl_cv_func_times_return=yes, cl_cv_func_times_return=no,
526 dnl When cross-compiling, don't assume anything.
527 cl_cv_func_times_return="guessing no")
529 case "$cl_cv_func_times_return" in
530 *yes) AC_DEFINE(HAVE_TIMES_CLOCK) ;;
537 AC_DEFUN(CL_GLOBAL_CONSTRUCTORS,
538 [AC_REQUIRE([CL_AS_UNDERSCORE])dnl
539 if test -n "$GCC"; then
540 AC_CACHE_CHECK(for the global constructors function prefix,
541 cl_cv_cplusplus_ctorprefix, [
542 cat > conftest.cc << EOF
543 struct foo { foo (); };
546 # look for the assembly language name in the .s file
547 AC_TRY_COMMAND(${CXX-g++} $CXXFLAGS -S conftest.cc) >/dev/null 2>&1
548 if grep '_GLOBAL_\$I\$foobar' conftest.s >/dev/null ; then
549 cl_cv_cplusplus_ctorprefix='_GLOBAL_$I$'
551 if grep '_GLOBAL_\.I\.foobar' conftest.s >/dev/null ; then
552 cl_cv_cplusplus_ctorprefix='_GLOBAL_.I.'
554 if grep '_GLOBAL__I_foobar' conftest.s >/dev/null ; then
555 cl_cv_cplusplus_ctorprefix='_GLOBAL__I_'
557 cl_cv_cplusplus_ctorprefix=unknown
563 if test "$cl_cv_cplusplus_ctorprefix" '!=' unknown; then
564 ac_value='"'"$cl_cv_cplusplus_ctorprefix"'"'
565 AC_DEFINE_UNQUOTED(CL_GLOBAL_CONSTRUCTOR_PREFIX,$ac_value)
566 ac_value=`echo "$ac_value" | sed -e 's,I,D,'`
567 AC_DEFINE_UNQUOTED(CL_GLOBAL_DESTRUCTOR_PREFIX,$ac_value)
568 dnl Check whether the global constructors/destructors functions are file-scope
569 dnl only by default. This is the case in egcs-1.1.2 or newer.
570 AC_CACHE_CHECK(whether the global constructors function need to be exported,
571 cl_cv_cplusplus_ctorexport, [
572 cat > conftest1.cc << EOF
573 struct foo { foo (); };
576 cat > conftest2.cc << EOF
577 #include "confdefs.h"
578 #ifdef ASM_UNDERSCORE
579 #define ASM_UNDERSCORE_PREFIX "_"
581 #define ASM_UNDERSCORE_PREFIX ""
583 struct foo { foo (); };
585 extern "C" void ctor (void) __asm__ (ASM_UNDERSCORE_PREFIX CL_GLOBAL_CONSTRUCTOR_PREFIX "foobar");
586 int main() { ctor(); return 0; }
588 if AC_TRY_COMMAND(${CXX-g++} -o conftest${ac_exeext} $CXXFLAGS $CPPFLAGS $LDFLAGS conftest1.cc conftest2.cc $LIBS 1>&5) >/dev/null 2>&1 && test -s conftest${ac_exeext}; then
589 cl_cv_cplusplus_ctorexport=no
591 cl_cv_cplusplus_ctorexport=yes
595 if test "$cl_cv_cplusplus_ctorexport" = yes; then
596 AC_DEFINE(CL_NEED_GLOBALIZE_CTORDTOR)
602 AC_DEFUN(CL_CHAR_UNSIGNED,
603 [dnl This is mostly copied from AC_C_CHAR_UNSIGNED.
604 AC_CACHE_CHECK(whether characters are unsigned, ac_cv_c_char_unsigned, [
605 if test $ac_cv_prog_gcc = yes; then
606 # GCC predefines this symbol on systems where it applies.
608 [#ifdef __CHAR_UNSIGNED__
611 ], ac_cv_c_char_unsigned=yes, ac_cv_c_char_unsigned=no)
614 [/* volatile prevents gcc2 from optimizing the test away on sparcs. */
615 #if !defined(__STDC__) || __STDC__ != 1
619 volatile char c = 255; exit(c < 0);
620 }], ac_cv_c_char_unsigned=yes, ac_cv_c_char_unsigned=no,
621 ac_cv_c_char_unsigned="guessing no")
623 if test $ac_cv_prog_gcc = no; then
624 # GCC defines __CHAR_UNSIGNED__ by itself, no need to fix up.
625 case "$ac_cv_c_char_unsigned" in
626 *yes) AC_DEFINE(__CHAR_UNSIGNED__) ;;
635 CL_COMPILE_CHECK([bool type], cl_cv_cplusplus_bool, , [bool x;],
636 AC_DEFINE(HAVE_BOOL), AC_DEFINE(bool,int))dnl
641 [AC_REQUIRE([AC_PROG_CC])dnl
642 AC_REQUIRE([CL_CHAR_UNSIGNED])dnl
645 if test $cross_compiling = no; then
646 if test -z "$[$4]"; then
647 AC_CHECKING(for [$1])
648 cat > conftest.$ac_ext <<EOF
649 #include "confdefs.h"
651 cat "$cl_machine_file_c" >> conftest.$ac_ext
653 if test $ac_cv_prog_gcc = yes; then
654 # gcc -O (gcc version <= 2.3.2) crashes when compiling long long shifts for
655 # target 80386. Strip "-O".
656 CC=`echo "$CC " | sed -e 's/-O //g'`
660 if test -s conftest; then
661 echo "creating $cl_machine_file_h"
662 ./conftest > conftest.h
663 if cmp -s "$cl_machine_file_h" conftest.h 2>/dev/null; then
664 # The file exists and we would not be changing it
667 rm -f "$cl_machine_file_h"
668 mv conftest.h "$cl_machine_file_h"
672 echo "creation of $cl_machine_file_h failed"
677 echo "cross-compiling - cannot create $cl_machine_file_h"
681 ## libtool.m4 - Configure libtool for the target system. -*-Shell-script-*-
682 ## Copyright (C) 1996-1998 Free Software Foundation, Inc.
683 ## Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996
685 ## This program is free software; you can redistribute it and/or modify
686 ## it under the terms of the GNU General Public License as published by
687 ## the Free Software Foundation; either version 2 of the License, or
688 ## (at your option) any later version.
690 ## This program is distributed in the hope that it will be useful, but
691 ## WITHOUT ANY WARRANTY; without even the implied warranty of
692 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
693 ## General Public License for more details.
695 ## You should have received a copy of the GNU General Public License
696 ## along with this program; if not, write to the Free Software
697 ## Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
699 ## As a special exception to the GNU General Public License, if you
700 ## distribute this file as part of a program that contains a
701 ## configuration script generated by Autoconf, you may include it under
702 ## the same distribution terms that you use for the rest of that program.
704 # serial 24 AM_PROG_LIBTOOL
705 AC_DEFUN(AM_PROG_LIBTOOL,
706 [AC_REQUIRE([AM_ENABLE_SHARED])dnl
707 AC_REQUIRE([AM_ENABLE_STATIC])dnl
708 AC_REQUIRE([CL_CANONICAL_HOST])dnl
709 AC_REQUIRE([CL_PROG_RANLIB])dnl
710 AC_REQUIRE([AC_PROG_CC])dnl
711 AC_REQUIRE([AM_PROG_LD])dnl
712 AC_REQUIRE([AM_PROG_NM])dnl
713 AC_REQUIRE([AC_PROG_LN_S])dnl
715 # Always use our own libtool.
716 LIBTOOL='$(SHELL) $(top_builddir)/libtool'
719 # Check for any special flags to pass to ltconfig.
721 test "$enable_shared" = no && libtool_flags="$libtool_flags --disable-shared"
722 test "$enable_static" = no && libtool_flags="$libtool_flags --disable-static"
723 test "$silent" = yes && libtool_flags="$libtool_flags --silent"
724 test "$ac_cv_prog_gcc" = yes && libtool_flags="$libtool_flags --with-gcc"
725 test "$ac_cv_prog_gnu_ld" = yes && libtool_flags="$libtool_flags --with-gnu-ld"
727 # Some flags need to be propagated to the compiler or linker for good
731 # Find out which ABI we are using.
732 echo '[#]line __oline__ "configure"' > conftest.$ac_ext
733 if AC_TRY_EVAL(ac_compile); then
734 case "`/usr/bin/file conftest.o`" in
750 # On SCO OpenServer 5, we need -belf to get full-featured binaries.
751 CFLAGS="$CFLAGS -belf"
755 # Actually configure libtool. ac_aux_dir is where install-sh is found.
756 CC="$CC" CFLAGS="$CFLAGS" CPPFLAGS="$CPPFLAGS" \
757 LD="$LD" NM="$NM" RANLIB="$RANLIB" LN_S="$LN_S" \
758 ${CONFIG_SHELL-/bin/sh} $ac_aux_dir/ltconfig \
759 $libtool_flags --no-verify $ac_aux_dir/ltmain.sh $host \
760 || AC_MSG_ERROR([libtool configure failed])
763 # AM_ENABLE_SHARED - implement the --enable-shared flag
764 # Usage: AM_ENABLE_SHARED[(DEFAULT)]
765 # Where DEFAULT is either `yes' or `no'. If omitted, it defaults to
767 AC_DEFUN(AM_ENABLE_SHARED,
768 [define([AM_ENABLE_SHARED_DEFAULT], ifelse($1, no, no, yes))dnl
769 AC_ARG_ENABLE(shared,
770 changequote(<<, >>)dnl
771 << --enable-shared build shared libraries [default=>>AM_ENABLE_SHARED_DEFAULT]
773 [ --enable-shared=PKGS only build shared libraries if the current package
774 appears as an element in the PKGS list],
775 [p=${PACKAGE-default}
777 yes) enable_shared=yes ;;
778 no) enable_shared=no ;;
781 # Look at the argument we got. We use all the common list separators.
782 IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:,"
783 for pkg in $enableval; do
784 if test "X$pkg" = "X$p"; then
791 enable_shared=AM_ENABLE_SHARED_DEFAULT)dnl
794 # AM_DISABLE_SHARED - set the default shared flag to --disable-shared
795 AC_DEFUN(AM_DISABLE_SHARED,
796 [AM_ENABLE_SHARED(no)])
798 # AM_DISABLE_STATIC - set the default static flag to --disable-static
799 AC_DEFUN(AM_DISABLE_STATIC,
800 [AM_ENABLE_STATIC(no)])
802 # AM_ENABLE_STATIC - implement the --enable-static flag
803 # Usage: AM_ENABLE_STATIC[(DEFAULT)]
804 # Where DEFAULT is either `yes' or `no'. If omitted, it defaults to
806 AC_DEFUN(AM_ENABLE_STATIC,
807 [define([AM_ENABLE_STATIC_DEFAULT], ifelse($1, no, no, yes))dnl
808 AC_ARG_ENABLE(static,
809 changequote(<<, >>)dnl
810 << --enable-static build static libraries [default=>>AM_ENABLE_STATIC_DEFAULT]
812 [ --enable-static=PKGS only build shared libraries if the current package
813 appears as an element in the PKGS list],
814 [p=${PACKAGE-default}
816 yes) enable_static=yes ;;
817 no) enable_static=no ;;
820 # Look at the argument we got. We use all the common list separators.
821 IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:,"
822 for pkg in $enableval; do
823 if test "X$pkg" = "X$p"; then
830 enable_static=AM_ENABLE_STATIC_DEFAULT)dnl
834 # AM_PROG_LD - find the path to the GNU or non-GNU linker
837 [ --with-gnu-ld assume the C compiler uses GNU ld [default=no]],
838 test "$withval" = no || with_gnu_ld=yes, with_gnu_ld=no)
839 AC_REQUIRE([AC_PROG_CC])
841 if test "$ac_cv_prog_gcc" = yes; then
842 # Check if gcc -print-prog-name=ld gives a path.
843 AC_MSG_CHECKING([for ld used by GCC])
844 ac_prog=`($CC -print-prog-name=ld) 2>&5`
846 # Accept absolute paths.
848 test -z "$LD" && LD="$ac_prog"
851 # If it fails, then pretend we aren't using GCC.
855 # If it is relative, then search for the first ld in PATH.
859 elif test "$with_gnu_ld" = yes; then
860 AC_MSG_CHECKING([for GNU ld])
862 AC_MSG_CHECKING([for non-GNU ld])
864 AC_CACHE_VAL(ac_cv_path_LD,
865 [if test -z "$LD"; then
866 IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:"
867 for ac_dir in $PATH; do
868 test -z "$ac_dir" && ac_dir=.
869 if test -f "$ac_dir/$ac_prog"; then
870 ac_cv_path_LD="$ac_dir/$ac_prog"
871 # Check to see if the program is GNU ld. I'd rather use --version,
872 # but apparently some GNU ld's only accept -v.
873 # Break only if it was the GNU/non-GNU ld that we prefer.
874 if "$ac_cv_path_LD" -v 2>&1 < /dev/null | egrep '(GNU|with BFD)' > /dev/null; then
875 test "$with_gnu_ld" != no && break
877 test "$with_gnu_ld" != yes && break
883 ac_cv_path_LD="$LD" # Let the user override the test with a path.
886 if test -n "$LD"; then
891 test -z "$LD" && AC_MSG_ERROR([no acceptable ld found in \$PATH])
896 AC_DEFUN(AM_PROG_LD_GNU,
897 [AC_CACHE_CHECK([if the linker ($LD) is GNU ld], ac_cv_prog_gnu_ld,
898 [# I'd rather use --version here, but apparently some GNU ld's only accept -v.
899 if $LD -v 2>&1 </dev/null | egrep '(GNU|with BFD)' 1>&5; then
900 ac_cv_prog_gnu_ld=yes
906 # AM_PROG_NM - find the path to a BSD-compatible name lister
908 [AC_MSG_CHECKING([for BSD-compatible nm])
909 AC_CACHE_VAL(ac_cv_path_NM,
912 ac_cv_path_NM="$NM" # Let the user override the test with a path.
915 IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:"
916 for ac_dir in /usr/ucb /usr/ccs/bin $PATH /bin; do
917 test -z "$ac_dir" && ac_dir=.
918 if test -f $ac_dir/nm; then
919 # Check to see if the nm accepts a BSD-compat flag.
920 # Adding the `sed 1q' prevents false positives on HP-UX, which says:
921 # nm: unknown option "B" ignored
922 if ($ac_dir/nm -B /dev/null 2>&1 | sed '1q'; exit 0) | egrep /dev/null >/dev/null; then
923 ac_cv_path_NM="$ac_dir/nm -B"
924 elif ($ac_dir/nm -p /dev/null 2>&1 | sed '1q'; exit 0) | egrep /dev/null >/dev/null; then
925 ac_cv_path_NM="$ac_dir/nm -p"
927 ac_cv_path_NM="$ac_dir/nm"
933 test -z "$ac_cv_path_NM" && ac_cv_path_NM=nm
941 # Is the gmp header file new enough? (should be implemented with an argument)
942 AC_DEFUN(CL_GMP_H_VERSION,
943 [AC_CACHE_CHECK([for recent enough gmp.h], cl_cv_new_gmp_h, [
944 AC_TRY_CPP([#include <gmp.h>
945 #if !defined(__GNU_MP_VERSION) || (__GNU_MP_VERSION < 3)
946 #error "ancient gmp.h"
948 cl_cv_new_gmp_h="yes", cl_cv_new_gmp_h="no")
951 # Does libgmp provide some functionality introduced in version 3.0?
952 AC_DEFUN(CL_GMP_CHECK,
953 [AC_CACHE_CHECK([for working libgmp], cl_cv_new_libgmp, [
956 AC_TRY_LINK([#include <gmp.h>],[mpn_divexact_by3(0,0,0)],
957 cl_cv_new_libgmp="yes", cl_cv_new_libgmp="no"; LIBS=$SAVELIBS)