acinclude.m4 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284
  1. dnl cloned from autoconf 2.13 acspecific.m4
  2. AC_DEFUN([AC_C_LONG_LONG],
  3. [AC_CACHE_CHECK(for long long, ac_cv_c_long_long,
  4. [if test "$GCC" = yes; then
  5. ac_cv_c_long_long=yes
  6. else
  7. AC_TRY_RUN([int main() {
  8. long long foo = 0;
  9. exit(sizeof(long long) < sizeof(long)); }],
  10. ac_cv_c_long_long=yes, ac_cv_c_long_long=no)
  11. fi])
  12. if test $ac_cv_c_long_long = yes; then
  13. AC_DEFINE(HAVE_LONG_LONG)
  14. fi
  15. ])
  16. dnl from autoconf 2.13 acspecific.m4, with changes to check for daylight
  17. AC_DEFUN([AC_STRUCT_TIMEZONE_DAYLIGHT],
  18. [AC_REQUIRE([AC_STRUCT_TM])dnl
  19. AC_CACHE_CHECK([for tm_zone in struct tm], ac_cv_struct_tm_zone,
  20. [AC_TRY_COMPILE([#include <sys/types.h>
  21. #include <$ac_cv_struct_tm>], [struct tm tm; tm.tm_zone;],
  22. ac_cv_struct_tm_zone=yes, ac_cv_struct_tm_zone=no)])
  23. if test "$ac_cv_struct_tm_zone" = yes; then
  24. AC_DEFINE(HAVE_TM_ZONE,1,[HAVE_TM_ZONE])
  25. fi
  26. AC_CACHE_CHECK(for tzname, ac_cv_var_tzname,
  27. [AC_TRY_LINK(
  28. changequote(<<, >>)dnl
  29. <<#include <time.h>
  30. #ifndef tzname /* For SGI. */
  31. extern char *tzname[]; /* RS6000 and others reject char **tzname. */
  32. #endif>>,
  33. changequote([, ])dnl
  34. [atoi(*tzname);], ac_cv_var_tzname=yes, ac_cv_var_tzname=no)])
  35. if test $ac_cv_var_tzname = yes; then
  36. AC_DEFINE(HAVE_TZNAME,1,[HAVE_TZNAME])
  37. fi
  38. AC_CACHE_CHECK([for tm_isdst in struct tm], ac_cv_struct_tm_isdst,
  39. [AC_TRY_COMPILE([#include <sys/types.h>
  40. #include <$ac_cv_struct_tm>], [struct tm tm; tm.tm_isdst;],
  41. ac_cv_struct_tm_isdst=yes, ac_cv_struct_tm_isdst=no)])
  42. if test "$ac_cv_struct_tm_isdst" = yes; then
  43. AC_DEFINE(HAVE_TM_ISDST)
  44. fi
  45. AC_CACHE_CHECK(for daylight, ac_cv_var_daylight,
  46. [AC_TRY_LINK(
  47. changequote(<<, >>)dnl
  48. <<#include <time.h>
  49. #ifndef daylight /* In case IRIX #defines this, too */
  50. extern int daylight;
  51. #endif>>,
  52. changequote([, ])dnl
  53. [atoi(daylight);], ac_cv_var_daylight=yes, ac_cv_var_daylight=no)])
  54. if test $ac_cv_var_daylight = yes; then
  55. AC_DEFINE(HAVE_DAYLIGHT)
  56. fi
  57. ])
  58. dnl from autoconf 2.13 acgeneral.m4, with patch:
  59. dnl Date: Fri, 15 Jan 1999 05:52:41 -0800
  60. dnl Message-ID: <199901151352.FAA18237@shade.twinsun.com>
  61. dnl From: eggert@twinsun.com (Paul Eggert)
  62. dnl Subject: autoconf 2.13 AC_CHECK_TYPE doesn't allow shell vars
  63. dnl Newsgroups: gnu.utils.bug
  64. dnl
  65. dnl now include <stdint.h> if available
  66. dnl AC_CHECK_TYPE2_STDC(TYPE, DEFAULT)
  67. AC_DEFUN([AC_CHECK_TYPE2_STDC],
  68. [AC_REQUIRE([AC_HEADER_STDC])dnl
  69. AC_REQUIRE([AC_HEADER_STDINT])dnl
  70. AC_MSG_CHECKING(for $1)
  71. AC_CACHE_VAL(ac_cv_type_$1,
  72. [AC_EGREP_CPP(dnl
  73. [(^|[^a-zA-Z_0-9])$1[^a-zA-Z_0-9]],
  74. [#if HAVE_STDINT_H
  75. #include <stdint.h>
  76. #endif
  77. #include <sys/types.h>
  78. #if STDC_HEADERS
  79. #include <stdlib.h>
  80. #include <stddef.h>
  81. #endif], eval "ac_cv_type_$1=yes", eval "ac_cv_type_$1=no")])dnl
  82. if eval "test \"`echo '$ac_cv_type_'$1`\" = yes"; then
  83. AC_MSG_RESULT(yes)
  84. else
  85. AC_MSG_RESULT(no)
  86. AC_DEFINE_UNQUOTED($1, $2)
  87. fi
  88. ])
  89. dnl from autoconf 2.13 acgeneral.m4, with additional third argument
  90. dnl AC_CHECK_SIZEOF_INCLUDES(TYPE [, CROSS-SIZE [, INCLUDES]])
  91. AC_DEFUN([AC_CHECK_SIZEOF_INCLUDES],
  92. [dnl The name to #define.
  93. define([AC_TYPE_NAME], translit(sizeof_$1, [[[a-z *]]], [[[A-Z_P]]]))dnl
  94. dnl The cache variable name.
  95. define([AC_CV_NAME], translit(ac_cv_sizeof_$1, [[[ *]]], [[[_p]]]))dnl
  96. AC_MSG_CHECKING(size of $1)
  97. AC_CACHE_VAL(AC_CV_NAME,
  98. [AC_TRY_RUN([$3
  99. #include <stdio.h>
  100. main()
  101. {
  102. FILE *f=fopen("conftestval", "w");
  103. if (!f) exit(1);
  104. fprintf(f, "%d\n", sizeof($1));
  105. exit(0);
  106. }], AC_CV_NAME=`cat conftestval`, AC_CV_NAME=0, ifelse([$2], , , AC_CV_NAME=$2))])dnl
  107. AC_MSG_RESULT($AC_CV_NAME)
  108. AC_DEFINE_UNQUOTED(AC_TYPE_NAME, $AC_CV_NAME)
  109. undefine([AC_TYPE_NAME])dnl
  110. undefine([AC_CV_NAME])dnl
  111. ])
  112. dnl AC_CHECK_SIZEOF_STDC_HEADERS(TYPE [, CROSS_SIZE])
  113. AC_DEFUN([AC_CHECK_SIZEOF_STDC_HEADERS],
  114. [AC_REQUIRE([AC_HEADER_STDC])dnl
  115. AC_REQUIRE([AC_HEADER_STDINT])dnl
  116. AC_CHECK_SIZEOF_INCLUDES($1, $2,
  117. [#if HAVE_STDINT_H
  118. #include <stdint.h>
  119. #endif
  120. #include <sys/types.h>
  121. #ifdef STDC_HEADERS
  122. #include <stdlib.h>
  123. #endif
  124. ])
  125. ])
  126. dnl AC_CHECK_TYPE_STDC(TYPE, DEFAULT)
  127. AC_DEFUN([AC_CHECK_TYPE_STDC],
  128. [AC_REQUIRE([AC_HEADER_STDC])dnl
  129. AC_REQUIRE([AC_HEADER_STDINT])dnl
  130. AC_MSG_CHECKING(for $1)
  131. AC_CACHE_VAL(ac_cv_type_$1,
  132. [AC_EGREP_CPP(dnl
  133. [(^|[^a-zA-Z_0-9])$1[^a-zA-Z_0-9]],
  134. [#if HAVE_STDINT_H
  135. #include <stdint.h>
  136. #endif
  137. #include <sys/types.h>
  138. #if STDC_HEADERS
  139. #include <stdlib.h>
  140. #include <stddef.h>
  141. #endif], ac_cv_type_$1=yes, ac_cv_type_$1=no)])dnl
  142. AC_MSG_RESULT($ac_cv_type_$1)
  143. if test $ac_cv_type_$1 = no; then
  144. AC_DEFINE($1, $2)
  145. fi
  146. ])
  147. dnl AC_HEADER_STDINT
  148. AC_DEFUN([AC_HEADER_STDINT], [AC_CHECK_HEADERS(stdint.h)])
  149. #serial 19
  150. dnl By default, many hosts won't let programs access large files;
  151. dnl one must use special compiler options to get large-file access to work.
  152. dnl For more details about this brain damage please see:
  153. dnl http://www.sas.com/standards/large.file/x_open.20Mar96.html
  154. dnl Written by Paul Eggert <eggert@twinsun.com>.
  155. dnl Internal subroutine of AC_SYS_LARGEFILE.
  156. dnl AC_SYS_LARGEFILE_TEST_INCLUDES
  157. AC_DEFUN([AC_SYS_LARGEFILE_TEST_INCLUDES],
  158. [[#include <sys/types.h>
  159. /* Check that off_t can represent 2**63 - 1 correctly.
  160. We can't simply "#define LARGE_OFF_T 9223372036854775807",
  161. since some C++ compilers masquerading as C compilers
  162. incorrectly reject 9223372036854775807. */
  163. # define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))
  164. int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721
  165. && LARGE_OFF_T % 2147483647 == 1)
  166. ? 1 : -1];
  167. ]])
  168. dnl Internal subroutine of AC_SYS_LARGEFILE.
  169. dnl AC_SYS_LARGEFILE_MACRO_VALUE(C-MACRO, VALUE, CACHE-VAR, COMMENT, INCLU=
  170. DES, FUNCTION-BODY)
  171. AC_DEFUN([AC_SYS_LARGEFILE_MACRO_VALUE],
  172. [AC_CACHE_CHECK([for $1 value needed for large files], $3,
  173. [$3=no
  174. AC_TRY_COMPILE([$5],
  175. [$6],
  176. ,
  177. [AC_TRY_COMPILE([#define $1 $2]
  178. [$5]
  179. ,
  180. [$6],
  181. [$3=$2])])])
  182. if test "[$]$3" != no; then
  183. AC_DEFINE_UNQUOTED([$1], [$]$3, [$4])
  184. fi])
  185. AC_DEFUN([AC_SYS_LARGEFILE],
  186. [AC_REQUIRE([AC_PROG_CC])
  187. AC_ARG_ENABLE(largefile,
  188. [ --disable-largefile omit support for large files])
  189. if test "$enable_largefile" != no; then
  190. AC_CACHE_CHECK([for special C compiler options needed for large files=
  191. ],
  192. ac_cv_sys_largefile_CC,
  193. [ac_cv_sys_largefile_CC=no
  194. if test "$GCC" != yes; then
  195. # IRIX 6.2 and later do not support large files by default,
  196. # so use the C compiler's -n32 option if that helps.
  197. AC_TRY_COMPILE(AC_SYS_LARGEFILE_TEST_INCLUDES, , ,
  198. [ac_save_CC="$CC"
  199. CC="$CC -n32"
  200. AC_TRY_COMPILE(AC_SYS_LARGEFILE_TEST_INCLUDES, ,
  201. ac_cv_sys_largefile_CC=' -n32')
  202. CC="$ac_save_CC"])
  203. fi])
  204. if test "$ac_cv_sys_largefile_CC" != no; then
  205. CC="$CC$ac_cv_sys_largefile_CC"
  206. fi
  207. AC_SYS_LARGEFILE_MACRO_VALUE(_FILE_OFFSET_BITS, 64,
  208. ac_cv_sys_file_offset_bits,
  209. [Number of bits in a file offset, on hosts where this is settable.],
  210. AC_SYS_LARGEFILE_TEST_INCLUDES)
  211. AC_SYS_LARGEFILE_MACRO_VALUE(_LARGE_FILES, 1,
  212. ac_cv_sys_large_files,
  213. [Define for large files, on AIX-style hosts.],
  214. AC_SYS_LARGEFILE_TEST_INCLUDES)
  215. fi
  216. ])
  217. AC_DEFUN([AC_FUNC_FSEEKO],
  218. [AC_SYS_LARGEFILE_MACRO_VALUE(_LARGEFILE_SOURCE, 1,
  219. ac_cv_sys_largefile_source,
  220. [Define to make fseeko visible on some hosts (e.g. glibc 2.2).],
  221. [#include <stdio.h>], [return !fseeko;])
  222. # We used to try defining _XOPEN_SOURCE=500 too, to work around a bug
  223. # in glibc 2.1.3, but that breaks too many other things.
  224. # If you want fseeko and ftello with glibc, upgrade to a fixed glibc.
  225. AC_CACHE_CHECK([for fseeko], ac_cv_func_fseeko,
  226. [ac_cv_func_fseeko=no
  227. AC_TRY_LINK([#include <stdio.h>],
  228. [return fseeko && fseeko (stdin, 0, 0);],
  229. [ac_cv_func_fseeko=yes])])
  230. if test $ac_cv_func_fseeko != no; then
  231. AC_DEFINE(HAVE_FSEEKO, 1,
  232. [Define if fseeko (and presumably ftello) exists and is declared.])
  233. fi])
  234. # serial 9
  235. # From Paul Eggert.
  236. # BeOS 5 has <wchar.h> but does not define mbstate_t,
  237. # so you can't declare an object of that type.
  238. # Check for this incompatibility with Standard C.
  239. # Include stdlib.h first, because otherwise this test would fail on Linux
  240. # (at least glibc-2.1.3) because the "_XOPEN_SOURCE 500" definition elicits
  241. # a syntax error in wchar.h due to the use of undefined __int32_t.
  242. AC_DEFUN([AC_MBSTATE_T],
  243. [
  244. AC_CHECK_HEADERS(stdlib.h)
  245. AC_CACHE_CHECK([for mbstate_t], ac_cv_type_mbstate_t,
  246. [AC_TRY_COMPILE([
  247. #if HAVE_STDLIB_H
  248. # include <stdlib.h>
  249. #endif
  250. #include <wchar.h>],
  251. [mbstate_t x; return sizeof x;],
  252. ac_cv_type_mbstate_t=yes,
  253. ac_cv_type_mbstate_t=no)])
  254. if test $ac_cv_type_mbstate_t = no; then
  255. AC_DEFINE(mbstate_t, int,
  256. [Define to a type if <wchar.h> does not define.])
  257. fi])