]> www.ginac.de Git - cln.git/blob - autoconf/aclocal.m4
- autoconf/aclocal.m4 (CL_CANONICAL_HOST): Added missing changequote
[cln.git] / autoconf / aclocal.m4
1 dnl local autoconf macros
2 dnl Bruno Haible 21.9.1997
3 dnl Marcus Daniels 10.4.1997
4 dnl
5 AC_PREREQ(2.12)dnl
6 dnl
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
12 dnl Usage:
13 dnl AC_TRY_CPP(INCLUDES,
14 dnl            ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND])
15 dnl CL_CPP_CHECK(ECHO-TEXT, CACHE-ID,
16 dnl              INCLUDES,
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])
23 dnl
24 define(CL_CPP_CHECK,
25 [AC_MSG_CHECKING(for $1)
26 AC_CACHE_VAL($2,[
27 AC_TRY_CPP([$3], $2=yes, $2=no)
28 ])
29 AC_MSG_RESULT([$]$2)
30 if test [$]$2 = yes; then
31   ifelse([$4], , :, [$4])
32 ifelse([$5], , , [else
33   $5
34 ])dnl
35 fi
36 ])dnl
37 dnl
38 define(CL_COMPILE_CHECK,
39 [AC_MSG_CHECKING(for $1)
40 AC_CACHE_VAL($2,[
41 AC_TRY_COMPILE([$3],[$4], $2=yes, $2=no)
42 ])
43 AC_MSG_RESULT([$]$2)
44 if test [$]$2 = yes; then
45   ifelse([$5], , :, [$5])
46 ifelse([$6], , , [else
47   $6
48 ])dnl
49 fi
50 ])dnl
51 dnl
52 define(CL_LINK_CHECK,
53 [AC_MSG_CHECKING(for $1)
54 AC_CACHE_VAL($2,[
55 AC_TRY_LINK([$3],[$4], $2=yes, $2=no)
56 ])
57 AC_MSG_RESULT([$]$2)
58 if test [$]$2 = yes; then
59   ifelse([$5], , :, [$5])
60 ifelse([$6], , , [else
61   $6
62 ])dnl
63 fi
64 ])dnl
65 dnl
66 dnl CL_PROTO(IDENTIFIER, ACTION-IF-NOT-FOUND, FINAL-PROTOTYPE)
67 define(CL_PROTO,
68 [AC_MSG_CHECKING([for $1 declaration])
69 AC_CACHE_VAL(cl_cv_proto_[$1], [$2
70 cl_cv_proto_$1="$3"])
71 cl_cv_proto_$1=`echo "[$]cl_cv_proto_$1" | tr -s ' ' | sed -e 's/( /(/'`
72 AC_MSG_RESULTPROTO([$]cl_cv_proto_$1)
73 ])dnl
74 dnl
75 dnl CL_PROTO_RET(INCLUDES, DECL, CACHE-ID, TYPE-IF-OK, TYPE-IF-FAILS)
76 define(CL_PROTO_RET,
77 [AC_TRY_COMPILE([$1]
78 AC_LANG_EXTERN[$2
79 ], [], $3="$4", $3="$5")
80 ])dnl
81 dnl
82 dnl CL_PROTO_TRY(INCLUDES, ANSI-DECL, TRAD-DECL, ACTION-IF-OK, ACTION-IF-FAILS)
83 define(CL_PROTO_TRY,
84 [AC_TRY_COMPILE([$1]
85 AC_LANG_EXTERN
86 [#if defined(__STDC__) || defined(__cplusplus)
87 $2
88 #else
89 $3
90 #endif
91 ], [], [$4], [$5])
92 ])dnl
93 dnl
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")]
97 )dnl
98 dnl
99 dnl CL_SILENT(ACTION)
100 dnl performs ACTION, with AC_MSG_CHECKING and AC_MSG_RESULT being defined away.
101 define(CL_SILENT,
102 [pushdef([AC_MSG_CHECKING],[:])dnl
103 pushdef([AC_CHECKING],[:])dnl
104 pushdef([AC_MSG_RESULT],[:])dnl
105 pushdef([AC_MSG_RESULTPROTO],[:])dnl
106 $1[]dnl
107 popdef([AC_MSG_RESULTPROTO])dnl
108 popdef([AC_MSG_RESULT])dnl
109 popdef([AC_CHECKING])dnl
110 popdef([AC_MSG_CHECKING])dnl
111 ])dnl
112 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; }
118 EOF
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
123 else
124   cl_cv_prog_as_underscore=no
125 fi
126 rm -f conftest*
127 ])
128 if test $cl_cv_prog_as_underscore = yes; then
129   AS_UNDERSCORE=true
130   AC_DEFINE(ASM_UNDERSCORE)
131 else
132   AS_UNDERSCORE=false
133 fi
134 AC_SUBST(AS_UNDERSCORE)dnl
135 ])dnl
136 dnl
137 AC_DEFUN(CL_PROG_RANLIB, [AC_CHECK_PROG(RANLIB, ranlib, ranlib, true)])dnl
138 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
146 # IRIX /sbin/install
147 # AIX /bin/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.
157     case "$ac_dir/" in
158     /|./|.//|/etc/*|/usr/sbin/*|/usr/etc/*|/sbin/*|/usr/afsws/bin/*|/usr/ucb/*) ;;
159     *)
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.
167             :
168           else
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".
172               :
173             else
174               cl_cv_path_install="$ac_dir/$ac_prog -c"
175               break 2
176             fi
177           fi
178         fi
179       done
180       ;;
181     esac
182   done
183   IFS="$ac_save_ifs"
184   # As a last resort, use cp.
185   test -z "$cl_cv_path_install" && cl_cv_path_install="cp"
186 ])dnl
187   INSTALL="$cl_cv_path_install"
188 fi
189 dnl We do special magic for INSTALL instead of AC_SUBST, to get
190 dnl relative paths right. 
191 AC_MSG_RESULT($INSTALL)
192 AC_SUBST(INSTALL)dnl
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
198   case "$INSTALL" in
199     cp | */cp ) INSTALL_DATA='$(INSTALL)' ;;
200     * )         INSTALL_DATA='$(INSTALL) -m 644' ;;
201   esac
202 fi
203 AC_SUBST(INSTALL_DATA)dnl
204 ])dnl
205 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)
218 fi
219 host_alias=$host
220 case "$host_alias" in
221 NONE)
222   case $nonopt in
223   NONE) dnl config.guess needs to compile things
224         host_alias=`export CC; $ac_config_guess` ;;
225   *)    host_alias=$nonopt ;;
226   esac ;;
227 esac
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`
231 else
232   host=unknown-unknown-unknown
233 fi
234 cl_cv_host="$host"
235 ])
236 host="$cl_cv_host"
237 changequote(,)dnl
238 host_cpu=`echo $host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'`
239 host_vendor=`echo $host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'`
240 host_os=`echo $host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'`
241 changequote([,])dnl
242 AC_SUBST(host)dnl
243 AC_SUBST(host_cpu)dnl
244 AC_SUBST(host_vendor)dnl
245 AC_SUBST(host_os)dnl
246 ])dnl
247 dnl
248 AC_DEFUN(CL_CANONICAL_HOST_CPU,
249 [AC_REQUIRE([CL_CANONICAL_HOST])AC_REQUIRE([AC_PROG_CC])
250 case "$host_cpu" in
251 changequote(,)dnl
252   i[4567]86 )
253     host_cpu=i386
254     ;;
255   alphaev[4-7] | alphaev56 | alphapca5[67] )
256     host_cpu=alpha
257     ;;
258   hppa1.0 | hppa1.1 | hppa2.0 )
259     host_cpu=hppa
260     ;;
261   powerpc )
262     host_cpu=rs6000
263     ;;
264   c1 | c2 | c32 | c34 | c38 | c4 )
265     host_cpu=convex
266     ;;
267 changequote([,])dnl
268   mips )
269     AC_CACHE_CHECK([for 64-bit MIPS], cl_cv_host_mips64, [
270 AC_EGREP_CPP(yes,
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. */
274   yes
275 #endif
276 #endif
277 ], cl_cv_host_mips64=yes, cl_cv_host_mips64=no)
278 ])
279 if test $cl_cv_host_mips64 = yes; then
280   host_cpu=mips64
281 fi
282     ;;
283 dnl UltraSPARCs running Linux have `uname -m` = "sparc64", but the C compiler
284 dnl still generates 32-bit code.
285   sparc | sparc64 )
286     AC_CACHE_CHECK([for 64-bit SPARC], cl_cv_host_sparc64, [
287 AC_EGREP_CPP(yes,
288 [#if defined(__sparcv9) || defined(__arch64__)
289   yes
290 #endif
291 ], cl_cv_host_sparc64=yes, cl_cv_host_sparc64=no)
292 ])
293 if test $cl_cv_host_sparc64 = yes; then
294   host_cpu=sparc64
295 else
296   host_cpu=sparc
297 fi
298     ;;
299 esac
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
304 #endif
305 EOF
306 ])dnl
307 dnl
308 AC_DEFUN(CL_LONGLONG,
309 [AC_CACHE_CHECK(for long long type, cl_cv_c_longlong, [
310 AC_TRY_RUN([int main()
311 {
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
314    miscompiled. */
315 #ifdef __GNUC__
316 #if defined(__m68k__) || (defined(_IBMR2) || defined(__powerpc))
317 #if (__GNUC__ == 2)
318 #if (__GNUC_MINOR__ <= 7)
319   exit(1);
320 #endif
321 #endif
322 #endif
323 #endif
324   { long x = 944938507; long y = 737962842; long z = 162359677;
325     exit(!(((long long) x)*((long long) y)>>32 == z));
326   }
327 }],
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")
331 ])
332 case "$cl_cv_c_longlong" in
333   *yes) AC_DEFINE(HAVE_LONGLONG) ;;
334   *no) ;;
335 esac
336 ])dnl
337 dnl
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")
345 ])
346 case "$cl_cv_c_longdouble" in
347   *yes) AC_DEFINE(HAVE_LONGDOUBLE) ;;
348   *no) ;;
349 esac
350 ])dnl
351 dnl
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))
356 ])dnl
357 dnl
358 AC_DEFUN(CL_UNISTD_H,
359 [AC_CHECK_HEADERS(unistd.h)]
360 )dnl
361 dnl
362 AC_DEFUN(CL_ALLOCA,
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
370 #else
371 #ifdef _MSC_VER
372 #include <malloc.h>
373 #define alloca _alloca
374 #else
375 #ifdef HAVE_ALLOCA_H
376 #include <alloca.h>
377 #else
378 #ifdef _AIX
379  #pragma alloca
380 #else
381 #ifndef alloca
382 char *alloca ();
383 #endif
384 #endif
385 #endif
386 #endif
387 #endif
388 "
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}
398   AC_DEFINE(NO_ALLOCA)
399 fi
400 AC_SUBST(ALLOCA)dnl
401 ])dnl
402 dnl
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))
414 ])dnl
415 dnl
416 AC_DEFUN(CL_PERROR,
417 [AC_MSG_CHECKING(for perror declaration)
418 AC_CACHE_VAL(cl_cv_proto_perror, [
419 AC_TRY_COMPILE([
420 /* Some systems declare perror() in <errno.h>, some in <stdio.h>, some don't
421    declare it at all. */
422 #include <stdio.h>
423 #include <errno.h>
424 ]AC_LANG_EXTERN[double perror ();], [],
425 cl_cv_proto_perror=no, cl_cv_proto_perror=yes)
426 ])
427 AC_MSG_RESULT([$cl_cv_proto_perror])
428 if test $cl_cv_proto_perror = yes; then
429 AC_DEFINE(HAVE_PERROR_DECL)
430 fi
431 ])dnl
432 dnl
433 AC_DEFUN(CL_RUSAGE,
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], [
445     CL_PROTO_TRY([
446 #include <stdlib.h>
447 #ifdef HAVE_UNISTD_H
448 #include <unistd.h>
449 #endif
450 #include <sys/types.h> /* NetBSD 1.0 needs this */
451 #include <sys/time.h>
452 #include <sys/resource.h>
453 ],
454 [int getrusage (int who, struct rusage * rusage);],
455 [int getrusage();],
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)
460   fi
461 fi
462 ])dnl
463 dnl
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], [
470 CL_PROTO_TRY([
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 *",
477 CL_PROTO_TRY([
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)
489 else
490 AC_DEFINE_UNQUOTED(GETTIMEOFDAY_TZP_T,$cl_cv_proto_gettimeofday_arg2)
491 fi
492 fi
493 ])dnl
494 dnl
495 AC_DEFUN(CL_FTIME,
496 [AC_BEFORE([$0], [CL_TIMES_CLOCK])
497 AC_CHECK_FUNCS(ftime)])dnl
498 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, [
506 AC_TRY_RUN([
507 #include <sys/types.h>
508 #include <time.h> /* needed for CLK_TCK */
509 #ifndef CLK_TCK
510 #include <sys/time.h> /* needed for CLK_TCK on SYSV PTX */
511 #endif
512 #include <sys/times.h>
513 int main ()
514 { struct tms buffer;
515   clock_t result1;
516   clock_t result2;
517   int ticks;
518   result1 = times(&buffer);
519   if ((result1 == (clock_t)0) || (result1 == (clock_t)(-1))) exit(1);
520   sleep(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")
528 ])
529 case "$cl_cv_func_times_return" in
530   *yes) AC_DEFINE(HAVE_TIMES_CLOCK) ;;
531   *no)  ;;
532 esac
533 fi
534 fi
535 ])dnl
536 dnl
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 (); };
544 foo foobar;
545 EOF
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$'
550 else
551   if grep '_GLOBAL_\.I\.foobar' conftest.s >/dev/null ; then
552     cl_cv_cplusplus_ctorprefix='_GLOBAL_.I.'
553   else
554     if grep '_GLOBAL__I_foobar' conftest.s >/dev/null ; then
555       cl_cv_cplusplus_ctorprefix='_GLOBAL__I_'
556     else
557       cl_cv_cplusplus_ctorprefix=unknown
558     fi
559   fi
560 fi
561 rm -f conftest*
562 ])
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 (); };
574 foo foobar;
575 EOF
576 cat > conftest2.cc << EOF
577 #include "confdefs.h"
578 #ifdef ASM_UNDERSCORE
579 #define ASM_UNDERSCORE_PREFIX "_"
580 #else
581 #define ASM_UNDERSCORE_PREFIX ""
582 #endif
583 struct foo { foo (); };
584 foo::foo () {}
585 extern "C" void ctor (void) __asm__ (ASM_UNDERSCORE_PREFIX CL_GLOBAL_CONSTRUCTOR_PREFIX "foobar");
586 int main() { ctor(); return 0; }
587 EOF
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
590 else
591   cl_cv_cplusplus_ctorexport=yes
592 fi
593 rm -f conftest*
594 ])
595 if test "$cl_cv_cplusplus_ctorexport" = yes; then
596   AC_DEFINE(CL_NEED_GLOBALIZE_CTORDTOR)
597 fi
598 fi
599 fi
600 ])dnl
601 dnl
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.
607 AC_EGREP_CPP(yes,
608 [#ifdef __CHAR_UNSIGNED__
609   yes
610 #endif
611 ], ac_cv_c_char_unsigned=yes, ac_cv_c_char_unsigned=no)
612 else
613 AC_TRY_RUN(
614 [/* volatile prevents gcc2 from optimizing the test away on sparcs.  */
615 #if !defined(__STDC__) || __STDC__ != 1
616 #define volatile
617 #endif
618 int main() {
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")
622 fi])
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__) ;;
627     *no) ;;
628   esac
629 fi
630 ])dnl
631 dnl
632 AC_DEFUN(CL_BOOL,
633 [AC_LANG_SAVE()
634 AC_LANG_CPLUSPLUS()
635 CL_COMPILE_CHECK([bool type], cl_cv_cplusplus_bool, , [bool x;],
636 AC_DEFINE(HAVE_BOOL), AC_DEFINE(bool,int))dnl
637 AC_LANG_RESTORE()
638 ])dnl
639 dnl
640 AC_DEFUN(CL_MACHINE,
641 [AC_REQUIRE([AC_PROG_CC])dnl
642 AC_REQUIRE([CL_CHAR_UNSIGNED])dnl
643 cl_machine_file_c=$2
644 cl_machine_file_h=$3
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"
650 EOF
651 cat "$cl_machine_file_c" >> conftest.$ac_ext
652 ORIGCC="$CC"
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'`
657 fi
658 AC_TRY_EVAL(ac_link)
659 CC="$ORIGCC"
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
665     rm -f conftest.h
666   else
667     rm -f "$cl_machine_file_h"
668     mv conftest.h "$cl_machine_file_h"
669   fi
670   [$4]=1
671 else
672   echo "creation of $cl_machine_file_h failed"
673 fi
674 rm -f conftest*
675 fi
676 else
677 echo "cross-compiling - cannot create $cl_machine_file_h"
678 fi
679 ])dnl
680 dnl
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
684 ##
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.
689 ##
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.
694 ##
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.
698 ##
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.
703
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
714 dnl
715 # Always use our own libtool.
716 LIBTOOL='$(SHELL) $(top_builddir)/libtool'
717 AC_SUBST(LIBTOOL)dnl
718
719 # Check for any special flags to pass to ltconfig.
720 libtool_flags=
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"
726
727 # Some flags need to be propagated to the compiler or linker for good
728 # libtool support.
729 case "$host" in
730 *-*-irix6*)
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
735     *32-bit*)
736       LD="${LD-ld} -32"
737       ;;
738     *N32*)
739       LD="${LD-ld} -n32"
740       ;;
741     *64-bit*)
742       LD="${LD-ld} -64"
743       ;;
744     esac
745   fi
746   rm -rf conftest*
747   ;;
748
749 *-*-sco3.2v5*)
750   # On SCO OpenServer 5, we need -belf to get full-featured binaries.
751   CFLAGS="$CFLAGS -belf"
752   ;;
753 esac
754
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])
761 ])
762
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
766 #   `yes'.
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]
772 changequote([, ])dnl
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}
776 case "$enableval" in
777 yes) enable_shared=yes ;;
778 no) enable_shared=no ;;
779 *)
780   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
785       enable_shared=yes
786     fi
787   done
788   IFS="$ac_save_ifs"
789   ;;
790 esac],
791 enable_shared=AM_ENABLE_SHARED_DEFAULT)dnl
792 ])
793
794 # AM_DISABLE_SHARED - set the default shared flag to --disable-shared
795 AC_DEFUN(AM_DISABLE_SHARED,
796 [AM_ENABLE_SHARED(no)])
797
798 # AM_DISABLE_STATIC - set the default static flag to --disable-static
799 AC_DEFUN(AM_DISABLE_STATIC,
800 [AM_ENABLE_STATIC(no)])
801
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
805 #   `yes'.
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]
811 changequote([, ])dnl
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}
815 case "$enableval" in
816 yes) enable_static=yes ;;
817 no) enable_static=no ;;
818 *)
819   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
824       enable_static=yes
825     fi
826   done
827   IFS="$ac_save_ifs"
828   ;;
829 esac],
830 enable_static=AM_ENABLE_STATIC_DEFAULT)dnl
831 ])
832
833
834 # AM_PROG_LD - find the path to the GNU or non-GNU linker
835 AC_DEFUN(AM_PROG_LD,
836 [AC_ARG_WITH(gnu-ld,
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])
840 ac_prog=ld
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`
845   case "$ac_prog" in
846   # Accept absolute paths.
847   /* | [A-Za-z]:\\*)
848     test -z "$LD" && LD="$ac_prog"
849     ;;
850   "")
851     # If it fails, then pretend we aren't using GCC.
852     ac_prog=ld
853     ;;
854   *)
855     # If it is relative, then search for the first ld in PATH.
856     with_gnu_ld=unknown
857     ;;
858   esac
859 elif test "$with_gnu_ld" = yes; then
860   AC_MSG_CHECKING([for GNU ld])
861 else
862   AC_MSG_CHECKING([for non-GNU ld])
863 fi
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
876       else
877         test "$with_gnu_ld" != yes && break
878       fi
879     fi
880   done
881   IFS="$ac_save_ifs"
882 else
883   ac_cv_path_LD="$LD" # Let the user override the test with a path.
884 fi])
885 LD="$ac_cv_path_LD"
886 if test -n "$LD"; then
887   AC_MSG_RESULT($LD)
888 else
889   AC_MSG_RESULT(no)
890 fi
891 test -z "$LD" && AC_MSG_ERROR([no acceptable ld found in \$PATH])
892 AC_SUBST(LD)
893 AM_PROG_LD_GNU
894 ])
895
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
901 else
902   ac_cv_prog_gnu_ld=no
903 fi])
904 ])
905
906 # AM_PROG_NM - find the path to a BSD-compatible name lister
907 AC_DEFUN(AM_PROG_NM,
908 [AC_MSG_CHECKING([for BSD-compatible nm])
909 AC_CACHE_VAL(ac_cv_path_NM,
910 [case "$NM" in
911 /* | [A-Za-z]:\\*)
912   ac_cv_path_NM="$NM" # Let the user override the test with a path.
913   ;;
914 *)
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"
926       else
927         ac_cv_path_NM="$ac_dir/nm"
928       fi
929       break
930     fi
931   done
932   IFS="$ac_save_ifs"
933   test -z "$ac_cv_path_NM" && ac_cv_path_NM=nm
934   ;;
935 esac])
936 NM="$ac_cv_path_NM"
937 AC_MSG_RESULT([$NM])
938 AC_SUBST(NM)
939 ])