You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

939 lines
27 KiB

25 years ago
25 years ago
25 years ago
25 years ago
  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. # serial 24 AM_PROG_LIBTOOL
  704. AC_DEFUN(AM_PROG_LIBTOOL,
  705. [AC_REQUIRE([AM_ENABLE_SHARED])dnl
  706. AC_REQUIRE([AM_ENABLE_STATIC])dnl
  707. AC_REQUIRE([CL_CANONICAL_HOST])dnl
  708. AC_REQUIRE([CL_PROG_RANLIB])dnl
  709. AC_REQUIRE([AC_PROG_CC])dnl
  710. AC_REQUIRE([AM_PROG_LD])dnl
  711. AC_REQUIRE([AM_PROG_NM])dnl
  712. AC_REQUIRE([AC_PROG_LN_S])dnl
  713. dnl
  714. # Always use our own libtool.
  715. LIBTOOL='$(SHELL) $(top_builddir)/libtool'
  716. AC_SUBST(LIBTOOL)dnl
  717. # Check for any special flags to pass to ltconfig.
  718. libtool_flags=
  719. test "$enable_shared" = no && libtool_flags="$libtool_flags --disable-shared"
  720. test "$enable_static" = no && libtool_flags="$libtool_flags --disable-static"
  721. test "$silent" = yes && libtool_flags="$libtool_flags --silent"
  722. test "$ac_cv_prog_gcc" = yes && libtool_flags="$libtool_flags --with-gcc"
  723. test "$ac_cv_prog_gnu_ld" = yes && libtool_flags="$libtool_flags --with-gnu-ld"
  724. # Some flags need to be propagated to the compiler or linker for good
  725. # libtool support.
  726. case "$host" in
  727. *-*-irix6*)
  728. # Find out which ABI we are using.
  729. echo '[#]line __oline__ "configure"' > conftest.$ac_ext
  730. if AC_TRY_EVAL(ac_compile); then
  731. case "`/usr/bin/file conftest.o`" in
  732. *32-bit*)
  733. LD="${LD-ld} -32"
  734. ;;
  735. *N32*)
  736. LD="${LD-ld} -n32"
  737. ;;
  738. *64-bit*)
  739. LD="${LD-ld} -64"
  740. ;;
  741. esac
  742. fi
  743. rm -rf conftest*
  744. ;;
  745. *-*-sco3.2v5*)
  746. # On SCO OpenServer 5, we need -belf to get full-featured binaries.
  747. CFLAGS="$CFLAGS -belf"
  748. ;;
  749. esac
  750. # Actually configure libtool. ac_aux_dir is where install-sh is found.
  751. CC="$CC" CFLAGS="$CFLAGS" CPPFLAGS="$CPPFLAGS" \
  752. LD="$LD" NM="$NM" RANLIB="$RANLIB" LN_S="$LN_S" \
  753. ${CONFIG_SHELL-/bin/sh} $ac_aux_dir/ltconfig \
  754. $libtool_flags --no-verify $ac_aux_dir/ltmain.sh $host \
  755. || AC_MSG_ERROR([libtool configure failed])
  756. ])
  757. # AM_ENABLE_SHARED - implement the --enable-shared flag
  758. # Usage: AM_ENABLE_SHARED[(DEFAULT)]
  759. # Where DEFAULT is either `yes' or `no'. If omitted, it defaults to
  760. # `yes'.
  761. AC_DEFUN(AM_ENABLE_SHARED,
  762. [define([AM_ENABLE_SHARED_DEFAULT], ifelse($1, no, no, yes))dnl
  763. AC_ARG_ENABLE(shared,
  764. changequote(<<, >>)dnl
  765. << --enable-shared build shared libraries [default=>>AM_ENABLE_SHARED_DEFAULT]
  766. changequote([, ])dnl
  767. [ --enable-shared=PKGS only build shared libraries if the current package
  768. appears as an element in the PKGS list],
  769. [p=${PACKAGE-default}
  770. case "$enableval" in
  771. yes) enable_shared=yes ;;
  772. no) enable_shared=no ;;
  773. *)
  774. enable_shared=no
  775. # Look at the argument we got. We use all the common list separators.
  776. IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:,"
  777. for pkg in $enableval; do
  778. if test "X$pkg" = "X$p"; then
  779. enable_shared=yes
  780. fi
  781. done
  782. IFS="$ac_save_ifs"
  783. ;;
  784. esac],
  785. enable_shared=AM_ENABLE_SHARED_DEFAULT)dnl
  786. ])
  787. # AM_DISABLE_SHARED - set the default shared flag to --disable-shared
  788. AC_DEFUN(AM_DISABLE_SHARED,
  789. [AM_ENABLE_SHARED(no)])
  790. # AM_DISABLE_STATIC - set the default static flag to --disable-static
  791. AC_DEFUN(AM_DISABLE_STATIC,
  792. [AM_ENABLE_STATIC(no)])
  793. # AM_ENABLE_STATIC - implement the --enable-static flag
  794. # Usage: AM_ENABLE_STATIC[(DEFAULT)]
  795. # Where DEFAULT is either `yes' or `no'. If omitted, it defaults to
  796. # `yes'.
  797. AC_DEFUN(AM_ENABLE_STATIC,
  798. [define([AM_ENABLE_STATIC_DEFAULT], ifelse($1, no, no, yes))dnl
  799. AC_ARG_ENABLE(static,
  800. changequote(<<, >>)dnl
  801. << --enable-static build static libraries [default=>>AM_ENABLE_STATIC_DEFAULT]
  802. changequote([, ])dnl
  803. [ --enable-static=PKGS only build shared libraries if the current package
  804. appears as an element in the PKGS list],
  805. [p=${PACKAGE-default}
  806. case "$enableval" in
  807. yes) enable_static=yes ;;
  808. no) enable_static=no ;;
  809. *)
  810. enable_static=no
  811. # Look at the argument we got. We use all the common list separators.
  812. IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:,"
  813. for pkg in $enableval; do
  814. if test "X$pkg" = "X$p"; then
  815. enable_static=yes
  816. fi
  817. done
  818. IFS="$ac_save_ifs"
  819. ;;
  820. esac],
  821. enable_static=AM_ENABLE_STATIC_DEFAULT)dnl
  822. ])
  823. # AM_PROG_LD - find the path to the GNU or non-GNU linker
  824. AC_DEFUN(AM_PROG_LD,
  825. [AC_ARG_WITH(gnu-ld,
  826. [ --with-gnu-ld assume the C compiler uses GNU ld [default=no]],
  827. test "$withval" = no || with_gnu_ld=yes, with_gnu_ld=no)
  828. AC_REQUIRE([AC_PROG_CC])
  829. ac_prog=ld
  830. if test "$ac_cv_prog_gcc" = yes; then
  831. # Check if gcc -print-prog-name=ld gives a path.
  832. AC_MSG_CHECKING([for ld used by GCC])
  833. ac_prog=`($CC -print-prog-name=ld) 2>&5`
  834. case "$ac_prog" in
  835. # Accept absolute paths.
  836. /* | [A-Za-z]:\\*)
  837. test -z "$LD" && LD="$ac_prog"
  838. ;;
  839. "")
  840. # If it fails, then pretend we aren't using GCC.
  841. ac_prog=ld
  842. ;;
  843. *)
  844. # If it is relative, then search for the first ld in PATH.
  845. with_gnu_ld=unknown
  846. ;;
  847. esac
  848. elif test "$with_gnu_ld" = yes; then
  849. AC_MSG_CHECKING([for GNU ld])
  850. else
  851. AC_MSG_CHECKING([for non-GNU ld])
  852. fi
  853. AC_CACHE_VAL(ac_cv_path_LD,
  854. [if test -z "$LD"; then
  855. IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:"
  856. for ac_dir in $PATH; do
  857. test -z "$ac_dir" && ac_dir=.
  858. if test -f "$ac_dir/$ac_prog"; then
  859. ac_cv_path_LD="$ac_dir/$ac_prog"
  860. # Check to see if the program is GNU ld. I'd rather use --version,
  861. # but apparently some GNU ld's only accept -v.
  862. # Break only if it was the GNU/non-GNU ld that we prefer.
  863. if "$ac_cv_path_LD" -v 2>&1 < /dev/null | egrep '(GNU|with BFD)' > /dev/null; then
  864. test "$with_gnu_ld" != no && break
  865. else
  866. test "$with_gnu_ld" != yes && break
  867. fi
  868. fi
  869. done
  870. IFS="$ac_save_ifs"
  871. else
  872. ac_cv_path_LD="$LD" # Let the user override the test with a path.
  873. fi])
  874. LD="$ac_cv_path_LD"
  875. if test -n "$LD"; then
  876. AC_MSG_RESULT($LD)
  877. else
  878. AC_MSG_RESULT(no)
  879. fi
  880. test -z "$LD" && AC_MSG_ERROR([no acceptable ld found in \$PATH])
  881. AC_SUBST(LD)
  882. AM_PROG_LD_GNU
  883. ])
  884. AC_DEFUN(AM_PROG_LD_GNU,
  885. [AC_CACHE_CHECK([if the linker ($LD) is GNU ld], ac_cv_prog_gnu_ld,
  886. [# I'd rather use --version here, but apparently some GNU ld's only accept -v.
  887. if $LD -v 2>&1 </dev/null | egrep '(GNU|with BFD)' 1>&5; then
  888. ac_cv_prog_gnu_ld=yes
  889. else
  890. ac_cv_prog_gnu_ld=no
  891. fi])
  892. ])
  893. # AM_PROG_NM - find the path to a BSD-compatible name lister
  894. AC_DEFUN(AM_PROG_NM,
  895. [AC_MSG_CHECKING([for BSD-compatible nm])
  896. AC_CACHE_VAL(ac_cv_path_NM,
  897. [case "$NM" in
  898. /* | [A-Za-z]:\\*)
  899. ac_cv_path_NM="$NM" # Let the user override the test with a path.
  900. ;;
  901. *)
  902. IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:"
  903. for ac_dir in /usr/ucb /usr/ccs/bin $PATH /bin; do
  904. test -z "$ac_dir" && ac_dir=.
  905. if test -f $ac_dir/nm; then
  906. # Check to see if the nm accepts a BSD-compat flag.
  907. # Adding the `sed 1q' prevents false positives on HP-UX, which says:
  908. # nm: unknown option "B" ignored
  909. if ($ac_dir/nm -B /dev/null 2>&1 | sed '1q'; exit 0) | egrep /dev/null >/dev/null; then
  910. ac_cv_path_NM="$ac_dir/nm -B"
  911. elif ($ac_dir/nm -p /dev/null 2>&1 | sed '1q'; exit 0) | egrep /dev/null >/dev/null; then
  912. ac_cv_path_NM="$ac_dir/nm -p"
  913. else
  914. ac_cv_path_NM="$ac_dir/nm"
  915. fi
  916. break
  917. fi
  918. done
  919. IFS="$ac_save_ifs"
  920. test -z "$ac_cv_path_NM" && ac_cv_path_NM=nm
  921. ;;
  922. esac])
  923. NM="$ac_cv_path_NM"
  924. AC_MSG_RESULT([$NM])
  925. AC_SUBST(NM)
  926. ])