1 m4_include(../config/acx.m4)
2 m4_include(../config/no-executables.m4)
4 dnl Check that we have a working GNU Fortran compiler
5 AC_DEFUN([LIBGFOR_WORKING_GFORTRAN], [
6 AC_MSG_CHECKING([whether the GNU Fortran compiler is working])
7 AC_LANG_PUSH([Fortran])
10 real, parameter :: bar = sin (12.34 / 2.5)
12 [AC_MSG_RESULT([yes])],
14 AC_MSG_ERROR([GNU Fortran is not working; please report a bug in http://gcc.gnu.org/bugzilla, attaching $PWD/config.log])
16 AC_LANG_POP([Fortran])
21 dnl * If we have gettimeofday;
22 dnl * If we have struct timezone for use in calling it;
23 dnl * If calling it with a timezone pointer actually works -- this is deemed
24 dnl obsolete or undefined on some systems which say you should use a null
25 dnl pointer -- and undefine HAVE_TIMEZONE if so;
26 dnl * Whether it only takes one arg.
27 AC_DEFUN([LIBGFOR_GETTIMEOFDAY], [
28 AC_CHECK_FUNCS(gettimeofday)
29 if test "$ac_cv_func_gettimeofday" = yes; then
30 AC_CACHE_CHECK([for struct timezone], gfor_cv_struct_timezone,
31 [AC_TRY_COMPILE([#include <sys/time.h>],
32 [struct timezone tz;],
33 gfor_cv_struct_timezone=yes, gfor_cv_struct_timezone=no)])
34 if test $gfor_cv_struct_timezone = yes; then
35 dnl It may be that we can't call gettimeofday with a non-null pointer.
36 dnl In that case we'll lie about struct timezone.
38 #ifdef TIME_WITH_SYS_TIME
42 #ifdef HAVE_SYS_TIME_H
51 struct timezone dummy;
52 if (gettimeofday (&time, &dummy))
57 [gfor_have_struct_timezone=yes], [gfor_have_struct_timezone=no],
58 [gfor_have_struct_timezone=yes])
59 if test $gfor_have_struct_timezone = yes; then
60 AC_DEFINE(HAVE_TIMEZONE, 1, [Do we have struct timezone])
63 AC_REQUIRE([AC_HEADER_TIME])
64 AC_CACHE_CHECK([whether gettimeofday can accept two arguments],
65 emacs_cv_gettimeofday_two_arguments,
67 #ifdef TIME_WITH_SYS_TIME
71 #ifdef HAVE_SYS_TIME_H
81 struct timezone dummy;
86 gettimeofday (&time, DUMMY);],
87 emacs_cv_gettimeofday_two_arguments=yes,
88 emacs_cv_gettimeofday_two_arguments=no)])
89 if test $emacs_cv_gettimeofday_two_arguments = no; then
90 AC_DEFINE(GETTIMEOFDAY_ONE_ARGUMENT, 1,
91 [Does gettimeofday take a single argument])
95 sinclude(../libtool.m4)
96 dnl The lines below arrange for aclocal not to bring an installed
97 dnl libtool.m4 into aclocal.m4, while still arranging for automake to
98 dnl add a definition of LIBTOOL to Makefile.in.
99 ifelse(,,,[AC_SUBST(LIBTOOL)
100 AC_DEFUN([AM_PROG_LIBTOOL])
101 AC_DEFUN([AC_LIBTOOL_DLOPEN])
102 AC_DEFUN([AC_PROG_LD])
105 dnl Check whether the target is ILP32.
106 AC_DEFUN([LIBGFOR_TARGET_ILP32], [
107 AC_CACHE_CHECK([whether the target is ILP32], target_ilp32, [
108 save_CFLAGS="$CFLAGS"
111 if (sizeof(int) == 4 && sizeof(long) == 4 && sizeof(void *) == 4)
114 undefined_function ();
118 CFLAGS="$save_CFLAGS"])
119 if test $target_ilp32 = yes; then
120 AC_DEFINE(TARGET_ILP32, 1,
121 [Define to 1 if the target is ILP32.])
125 dnl Check whether the target supports hidden visibility.
126 AC_DEFUN([LIBGFOR_CHECK_ATTRIBUTE_VISIBILITY], [
127 AC_CACHE_CHECK([whether the target supports hidden visibility],
128 have_attribute_visibility, [
129 save_CFLAGS="$CFLAGS"
130 CFLAGS="$CFLAGS -Werror"
131 AC_TRY_COMPILE([void __attribute__((visibility("hidden"))) foo(void) { }],
132 [], have_attribute_visibility=yes,
133 have_attribute_visibility=no)
134 CFLAGS="$save_CFLAGS"])
135 if test $have_attribute_visibility = yes; then
136 AC_DEFINE(HAVE_ATTRIBUTE_VISIBILITY, 1,
137 [Define to 1 if the target supports __attribute__((visibility(...))).])
140 dnl Check whether the target supports dllexport
141 AC_DEFUN([LIBGFOR_CHECK_ATTRIBUTE_DLLEXPORT], [
142 AC_CACHE_CHECK([whether the target supports dllexport],
143 have_attribute_dllexport, [
144 save_CFLAGS="$CFLAGS"
145 CFLAGS="$CFLAGS -Werror"
146 AC_TRY_COMPILE([void __attribute__((dllexport)) foo(void) { }],
147 [], have_attribute_dllexport=yes,
148 have_attribute_dllexport=no)
149 CFLAGS="$save_CFLAGS"])
150 if test $have_attribute_dllexport = yes; then
151 AC_DEFINE(HAVE_ATTRIBUTE_DLLEXPORT, 1,
152 [Define to 1 if the target supports __attribute__((dllexport)).])
155 dnl Check whether the target supports symbol aliases.
156 AC_DEFUN([LIBGFOR_CHECK_ATTRIBUTE_ALIAS], [
157 AC_CACHE_CHECK([whether the target supports symbol aliases],
158 have_attribute_alias, [
161 extern void bar(void) __attribute__((alias("foo")));],
162 [bar();], have_attribute_alias=yes, have_attribute_alias=no)])
163 if test $have_attribute_alias = yes; then
164 AC_DEFINE(HAVE_ATTRIBUTE_ALIAS, 1,
165 [Define to 1 if the target supports __attribute__((alias(...))).])
168 dnl Check whether the target supports __sync_fetch_and_add.
169 AC_DEFUN([LIBGFOR_CHECK_SYNC_FETCH_AND_ADD], [
170 AC_CACHE_CHECK([whether the target supports __sync_fetch_and_add],
171 have_sync_fetch_and_add, [
172 AC_TRY_LINK([int foovar = 0;], [
173 if (foovar <= 0) return __sync_fetch_and_add (&foovar, 1);
174 if (foovar > 10) return __sync_add_and_fetch (&foovar, -1);],
175 have_sync_fetch_and_add=yes, have_sync_fetch_and_add=no)])
176 if test $have_sync_fetch_and_add = yes; then
177 AC_DEFINE(HAVE_SYNC_FETCH_AND_ADD, 1,
178 [Define to 1 if the target supports __sync_fetch_and_add])
181 dnl Check if threads are supported.
182 AC_DEFUN([LIBGFOR_CHECK_GTHR_DEFAULT], [
183 AC_CACHE_CHECK([configured target thread model],
184 target_thread_file, [
185 target_thread_file=`$CC -v 2>&1 | sed -n 's/^Thread model: //p'`])
187 if test $target_thread_file != single; then
188 AC_DEFINE(HAVE_GTHR_DEFAULT, 1,
189 [Define if the compiler has a thread header that is non single.])
192 dnl Check for pragma weak.
193 AC_DEFUN([LIBGFOR_GTHREAD_WEAK], [
194 AC_CACHE_CHECK([whether pragma weak works],
196 gfor_save_CFLAGS="$CFLAGS"
197 CFLAGS="$CFLAGS -Wunknown-pragmas"
198 AC_TRY_COMPILE([void foo (void);
199 #pragma weak foo], [if (foo) foo ();],
200 have_pragma_weak=yes, have_pragma_weak=no)])
201 if test $have_pragma_weak = yes; then
202 AC_DEFINE(SUPPORTS_WEAK, 1,
203 [Define to 1 if the target supports #pragma weak])
206 *-*-darwin* | *-*-hpux* | *-*-cygwin*)
207 AC_DEFINE(GTHREAD_USE_WEAK, 0,
208 [Define to 0 if the target shouldn't use #pragma weak])
212 dnl Check whether target can unlink a file still open.
213 AC_DEFUN([LIBGFOR_CHECK_UNLINK_OPEN_FILE], [
214 AC_CACHE_CHECK([whether the target can unlink an open file],
215 have_unlink_open_file, [
220 #include <sys/stat.h>
226 fd = open ("testfile", O_RDWR | O_CREAT, S_IWRITE | S_IREAD);
229 if (unlink ("testfile") == -1)
231 write (fd, "This is a test\n", 15);
234 if (open ("testfile", O_RDONLY, S_IWRITE | S_IREAD) == -1 && errno == ENOENT)
238 }], have_unlink_open_file=yes, have_unlink_open_file=no, [
240 *mingw*) have_unlink_open_file=no ;;
241 *) have_unlink_open_file=yes;;
243 if test x"$have_unlink_open_file" = xyes; then
244 AC_DEFINE(HAVE_UNLINK_OPEN_FILE, 1, [Define if target can unlink open files.])
247 dnl Check whether CRLF is the line terminator
248 AC_DEFUN([LIBGFOR_CHECK_CRLF], [
249 AC_CACHE_CHECK([whether the target has CRLF as line terminator],
252 /* This test program should exit with status 0 if system uses a CRLF as
253 line terminator, and status 1 otherwise.
254 Since it is used to check for mingw systems, and should return 0 in any
255 other case, in case of a failure we will not use CRLF. */
256 #include <sys/stat.h>
269 fd = open ("foo", O_WRONLY | O_CREAT | O_TRUNC, S_IRWXU);
272 if (write (fd, "\n", 1) < 0)
277 if ((fd = open ("foo", O_RDONLY | O_BINARY, S_IRWXU)) < 0)
279 bytes = read (fd, buff, 5);
280 if (bytes == 2 && buff[0] == '\r' && buff[1] == '\n')
285 }], have_crlf=yes, have_crlf=no, [
287 *mingw*) have_crlf=yes ;;
290 if test x"$have_crlf" = xyes; then
291 AC_DEFINE(HAVE_CRLF, 1, [Define if CRLF is line terminator.])
294 dnl Check whether isfinite is broken.
295 dnl The most common problem is that it does not work on long doubles.
296 AC_DEFUN([LIBGFOR_CHECK_FOR_BROKEN_ISFINITE], [
297 AC_CACHE_CHECK([whether isfinite is broken],
298 have_broken_isfinite, [
299 libgfor_check_for_broken_isfinite_save_LIBS=$LIBS
310 if (!isfinite(LDBL_MAX)) return 1;
313 if (!isfinite(DBL_MAX)) return 1;
317 }], have_broken_isfinite=no, have_broken_isfinite=yes, [
319 hppa*-*-hpux*) have_broken_isfinite=yes ;;
320 *) have_broken_isfinite=no ;;
322 LIBS=$libgfor_check_for_broken_isfinite_save_LIBS)
323 if test x"$have_broken_isfinite" = xyes; then
324 AC_DEFINE(HAVE_BROKEN_ISFINITE, 1, [Define if isfinite is broken.])
327 dnl Check whether isnan is broken.
328 dnl The most common problem is that it does not work on long doubles.
329 AC_DEFUN([LIBGFOR_CHECK_FOR_BROKEN_ISNAN], [
330 AC_CACHE_CHECK([whether isnan is broken],
332 libgfor_check_for_broken_isnan_save_LIBS=$LIBS
345 x = __builtin_nanl ("");
346 if (!isnan(x)) return 1;
347 if (isnan(LDBL_MAX)) return 1;
349 x = (long double) NAN;
350 if (!isnan(x)) return 1;
357 y = __builtin_nan ("");
358 if (!isnan(y)) return 1;
359 if (isnan(DBL_MAX)) return 1;
362 if (!isnan(y)) return 1;
368 }], have_broken_isnan=no, have_broken_isnan=yes, [
370 hppa*-*-hpux*) have_broken_isnan=yes ;;
371 *) have_broken_isnan=no ;;
373 LIBS=$libgfor_check_for_broken_isnan_save_LIBS)
374 if test x"$have_broken_isnan" = xyes; then
375 AC_DEFINE(HAVE_BROKEN_ISNAN, 1, [Define if isnan is broken.])
378 dnl Check whether fpclassify is broken.
379 dnl The most common problem is that it does not work on long doubles.
380 AC_DEFUN([LIBGFOR_CHECK_FOR_BROKEN_FPCLASSIFY], [
381 AC_CACHE_CHECK([whether fpclassify is broken],
382 have_broken_fpclassify, [
383 libgfor_check_for_broken_fpclassify_save_LIBS=$LIBS
394 if (fpclassify(LDBL_MAX) == FP_NAN
395 || fpclassify(LDBL_MAX) == FP_INFINITE) return 1;
398 if (fpclassify(DBL_MAX) == FP_NAN
399 || fpclassify(DBL_MAX) == FP_INFINITE) return 1;
403 }], have_broken_fpclassify=no, have_broken_fpclassify=yes, [
405 hppa*-*-hpux*) have_broken_fpclassify=yes ;;
406 *) have_broken_fpclassify=no ;;
408 LIBS=$libgfor_check_for_broken_fpclassify_save_LIBS)
409 if test x"$have_broken_fpclassify" = xyes; then
410 AC_DEFINE(HAVE_BROKEN_FPCLASSIFY, 1, [Define if fpclassify is broken.])
413 dnl Check whether the st_ino and st_dev stat fields taken together uniquely
414 dnl identify the file within the system. This is should be true for POSIX
415 dnl systems; it is known to be false on mingw32.
416 AC_DEFUN([LIBGFOR_CHECK_WORKING_STAT], [
417 AC_CACHE_CHECK([whether the target stat is reliable],
421 #include <sys/types.h>
422 #include <sys/stat.h>
428 struct stat st1, st2;
430 f = fopen ("foo", "w");
431 g = fopen ("bar", "w");
432 if (stat ("foo", &st1) != 0 || stat ("bar", &st2))
434 if (st1.st_dev == st2.st_dev && st1.st_ino == st2.st_ino)
439 }], have_working_stat=yes, have_working_stat=no, [
441 *mingw*) have_working_stat=no ;;
442 *) have_working_stat=yes;;
444 if test x"$have_working_stat" = xyes; then
445 AC_DEFINE(HAVE_WORKING_STAT, 1, [Define if target has a reliable stat.])
448 dnl Checks for fpsetmask function.
449 AC_DEFUN([LIBGFOR_CHECK_FPSETMASK], [
450 AC_CACHE_CHECK([whether fpsetmask is present], have_fpsetmask, [
452 #if HAVE_FLOATINGPOINT_H
453 # include <floatingpoint.h>
454 #endif /* HAVE_FLOATINGPOINT_H */
457 #endif /* HAVE_IEEEFP_H */],[fpsetmask(0);],
458 eval "have_fpsetmask=yes", eval "have_fpsetmask=no")
460 if test x"$have_fpsetmask" = xyes; then
461 AC_DEFINE(HAVE_FPSETMASK, 1, [Define if you have fpsetmask.])