initial commit
[glibc.git] / sysdeps / unix / sysv / linux / mips / configure.ac
1 sinclude(./aclocal.m4)dnl Autoconf lossage
2 GLIBC_PROVIDES dnl See aclocal.m4 in the top level source directory.
3 # Local configure fragment for sysdeps/unix/sysv/linux/mips.
4
5 AC_COMPILE_IFELSE(
6 [AC_LANG_PROGRAM([
7 #if (_MIPS_SIM != _ABIO32)
8 #error Not O32 ABI
9 #endif])],
10 [libc_mips_abi=o32],
11 [AC_COMPILE_IFELSE(
12 [AC_LANG_PROGRAM([
13 #if (_MIPS_SIM != _ABIN32)
14 #error Not N32 ABI
15 #endif])],
16 [libc_mips_abi=n32],
17 [AC_COMPILE_IFELSE(
18 [AC_LANG_PROGRAM([
19 #if (_MIPS_SIM != _ABI64)
20 #error Not 64 ABI
21 #endif])],
22 [libc_mips_abi=n64],
23 [])])])
24
25 if test -z "$libc_mips_abi"; then
26 AC_MSG_ERROR([could not determine what ABI the compiler is using])
27 fi
28
29 AC_COMPILE_IFELSE(
30 [AC_LANG_PROGRAM([
31 #if !defined(__mips_soft_float)
32 #error Not soft ABI
33 #endif])],
34 [libc_mips_float=soft],
35 [AC_COMPILE_IFELSE(
36 [AC_LANG_PROGRAM([
37 #if !defined(__mips_hard_float)
38 #error Not hard ABI
39 #endif])],
40 [libc_mips_float=hard],
41 [])])
42
43 if test -z "$libc_mips_float"; then
44 AC_MSG_ERROR([could not determine if compiler is using hard or soft floating point ABI])
45 fi
46
47 libc_mips_o32_fp=
48 libc_cv_mips_fp64=
49 libc_cv_mips_modd_spreg=
50
51 if test x"$libc_mips_abi" = xo32 -a x"$libc_mips_float" = xhard; then
52 AC_COMPILE_IFELSE(
53 [AC_LANG_PROGRAM([
54 #if !defined(__mips_fpr)
55 #error Missing FPR sizes
56 #endif])],
57 [AC_COMPILE_IFELSE(
58 [AC_LANG_PROGRAM([
59 #if (__mips_fpr != 32)
60 #error Not FP32
61 #endif])],
62 [libc_mips_o32_fp=32],
63 [AC_COMPILE_IFELSE(
64 [AC_LANG_PROGRAM([
65 #if (__mips_fpr != 0) || !defined(_MIPS_SPFPSET) || (_MIPS_SPFPSET != 16)
66 #error Not FPXX (without odd single-precision registers)
67 #endif])],
68 [libc_mips_o32_fp=xx],
69 [AC_COMPILE_IFELSE(
70 [AC_LANG_PROGRAM([
71 #if (__mips_fpr != 0)
72 #error Not FPXX (with odd single precision registers)
73 #endif])],
74 [libc_mips_o32_fp=xxo],
75 [AC_COMPILE_IFELSE(
76 [AC_LANG_PROGRAM([
77 #if (__mips_fpr != 64) || !defined(_MIPS_SPFPSET) || (_MIPS_SPFPSET != 16)
78 #error Not FP64A
79 #endif])],
80 [libc_mips_o32_fp=64a],
81 [AC_COMPILE_IFELSE(
82 [AC_LANG_PROGRAM([
83 #if (__mips_fpr != 64)
84 #error Not FP64
85 #endif])],
86 [libc_mips_o32_fp=64],
87 [])])])])])],
88 [])
89
90 LIBC_TRY_CC_OPTION([-mfp64], [libc_cv_mips_fp64=yes], [libc_cv_mips_fp64=no])
91 LIBC_TRY_CC_OPTION([-Werror -modd-spreg], [libc_cv_mips_modd_spreg=yes], [libc_cv_mips_modd_spreg=no])
92 fi
93 LIBC_CONFIG_VAR([o32-fpabi],[${libc_mips_o32_fp}])
94 LIBC_CONFIG_VAR([has-mpf64],[${libc_cv_mips_fp64}])
95 LIBC_CONFIG_VAR([has-modd-spreg],[${libc_cv_mips_modd_spreg}])
96
97 AC_COMPILE_IFELSE(
98 [AC_LANG_PROGRAM([
99 #include <linux/prctl.h>
100 #if !defined(PR_GET_FP_MODE) || !defined(PR_SET_FP_MODE)
101 #error New prctl support for setting FP modes not found
102 #endif])],
103 [libc_mips_mode_switch=yes],
104 [libc_mips_mode_switch=no])
105 LIBC_CONFIG_VAR([mips-mode-switch],[${libc_mips_mode_switch}])
106
107 AC_CACHE_CHECK([whether the compiler is using the 2008 NaN encoding],
108 libc_cv_mips_nan2008, [AC_EGREP_CPP(yes, [dnl
109 #ifdef __mips_nan2008
110 yes
111 #endif], libc_cv_mips_nan2008=yes, libc_cv_mips_nan2008=no)])
112
113 libc_mips_nan=
114 if test x"$libc_cv_mips_nan2008" = xyes; then
115 libc_mips_nan=_2008
116 fi
117
118 LIBC_CONFIG_VAR([default-abi],
119 [${libc_mips_abi}_${libc_mips_float}${libc_mips_nan}])
120
121 case $machine in
122 mips/mips64/n64/*)
123 LIBC_SLIBDIR_RTLDDIR([lib64], [lib64])
124 ;;
125 mips/mips64/n32/*)
126 LIBC_SLIBDIR_RTLDDIR([lib32], [lib32])
127 ;;
128 esac
129
130 libc_cv_gcc_unwind_find_fde=yes
131
132 if test -z "$arch_minimum_kernel"; then
133 if test x$libc_cv_mips_nan2008 = xyes; then
134 arch_minimum_kernel=4.5.0
135 fi
136 fi
137
138 # Check if we are supposed to run on kernels older than 4.8.0. If so,
139 # force executable stack to avoid potential runtime problems with fpu
140 # emulation.
141 # NOTE: The check below assumes that in absence of user-provided minimum_kernel
142 # we will default to arch_minimum_kernel which is currently less than 4.8.0 for
143 # all known configurations. If this changes, the check must be updated.
144 AC_CACHE_CHECK([whether the compiler must use executable stack],
145 libc_cv_mips_force_execstack, [dnl
146 libc_cv_mips_force_execstack=no
147 if test $libc_mips_float = hard; then
148 if test -n "$minimum_kernel"; then
149 changequote(,)
150 min_version=$((`echo "$minimum_kernel.0.0.0" | sed 's/\([0-9]*\)\.\([0-9]*\)\.\([0-9]*\).*/\1 \* 65536 + \2 \* 256 + \3/'`))
151 changequote([,])
152 if test $min_version -lt 264192; then
153 libc_cv_mips_force_execstack=yes
154 fi
155 else
156 libc_cv_mips_force_execstack=yes
157 fi
158 fi])
159
160 libc_mips_has_gnustack=$libc_cv_as_noexecstack
161
162 if test $libc_cv_mips_force_execstack = yes; then
163 libc_mips_has_gnustack=no
164 AC_MSG_WARN([forcing executable stack for pre-4.8.0 Linux kernels])
165 fi
166
167 LIBC_CONFIG_VAR([mips-force-execstack],[${libc_cv_mips_force_execstack}])
168 LIBC_CONFIG_VAR([mips-has-gnustack],[${libc_mips_has_gnustack}])