2 dnl * If we have gettimeofday;
3 dnl * If we have struct timezone for use in calling it;
4 dnl * If calling it with a timezone pointer actually works -- this is deemed
5 dnl obsolete or undefined on some systems which say you should use a null
6 dnl pointer -- and undefine HAVE_TIMEZONE if so;
7 dnl * Whether it only takes one arg.
8 AC_DEFUN([LIBGFOR_GETTIMEOFDAY], [
9 AC_CHECK_FUNCS(gettimeofday)
10 if test "$ac_cv_func_gettimeofday" = yes; then
11 AC_CACHE_CHECK([for struct timezone], gfor_cv_struct_timezone,
12 [AC_TRY_COMPILE([#include <sys/time.h>],
13 [struct timezone tz;],
14 gfor_cv_struct_timezone=yes, gfor_cv_struct_timezone=no)])
15 if test $gfor_cv_struct_timezone = yes; then
16 dnl It may be that we can't call gettimeofday with a non-null pointer.
17 dnl In that case we'll lie about struct timezone.
19 #ifdef TIME_WITH_SYS_TIME
23 #ifdef HAVE_SYS_TIME_H
32 struct timezone dummy;
33 if (gettimeofday (&time, &dummy))
38 [gfor_have_struct_timezone=yes], [gfor_have_struct_timezone=no],
39 [gfor_have_struct_timezone=yes])
40 if test $gfor_have_struct_timezone = yes; then
41 AC_DEFINE(HAVE_TIMEZONE, 1, [Do we have struct timezone])
44 AC_REQUIRE([AC_HEADER_TIME])
45 AC_CACHE_CHECK([whether gettimeofday can accept two arguments],
46 emacs_cv_gettimeofday_two_arguments,
48 #ifdef TIME_WITH_SYS_TIME
52 #ifdef HAVE_SYS_TIME_H
62 struct timezone dummy;
67 gettimeofday (&time, DUMMY);],
68 emacs_cv_gettimeofday_two_arguments=yes,
69 emacs_cv_gettimeofday_two_arguments=no)])
70 if test $emacs_cv_gettimeofday_two_arguments = no; then
71 AC_DEFINE(GETTIMEOFDAY_ONE_ARGUMENT, 1,
72 [Does gettimeofday take a single argument])
76 sinclude(../libtool.m4)
77 dnl The lines below arrange for aclocal not to bring an installed
78 dnl libtool.m4 into aclocal.m4, while still arranging for automake to
79 dnl add a definition of LIBTOOL to Makefile.in.
80 ifelse(,,,[AC_SUBST(LIBTOOL)
81 AC_DEFUN([AM_PROG_LIBTOOL])
82 AC_DEFUN([AC_LIBTOOL_DLOPEN])
83 AC_DEFUN([AC_PROG_LD])
86 dnl Check whether the target is ILP32.
87 AC_DEFUN([LIBGFOR_TARGET_ILP32], [
88 AC_CACHE_CHECK([whether the target is ILP32], target_ilp32, [
92 if (sizeof(int) == 4 && sizeof(long) == 4 && sizeof(void *) == 4)
95 undefined_function ();
99 CFLAGS="$save_CFLAGS"])
100 if test $target_ilp32 = yes; then
101 AC_DEFINE(TARGET_ILP32, 1,
102 [Define to 1 if the target is ILP32.])
106 dnl Check whether the target supports hidden visibility.
107 AC_DEFUN([LIBGFOR_CHECK_ATTRIBUTE_VISIBILITY], [
108 AC_CACHE_CHECK([whether the target supports hidden visibility],
109 have_attribute_visibility, [
110 save_CFLAGS="$CFLAGS"
111 CFLAGS="$CFLAGS -Werror"
112 AC_TRY_COMPILE([void __attribute__((visibility("hidden"))) foo(void) { }],
113 [], have_attribute_visibility=yes,
114 have_attribute_visibility=no)
115 CFLAGS="$save_CFLAGS"])
116 if test $have_attribute_visibility = yes; then
117 AC_DEFINE(HAVE_ATTRIBUTE_VISIBILITY, 1,
118 [Define to 1 if the target supports __attribute__((visibility(...))).])
121 dnl Check whether the target supports dllexport
122 AC_DEFUN([LIBGFOR_CHECK_ATTRIBUTE_DLLEXPORT], [
123 AC_CACHE_CHECK([whether the target supports dllexport],
124 have_attribute_dllexport, [
125 save_CFLAGS="$CFLAGS"
126 CFLAGS="$CFLAGS -Werror"
127 AC_TRY_COMPILE([void __attribute__((dllexport)) foo(void) { }],
128 [], have_attribute_dllexport=yes,
129 have_attribute_dllexport=no)
130 CFLAGS="$save_CFLAGS"])
131 if test $have_attribute_dllexport = yes; then
132 AC_DEFINE(HAVE_ATTRIBUTE_DLLEXPORT, 1,
133 [Define to 1 if the target supports __attribute__((dllexport)).])
136 dnl Check whether the target supports symbol aliases.
137 AC_DEFUN([LIBGFOR_CHECK_ATTRIBUTE_ALIAS], [
138 AC_CACHE_CHECK([whether the target supports symbol aliases],
139 have_attribute_alias, [
141 #define ULP STR1(__USER_LABEL_PREFIX__)
142 #define STR1(x) STR2(x)
145 extern void bar(void) __attribute__((alias(ULP "foo")));],
146 [bar();], have_attribute_alias=yes, have_attribute_alias=no)])
147 if test $have_attribute_alias = yes; then
148 AC_DEFINE(HAVE_ATTRIBUTE_ALIAS, 1,
149 [Define to 1 if the target supports __attribute__((alias(...))).])
152 dnl Check whether target can unlink a file still open.
153 AC_DEFUN([LIBGFOR_CHECK_UNLINK_OPEN_FILE], [
154 AC_CACHE_CHECK([whether the target can unlink an open file],
155 have_unlink_open_file, [
160 #include <sys/stat.h>
166 fd = open ("testfile", O_RDWR | O_CREAT, S_IWRITE | S_IREAD);
169 if (unlink ("testfile") == -1)
171 write (fd, "This is a test\n", 15);
174 if (open ("testfile", O_RDONLY, S_IWRITE | S_IREAD) == -1 && errno == ENOENT)
178 }], have_unlink_open_file=yes, have_unlink_open_file=no, [
180 *mingw*) have_unlink_open_file=no ;;
181 *) have_unlink_open_file=yes;;
183 if test x"$have_unlink_open_file" = xyes; then
184 AC_DEFINE(HAVE_UNLINK_OPEN_FILE, 1, [Define if target can unlink open files.])
187 dnl Check whether CRLF is the line terminator
188 AC_DEFUN([LIBGFOR_CHECK_CRLF], [
189 AC_CACHE_CHECK([whether the target has CRLF as line terminator],
192 /* This test program should exit with status 0 if system uses a CRLF as
193 line terminator, and status 1 otherwise.
194 Since it is used to check for mingw systems, and should return 0 in any
195 other case, in case of a failure we will not use CRLF. */
196 #include <sys/stat.h>
209 fd = open ("foo", O_WRONLY | O_CREAT | O_TRUNC, S_IRWXU);
212 if (write (fd, "\n", 1) < 0)
217 if ((fd = open ("foo", O_RDONLY | O_BINARY, S_IRWXU)) < 0)
219 bytes = read (fd, buff, 5);
220 if (bytes == 2 && buff[0] == '\r' && buff[1] == '\n')
225 }], have_crlf=yes, have_crlf=no, [
227 *mingw*) have_crlf=yes ;;
230 if test x"$have_crlf" = xyes; then
231 AC_DEFINE(HAVE_CRLF, 1, [Define if CRLF is line terminator.])
234 dnl Check whether isfinite is broken.
235 dnl The most common problem is that it does not work on long doubles.
236 AC_DEFUN([LIBGFOR_CHECK_FOR_BROKEN_ISFINITE], [
237 AC_CACHE_CHECK([whether isfinite is broken],
238 have_broken_isfinite, [
239 libgfor_check_for_broken_isfinite_save_LIBS=$LIBS
250 if (!isfinite(LDBL_MAX)) return 1;
253 if (!isfinite(DBL_MAX)) return 1;
257 }], have_broken_isfinite=no, have_broken_isfinite=yes, [
259 hppa*-*-hpux*) have_broken_isfinite=yes ;;
260 *) have_broken_isfinite=no ;;
262 LIBS=$libgfor_check_for_broken_isfinite_save_LIBS)
263 if test x"$have_broken_isfinite" = xyes; then
264 AC_DEFINE(HAVE_BROKEN_ISFINITE, 1, [Define if isfinite is broken.])
267 dnl Check whether isnan is broken.
268 dnl The most common problem is that it does not work on long doubles.
269 AC_DEFUN([LIBGFOR_CHECK_FOR_BROKEN_ISNAN], [
270 AC_CACHE_CHECK([whether isnan is broken],
272 libgfor_check_for_broken_isnan_save_LIBS=$LIBS
285 x = __builtin_nanl ("");
286 if (!isnan(x)) return 1;
287 if (isnan(LDBL_MAX)) return 1;
289 x = (long double) NAN;
290 if (!isnan(x)) return 1;
297 y = __builtin_nan ("");
298 if (!isnan(y)) return 1;
299 if (isnan(DBL_MAX)) return 1;
302 if (!isnan(y)) return 1;
308 }], have_broken_isnan=no, have_broken_isnan=yes, [
310 hppa*-*-hpux*) have_broken_isnan=yes ;;
311 *) have_broken_isnan=no ;;
313 LIBS=$libgfor_check_for_broken_isnan_save_LIBS)
314 if test x"$have_broken_isnan" = xyes; then
315 AC_DEFINE(HAVE_BROKEN_ISNAN, 1, [Define if isnan is broken.])
318 dnl Check whether fpclassify is broken.
319 dnl The most common problem is that it does not work on long doubles.
320 AC_DEFUN([LIBGFOR_CHECK_FOR_BROKEN_FPCLASSIFY], [
321 AC_CACHE_CHECK([whether fpclassify is broken],
322 have_broken_fpclassify, [
323 libgfor_check_for_broken_fpclassify_save_LIBS=$LIBS
334 if (fpclassify(LDBL_MAX) == FP_NAN
335 || fpclassify(LDBL_MAX) == FP_INFINITE) return 1;
338 if (fpclassify(DBL_MAX) == FP_NAN
339 || fpclassify(DBL_MAX) == FP_INFINITE) return 1;
343 }], have_broken_fpclassify=no, have_broken_fpclassify=yes, [
345 hppa*-*-hpux*) have_broken_fpclassify=yes ;;
346 *) have_broken_fpclassify=no ;;
348 LIBS=$libgfor_check_for_broken_fpclassify_save_LIBS)
349 if test x"$have_broken_fpclassify" = xyes; then
350 AC_DEFINE(HAVE_BROKEN_FPCLASSIFY, 1, [Define if fpclassify is broken.])