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 is ILP32.
31 AC_DEFUN([LIBGFOR_TARGET_ILP32], [
32 AC_CACHE_CHECK([whether the target is ILP32], target_ilp32, [
36 if (sizeof(int) == 4 && sizeof(long) == 4 && sizeof(void *) == 4)
39 undefined_function ();
43 CFLAGS="$save_CFLAGS"])
44 if test $target_ilp32 = yes; then
45 AC_DEFINE(TARGET_ILP32, 1,
46 [Define to 1 if the target is ILP32.])
50 dnl Check whether the target supports hidden visibility.
51 AC_DEFUN([LIBGFOR_CHECK_ATTRIBUTE_VISIBILITY], [
52 AC_CACHE_CHECK([whether the target supports hidden visibility],
53 have_attribute_visibility, [
55 CFLAGS="$CFLAGS -Werror"
56 AC_TRY_COMPILE([void __attribute__((visibility("hidden"))) foo(void) { }],
57 [], have_attribute_visibility=yes,
58 have_attribute_visibility=no)
59 CFLAGS="$save_CFLAGS"])
60 if test $have_attribute_visibility = yes; then
61 AC_DEFINE(HAVE_ATTRIBUTE_VISIBILITY, 1,
62 [Define to 1 if the target supports __attribute__((visibility(...))).])
65 dnl Check whether the target supports dllexport
66 AC_DEFUN([LIBGFOR_CHECK_ATTRIBUTE_DLLEXPORT], [
67 AC_CACHE_CHECK([whether the target supports dllexport],
68 have_attribute_dllexport, [
70 CFLAGS="$CFLAGS -Werror"
71 AC_TRY_COMPILE([void __attribute__((dllexport)) foo(void) { }],
72 [], have_attribute_dllexport=yes,
73 have_attribute_dllexport=no)
74 CFLAGS="$save_CFLAGS"])
75 if test $have_attribute_dllexport = yes; then
76 AC_DEFINE(HAVE_ATTRIBUTE_DLLEXPORT, 1,
77 [Define to 1 if the target supports __attribute__((dllexport)).])
80 dnl Check whether the target supports symbol aliases.
81 AC_DEFUN([LIBGFOR_CHECK_ATTRIBUTE_ALIAS], [
82 AC_CACHE_CHECK([whether the target supports symbol aliases],
83 have_attribute_alias, [
86 extern void bar(void) __attribute__((alias("foo")));],
87 [bar();], have_attribute_alias=yes, have_attribute_alias=no)])
88 if test $have_attribute_alias = yes; then
89 AC_DEFINE(HAVE_ATTRIBUTE_ALIAS, 1,
90 [Define to 1 if the target supports __attribute__((alias(...))).])
93 dnl Check whether the target supports __sync_fetch_and_add.
94 AC_DEFUN([LIBGFOR_CHECK_SYNC_FETCH_AND_ADD], [
95 AC_CACHE_CHECK([whether the target supports __sync_fetch_and_add],
96 have_sync_fetch_and_add, [
97 AC_TRY_LINK([int foovar = 0;], [
98 if (foovar <= 0) return __sync_fetch_and_add (&foovar, 1);
99 if (foovar > 10) return __sync_add_and_fetch (&foovar, -1);],
100 have_sync_fetch_and_add=yes, have_sync_fetch_and_add=no)])
101 if test $have_sync_fetch_and_add = yes; then
102 AC_DEFINE(HAVE_SYNC_FETCH_AND_ADD, 1,
103 [Define to 1 if the target supports __sync_fetch_and_add])
106 dnl Check if threads are supported.
107 AC_DEFUN([LIBGFOR_CHECK_GTHR_DEFAULT], [
108 AC_CACHE_CHECK([configured target thread model],
109 target_thread_file, [
110 target_thread_file=`$CC -v 2>&1 | sed -n 's/^Thread model: //p'`])
112 if test $target_thread_file != single; then
113 AC_DEFINE(HAVE_GTHR_DEFAULT, 1,
114 [Define if the compiler has a thread header that is non single.])
117 dnl Check for pragma weak.
118 AC_DEFUN([LIBGFOR_GTHREAD_WEAK], [
119 AC_CACHE_CHECK([whether pragma weak works],
121 gfor_save_CFLAGS="$CFLAGS"
122 CFLAGS="$CFLAGS -Wunknown-pragmas"
123 AC_TRY_COMPILE([void foo (void);
124 #pragma weak foo], [if (foo) foo ();],
125 have_pragma_weak=yes, have_pragma_weak=no)])
126 if test $have_pragma_weak = yes; then
127 AC_DEFINE(SUPPORTS_WEAK, 1,
128 [Define to 1 if the target supports #pragma weak])
131 *-*-darwin* | *-*-hpux* | *-*-cygwin* | *-*-mingw* )
132 AC_DEFINE(GTHREAD_USE_WEAK, 0,
133 [Define to 0 if the target shouldn't use #pragma weak])
137 dnl Check whether target can unlink a file still open.
138 AC_DEFUN([LIBGFOR_CHECK_UNLINK_OPEN_FILE], [
139 AC_CACHE_CHECK([whether the target can unlink an open file],
140 have_unlink_open_file, [
145 #include <sys/stat.h>
151 fd = open ("testfile", O_RDWR | O_CREAT, S_IWRITE | S_IREAD);
154 if (unlink ("testfile") == -1)
156 write (fd, "This is a test\n", 15);
159 if (open ("testfile", O_RDONLY, S_IWRITE | S_IREAD) == -1 && errno == ENOENT)
163 }], have_unlink_open_file=yes, have_unlink_open_file=no, [
165 *mingw*) have_unlink_open_file=no ;;
166 *) have_unlink_open_file=yes;;
168 if test x"$have_unlink_open_file" = xyes; then
169 AC_DEFINE(HAVE_UNLINK_OPEN_FILE, 1, [Define if target can unlink open files.])
172 dnl Check whether CRLF is the line terminator
173 AC_DEFUN([LIBGFOR_CHECK_CRLF], [
174 AC_CACHE_CHECK([whether the target has CRLF as line terminator],
177 /* This test program should exit with status 0 if system uses a CRLF as
178 line terminator, and status 1 otherwise.
179 Since it is used to check for mingw systems, and should return 0 in any
180 other case, in case of a failure we will not use CRLF. */
181 #include <sys/stat.h>
194 fd = open ("foo", O_WRONLY | O_CREAT | O_TRUNC, S_IRWXU);
197 if (write (fd, "\n", 1) < 0)
202 if ((fd = open ("foo", O_RDONLY | O_BINARY, S_IRWXU)) < 0)
204 bytes = read (fd, buff, 5);
205 if (bytes == 2 && buff[0] == '\r' && buff[1] == '\n')
210 }], have_crlf=yes, have_crlf=no, [
212 *mingw*) have_crlf=yes ;;
215 if test x"$have_crlf" = xyes; then
216 AC_DEFINE(HAVE_CRLF, 1, [Define if CRLF is line terminator.])
219 dnl Check whether isfinite is broken.
220 dnl The most common problem is that it does not work on long doubles.
221 AC_DEFUN([LIBGFOR_CHECK_FOR_BROKEN_ISFINITE], [
222 AC_CACHE_CHECK([whether isfinite is broken],
223 have_broken_isfinite, [
224 libgfor_check_for_broken_isfinite_save_LIBS=$LIBS
235 if (!isfinite(LDBL_MAX)) return 1;
238 if (!isfinite(DBL_MAX)) return 1;
242 }], have_broken_isfinite=no, have_broken_isfinite=yes, [
244 hppa*-*-hpux*) have_broken_isfinite=yes ;;
245 *) have_broken_isfinite=no ;;
247 LIBS=$libgfor_check_for_broken_isfinite_save_LIBS)
248 if test x"$have_broken_isfinite" = xyes; then
249 AC_DEFINE(HAVE_BROKEN_ISFINITE, 1, [Define if isfinite is broken.])
252 dnl Check whether isnan is broken.
253 dnl The most common problem is that it does not work on long doubles.
254 AC_DEFUN([LIBGFOR_CHECK_FOR_BROKEN_ISNAN], [
255 AC_CACHE_CHECK([whether isnan is broken],
257 libgfor_check_for_broken_isnan_save_LIBS=$LIBS
270 x = __builtin_nanl ("");
271 if (!isnan(x)) return 1;
272 if (isnan(LDBL_MAX)) return 1;
274 x = (long double) NAN;
275 if (!isnan(x)) return 1;
282 y = __builtin_nan ("");
283 if (!isnan(y)) return 1;
284 if (isnan(DBL_MAX)) return 1;
287 if (!isnan(y)) return 1;
293 }], have_broken_isnan=no, have_broken_isnan=yes, [
295 hppa*-*-hpux*) have_broken_isnan=yes ;;
296 *) have_broken_isnan=no ;;
298 LIBS=$libgfor_check_for_broken_isnan_save_LIBS)
299 if test x"$have_broken_isnan" = xyes; then
300 AC_DEFINE(HAVE_BROKEN_ISNAN, 1, [Define if isnan is broken.])
303 dnl Check whether fpclassify is broken.
304 dnl The most common problem is that it does not work on long doubles.
305 AC_DEFUN([LIBGFOR_CHECK_FOR_BROKEN_FPCLASSIFY], [
306 AC_CACHE_CHECK([whether fpclassify is broken],
307 have_broken_fpclassify, [
308 libgfor_check_for_broken_fpclassify_save_LIBS=$LIBS
319 if (fpclassify(LDBL_MAX) == FP_NAN
320 || fpclassify(LDBL_MAX) == FP_INFINITE) return 1;
323 if (fpclassify(DBL_MAX) == FP_NAN
324 || fpclassify(DBL_MAX) == FP_INFINITE) return 1;
328 }], have_broken_fpclassify=no, have_broken_fpclassify=yes, [
330 hppa*-*-hpux*) have_broken_fpclassify=yes ;;
331 *) have_broken_fpclassify=no ;;
333 LIBS=$libgfor_check_for_broken_fpclassify_save_LIBS)
334 if test x"$have_broken_fpclassify" = xyes; then
335 AC_DEFINE(HAVE_BROKEN_FPCLASSIFY, 1, [Define if fpclassify is broken.])
338 dnl Check whether the st_ino and st_dev stat fields taken together uniquely
339 dnl identify the file within the system. This is should be true for POSIX
340 dnl systems; it is known to be false on mingw32.
341 AC_DEFUN([LIBGFOR_CHECK_WORKING_STAT], [
342 AC_CACHE_CHECK([whether the target stat is reliable],
346 #include <sys/types.h>
347 #include <sys/stat.h>
353 struct stat st1, st2;
355 f = fopen ("foo", "w");
356 g = fopen ("bar", "w");
357 if (stat ("foo", &st1) != 0 || stat ("bar", &st2))
359 if (st1.st_dev == st2.st_dev && st1.st_ino == st2.st_ino)
364 }], have_working_stat=yes, have_working_stat=no, [
366 *mingw*) have_working_stat=no ;;
367 *) have_working_stat=yes;;
369 if test x"$have_working_stat" = xyes; then
370 AC_DEFINE(HAVE_WORKING_STAT, 1, [Define if target has a reliable stat.])
373 dnl Checks for fpsetmask function.
374 AC_DEFUN([LIBGFOR_CHECK_FPSETMASK], [
375 AC_CACHE_CHECK([whether fpsetmask is present], have_fpsetmask, [
377 #if HAVE_FLOATINGPOINT_H
378 # include <floatingpoint.h>
379 #endif /* HAVE_FLOATINGPOINT_H */
382 #endif /* HAVE_IEEEFP_H */],[fpsetmask(0);],
383 eval "have_fpsetmask=yes", eval "have_fpsetmask=no")
385 if test x"$have_fpsetmask" = xyes; then
386 AC_DEFINE(HAVE_FPSETMASK, 1, [Define if you have fpsetmask.])