acinclude.m4 6.9 KB

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