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.

937 lines
27 KiB

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. ac_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. host_cpu=`echo $host | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\1/'`
  238. host_vendor=`echo $host | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\2/'`
  239. host_os=`echo $host | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\3/'`
  240. AC_SUBST(host)dnl
  241. AC_SUBST(host_cpu)dnl
  242. AC_SUBST(host_vendor)dnl
  243. AC_SUBST(host_os)dnl
  244. ])dnl
  245. dnl
  246. AC_DEFUN(CL_CANONICAL_HOST_CPU,
  247. [AC_REQUIRE([CL_CANONICAL_HOST])AC_REQUIRE([AC_PROG_CC])
  248. case "$host_cpu" in
  249. changequote(,)dnl
  250. i[4567]86 )
  251. host_cpu=i386
  252. ;;
  253. alphaev[4-7] | alphaev56 | alphapca5[67] )
  254. host_cpu=alpha
  255. ;;
  256. hppa1.0 | hppa1.1 | hppa2.0 )
  257. host_cpu=hppa
  258. ;;
  259. powerpc )
  260. host_cpu=rs6000
  261. ;;
  262. c1 | c2 | c32 | c34 | c38 | c4 )
  263. host_cpu=convex
  264. ;;
  265. changequote([,])dnl
  266. mips )
  267. AC_CACHE_CHECK([for 64-bit MIPS], cl_cv_host_mips64, [
  268. AC_EGREP_CPP(yes,
  269. [#if defined(_MIPS_SZLONG)
  270. #if (_MIPS_SZLONG == 64)
  271. /* We should also check for (_MIPS_SZPTR == 64), but gcc keeps this at 32. */
  272. yes
  273. #endif
  274. #endif
  275. ], cl_cv_host_mips64=yes, cl_cv_host_mips64=no)
  276. ])
  277. if test $cl_cv_host_mips64 = yes; then
  278. host_cpu=mips64
  279. fi
  280. ;;
  281. dnl UltraSPARCs running Linux have `uname -m` = "sparc64", but the C compiler
  282. dnl still generates 32-bit code.
  283. sparc | sparc64 )
  284. AC_CACHE_CHECK([for 64-bit SPARC], cl_cv_host_sparc64, [
  285. AC_EGREP_CPP(yes,
  286. [#if defined(__sparcv9) || defined(__arch64__)
  287. yes
  288. #endif
  289. ], cl_cv_host_sparc64=yes, cl_cv_host_sparc64=no)
  290. ])
  291. if test $cl_cv_host_sparc64 = yes; then
  292. host_cpu=sparc64
  293. else
  294. host_cpu=sparc
  295. fi
  296. ;;
  297. esac
  298. dnl was AC_DEFINE_UNQUOTED(__${host_cpu}__) but KAI C++ 3.2d doesn't like this
  299. cat >> confdefs.h <<EOF
  300. #ifndef __${host_cpu}__
  301. #define __${host_cpu}__ 1
  302. #endif
  303. EOF
  304. ])dnl
  305. dnl
  306. AC_DEFUN(CL_LONGLONG,
  307. [AC_CACHE_CHECK(for long long type, cl_cv_c_longlong, [
  308. AC_TRY_RUN([int main()
  309. {
  310. /* long longs don't work right with gcc-2.7.2 on m68k */
  311. /* long longs don't work right with gcc-2.7.2 on rs6000: avcall/tests.c gets
  312. miscompiled. */
  313. #ifdef __GNUC__
  314. #if defined(__m68k__) || (defined(_IBMR2) || defined(__powerpc))
  315. #if (__GNUC__ == 2)
  316. #if (__GNUC_MINOR__ <= 7)
  317. exit(1);
  318. #endif
  319. #endif
  320. #endif
  321. #endif
  322. { long x = 944938507; long y = 737962842; long z = 162359677;
  323. exit(!(((long long) x)*((long long) y)>>32 == z));
  324. }
  325. }],
  326. cl_cv_c_longlong=yes, cl_cv_c_longlong=no,
  327. dnl When cross-compiling, don't assume anything.
  328. cl_cv_c_longlong="guessing no")
  329. ])
  330. case "$cl_cv_c_longlong" in
  331. *yes) AC_DEFINE(HAVE_LONGLONG) ;;
  332. *no) ;;
  333. esac
  334. ])dnl
  335. dnl
  336. AC_DEFUN(CL_LONGDOUBLE,
  337. [AC_CACHE_CHECK(for long double type, cl_cv_c_longdouble, [
  338. AC_TRY_RUN([int main()
  339. { long double x = 2.7182818284590452354L; x = x*x; exit (x==0.0L); }],
  340. cl_cv_c_longdouble=yes, cl_cv_c_longdouble=no,
  341. dnl When cross-compiling, don't assume anything.
  342. cl_cv_c_longdouble="guessing no")
  343. ])
  344. case "$cl_cv_c_longdouble" in
  345. *yes) AC_DEFINE(HAVE_LONGDOUBLE) ;;
  346. *no) ;;
  347. esac
  348. ])dnl
  349. dnl
  350. AC_DEFUN(CL_TEMPLATE_NULL,
  351. [CL_COMPILE_CHECK([working template<>], cl_cv_c_templatenull,
  352. [template <class T> class c {}; template <> class c<int> { int x; };], ,
  353. AC_DEFINE(HAVE_TEMPLATE_NULL))
  354. ])dnl
  355. dnl
  356. AC_DEFUN(CL_UNISTD_H,
  357. [AC_CHECK_HEADERS(unistd.h)]
  358. )dnl
  359. dnl
  360. AC_DEFUN(CL_ALLOCA,
  361. [# The Ultrix 4.2 mips builtin alloca declared by alloca.h only works
  362. # for constant arguments. Useless!
  363. CL_LINK_CHECK(working alloca.h, cl_cv_header_alloca_h,
  364. [#include <alloca.h>], [char *p = (char *) alloca(2 * sizeof(int));],
  365. AC_DEFINE(HAVE_ALLOCA_H))dnl
  366. decl="#ifdef __GNUC__
  367. #define alloca __builtin_alloca
  368. #else
  369. #ifdef _MSC_VER
  370. #include <malloc.h>
  371. #define alloca _alloca
  372. #else
  373. #ifdef HAVE_ALLOCA_H
  374. #include <alloca.h>
  375. #else
  376. #ifdef _AIX
  377. #pragma alloca
  378. #else
  379. #ifndef alloca
  380. char *alloca ();
  381. #endif
  382. #endif
  383. #endif
  384. #endif
  385. #endif
  386. "
  387. CL_LINK_CHECK([alloca], cl_cv_func_alloca,
  388. $decl, [char *p = (char *) alloca(1);],
  389. , [alloca_missing=1])dnl
  390. if test -n "$alloca_missing"; then
  391. # The SVR3 libPW and SVR4 libucb both contain incompatible functions
  392. # that cause trouble. Some versions do not even contain alloca or
  393. # contain a buggy version. If you still want to use their alloca,
  394. # use ar to extract alloca.o from them instead of compiling alloca.c.
  395. ALLOCA=alloca.${ac_objext}
  396. AC_DEFINE(NO_ALLOCA)
  397. fi
  398. AC_SUBST(ALLOCA)dnl
  399. ])dnl
  400. dnl
  401. AC_DEFUN(CL_FPU_CONTROL,
  402. [dnl Check for Linux with <fpu_control.h> and fpu_control_t or __setfpucw().
  403. dnl glibc versions since October 1998 define fpu_control_t. Earlier versions
  404. dnl define and declare __setfpucw(). Very early Linux libc versions have none,
  405. dnl and __fpu_control is of type `unsigned short'.
  406. CL_COMPILE_CHECK([fpu_control_t], cl_cv_type_fpu_control_t,
  407. [#include <fpu_control.h>], [fpu_control_t x;],
  408. AC_DEFINE(HAVE_FPU_CONTROL_T))
  409. CL_COMPILE_CHECK([__setfpucw], cl_cv_func_setfpucw,
  410. [#include <fpu_control.h>], [__setfpucw(_FPU_IEEE);],
  411. AC_DEFINE(HAVE_SETFPUCW))
  412. ])dnl
  413. dnl
  414. AC_DEFUN(CL_PERROR,
  415. [AC_MSG_CHECKING(for perror declaration)
  416. AC_CACHE_VAL(cl_cv_proto_perror, [
  417. AC_TRY_COMPILE([
  418. /* Some systems declare perror() in <errno.h>, some in <stdio.h>, some don't
  419. declare it at all. */
  420. #include <stdio.h>
  421. #include <errno.h>
  422. ]AC_LANG_EXTERN[double perror ();], [],
  423. cl_cv_proto_perror=no, cl_cv_proto_perror=yes)
  424. ])
  425. AC_MSG_RESULT([$cl_cv_proto_perror])
  426. if test $cl_cv_proto_perror = yes; then
  427. AC_DEFINE(HAVE_PERROR_DECL)
  428. fi
  429. ])dnl
  430. dnl
  431. AC_DEFUN(CL_RUSAGE,
  432. [AC_CHECK_HEADERS(sys/resource.h sys/times.h)dnl
  433. if test $ac_cv_header_sys_resource_h = yes; then
  434. dnl HAVE_SYS_RESOURCE_H defined
  435. CL_LINK_CHECK([getrusage], cl_cv_func_getrusage,
  436. [#include <sys/types.h> /* NetBSD 1.0 needs this */
  437. #include <sys/time.h>
  438. #include <sys/resource.h>],
  439. [struct rusage x; int y = RUSAGE_SELF; getrusage(y,&x); x.ru_utime.tv_sec;],
  440. AC_DEFINE(HAVE_GETRUSAGE))dnl
  441. if test $cl_cv_func_getrusage = yes; then
  442. CL_PROTO([getrusage], [
  443. CL_PROTO_TRY([
  444. #include <stdlib.h>
  445. #ifdef HAVE_UNISTD_H
  446. #include <unistd.h>
  447. #endif
  448. #include <sys/types.h> /* NetBSD 1.0 needs this */
  449. #include <sys/time.h>
  450. #include <sys/resource.h>
  451. ],
  452. [int getrusage (int who, struct rusage * rusage);],
  453. [int getrusage();],
  454. [cl_cv_proto_getrusage_arg1="int"],
  455. [cl_cv_proto_getrusage_arg1="enum __rusage_who"])
  456. ], [extern int getrusage ($cl_cv_proto_getrusage_arg1, struct rusage *);])
  457. AC_DEFINE_UNQUOTED(RUSAGE_WHO_T,$cl_cv_proto_getrusage_arg1)
  458. fi
  459. fi
  460. ])dnl
  461. dnl
  462. AC_DEFUN(CL_GETTIMEOFDAY,
  463. [AC_BEFORE([$0], [CL_TIMES_CLOCK])
  464. AC_CHECK_FUNCS(gettimeofday)dnl
  465. if test $ac_cv_func_gettimeofday = yes; then
  466. dnl HAVE_GETTIMEOFDAY is defined
  467. CL_PROTO([gettimeofday], [
  468. CL_PROTO_TRY([
  469. #include <sys/types.h>
  470. #include <sys/time.h>
  471. ], [int gettimeofday (struct timeval * tp, struct timezone * tzp);],
  472. [int gettimeofday();],
  473. cl_cv_proto_gettimeofday_dots=no
  474. cl_cv_proto_gettimeofday_arg2="struct timezone *",
  475. CL_PROTO_TRY([
  476. #include <sys/types.h>
  477. #include <sys/time.h>
  478. ], [int gettimeofday (struct timeval * tp, void * tzp);],
  479. [int gettimeofday();],
  480. cl_cv_proto_gettimeofday_dots=no
  481. cl_cv_proto_gettimeofday_arg2="void *",
  482. cl_cv_proto_gettimeofday_dots=yes
  483. cl_cv_proto_gettimeofday_arg2="..."))
  484. ], [extern int gettimeofday (struct timeval *, $cl_cv_proto_gettimeofday_arg2);])
  485. if test $cl_cv_proto_gettimeofday_dots = yes; then
  486. AC_DEFINE(GETTIMEOFDAY_DOTS)
  487. else
  488. AC_DEFINE_UNQUOTED(GETTIMEOFDAY_TZP_T,$cl_cv_proto_gettimeofday_arg2)
  489. fi
  490. fi
  491. ])dnl
  492. dnl
  493. AC_DEFUN(CL_FTIME,
  494. [AC_BEFORE([$0], [CL_TIMES_CLOCK])
  495. AC_CHECK_FUNCS(ftime)])dnl
  496. dnl
  497. AC_DEFUN(CL_TIMES_CLOCK,
  498. [AC_REQUIRE([CL_GETTIMEOFDAY])dnl
  499. AC_REQUIRE([CL_FTIME])dnl
  500. if test $ac_cv_func_gettimeofday = no -a $ac_cv_func_ftime = no; then
  501. AC_CHECK_FUNC(times, , no_times=1)dnl
  502. if test -z "$no_times"; then
  503. AC_CACHE_CHECK(for times return value, cl_cv_func_times_return, [
  504. AC_TRY_RUN([
  505. #include <sys/types.h>
  506. #include <time.h> /* needed for CLK_TCK */
  507. #ifndef CLK_TCK
  508. #include <sys/time.h> /* needed for CLK_TCK on SYSV PTX */
  509. #endif
  510. #include <sys/times.h>
  511. int main ()
  512. { struct tms buffer;
  513. clock_t result1;
  514. clock_t result2;
  515. int ticks;
  516. result1 = times(&buffer);
  517. if ((result1 == (clock_t)0) || (result1 == (clock_t)(-1))) exit(1);
  518. sleep(1);
  519. result2 = times(&buffer);
  520. if ((result2 == (clock_t)0) || (result2 == (clock_t)(-1))) exit(1);
  521. ticks = result2 - result1;
  522. exit(!((ticks >= CLK_TCK/2) && (ticks <= 3*CLK_TCK/2)));
  523. }], cl_cv_func_times_return=yes, cl_cv_func_times_return=no,
  524. dnl When cross-compiling, don't assume anything.
  525. cl_cv_func_times_return="guessing no")
  526. ])
  527. case "$cl_cv_func_times_return" in
  528. *yes) AC_DEFINE(HAVE_TIMES_CLOCK) ;;
  529. *no) ;;
  530. esac
  531. fi
  532. fi
  533. ])dnl
  534. dnl
  535. AC_DEFUN(CL_GLOBAL_CONSTRUCTORS,
  536. [AC_REQUIRE([CL_AS_UNDERSCORE])dnl
  537. if test -n "$GCC"; then
  538. AC_CACHE_CHECK(for the global constructors function prefix,
  539. cl_cv_cplusplus_ctorprefix, [
  540. cat > conftest.cc << EOF
  541. struct foo { foo (); };
  542. foo foobar;
  543. EOF
  544. # look for the assembly language name in the .s file
  545. AC_TRY_COMMAND(${CXX-g++} $CXXFLAGS -S conftest.cc) >/dev/null 2>&1
  546. if grep '_GLOBAL_\$I\$foobar' conftest.s >/dev/null ; then
  547. cl_cv_cplusplus_ctorprefix='_GLOBAL_$I$'
  548. else
  549. if grep '_GLOBAL_\.I\.foobar' conftest.s >/dev/null ; then
  550. cl_cv_cplusplus_ctorprefix='_GLOBAL_.I.'
  551. else
  552. if grep '_GLOBAL__I_foobar' conftest.s >/dev/null ; then
  553. cl_cv_cplusplus_ctorprefix='_GLOBAL__I_'
  554. else
  555. cl_cv_cplusplus_ctorprefix=unknown
  556. fi
  557. fi
  558. fi
  559. rm -f conftest*
  560. ])
  561. if test "$cl_cv_cplusplus_ctorprefix" '!=' unknown; then
  562. ac_value='"'"$cl_cv_cplusplus_ctorprefix"'"'
  563. AC_DEFINE_UNQUOTED(CL_GLOBAL_CONSTRUCTOR_PREFIX,$ac_value)
  564. ac_value=`echo "$ac_value" | sed -e 's,I,D,'`
  565. AC_DEFINE_UNQUOTED(CL_GLOBAL_DESTRUCTOR_PREFIX,$ac_value)
  566. dnl Check whether the global constructors/destructors functions are file-scope
  567. dnl only by default. This is the case in egcs-1.1.2 or newer.
  568. AC_CACHE_CHECK(whether the global constructors function need to be exported,
  569. cl_cv_cplusplus_ctorexport, [
  570. cat > conftest1.cc << EOF
  571. struct foo { foo (); };
  572. foo foobar;
  573. EOF
  574. cat > conftest2.cc << EOF
  575. #include "confdefs.h"
  576. #ifdef ASM_UNDERSCORE
  577. #define ASM_UNDERSCORE_PREFIX "_"
  578. #else
  579. #define ASM_UNDERSCORE_PREFIX ""
  580. #endif
  581. struct foo { foo (); };
  582. foo::foo () {}
  583. extern "C" void ctor (void) __asm__ (ASM_UNDERSCORE_PREFIX CL_GLOBAL_CONSTRUCTOR_PREFIX "foobar");
  584. int main() { ctor(); return 0; }
  585. EOF
  586. 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
  587. cl_cv_cplusplus_ctorexport=no
  588. else
  589. cl_cv_cplusplus_ctorexport=yes
  590. fi
  591. rm -f conftest*
  592. ])
  593. if test "$cl_cv_cplusplus_ctorexport" = yes; then
  594. AC_DEFINE(CL_NEED_GLOBALIZE_CTORDTOR)
  595. fi
  596. fi
  597. fi
  598. ])dnl
  599. dnl
  600. AC_DEFUN(CL_CHAR_UNSIGNED,
  601. [dnl This is mostly copied from AC_C_CHAR_UNSIGNED.
  602. AC_CACHE_CHECK(whether characters are unsigned, ac_cv_c_char_unsigned, [
  603. if test $ac_cv_prog_gcc = yes; then
  604. # GCC predefines this symbol on systems where it applies.
  605. AC_EGREP_CPP(yes,
  606. [#ifdef __CHAR_UNSIGNED__
  607. yes
  608. #endif
  609. ], ac_cv_c_char_unsigned=yes, ac_cv_c_char_unsigned=no)
  610. else
  611. AC_TRY_RUN(
  612. [/* volatile prevents gcc2 from optimizing the test away on sparcs. */
  613. #if !defined(__STDC__) || __STDC__ != 1
  614. #define volatile
  615. #endif
  616. int main() {
  617. volatile char c = 255; exit(c < 0);
  618. }], ac_cv_c_char_unsigned=yes, ac_cv_c_char_unsigned=no,
  619. ac_cv_c_char_unsigned="guessing no")
  620. fi])
  621. if test $ac_cv_prog_gcc = no; then
  622. # GCC defines __CHAR_UNSIGNED__ by itself, no need to fix up.
  623. case "$ac_cv_c_char_unsigned" in
  624. *yes) AC_DEFINE(__CHAR_UNSIGNED__) ;;
  625. *no) ;;
  626. esac
  627. fi
  628. ])dnl
  629. dnl
  630. AC_DEFUN(CL_BOOL,
  631. [AC_LANG_SAVE()
  632. AC_LANG_CPLUSPLUS()
  633. CL_COMPILE_CHECK([bool type], cl_cv_cplusplus_bool, , [bool x;],
  634. AC_DEFINE(HAVE_BOOL), AC_DEFINE(bool,int))dnl
  635. AC_LANG_RESTORE()
  636. ])dnl
  637. dnl
  638. AC_DEFUN(CL_MACHINE,
  639. [AC_REQUIRE([AC_PROG_CC])dnl
  640. AC_REQUIRE([CL_CHAR_UNSIGNED])dnl
  641. cl_machine_file_c=$2
  642. cl_machine_file_h=$3
  643. if test $cross_compiling = no; then
  644. if test -z "$[$4]"; then
  645. AC_CHECKING(for [$1])
  646. cat > conftest.$ac_ext <<EOF
  647. #include "confdefs.h"
  648. EOF
  649. cat "$cl_machine_file_c" >> conftest.$ac_ext
  650. ORIGCC="$CC"
  651. if test $ac_cv_prog_gcc = yes; then
  652. # gcc -O (gcc version <= 2.3.2) crashes when compiling long long shifts for
  653. # target 80386. Strip "-O".
  654. CC=`echo "$CC " | sed -e 's/-O //g'`
  655. fi
  656. AC_TRY_EVAL(ac_link)
  657. CC="$ORIGCC"
  658. if test -s conftest; then
  659. echo "creating $cl_machine_file_h"
  660. ./conftest > conftest.h
  661. if cmp -s "$cl_machine_file_h" conftest.h 2>/dev/null; then
  662. # The file exists and we would not be changing it
  663. rm -f conftest.h
  664. else
  665. rm -f "$cl_machine_file_h"
  666. mv conftest.h "$cl_machine_file_h"
  667. fi
  668. [$4]=1
  669. else
  670. echo "creation of $cl_machine_file_h failed"
  671. fi
  672. rm -f conftest*
  673. fi
  674. else
  675. echo "cross-compiling - cannot create $cl_machine_file_h"
  676. fi
  677. ])dnl
  678. dnl
  679. ## libtool.m4 - Configure libtool for the target system. -*-Shell-script-*-
  680. ## Copyright (C) 1996-1998 Free Software Foundation, Inc.
  681. ## Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996
  682. ##
  683. ## This program is free software; you can redistribute it and/or modify
  684. ## it under the terms of the GNU General Public License as published by
  685. ## the Free Software Foundation; either version 2 of the License, or
  686. ## (at your option) any later version.
  687. ##
  688. ## This program is distributed in the hope that it will be useful, but
  689. ## WITHOUT ANY WARRANTY; without even the implied warranty of
  690. ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  691. ## General Public License for more details.
  692. ##
  693. ## You should have received a copy of the GNU General Public License
  694. ## along with this program; if not, write to the Free Software
  695. ## Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  696. ##
  697. ## As a special exception to the GNU General Public License, if you
  698. ## distribute this file as part of a program that contains a
  699. ## configuration script generated by Autoconf, you may include it under
  700. ## the same distribution terms that you use for the rest of that program.
  701. # serial 24 AM_PROG_LIBTOOL
  702. AC_DEFUN(AM_PROG_LIBTOOL,
  703. [AC_REQUIRE([AM_ENABLE_SHARED])dnl
  704. AC_REQUIRE([AM_ENABLE_STATIC])dnl
  705. AC_REQUIRE([CL_CANONICAL_HOST])dnl
  706. AC_REQUIRE([CL_PROG_RANLIB])dnl
  707. AC_REQUIRE([AC_PROG_CC])dnl
  708. AC_REQUIRE([AM_PROG_LD])dnl
  709. AC_REQUIRE([AM_PROG_NM])dnl
  710. AC_REQUIRE([AC_PROG_LN_S])dnl
  711. dnl
  712. # Always use our own libtool.
  713. LIBTOOL='$(SHELL) $(top_builddir)/libtool'
  714. AC_SUBST(LIBTOOL)dnl
  715. # Check for any special flags to pass to ltconfig.
  716. libtool_flags=
  717. test "$enable_shared" = no && libtool_flags="$libtool_flags --disable-shared"
  718. test "$enable_static" = no && libtool_flags="$libtool_flags --disable-static"
  719. test "$silent" = yes && libtool_flags="$libtool_flags --silent"
  720. test "$ac_cv_prog_gcc" = yes && libtool_flags="$libtool_flags --with-gcc"
  721. test "$ac_cv_prog_gnu_ld" = yes && libtool_flags="$libtool_flags --with-gnu-ld"
  722. # Some flags need to be propagated to the compiler or linker for good
  723. # libtool support.
  724. case "$host" in
  725. *-*-irix6*)
  726. # Find out which ABI we are using.
  727. echo '[#]line __oline__ "configure"' > conftest.$ac_ext
  728. if AC_TRY_EVAL(ac_compile); then
  729. case "`/usr/bin/file conftest.o`" in
  730. *32-bit*)
  731. LD="${LD-ld} -32"
  732. ;;
  733. *N32*)
  734. LD="${LD-ld} -n32"
  735. ;;
  736. *64-bit*)
  737. LD="${LD-ld} -64"
  738. ;;
  739. esac
  740. fi
  741. rm -rf conftest*
  742. ;;
  743. *-*-sco3.2v5*)
  744. # On SCO OpenServer 5, we need -belf to get full-featured binaries.
  745. CFLAGS="$CFLAGS -belf"
  746. ;;
  747. esac
  748. # Actually configure libtool. ac_aux_dir is where install-sh is found.
  749. CC="$CC" CFLAGS="$CFLAGS" CPPFLAGS="$CPPFLAGS" \
  750. LD="$LD" NM="$NM" RANLIB="$RANLIB" LN_S="$LN_S" \
  751. ${CONFIG_SHELL-/bin/sh} $ac_aux_dir/ltconfig \
  752. $libtool_flags --no-verify $ac_aux_dir/ltmain.sh $host \
  753. || AC_MSG_ERROR([libtool configure failed])
  754. ])
  755. # AM_ENABLE_SHARED - implement the --enable-shared flag
  756. # Usage: AM_ENABLE_SHARED[(DEFAULT)]
  757. # Where DEFAULT is either `yes' or `no'. If omitted, it defaults to
  758. # `yes'.
  759. AC_DEFUN(AM_ENABLE_SHARED,
  760. [define([AM_ENABLE_SHARED_DEFAULT], ifelse($1, no, no, yes))dnl
  761. AC_ARG_ENABLE(shared,
  762. changequote(<<, >>)dnl
  763. << --enable-shared build shared libraries [default=>>AM_ENABLE_SHARED_DEFAULT]
  764. changequote([, ])dnl
  765. [ --enable-shared=PKGS only build shared libraries if the current package
  766. appears as an element in the PKGS list],
  767. [p=${PACKAGE-default}
  768. case "$enableval" in
  769. yes) enable_shared=yes ;;
  770. no) enable_shared=no ;;
  771. *)
  772. enable_shared=no
  773. # Look at the argument we got. We use all the common list separators.
  774. IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:,"
  775. for pkg in $enableval; do
  776. if test "X$pkg" = "X$p"; then
  777. enable_shared=yes
  778. fi
  779. done
  780. IFS="$ac_save_ifs"
  781. ;;
  782. esac],
  783. enable_shared=AM_ENABLE_SHARED_DEFAULT)dnl
  784. ])
  785. # AM_DISABLE_SHARED - set the default shared flag to --disable-shared
  786. AC_DEFUN(AM_DISABLE_SHARED,
  787. [AM_ENABLE_SHARED(no)])
  788. # AM_DISABLE_STATIC - set the default static flag to --disable-static
  789. AC_DEFUN(AM_DISABLE_STATIC,
  790. [AM_ENABLE_STATIC(no)])
  791. # AM_ENABLE_STATIC - implement the --enable-static flag
  792. # Usage: AM_ENABLE_STATIC[(DEFAULT)]
  793. # Where DEFAULT is either `yes' or `no'. If omitted, it defaults to
  794. # `yes'.
  795. AC_DEFUN(AM_ENABLE_STATIC,
  796. [define([AM_ENABLE_STATIC_DEFAULT], ifelse($1, no, no, yes))dnl
  797. AC_ARG_ENABLE(static,
  798. changequote(<<, >>)dnl
  799. << --enable-static build static libraries [default=>>AM_ENABLE_STATIC_DEFAULT]
  800. changequote([, ])dnl
  801. [ --enable-static=PKGS only build shared libraries if the current package
  802. appears as an element in the PKGS list],
  803. [p=${PACKAGE-default}
  804. case "$enableval" in
  805. yes) enable_static=yes ;;
  806. no) enable_static=no ;;
  807. *)
  808. enable_static=no
  809. # Look at the argument we got. We use all the common list separators.
  810. IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:,"
  811. for pkg in $enableval; do
  812. if test "X$pkg" = "X$p"; then
  813. enable_static=yes
  814. fi
  815. done
  816. IFS="$ac_save_ifs"
  817. ;;
  818. esac],
  819. enable_static=AM_ENABLE_STATIC_DEFAULT)dnl
  820. ])
  821. # AM_PROG_LD - find the path to the GNU or non-GNU linker
  822. AC_DEFUN(AM_PROG_LD,
  823. [AC_ARG_WITH(gnu-ld,
  824. [ --with-gnu-ld assume the C compiler uses GNU ld [default=no]],
  825. test "$withval" = no || with_gnu_ld=yes, with_gnu_ld=no)
  826. AC_REQUIRE([AC_PROG_CC])
  827. ac_prog=ld
  828. if test "$ac_cv_prog_gcc" = yes; then
  829. # Check if gcc -print-prog-name=ld gives a path.
  830. AC_MSG_CHECKING([for ld used by GCC])
  831. ac_prog=`($CC -print-prog-name=ld) 2>&5`
  832. case "$ac_prog" in
  833. # Accept absolute paths.
  834. /* | [A-Za-z]:\\*)
  835. test -z "$LD" && LD="$ac_prog"
  836. ;;
  837. "")
  838. # If it fails, then pretend we aren't using GCC.
  839. ac_prog=ld
  840. ;;
  841. *)
  842. # If it is relative, then search for the first ld in PATH.
  843. with_gnu_ld=unknown
  844. ;;
  845. esac
  846. elif test "$with_gnu_ld" = yes; then
  847. AC_MSG_CHECKING([for GNU ld])
  848. else
  849. AC_MSG_CHECKING([for non-GNU ld])
  850. fi
  851. AC_CACHE_VAL(ac_cv_path_LD,
  852. [if test -z "$LD"; then
  853. IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:"
  854. for ac_dir in $PATH; do
  855. test -z "$ac_dir" && ac_dir=.
  856. if test -f "$ac_dir/$ac_prog"; then
  857. ac_cv_path_LD="$ac_dir/$ac_prog"
  858. # Check to see if the program is GNU ld. I'd rather use --version,
  859. # but apparently some GNU ld's only accept -v.
  860. # Break only if it was the GNU/non-GNU ld that we prefer.
  861. if "$ac_cv_path_LD" -v 2>&1 < /dev/null | egrep '(GNU|with BFD)' > /dev/null; then
  862. test "$with_gnu_ld" != no && break
  863. else
  864. test "$with_gnu_ld" != yes && break
  865. fi
  866. fi
  867. done
  868. IFS="$ac_save_ifs"
  869. else
  870. ac_cv_path_LD="$LD" # Let the user override the test with a path.
  871. fi])
  872. LD="$ac_cv_path_LD"
  873. if test -n "$LD"; then
  874. AC_MSG_RESULT($LD)
  875. else
  876. AC_MSG_RESULT(no)
  877. fi
  878. test -z "$LD" && AC_MSG_ERROR([no acceptable ld found in \$PATH])
  879. AC_SUBST(LD)
  880. AM_PROG_LD_GNU
  881. ])
  882. AC_DEFUN(AM_PROG_LD_GNU,
  883. [AC_CACHE_CHECK([if the linker ($LD) is GNU ld], ac_cv_prog_gnu_ld,
  884. [# I'd rather use --version here, but apparently some GNU ld's only accept -v.
  885. if $LD -v 2>&1 </dev/null | egrep '(GNU|with BFD)' 1>&5; then
  886. ac_cv_prog_gnu_ld=yes
  887. else
  888. ac_cv_prog_gnu_ld=no
  889. fi])
  890. ])
  891. # AM_PROG_NM - find the path to a BSD-compatible name lister
  892. AC_DEFUN(AM_PROG_NM,
  893. [AC_MSG_CHECKING([for BSD-compatible nm])
  894. AC_CACHE_VAL(ac_cv_path_NM,
  895. [case "$NM" in
  896. /* | [A-Za-z]:\\*)
  897. ac_cv_path_NM="$NM" # Let the user override the test with a path.
  898. ;;
  899. *)
  900. IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:"
  901. for ac_dir in /usr/ucb /usr/ccs/bin $PATH /bin; do
  902. test -z "$ac_dir" && ac_dir=.
  903. if test -f $ac_dir/nm; then
  904. # Check to see if the nm accepts a BSD-compat flag.
  905. # Adding the `sed 1q' prevents false positives on HP-UX, which says:
  906. # nm: unknown option "B" ignored
  907. if ($ac_dir/nm -B /dev/null 2>&1 | sed '1q'; exit 0) | egrep /dev/null >/dev/null; then
  908. ac_cv_path_NM="$ac_dir/nm -B"
  909. elif ($ac_dir/nm -p /dev/null 2>&1 | sed '1q'; exit 0) | egrep /dev/null >/dev/null; then
  910. ac_cv_path_NM="$ac_dir/nm -p"
  911. else
  912. ac_cv_path_NM="$ac_dir/nm"
  913. fi
  914. break
  915. fi
  916. done
  917. IFS="$ac_save_ifs"
  918. test -z "$ac_cv_path_NM" && ac_cv_path_NM=nm
  919. ;;
  920. esac])
  921. NM="$ac_cv_path_NM"
  922. AC_MSG_RESULT([$NM])
  923. AC_SUBST(NM)
  924. ])