]>
Commit | Line | Data |
---|---|---|
891c05b1 JJ |
1 | m4_include(../config/acx.m4) |
2 | m4_include(../config/no-executables.m4) | |
3 | ||
15e92535 FXC |
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]) | |
8 | AC_COMPILE_IFELSE([[ | |
9 | program foo | |
10 | real, parameter :: bar = sin (12.34 / 2.5) | |
11 | end program foo]], | |
12 | [AC_MSG_RESULT([yes])], | |
13 | [AC_MSG_RESULT([no]) | |
14 | AC_MSG_ERROR([GNU Fortran is not working; please report a bug in http://gcc.gnu.org/bugzilla, attaching $PWD/config.log]) | |
15 | ]) | |
16 | AC_LANG_POP([Fortran]) | |
17 | ]) | |
18 | ||
19 | ||
6de9cd9a DN |
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]) | |
28 | ]) | |
29 | ||
3969c39f EB |
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, [ | |
33 | save_CFLAGS="$CFLAGS" | |
34 | CFLAGS="-O2" | |
35 | AC_TRY_LINK(,[ | |
36 | if (sizeof(int) == 4 && sizeof(long) == 4 && sizeof(void *) == 4) | |
37 | ; | |
38 | else | |
39 | undefined_function (); | |
40 | ], | |
41 | target_ilp32=yes, | |
42 | target_ilp32=no) | |
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.]) | |
47 | fi | |
48 | ]) | |
7d7b8bfe RH |
49 | |
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, [ | |
54 | save_CFLAGS="$CFLAGS" | |
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(...))).]) | |
63 | fi]) | |
64 | ||
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, [ | |
69 | save_CFLAGS="$CFLAGS" | |
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)).]) | |
78 | fi]) | |
79 | ||
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, [ | |
84 | AC_TRY_LINK([ | |
7d7b8bfe | 85 | void foo(void) { } |
16a314a9 | 86 | extern void bar(void) __attribute__((alias("foo")));], |
7d7b8bfe RH |
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(...))).]) | |
91 | fi]) | |
10c682a0 | 92 | |
5e805e44 JJ |
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]) | |
104 | fi]) | |
105 | ||
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'`]) | |
111 | ||
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.]) | |
115 | fi]) | |
116 | ||
117 | dnl Check for pragma weak. | |
e669bd2b | 118 | AC_DEFUN([LIBGFOR_GTHREAD_WEAK], [ |
5e805e44 JJ |
119 | AC_CACHE_CHECK([whether pragma weak works], |
120 | have_pragma_weak, [ | |
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 | |
e669bd2b | 127 | AC_DEFINE(SUPPORTS_WEAK, 1, |
5e805e44 | 128 | [Define to 1 if the target supports #pragma weak]) |
e669bd2b JJ |
129 | fi |
130 | case "$host" in | |
6e20eae9 | 131 | *-*-darwin* | *-*-hpux* | *-*-cygwin* | *-*-mingw* ) |
e669bd2b JJ |
132 | AC_DEFINE(GTHREAD_USE_WEAK, 0, |
133 | [Define to 0 if the target shouldn't use #pragma weak]) | |
134 | ;; | |
135 | esac]) | |
5e805e44 | 136 | |
10c682a0 FXC |
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, [ | |
141 | AC_TRY_RUN([ | |
142 | #include <errno.h> | |
143 | #include <fcntl.h> | |
144 | #include <unistd.h> | |
145 | #include <sys/stat.h> | |
146 | ||
147 | int main () | |
148 | { | |
149 | int fd; | |
150 | ||
151 | fd = open ("testfile", O_RDWR | O_CREAT, S_IWRITE | S_IREAD); | |
152 | if (fd <= 0) | |
153 | return 0; | |
154 | if (unlink ("testfile") == -1) | |
155 | return 1; | |
156 | write (fd, "This is a test\n", 15); | |
157 | close (fd); | |
158 | ||
159 | if (open ("testfile", O_RDONLY, S_IWRITE | S_IREAD) == -1 && errno == ENOENT) | |
160 | return 0; | |
161 | else | |
162 | return 1; | |
163 | }], have_unlink_open_file=yes, have_unlink_open_file=no, [ | |
164 | case "${target}" in | |
165 | *mingw*) have_unlink_open_file=no ;; | |
166 | *) have_unlink_open_file=yes;; | |
167 | esac])]) | |
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.]) | |
170 | fi]) | |
3c127520 FXC |
171 | |
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], | |
175 | have_crlf, [ | |
176 | AC_TRY_RUN([ | |
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> | |
182 | #include <stdlib.h> | |
183 | #include <fcntl.h> | |
184 | #include <stdio.h> | |
185 | ||
186 | int main () | |
187 | { | |
188 | #ifndef O_BINARY | |
189 | exit(1); | |
190 | #else | |
191 | int fd, bytes; | |
192 | char buff[5]; | |
193 | ||
194 | fd = open ("foo", O_WRONLY | O_CREAT | O_TRUNC, S_IRWXU); | |
195 | if (fd < 0) | |
196 | exit(1); | |
197 | if (write (fd, "\n", 1) < 0) | |
198 | perror ("write"); | |
199 | ||
200 | close (fd); | |
201 | ||
202 | if ((fd = open ("foo", O_RDONLY | O_BINARY, S_IRWXU)) < 0) | |
203 | exit(1); | |
204 | bytes = read (fd, buff, 5); | |
205 | if (bytes == 2 && buff[0] == '\r' && buff[1] == '\n') | |
206 | exit(0); | |
207 | else | |
208 | exit(1); | |
209 | #endif | |
210 | }], have_crlf=yes, have_crlf=no, [ | |
211 | case "${target}" in | |
212 | *mingw*) have_crlf=yes ;; | |
213 | *) have_crlf=no;; | |
214 | esac])]) | |
215 | if test x"$have_crlf" = xyes; then | |
216 | AC_DEFINE(HAVE_CRLF, 1, [Define if CRLF is line terminator.]) | |
217 | fi]) | |
118ea208 SE |
218 | |
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 | |
225 | LIBS="$LIBS -lm" | |
226 | AC_TRY_RUN([ | |
227 | #ifdef HAVE_MATH_H | |
228 | #include <math.h> | |
229 | #endif | |
230 | #include <float.h> | |
231 | int main () | |
232 | { | |
233 | #ifdef isfinite | |
234 | #ifdef LDBL_MAX | |
235 | if (!isfinite(LDBL_MAX)) return 1; | |
236 | #endif | |
237 | #ifdef DBL_MAX | |
238 | if (!isfinite(DBL_MAX)) return 1; | |
239 | #endif | |
240 | #endif | |
241 | return 0; | |
242 | }], have_broken_isfinite=no, have_broken_isfinite=yes, [ | |
243 | case "${target}" in | |
244 | hppa*-*-hpux*) have_broken_isfinite=yes ;; | |
245 | *) have_broken_isfinite=no ;; | |
246 | esac])] | |
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.]) | |
250 | fi]) | |
251 | ||
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], | |
256 | have_broken_isnan, [ | |
257 | libgfor_check_for_broken_isnan_save_LIBS=$LIBS | |
258 | LIBS="$LIBS -lm" | |
259 | AC_TRY_RUN([ | |
260 | #ifdef HAVE_MATH_H | |
261 | #include <math.h> | |
262 | #endif | |
263 | #include <float.h> | |
264 | int main () | |
265 | { | |
266 | #ifdef isnan | |
267 | #ifdef LDBL_MAX | |
268 | { | |
269 | long double x; | |
270 | x = __builtin_nanl (""); | |
271 | if (!isnan(x)) return 1; | |
272 | if (isnan(LDBL_MAX)) return 1; | |
273 | #ifdef NAN | |
274 | x = (long double) NAN; | |
275 | if (!isnan(x)) return 1; | |
276 | #endif | |
277 | } | |
278 | #endif | |
279 | #ifdef DBL_MAX | |
280 | { | |
281 | double y; | |
282 | y = __builtin_nan (""); | |
283 | if (!isnan(y)) return 1; | |
284 | if (isnan(DBL_MAX)) return 1; | |
285 | #ifdef NAN | |
286 | y = (double) NAN; | |
287 | if (!isnan(y)) return 1; | |
288 | #endif | |
289 | } | |
290 | #endif | |
291 | #endif | |
292 | return 0; | |
293 | }], have_broken_isnan=no, have_broken_isnan=yes, [ | |
294 | case "${target}" in | |
295 | hppa*-*-hpux*) have_broken_isnan=yes ;; | |
296 | *) have_broken_isnan=no ;; | |
297 | esac])] | |
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.]) | |
301 | fi]) | |
302 | ||
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 | |
309 | LIBS="$LIBS -lm" | |
310 | AC_TRY_RUN([ | |
311 | #ifdef HAVE_MATH_H | |
312 | #include <math.h> | |
313 | #endif | |
314 | #include <float.h> | |
315 | int main () | |
316 | { | |
317 | #ifdef fpclassify | |
318 | #ifdef LDBL_MAX | |
319 | if (fpclassify(LDBL_MAX) == FP_NAN | |
320 | || fpclassify(LDBL_MAX) == FP_INFINITE) return 1; | |
321 | #endif | |
322 | #ifdef DBL_MAX | |
323 | if (fpclassify(DBL_MAX) == FP_NAN | |
324 | || fpclassify(DBL_MAX) == FP_INFINITE) return 1; | |
325 | #endif | |
326 | #endif | |
327 | return 0; | |
328 | }], have_broken_fpclassify=no, have_broken_fpclassify=yes, [ | |
329 | case "${target}" in | |
330 | hppa*-*-hpux*) have_broken_fpclassify=yes ;; | |
331 | *) have_broken_fpclassify=no ;; | |
332 | esac])] | |
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.]) | |
336 | fi]) | |
ad238e4f FXC |
337 | |
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], | |
343 | have_working_stat, [ | |
344 | AC_TRY_RUN([ | |
345 | #include <stdio.h> | |
346 | #include <sys/types.h> | |
347 | #include <sys/stat.h> | |
348 | #include <unistd.h> | |
349 | ||
350 | int main () | |
351 | { | |
352 | FILE *f, *g; | |
353 | struct stat st1, st2; | |
354 | ||
355 | f = fopen ("foo", "w"); | |
356 | g = fopen ("bar", "w"); | |
357 | if (stat ("foo", &st1) != 0 || stat ("bar", &st2)) | |
358 | return 1; | |
359 | if (st1.st_dev == st2.st_dev && st1.st_ino == st2.st_ino) | |
360 | return 1; | |
361 | fclose(f); | |
362 | fclose(g); | |
363 | return 0; | |
364 | }], have_working_stat=yes, have_working_stat=no, [ | |
365 | case "${target}" in | |
366 | *mingw*) have_working_stat=no ;; | |
367 | *) have_working_stat=yes;; | |
368 | esac])]) | |
369 | if test x"$have_working_stat" = xyes; then | |
370 | AC_DEFINE(HAVE_WORKING_STAT, 1, [Define if target has a reliable stat.]) | |
371 | fi]) | |
3b14f664 FXC |
372 | |
373 | dnl Checks for fpsetmask function. | |
374 | AC_DEFUN([LIBGFOR_CHECK_FPSETMASK], [ | |
375 | AC_CACHE_CHECK([whether fpsetmask is present], have_fpsetmask, [ | |
376 | AC_TRY_LINK([ | |
377 | #if HAVE_FLOATINGPOINT_H | |
378 | # include <floatingpoint.h> | |
379 | #endif /* HAVE_FLOATINGPOINT_H */ | |
380 | #if HAVE_IEEEFP_H | |
381 | # include <ieeefp.h> | |
382 | #endif /* HAVE_IEEEFP_H */],[fpsetmask(0);], | |
383 | eval "have_fpsetmask=yes", eval "have_fpsetmask=no") | |
384 | ]) | |
385 | if test x"$have_fpsetmask" = xyes; then | |
386 | AC_DEFINE(HAVE_FPSETMASK, 1, [Define if you have fpsetmask.]) | |
387 | fi | |
388 | ]) |