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])
20 sinclude(../libtool.m4)
21 dnl The lines below arrange for aclocal not to bring an installed
22 dnl libtool.m4 into aclocal.m4, while still arranging for automake to
23 dnl add a definition of LIBTOOL to Makefile.in.
24 ifelse(,,,[AC_SUBST(LIBTOOL)
25 AC_DEFUN([AM_PROG_LIBTOOL])
26 AC_DEFUN([AC_LIBTOOL_DLOPEN])
27 AC_DEFUN([AC_PROG_LD])
30 dnl Check whether the target supports hidden visibility.
31 AC_DEFUN([LIBGFOR_CHECK_ATTRIBUTE_VISIBILITY], [
32 AC_CACHE_CHECK([whether the target supports hidden visibility],
33 have_attribute_visibility, [
35 CFLAGS="$CFLAGS -Werror"
36 AC_TRY_COMPILE([void __attribute__((visibility("hidden"))) foo(void) { }],
37 [], have_attribute_visibility=yes,
38 have_attribute_visibility=no)
39 CFLAGS="$save_CFLAGS"])
40 if test $have_attribute_visibility = yes; then
41 AC_DEFINE(HAVE_ATTRIBUTE_VISIBILITY, 1,
42 [Define to 1 if the target supports __attribute__((visibility(...))).])
45 dnl Check whether the target supports dllexport
46 AC_DEFUN([LIBGFOR_CHECK_ATTRIBUTE_DLLEXPORT], [
47 AC_CACHE_CHECK([whether the target supports dllexport],
48 have_attribute_dllexport, [
50 CFLAGS="$CFLAGS -Werror"
51 AC_TRY_COMPILE([void __attribute__((dllexport)) foo(void) { }],
52 [], have_attribute_dllexport=yes,
53 have_attribute_dllexport=no)
54 CFLAGS="$save_CFLAGS"])
55 if test $have_attribute_dllexport = yes; then
56 AC_DEFINE(HAVE_ATTRIBUTE_DLLEXPORT, 1,
57 [Define to 1 if the target supports __attribute__((dllexport)).])
60 dnl Check whether the target supports symbol aliases.
61 AC_DEFUN([LIBGFOR_CHECK_ATTRIBUTE_ALIAS], [
62 AC_CACHE_CHECK([whether the target supports symbol aliases],
63 have_attribute_alias, [
66 extern void bar(void) __attribute__((alias("foo")));],
67 [bar();], have_attribute_alias=yes, have_attribute_alias=no)])
68 if test $have_attribute_alias = yes; then
69 AC_DEFINE(HAVE_ATTRIBUTE_ALIAS, 1,
70 [Define to 1 if the target supports __attribute__((alias(...))).])
73 dnl Check whether the target supports __sync_fetch_and_add.
74 AC_DEFUN([LIBGFOR_CHECK_SYNC_FETCH_AND_ADD], [
75 AC_CACHE_CHECK([whether the target supports __sync_fetch_and_add],
76 have_sync_fetch_and_add, [
77 AC_TRY_LINK([int foovar = 0;], [
78 if (foovar <= 0) return __sync_fetch_and_add (&foovar, 1);
79 if (foovar > 10) return __sync_add_and_fetch (&foovar, -1);],
80 have_sync_fetch_and_add=yes, have_sync_fetch_and_add=no)])
81 if test $have_sync_fetch_and_add = yes; then
82 AC_DEFINE(HAVE_SYNC_FETCH_AND_ADD, 1,
83 [Define to 1 if the target supports __sync_fetch_and_add])
86 dnl Check if threads are supported.
87 AC_DEFUN([LIBGFOR_CHECK_GTHR_DEFAULT], [
88 AC_CACHE_CHECK([configured target thread model],
90 target_thread_file=`$CC -v 2>&1 | sed -n 's/^Thread model: //p'`])
92 if test $target_thread_file != single; then
93 AC_DEFINE(HAVE_GTHR_DEFAULT, 1,
94 [Define if the compiler has a thread header that is non single.])
97 dnl Check for pragma weak.
98 AC_DEFUN([LIBGFOR_GTHREAD_WEAK], [
99 AC_CACHE_CHECK([whether pragma weak works],
101 gfor_save_CFLAGS="$CFLAGS"
102 CFLAGS="$CFLAGS -Wunknown-pragmas"
103 AC_TRY_COMPILE([void foo (void);
104 #pragma weak foo], [if (foo) foo ();],
105 have_pragma_weak=yes, have_pragma_weak=no)])
106 if test $have_pragma_weak = yes; then
107 AC_DEFINE(SUPPORTS_WEAK, 1,
108 [Define to 1 if the target supports #pragma weak])
111 *-*-darwin* | *-*-hpux* | *-*-cygwin* | *-*-mingw* )
112 AC_DEFINE(GTHREAD_USE_WEAK, 0,
113 [Define to 0 if the target shouldn't use #pragma weak])
117 dnl Check whether target can unlink a file still open.
118 AC_DEFUN([LIBGFOR_CHECK_UNLINK_OPEN_FILE], [
119 AC_CACHE_CHECK([whether the target can unlink an open file],
120 have_unlink_open_file, [
125 #include <sys/stat.h>
131 fd = open ("testfile", O_RDWR | O_CREAT, S_IWRITE | S_IREAD);
134 if (unlink ("testfile") == -1)
136 write (fd, "This is a test\n", 15);
139 if (open ("testfile", O_RDONLY, S_IWRITE | S_IREAD) == -1 && errno == ENOENT)
143 }], have_unlink_open_file=yes, have_unlink_open_file=no, [
145 *mingw*) have_unlink_open_file=no ;;
146 *) have_unlink_open_file=yes;;
148 if test x"$have_unlink_open_file" = xyes; then
149 AC_DEFINE(HAVE_UNLINK_OPEN_FILE, 1, [Define if target can unlink open files.])
152 dnl Check whether CRLF is the line terminator
153 AC_DEFUN([LIBGFOR_CHECK_CRLF], [
154 AC_CACHE_CHECK([whether the target has CRLF as line terminator],
157 /* This test program should exit with status 0 if system uses a CRLF as
158 line terminator, and status 1 otherwise.
159 Since it is used to check for mingw systems, and should return 0 in any
160 other case, in case of a failure we will not use CRLF. */
161 #include <sys/stat.h>
174 fd = open ("foo", O_WRONLY | O_CREAT | O_TRUNC, S_IRWXU);
177 if (write (fd, "\n", 1) < 0)
182 if ((fd = open ("foo", O_RDONLY | O_BINARY, S_IRWXU)) < 0)
184 bytes = read (fd, buff, 5);
185 if (bytes == 2 && buff[0] == '\r' && buff[1] == '\n')
190 }], have_crlf=yes, have_crlf=no, [
192 *mingw*) have_crlf=yes ;;
195 if test x"$have_crlf" = xyes; then
196 AC_DEFINE(HAVE_CRLF, 1, [Define if CRLF is line terminator.])
199 dnl Check whether isfinite is broken.
200 dnl The most common problem is that it does not work on long doubles.
201 AC_DEFUN([LIBGFOR_CHECK_FOR_BROKEN_ISFINITE], [
202 AC_CACHE_CHECK([whether isfinite is broken],
203 have_broken_isfinite, [
204 libgfor_check_for_broken_isfinite_save_LIBS=$LIBS
215 if (!isfinite(LDBL_MAX)) return 1;
218 if (!isfinite(DBL_MAX)) return 1;
222 }], have_broken_isfinite=no, have_broken_isfinite=yes, [
224 hppa*-*-hpux*) have_broken_isfinite=yes ;;
225 *) have_broken_isfinite=no ;;
227 LIBS=$libgfor_check_for_broken_isfinite_save_LIBS)
228 if test x"$have_broken_isfinite" = xyes; then
229 AC_DEFINE(HAVE_BROKEN_ISFINITE, 1, [Define if isfinite is broken.])
232 dnl Check whether isnan is broken.
233 dnl The most common problem is that it does not work on long doubles.
234 AC_DEFUN([LIBGFOR_CHECK_FOR_BROKEN_ISNAN], [
235 AC_CACHE_CHECK([whether isnan is broken],
237 libgfor_check_for_broken_isnan_save_LIBS=$LIBS
250 x = __builtin_nanl ("");
251 if (!isnan(x)) return 1;
252 if (isnan(LDBL_MAX)) return 1;
254 x = (long double) NAN;
255 if (!isnan(x)) return 1;
262 y = __builtin_nan ("");
263 if (!isnan(y)) return 1;
264 if (isnan(DBL_MAX)) return 1;
267 if (!isnan(y)) return 1;
273 }], have_broken_isnan=no, have_broken_isnan=yes, [
275 hppa*-*-hpux*) have_broken_isnan=yes ;;
276 *) have_broken_isnan=no ;;
278 LIBS=$libgfor_check_for_broken_isnan_save_LIBS)
279 if test x"$have_broken_isnan" = xyes; then
280 AC_DEFINE(HAVE_BROKEN_ISNAN, 1, [Define if isnan is broken.])
283 dnl Check whether fpclassify is broken.
284 dnl The most common problem is that it does not work on long doubles.
285 AC_DEFUN([LIBGFOR_CHECK_FOR_BROKEN_FPCLASSIFY], [
286 AC_CACHE_CHECK([whether fpclassify is broken],
287 have_broken_fpclassify, [
288 libgfor_check_for_broken_fpclassify_save_LIBS=$LIBS
299 if (fpclassify(LDBL_MAX) == FP_NAN
300 || fpclassify(LDBL_MAX) == FP_INFINITE) return 1;
303 if (fpclassify(DBL_MAX) == FP_NAN
304 || fpclassify(DBL_MAX) == FP_INFINITE) return 1;
308 }], have_broken_fpclassify=no, have_broken_fpclassify=yes, [
310 hppa*-*-hpux*) have_broken_fpclassify=yes ;;
311 *) have_broken_fpclassify=no ;;
313 LIBS=$libgfor_check_for_broken_fpclassify_save_LIBS)
314 if test x"$have_broken_fpclassify" = xyes; then
315 AC_DEFINE(HAVE_BROKEN_FPCLASSIFY, 1, [Define if fpclassify is broken.])
318 dnl Check whether the st_ino and st_dev stat fields taken together uniquely
319 dnl identify the file within the system. This is should be true for POSIX
320 dnl systems; it is known to be false on mingw32.
321 AC_DEFUN([LIBGFOR_CHECK_WORKING_STAT], [
322 AC_CACHE_CHECK([whether the target stat is reliable],
326 #include <sys/types.h>
327 #include <sys/stat.h>
333 struct stat st1, st2;
335 f = fopen ("foo", "w");
336 g = fopen ("bar", "w");
337 if (stat ("foo", &st1) != 0 || stat ("bar", &st2))
339 if (st1.st_dev == st2.st_dev && st1.st_ino == st2.st_ino)
344 }], have_working_stat=yes, have_working_stat=no, [
346 *mingw*) have_working_stat=no ;;
347 *) have_working_stat=yes;;
349 if test x"$have_working_stat" = xyes; then
350 AC_DEFINE(HAVE_WORKING_STAT, 1, [Define if target has a reliable stat.])
353 dnl Checks for fpsetmask function.
354 AC_DEFUN([LIBGFOR_CHECK_FPSETMASK], [
355 AC_CACHE_CHECK([whether fpsetmask is present], have_fpsetmask, [
357 #if HAVE_FLOATINGPOINT_H
358 # include <floatingpoint.h>
359 #endif /* HAVE_FLOATINGPOINT_H */
362 #endif /* HAVE_IEEEFP_H */],[fpsetmask(0);],
363 eval "have_fpsetmask=yes", eval "have_fpsetmask=no")
365 if test x"$have_fpsetmask" = xyes; then
366 AC_DEFINE(HAVE_FPSETMASK, 1, [Define if you have fpsetmask.])
370 dnl Check whether we have a mingw that provides a __mingw_snprintf function
371 AC_DEFUN([LIBGFOR_CHECK_MINGW_SNPRINTF], [
372 AC_CACHE_CHECK([whether __mingw_snprintf is present], have_mingw_snprintf, [
375 extern int __mingw_snprintf (char *, size_t, const char *, ...);
377 __mingw_snprintf (NULL, 0, "%d\n", 1);
379 eval "have_mingw_snprintf=yes", eval "have_mingw_snprintf=no")
381 if test x"$have_mingw_snprintf" = xyes; then
382 AC_DEFINE(HAVE_MINGW_SNPRINTF, 1, [Define if you have __mingw_snprintf.])