Skip gnat.dg/prot7.adb on hppa.
[official-gcc.git] / libgfortran / configure.ac
blob07b9a48a19fb41bc9eea9c1ca1a2d7316237230e
1 # Process this file with autoconf to produce a configure script, like so:
2 # aclocal && autoconf && autoheader && automake
4 AC_INIT([GNU Fortran Runtime Library], 0.3,,[libgfortran])
5 AC_CONFIG_HEADER(config.h)
6 GCC_TOPLEV_SUBDIRS
8 # -------
9 # Options
10 # -------
12 AC_MSG_CHECKING([for --enable-version-specific-runtime-libs])
13 AC_ARG_ENABLE(version-specific-runtime-libs,
14 AS_HELP_STRING([--enable-version-specific-runtime-libs],
15   [specify that runtime libraries should be installed in a compiler-specific directory]),
16 [case "$enableval" in
17  yes) version_specific_libs=yes ;;
18  no)  version_specific_libs=no ;;
19  *)   AC_MSG_ERROR([Unknown argument to enable/disable version-specific libs]);;
20  esac],
21 [version_specific_libs=no])
22 AC_MSG_RESULT($version_specific_libs)
24 # Build with intermodule optimisations
25 AC_MSG_CHECKING([for --enable-intermodule])
26 AC_ARG_ENABLE(intermodule,
27 AS_HELP_STRING([--enable-intermodule],[build the library in one step]),
28 [case "$enable_intermodule" in
29   yes) onestep="-onestep";;
30     *) onestep="";;
31 esac],
32 [onestep=""])
33 AC_MSG_RESULT($enable_intermodule)
34 AM_CONDITIONAL(onestep,[test x$onestep = x-onestep])
35 AC_SUBST(onestep)
37 # Gets build, host, target, *_vendor, *_cpu, *_os, etc.
39 # You will slowly go insane if you do not grok the following fact:  when
40 # building this library, the top-level /target/ becomes the library's /host/.
42 # configure then causes --target to default to --host, exactly like any
43 # other package using autoconf.  Therefore, 'target' and 'host' will
44 # always be the same.  This makes sense both for native and cross compilers
45 # just think about it for a little while.  :-)
47 # Also, if this library is being configured as part of a cross compiler, the
48 # top-level configure script will pass the "real" host as $with_cross_host.
50 # Do not delete or change the following two lines.  For why, see
51 # http://gcc.gnu.org/ml/libstdc++/2003-07/msg00451.html
52 AC_CANONICAL_SYSTEM
53 ACX_NONCANONICAL_TARGET
55 target_alias=${target_alias-$host_alias}
56 AC_SUBST(target_alias)
58 # Sets up automake.  Must come after AC_CANONICAL_SYSTEM.  Each of the
59 # following is magically included in AUTOMAKE_OPTIONS in each Makefile.am.
60 #  1.9.6:  minimum required version
61 #  no-define:  PACKAGE and VERSION will not be #define'd in config.h (a bunch
62 #              of other PACKAGE_* variables will, however, and there's nothing
63 #              we can do about that; they come from AC_INIT).
64 #  foreign:  we don't follow the normal rules for GNU packages (no COPYING
65 #            file in the top srcdir, etc, etc), so stop complaining.
66 #  no-dist:  we don't want 'dist' and related rules.
67 #  -Wall:  turns on all automake warnings...
68 #  -Wno-portability:  ...except this one, since GNU make is required.
69 AM_INIT_AUTOMAKE([1.9.6 no-define foreign no-dist -Wall -Wno-portability])
71 AM_MAINTAINER_MODE
72 AM_ENABLE_MULTILIB(, ..)
74 # Handy for debugging:
75 #AC_MSG_NOTICE($build / $host / $target / $host_alias / $target_alias); sleep 5
77 # Are we being configured with some form of cross compiler?
78 # NB: We don't actually need to know this just now, but when, say, a test
79 #     suite is included, we'll have to know.
80 if test "$build" != "$host"; then
81   LIBGFOR_IS_NATIVE=false
82   GCC_NO_EXECUTABLES
83 else
84   LIBGFOR_IS_NATIVE=true
87 AC_USE_SYSTEM_EXTENSIONS
89 GCC_WITH_TOOLEXECLIBDIR
91 # Calculate toolexeclibdir
92 # Also toolexecdir, though it's only used in toolexeclibdir
93 case ${version_specific_libs} in
94   yes)
95     # Need the gcc compiler version to know where to install libraries
96     # and header files if --enable-version-specific-runtime-libs option
97     # is selected.
98     toolexecdir='$(libdir)/gcc/$(target_alias)'
99     toolexeclibdir='$(toolexecdir)/$(gcc_version)$(MULTISUBDIR)'
100     ;;
101   no)
102     if test -n "$with_cross_host" &&
103        test x"$with_cross_host" != x"no"; then
104       # Install a library built with a cross compiler in tooldir, not libdir.
105       toolexecdir='$(exec_prefix)/$(target_alias)'
106       case ${with_toolexeclibdir} in
107         no)
108           toolexeclibdir='$(toolexecdir)/lib'
109           ;;
110         *)
111           toolexeclibdir=${with_toolexeclibdir}
112           ;;
113       esac
114     else
115       toolexecdir='$(libdir)/gcc-lib/$(target_alias)'
116       toolexeclibdir='$(libdir)'
117     fi
118     multi_os_directory=`$CC -print-multi-os-directory`
119     case $multi_os_directory in
120       .) ;; # Avoid trailing /.
121       *) toolexeclibdir=$toolexeclibdir/$multi_os_directory ;;
122     esac
123     ;;
124 esac
125 AC_SUBST(toolexecdir)
126 AC_SUBST(toolexeclibdir)
128 # Create a spec file, so that compile/link tests don't fail
129 test -f libgfortran.spec || touch libgfortran.spec
131 AC_LANG_C
132 # Check the compiler.
133 # The same as in boehm-gc and libstdc++. Have to borrow it from there.
134 # We must force CC to /not/ be precious variables; otherwise
135 # the wrong, non-multilib-adjusted value will be used in multilibs.
136 # As a side effect, we have to subst CFLAGS ourselves.
138 m4_rename([_AC_ARG_VAR_PRECIOUS],[real_PRECIOUS])
139 m4_define([_AC_ARG_VAR_PRECIOUS],[])
140 AC_PROG_CC
141 m4_rename_force([real_PRECIOUS],[_AC_ARG_VAR_PRECIOUS])
143 AC_SUBST(CFLAGS)
145 AM_PROG_CC_C_O
147 # Add -Wall -fno-repack-arrays -fno-underscoring if we are using GCC.
148 have_real_17=no
149 if test "x$GCC" = "xyes"; then
150   AM_FCFLAGS="-I . -Wall -Werror -fimplicit-none -fno-repack-arrays -fno-underscoring"
151   ## We like to use C11 and C99 routines when available.  This makes
152   ## sure that
153   ## __STDC_VERSION__ is set such that libc includes make them available.
154   AM_CFLAGS="-std=gnu11 -Wall -Wstrict-prototypes -Wmissing-prototypes -Wold-style-definition -Wextra -Wwrite-strings -Werror=implicit-function-declaration -Werror=vla"
155   ## Compile the following tests with the same system header contents
156   ## that we'll encounter when compiling our own source files.
157   CFLAGS="-std=gnu11 $CFLAGS"
159   case x$target in
160     xpowerpc64le*-linux*)
161       AC_PREPROC_IFELSE(
162         [AC_LANG_PROGRAM([[#if __SIZEOF_LONG_DOUBLE__ != 16
163                            #error long double is double
164                            #endif]],
165                          [[(void) 0;]])],
166         [AM_FCFLAGS="$AM_FCFLAGS -mabi=ibmlongdouble -mno-gnu-attribute";
167          AM_CFLAGS="$AM_CFLAGS -mabi=ibmlongdouble -mno-gnu-attribute";
168          CFLAGS="$CFLAGS -mabi=ibmlongdouble -mno-gnu-attribute";
169          have_real_17=yes])
170       ;;
171     *)
172       ;;
173   esac
175 AM_CONDITIONAL([HAVE_REAL_17], [test "x$have_real_17" != xno])
177 # Add CET specific flags if CET is enabled
178 GCC_CET_FLAGS(CET_FLAGS)
179 AM_FCFLAGS="$AM_FCFLAGS $CET_FLAGS"
180 AM_CFLAGS="$AM_CFLAGS $CET_FLAGS"
181 CFLAGS="$CFLAGS $CET_FLAGS"
183 AC_SUBST(AM_FCFLAGS)
184 AC_SUBST(AM_CFLAGS)
185 AC_SUBST(CFLAGS)
187 # Check for symbol versioning (copied from libssp).
188 AC_MSG_CHECKING([whether symbol versioning is supported])
189 AC_ARG_ENABLE(symvers,
190 AS_HELP_STRING([--disable-symvers],
191   [disable symbol versioning for libgfortran]),
192 gfortran_use_symver=$enableval,
193 gfortran_use_symver=yes)
194 if test "x$gfortran_use_symver" != xno; then
195   save_LDFLAGS="$LDFLAGS"
196   LDFLAGS="$LDFLAGS -fPIC -shared -Wl,--version-script,./conftest.map"
197   cat > conftest.map <<EOF
198 FOO_1.0 {
199   global: *foo*; bar; local: *;
202   AC_LINK_IFELSE([AC_LANG_PROGRAM([[int foo;]],[[]])],[gfortran_use_symver=gnu],[gfortran_use_symver=no])
203   if test x$gfortran_use_symver = xno; then
204     case "$target_os" in
205       solaris2*)
206         LDFLAGS="$save_LDFLAGS"
207         LDFLAGS="$LDFLAGS -fPIC -shared -Wl,-M,./conftest.map"
208         # Sun ld cannot handle wildcards and treats all entries as undefined.
209         cat > conftest.map <<EOF
210 FOO_1.0 {
211   global: foo; local: *;
214         AC_LINK_IFELSE([AC_LANG_PROGRAM([[int foo;]],[[]])],[gfortran_use_symver=sun],[gfortran_use_symver=no])
215         ;;
216     esac
217   fi
218   LDFLAGS="$save_LDFLAGS"
220 AC_MSG_RESULT($gfortran_use_symver)
221 AM_CONDITIONAL(LIBGFOR_USE_SYMVER, [test "x$gfortran_use_symver" != xno])
222 AM_CONDITIONAL(LIBGFOR_USE_SYMVER_GNU, [test "x$gfortran_use_symver" = xgnu])
223 AM_CONDITIONAL(LIBGFOR_USE_SYMVER_SUN, [test "x$gfortran_use_symver" = xsun])
225 # For GPU offloading, not everything in libfortran can be supported.
226 # Currently, the only target that has this problem is nvptx.  The
227 # following is a (partial) list of features that are unsupportable on
228 # this particular target:
229 # * Constructors
230 # * alloca
231 # * C library support for I/O, with printf as the one notable exception
232 # * C library support for other features such as signal, environment
233 #   variables, time functions
235 AM_CONDITIONAL(LIBGFOR_MINIMAL, [test "x${target_cpu}" = xnvptx])
237 # Some compiler target support may have limited support for integer
238 # or floating point numbers – or may want to reduce the libgfortran size
239 # although they do have the support.
240 LIBGOMP_CHECKED_INT_KINDS="1 2 4 8 16"
241 LIBGOMP_CHECKED_REAL_KINDS="4 8 10 16"
243 AC_SUBST(LIBGOMP_CHECKED_INT_KINDS)
244 AC_SUBST(LIBGOMP_CHECKED_REAL_KINDS)
246 # Figure out whether the compiler supports "-ffunction-sections -fdata-sections",
247 # similarly to how libstdc++ does it
248 ac_test_CFLAGS="${CFLAGS+set}"
249 ac_save_CFLAGS="$CFLAGS"
251 # Check for -ffunction-sections -fdata-sections
252 AC_MSG_CHECKING([for gcc that supports -ffunction-sections -fdata-sections])
253 CFLAGS='-Werror -ffunction-sections -fdata-sections'
254 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[int foo;]])], [ac_fdsections=yes], [ac_fdsections=no])
255 if test "$ac_test_CFLAGS" = set; then
256   CFLAGS="$ac_save_CFLAGS"
257 else
258   # this is the suspicious part
259   CFLAGS=""
261 if test x"$ac_fdsections" = x"yes"; then
262   SECTION_FLAGS='-ffunction-sections -fdata-sections'
264 AC_MSG_RESULT($ac_fdsections)
265 AC_SUBST(SECTION_FLAGS)
267 # Check linker hardware capability support.
268 GCC_CHECK_LINKER_HWCAP
270 # Find other programs we need.
271 AC_CHECK_TOOL(AS, as)
272 AC_CHECK_TOOL(AR, ar)
273 AC_CHECK_TOOL(RANLIB, ranlib, ranlib-not-found-in-path-error)
274 AC_PROG_MAKE_SET
275 AC_PROG_INSTALL
277 # Configure libtool
278 #AC_MSG_NOTICE([====== Starting libtool configuration])
279 AC_LIBTOOL_DLOPEN
280 AM_PROG_LIBTOOL
281 LT_LIB_M
282 ACX_LT_HOST_FLAGS
283 AC_SUBST(enable_shared)
284 AC_SUBST(enable_static)
285 #AC_MSG_NOTICE([====== Finished libtool configuration]) ; sleep 10
287 # We need gfortran to compile parts of the library
288 #AC_PROG_FC(gfortran)
289 FC="$GFORTRAN"
290 AC_PROG_FC(gfortran)
292 # extra LD Flags which are required for targets
293 case "${host}" in
294   *-darwin*)
295     # Darwin needs -single_module when linking libgfortran
296     extra_ldflags_libgfortran=-Wl,-single_module
297     ;;
298 esac
299 AC_SUBST(extra_ldflags_libgfortran)
301 # We need a working compiler at that point, otherwise give a clear
302 # error message and bail out.
303 LIBGFOR_WORKING_GFORTRAN
305 AC_SYS_LARGEFILE
307 # Types
308 AC_TYPE_OFF_T
309 AC_TYPE_INTPTR_T
310 AC_TYPE_UINTPTR_T
311 AC_CHECK_TYPES([ptrdiff_t])
313 # check header files (we assume C89 is available, so don't check for that)
314 AC_CHECK_HEADERS_ONCE(unistd.h sys/random.h sys/time.h sys/times.h \
315 sys/resource.h sys/types.h sys/stat.h sys/uio.h sys/wait.h \
316 floatingpoint.h ieeefp.h fenv.h fptrap.h \
317 fpxcp.h pwd.h complex.h xlocale.h)
319 GCC_HEADER_STDINT(gstdint.h)
321 AC_CHECK_MEMBERS([struct stat.st_blksize, struct stat.st_blocks, struct stat.st_rdev])
323 case "${host}--x${with_newlib}" in
324   mips*--xyes)
325     hardwire_newlib=1;;
326   nvptx*--xyes)
327     hardwire_newlib=1;;
328 esac
330 # Check for library functions.
331 if test "${hardwire_newlib:-0}" -eq 1; then
332    # We are being configured with a cross compiler.  AC_REPLACE_FUNCS
333    # may not work correctly, because the compiler may not be able to
334    # link executables.
335    AC_DEFINE(HAVE_MKSTEMP, 1, [Define if you have mkstemp.])
336    AC_DEFINE(HAVE_STRTOF, 1, [Define if you have strtof.])
337    AC_DEFINE(HAVE_SNPRINTF, 1, [Define if you have snprintf.])
338    AC_DEFINE(HAVE_VSNPRINTF, 1, [Define if you have vsnprintf.])
339    AC_DEFINE(HAVE_LOCALTIME_R, 1, [Define if you have localtime_r.])
340    AC_DEFINE(HAVE_GMTIME_R, 1, [Define if you have gmtime_r.])
341    AC_DEFINE(HAVE_STRNLEN, 1, [Define if you have strnlen.])
342    AC_DEFINE(HAVE_STRNDUP, 1, [Define if you have strndup.])
344    # At some point, we should differentiate between architectures
345    # like x86, which have long double versions, and alpha/powerpc/etc.,
346    # which don't. For the time being, punt.
347    if test x"long_double_math_on_this_cpu" = x"yes"; then
348      AC_DEFINE(HAVE_STRTOLD, 1, [Define if you have strtold.])
349    fi
350 else
351    AC_CHECK_FUNCS_ONCE(getrusage times mkstemp strtof strtold snprintf \
352    ftruncate chsize chdir getentropy getlogin gethostname kill link symlink \
353    sleep ttyname sigaction waitpid \
354    alarm access fork posix_spawn setmode fcntl writev \
355    gettimeofday stat fstat lstat getpwuid vsnprintf dup \
356    getcwd localtime_r gmtime_r getpwuid_r ttyname_r clock_gettime \
357    getgid getpid getuid geteuid umask getegid \
358    secure_getenv __secure_getenv mkostemp strnlen strndup newlocale \
359    freelocale uselocale strerror_l strtof128 strfromf128)
362 # Check strerror_r, cannot be above as versions with two and three arguments exist
363 LIBGFOR_CHECK_STRERROR_R
365 # Check for C99 (and other IEEE) math functions
366 GCC_CHECK_MATH_FUNC([acosf])
367 GCC_CHECK_MATH_FUNC([acos])
368 GCC_CHECK_MATH_FUNC([acosl])
369 GCC_CHECK_MATH_FUNC([acoshf])
370 GCC_CHECK_MATH_FUNC([acosh])
371 GCC_CHECK_MATH_FUNC([acoshl])
372 GCC_CHECK_MATH_FUNC([asinf])
373 GCC_CHECK_MATH_FUNC([asin])
374 GCC_CHECK_MATH_FUNC([asinl])
375 GCC_CHECK_MATH_FUNC([asinhf])
376 GCC_CHECK_MATH_FUNC([asinh])
377 GCC_CHECK_MATH_FUNC([asinhl])
378 GCC_CHECK_MATH_FUNC([atan2f])
379 GCC_CHECK_MATH_FUNC([atan2])
380 GCC_CHECK_MATH_FUNC([atan2l])
381 GCC_CHECK_MATH_FUNC([atanf])
382 GCC_CHECK_MATH_FUNC([atan])
383 GCC_CHECK_MATH_FUNC([atanl])
384 GCC_CHECK_MATH_FUNC([atanhf])
385 GCC_CHECK_MATH_FUNC([atanh])
386 GCC_CHECK_MATH_FUNC([atanhl])
387 GCC_CHECK_MATH_FUNC([cargf])
388 GCC_CHECK_MATH_FUNC([carg])
389 GCC_CHECK_MATH_FUNC([cargl])
390 GCC_CHECK_MATH_FUNC([ceilf])
391 GCC_CHECK_MATH_FUNC([ceil])
392 GCC_CHECK_MATH_FUNC([ceill])
393 GCC_CHECK_MATH_FUNC([copysignf])
394 GCC_CHECK_MATH_FUNC([copysign])
395 GCC_CHECK_MATH_FUNC([copysignl])
396 GCC_CHECK_MATH_FUNC([cosf])
397 GCC_CHECK_MATH_FUNC([cos])
398 GCC_CHECK_MATH_FUNC([cosl])
399 GCC_CHECK_MATH_FUNC([ccosf])
400 GCC_CHECK_MATH_FUNC([ccos])
401 GCC_CHECK_MATH_FUNC([ccosl])
402 GCC_CHECK_MATH_FUNC([coshf])
403 GCC_CHECK_MATH_FUNC([cosh])
404 GCC_CHECK_MATH_FUNC([coshl])
405 GCC_CHECK_MATH_FUNC([ccoshf])
406 GCC_CHECK_MATH_FUNC([ccosh])
407 GCC_CHECK_MATH_FUNC([ccoshl])
408 GCC_CHECK_MATH_FUNC([expf])
409 GCC_CHECK_MATH_FUNC([exp])
410 GCC_CHECK_MATH_FUNC([expl])
411 GCC_CHECK_MATH_FUNC([cexpf])
412 GCC_CHECK_MATH_FUNC([cexp])
413 GCC_CHECK_MATH_FUNC([cexpl])
414 GCC_CHECK_MATH_FUNC([fabsf])
415 GCC_CHECK_MATH_FUNC([fabs])
416 GCC_CHECK_MATH_FUNC([fabsl])
417 GCC_CHECK_MATH_FUNC([cabsf])
418 GCC_CHECK_MATH_FUNC([cabs])
419 GCC_CHECK_MATH_FUNC([cabsl])
420 GCC_CHECK_MATH_FUNC([floorf])
421 GCC_CHECK_MATH_FUNC([floor])
422 GCC_CHECK_MATH_FUNC([floorl])
423 GCC_CHECK_MATH_FUNC([fmaf])
424 GCC_CHECK_MATH_FUNC([fma])
425 GCC_CHECK_MATH_FUNC([fmal])
426 GCC_CHECK_MATH_FUNC([fmodf])
427 GCC_CHECK_MATH_FUNC([fmod])
428 GCC_CHECK_MATH_FUNC([fmodl])
429 GCC_CHECK_MATH_FUNC([frexpf])
430 GCC_CHECK_MATH_FUNC([frexp])
431 GCC_CHECK_MATH_FUNC([frexpl])
432 GCC_CHECK_MATH_FUNC([hypotf])
433 GCC_CHECK_MATH_FUNC([hypot])
434 GCC_CHECK_MATH_FUNC([hypotl])
435 GCC_CHECK_MATH_FUNC([ldexpf])
436 GCC_CHECK_MATH_FUNC([ldexp])
437 GCC_CHECK_MATH_FUNC([ldexpl])
438 GCC_CHECK_MATH_FUNC([logf])
439 GCC_CHECK_MATH_FUNC([log])
440 GCC_CHECK_MATH_FUNC([logl])
441 GCC_CHECK_MATH_FUNC([clogf])
442 GCC_CHECK_MATH_FUNC([clog])
443 GCC_CHECK_MATH_FUNC([clogl])
444 GCC_CHECK_MATH_FUNC([log10f])
445 GCC_CHECK_MATH_FUNC([log10])
446 GCC_CHECK_MATH_FUNC([log10l])
447 GCC_CHECK_MATH_FUNC([clog10f])
448 GCC_CHECK_MATH_FUNC([clog10])
449 GCC_CHECK_MATH_FUNC([clog10l])
450 GCC_CHECK_MATH_FUNC([nextafterf])
451 GCC_CHECK_MATH_FUNC([nextafter])
452 GCC_CHECK_MATH_FUNC([nextafterl])
453 GCC_CHECK_MATH_FUNC([powf])
454 GCC_CHECK_MATH_FUNC([pow])
455 GCC_CHECK_MATH_FUNC([cpowf])
456 GCC_CHECK_MATH_FUNC([cpow])
457 GCC_CHECK_MATH_FUNC([cpowl])
458 GCC_CHECK_MATH_FUNC([roundf])
459 GCC_CHECK_MATH_FUNC([round])
460 GCC_CHECK_MATH_FUNC([roundl])
461 GCC_CHECK_MATH_FUNC([lroundf])
462 GCC_CHECK_MATH_FUNC([lround])
463 GCC_CHECK_MATH_FUNC([lroundl])
464 GCC_CHECK_MATH_FUNC([llroundf])
465 GCC_CHECK_MATH_FUNC([llround])
466 GCC_CHECK_MATH_FUNC([llroundl])
467 GCC_CHECK_MATH_FUNC([scalbnf])
468 GCC_CHECK_MATH_FUNC([scalbn])
469 GCC_CHECK_MATH_FUNC([scalbnl])
470 GCC_CHECK_MATH_FUNC([sinf])
471 GCC_CHECK_MATH_FUNC([sin])
472 GCC_CHECK_MATH_FUNC([sinl])
473 GCC_CHECK_MATH_FUNC([csinf])
474 GCC_CHECK_MATH_FUNC([csin])
475 GCC_CHECK_MATH_FUNC([csinl])
476 GCC_CHECK_MATH_FUNC([sinhf])
477 GCC_CHECK_MATH_FUNC([sinh])
478 GCC_CHECK_MATH_FUNC([sinhl])
479 GCC_CHECK_MATH_FUNC([csinhf])
480 GCC_CHECK_MATH_FUNC([csinh])
481 GCC_CHECK_MATH_FUNC([csinhl])
482 GCC_CHECK_MATH_FUNC([sqrtf])
483 GCC_CHECK_MATH_FUNC([sqrt])
484 GCC_CHECK_MATH_FUNC([sqrtl])
485 GCC_CHECK_MATH_FUNC([csqrtf])
486 GCC_CHECK_MATH_FUNC([csqrt])
487 GCC_CHECK_MATH_FUNC([csqrtl])
488 GCC_CHECK_MATH_FUNC([tanf])
489 GCC_CHECK_MATH_FUNC([tan])
490 GCC_CHECK_MATH_FUNC([tanl])
491 GCC_CHECK_MATH_FUNC([ctanf])
492 GCC_CHECK_MATH_FUNC([ctan])
493 GCC_CHECK_MATH_FUNC([ctanl])
494 GCC_CHECK_MATH_FUNC([tanhf])
495 GCC_CHECK_MATH_FUNC([tanh])
496 GCC_CHECK_MATH_FUNC([tanhl])
497 GCC_CHECK_MATH_FUNC([ctanhf])
498 GCC_CHECK_MATH_FUNC([ctanh])
499 GCC_CHECK_MATH_FUNC([ctanhl])
500 GCC_CHECK_MATH_FUNC([truncf])
501 GCC_CHECK_MATH_FUNC([trunc])
502 GCC_CHECK_MATH_FUNC([truncl])
503 GCC_CHECK_MATH_FUNC([erff])
504 GCC_CHECK_MATH_FUNC([erf])
505 GCC_CHECK_MATH_FUNC([erfcf])
506 GCC_CHECK_MATH_FUNC([erfc])
507 GCC_CHECK_MATH_FUNC([erfcl])
508 GCC_CHECK_MATH_FUNC([j0f])
509 GCC_CHECK_MATH_FUNC([j0])
510 GCC_CHECK_MATH_FUNC([j1f])
511 GCC_CHECK_MATH_FUNC([j1])
512 GCC_CHECK_MATH_FUNC([jnf])
513 GCC_CHECK_MATH_FUNC([jn])
514 GCC_CHECK_MATH_FUNC([jnl])
515 GCC_CHECK_MATH_FUNC([y0f])
516 GCC_CHECK_MATH_FUNC([y0])
517 GCC_CHECK_MATH_FUNC([y1f])
518 GCC_CHECK_MATH_FUNC([y1])
519 GCC_CHECK_MATH_FUNC([ynf])
520 GCC_CHECK_MATH_FUNC([yn])
521 GCC_CHECK_MATH_FUNC([ynl])
522 GCC_CHECK_MATH_FUNC([tgamma])
523 GCC_CHECK_MATH_FUNC([tgammaf])
524 GCC_CHECK_MATH_FUNC([lgamma])
525 GCC_CHECK_MATH_FUNC([lgammaf])
527 # Check for GFORTRAN_C99_1.1 funcs
528 GCC_CHECK_MATH_FUNC([cacos])
529 GCC_CHECK_MATH_FUNC([cacosf])
530 GCC_CHECK_MATH_FUNC([cacosh])
531 GCC_CHECK_MATH_FUNC([cacoshf])
532 GCC_CHECK_MATH_FUNC([cacoshl])
533 GCC_CHECK_MATH_FUNC([cacosl])
534 GCC_CHECK_MATH_FUNC([casin])
535 GCC_CHECK_MATH_FUNC([casinf])
536 GCC_CHECK_MATH_FUNC([casinh])
537 GCC_CHECK_MATH_FUNC([casinhf])
538 GCC_CHECK_MATH_FUNC([casinhl])
539 GCC_CHECK_MATH_FUNC([casinl])
540 GCC_CHECK_MATH_FUNC([catan])
541 GCC_CHECK_MATH_FUNC([catanf])
542 GCC_CHECK_MATH_FUNC([catanh])
543 GCC_CHECK_MATH_FUNC([catanhf])
544 GCC_CHECK_MATH_FUNC([catanhl])
545 GCC_CHECK_MATH_FUNC([catanl])
547 # For POWER, check the ieee128 math functions
549 if test "x$have_real_17" = "xyes"; then
550 AC_DEFINE_UNQUOTED(AS_TR_CPP(HAVE_REAL_17),[1],
551   [Define to 1 if you have REAL(KIND=17)])
553 LIBGFOR_CHECK_MATH_IEEE128([__acoshieee128])
554 LIBGFOR_CHECK_MATH_IEEE128([__acosieee128])
555 LIBGFOR_CHECK_MATH_IEEE128([__asinhieee128])
556 LIBGFOR_CHECK_MATH_IEEE128([__asinieee128])
557 LIBGFOR_CHECK_MATH_IEEE128([__atan2ieee128])
558 LIBGFOR_CHECK_MATH_IEEE128([__atanhieee128])
559 LIBGFOR_CHECK_MATH_IEEE128([__atanieee128])
560 LIBGFOR_CHECK_MATH_IEEE128([__coshieee128])
561 LIBGFOR_CHECK_MATH_IEEE128([__cosieee128])
562 LIBGFOR_CHECK_MATH_IEEE128([__erfieee128])
563 LIBGFOR_CHECK_MATH_IEEE128([__expieee128])
564 LIBGFOR_CHECK_MATH_IEEE128([__fabsieee128])
565 LIBGFOR_CHECK_MATH_IEEE128([__jnieee128])
566 LIBGFOR_CHECK_MATH_IEEE128([__log10ieee128])
567 LIBGFOR_CHECK_MATH_IEEE128([__logieee128])
568 LIBGFOR_CHECK_MATH_IEEE128([__powieee128])
569 LIBGFOR_CHECK_MATH_IEEE128([__sinhieee128])
570 LIBGFOR_CHECK_MATH_IEEE128([__sinieee128])
571 LIBGFOR_CHECK_MATH_IEEE128([__sqrtieee128])
572 LIBGFOR_CHECK_MATH_IEEE128([__tanhieee128])
573 LIBGFOR_CHECK_MATH_IEEE128([__tanieee128])
574 LIBGFOR_CHECK_MATH_IEEE128([__ynieee128])
577 # On AIX, clog is present in libm as __clog
578 AC_CHECK_LIB([m],[__clog],[AC_DEFINE([HAVE_CLOG],[1],[libm includes clog])])
580 GCC_CHECK_MATH_INLINE_BUILTIN_FALLBACK2([copysign], [double])
581 GCC_CHECK_MATH_INLINE_BUILTIN_FALLBACK2([copysignl], [long double])
582 GCC_CHECK_MATH_INLINE_BUILTIN_FALLBACK1([fabs], [double])
583 GCC_CHECK_MATH_INLINE_BUILTIN_FALLBACK1([fabsl], [long double])
585 GCC_CHECK_MATH_FUNC([acosf128])
586 GCC_CHECK_MATH_FUNC([acoshf128])
587 GCC_CHECK_MATH_FUNC([asinf128])
588 GCC_CHECK_MATH_FUNC([asinhf128])
589 GCC_CHECK_MATH_FUNC([atan2f128])
590 GCC_CHECK_MATH_FUNC([atanf128])
591 GCC_CHECK_MATH_FUNC([atanhf128])
592 GCC_CHECK_MATH_FUNC([cargf128])
593 GCC_CHECK_MATH_FUNC([ceilf128])
594 GCC_CHECK_MATH_FUNC([copysignf128])
595 GCC_CHECK_MATH_FUNC([cosf128])
596 GCC_CHECK_MATH_FUNC([ccosf128])
597 GCC_CHECK_MATH_FUNC([coshf128])
598 GCC_CHECK_MATH_FUNC([ccoshf128])
599 GCC_CHECK_MATH_FUNC([expf128])
600 GCC_CHECK_MATH_FUNC([cexpf128])
601 GCC_CHECK_MATH_FUNC([fabsf128])
602 GCC_CHECK_MATH_FUNC([cabsf128])
603 GCC_CHECK_MATH_FUNC([floorf128])
604 GCC_CHECK_MATH_FUNC([fmaf128])
605 GCC_CHECK_MATH_FUNC([fmodf128])
606 GCC_CHECK_MATH_FUNC([frexpf128])
607 GCC_CHECK_MATH_FUNC([hypotf128])
608 GCC_CHECK_MATH_FUNC([ldexpf128])
609 GCC_CHECK_MATH_FUNC([logf128])
610 GCC_CHECK_MATH_FUNC([clogf128])
611 GCC_CHECK_MATH_FUNC([log10f128])
612 GCC_CHECK_MATH_FUNC([clog10f128])
613 GCC_CHECK_MATH_FUNC([nextafterf128])
614 GCC_CHECK_MATH_FUNC([powf128])
615 GCC_CHECK_MATH_FUNC([cpowf128])
616 GCC_CHECK_MATH_FUNC([roundf128])
617 GCC_CHECK_MATH_FUNC([lroundf128])
618 GCC_CHECK_MATH_FUNC([llroundf128])
619 GCC_CHECK_MATH_FUNC([scalbnf128])
620 GCC_CHECK_MATH_FUNC([sinf128])
621 GCC_CHECK_MATH_FUNC([csinf128])
622 GCC_CHECK_MATH_FUNC([sinhf128])
623 GCC_CHECK_MATH_FUNC([csinhf128])
624 GCC_CHECK_MATH_FUNC([sqrtf128])
625 GCC_CHECK_MATH_FUNC([csqrtf128])
626 GCC_CHECK_MATH_FUNC([tanf128])
627 GCC_CHECK_MATH_FUNC([ctanf128])
628 GCC_CHECK_MATH_FUNC([tanhf128])
629 GCC_CHECK_MATH_FUNC([ctanhf128])
630 GCC_CHECK_MATH_FUNC([truncf128])
631 GCC_CHECK_MATH_FUNC([erff128])
632 GCC_CHECK_MATH_FUNC([erfcf128])
633 GCC_CHECK_MATH_FUNC([j0f128])
634 GCC_CHECK_MATH_FUNC([j1f128])
635 GCC_CHECK_MATH_FUNC([jnf128])
636 GCC_CHECK_MATH_FUNC([y0f128])
637 GCC_CHECK_MATH_FUNC([y1f128])
638 GCC_CHECK_MATH_FUNC([ynf128])
639 GCC_CHECK_MATH_FUNC([tgammaf128])
640 GCC_CHECK_MATH_FUNC([lgammaf128])
642 GCC_CHECK_MATH_FUNC([cacosf128])
643 GCC_CHECK_MATH_FUNC([cacoshf128])
644 GCC_CHECK_MATH_FUNC([casinf128])
645 GCC_CHECK_MATH_FUNC([casinhf128])
646 GCC_CHECK_MATH_FUNC([catanf128])
647 GCC_CHECK_MATH_FUNC([catanhf128])
649 # Check whether the system has a working stat()
650 LIBGFOR_CHECK_WORKING_STAT
652 # Check whether __mingw_snprintf() is present
653 LIBGFOR_CHECK_MINGW_SNPRINTF
655 have_iec_60559_libc_support=no
656 if test "x$ac_cv_func_strtof128$ac_cv_func_strfromf128" = xyesyes \
657    && test "x$gcc_cv_math_func_sinf128$gcc_cv_math_func_cacosf128" = xyesyes; then
658   have_iec_60559_libc_support=yes
661 # Check whether libquadmath should be used
662 AC_ARG_ENABLE(libquadmath-support,
663 AS_HELP_STRING([--disable-libquadmath-support],
664   [disable libquadmath support for Fortran]),
665 ENABLE_LIBQUADMATH_SUPPORT=$enableval,
666 if test "x$have_iec_60559_libc_support" = xyes; then
667   ENABLE_LIBQUADMATH_SUPPORT=default
668 else
669   ENABLE_LIBQUADMATH_SUPPORT=yes
671 enable_libquadmath_support=
672 if test "${ENABLE_LIBQUADMATH_SUPPORT}" = "no" ; then
673   enable_libquadmath_support=no
674 elif test "${ENABLE_LIBQUADMATH_SUPPORT}" = "default" ; then
675   enable_libquadmath_support=default
678 # Check whether we have a _Float128 type, depends on enable_libquadmath_support
679 # and have_iec_60559_libc_support.
680 LIBGFOR_CHECK_FLOAT128
682 # Check for GNU libc feenableexcept
683 AC_CHECK_LIB([m],[feenableexcept],[have_feenableexcept=yes AC_DEFINE([HAVE_FEENABLEEXCEPT],[1],[libm includes feenableexcept])])
685 # At least for glibc, clock_gettime is in librt.  But don't
686 # pull that in if it still doesn't give us the function we want.  This
687 # test is copied from libgomp, and modified to not link in -lrt as
688 # libgfortran calls clock_gettime via a weak reference if it's found
689 # in librt.
690 if test "$ac_cv_func_clock_gettime" = no; then
691   AC_CHECK_LIB(rt, clock_gettime,
692     [AC_DEFINE(HAVE_CLOCK_GETTIME_LIBRT, 1,
693                [Define to 1 if you have the `clock_gettime' function in librt.])])
696 # Check for SysV fpsetmask
697 LIBGFOR_CHECK_FPSETMASK
698 AC_CHECK_TYPES([fp_except,fp_except_t], [], [], [[
699 #ifdef HAVE_IEEEFP_H
700 #include <ieeefp.h>
701 #endif
702 #include <math.h>
704 AC_CHECK_TYPES([fp_rnd,fp_rnd_t], [], [], [[
705 #ifdef HAVE_IEEEFP_H
706 #include <ieeefp.h>
707 #endif
708 #include <math.h>
711 # Check whether we have fpsetsticky or fpresetsticky
712 AC_CHECK_FUNC([fpsetsticky],[have_fpsetsticky=yes AC_DEFINE([HAVE_FPSETSTICKY],[1],[fpsetsticky is present])])
713 AC_CHECK_FUNC([fpresetsticky],[have_fpresetsticky=yes AC_DEFINE([HAVE_FPRESETSTICKY],[1],[fpresetsticky is present])])
715 # Check for AIX fp_trap and fp_enable
716 AC_CHECK_FUNC([fp_trap],[have_fp_trap=yes AC_DEFINE([HAVE_FP_TRAP],[1],[fp_trap is present])])
717 AC_CHECK_FUNC([fp_enable],[have_fp_enable=yes AC_DEFINE([HAVE_FP_ENABLE],[1],[fp_enable is present])])
719 # Check if _SOFT_FLOAT is defined
720 AC_CHECK_DEFINE([_SOFT_FLOAT],[have_soft_float=yes])
722 # Runs configure.host to set up necessary host-dependent shell variables.
723 # We then display a message about it, and propagate them through the
724 # build chain.
725 . ${srcdir}/configure.host
726 AC_MSG_NOTICE([FPU dependent file will be ${fpu_host}.h])
727 AC_MSG_NOTICE([Support for IEEE modules: ${ieee_support}])
728 FPU_HOST_HEADER=config/${fpu_host}.h
729 AC_SUBST(FPU_HOST_HEADER)
731 # Whether we will build the IEEE modules
732 AM_CONDITIONAL(IEEE_SUPPORT,[test x${ieee_support} = xyes])
733 AC_SUBST(IEEE_SUPPORT)
735 # Some targets require additional compiler options for IEEE compatibility.
736 IEEE_FLAGS="${ieee_flags}"
737 AC_SUBST(IEEE_FLAGS)
739 # Conditionalize the makefile for this target machine.
740 tmake_file_=
741 for f in ${tmake_file}
743         if test -f ${srcdir}/config/$f
744         then
745                 tmake_file_="${tmake_file_} \$(srcdir)/config/$f"
746         fi
747 done
748 tmake_file="${tmake_file_}"
749 AC_SUBST(tmake_file)
752 # Check for POSIX getpwuid_r 
754 # There are two versions of getpwuid_r, the POSIX one with 5
755 # arguments, and another one with 4 arguments used by at least HP-UX
756 # 10.2.
757 if test "$ac_cv_func_getpwuid_r" = "yes"; then
758    AC_CACHE_CHECK([POSIX version of getpwuid_r with 5 arguments], libgfor_cv_posix_getpwuid_r, [
759    AC_LINK_IFELSE([AC_LANG_PROGRAM([
760 #include <stdio.h>
761 #include <sys/types.h>
762 #include <pwd.h>], [
763     getpwuid_r(0, NULL, NULL, 0, NULL);
764     ])],  [libgfor_cv_posix_getpwuid_r="yes"], [libgfor_cv_posix_getpwuid_r="no"])])
766 if test "$libgfor_cv_posix_getpwuid_r" = "yes"; then
767     AC_DEFINE([HAVE_POSIX_GETPWUID_R], [1], [Define to 1 if we have POSIX getpwuid_r which takes 5 arguments.])
771 # Check out attribute support.
772 LIBGFOR_CHECK_ATTRIBUTE_VISIBILITY
773 LIBGFOR_CHECK_ATTRIBUTE_ALIAS
775 # Check out atomic builtins support.
776 LIBGFOR_CHECK_ATOMIC_FETCH_ADD
778 # Check out #pragma weak.
779 LIBGFOR_GTHREAD_WEAK
781 # Check out weakref support.
782 LIBGFOR_CHECK_WEAKREF
784 # Various other checks on target
785 LIBGFOR_CHECK_UNLINK_OPEN_FILE
787 # Check whether line terminator is LF or CRLF
788 LIBGFOR_CHECK_CRLF
790 # Check whether we support AVX extensions
791 LIBGFOR_CHECK_AVX
793 # Check whether we support AVX2 extensions
794 LIBGFOR_CHECK_AVX2
796 # Check whether we support AVX512f extensions
797 LIBGFOR_CHECK_AVX512F
799 # Check for FMA3 extensions
800 LIBGFOR_CHECK_FMA3
802 # Check for FMA4 extensions
803 LIBGFOR_CHECK_FMA4
805 # Check if AVX128 works
806 LIBGFOR_CHECK_AVX128
808 # Determine what GCC version number to use in filesystem paths.
809 GCC_BASE_VER
811 AC_CACHE_SAVE
813 if test ${multilib} = yes; then
814   multilib_arg="--enable-multilib"
815 else
816   multilib_arg=
819 # Write our Makefile and spec file.
820 AC_CONFIG_FILES([
821 Makefile
822 libgfortran.spec
824 AC_OUTPUT