1sinclude(./aclocal.m4)dnl Autoconf lossage
2GLIBC_PROVIDES dnl See aclocal.m4 in the top level source directory.
3# Local configure fragment for sysdeps/unix/sysv/linux/mips.
4
5AC_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
25if test -z "$libc_mips_abi"; then
26  AC_MSG_ERROR([could not determine what ABI the compiler is using])
27fi
28
29AC_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
43if test -z "$libc_mips_float"; then
44  AC_MSG_ERROR([could not determine if compiler is using hard or soft floating point ABI])
45fi
46
47libc_mips_o32_fp=
48libc_cv_mips_fp64=
49libc_cv_mips_modd_spreg=
50
51if 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])
92fi
93LIBC_CONFIG_VAR([o32-fpabi],[${libc_mips_o32_fp}])
94LIBC_CONFIG_VAR([has-mpf64],[${libc_cv_mips_fp64}])
95LIBC_CONFIG_VAR([has-modd-spreg],[${libc_cv_mips_modd_spreg}])
96
97AC_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])
105LIBC_CONFIG_VAR([mips-mode-switch],[${libc_mips_mode_switch}])
106
107AC_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
110yes
111#endif], libc_cv_mips_nan2008=yes, libc_cv_mips_nan2008=no)])
112
113libc_mips_nan=
114if test x"$libc_cv_mips_nan2008" = xyes; then
115  libc_mips_nan=_2008
116fi
117
118LIBC_CONFIG_VAR([default-abi],
119  [${libc_mips_abi}_${libc_mips_float}${libc_mips_nan}])
120
121case $machine in
122mips/mips64/n64/*)
123  LIBC_SLIBDIR_RTLDDIR([lib64], [lib64])
124  ;;
125mips/mips64/n32/*)
126  LIBC_SLIBDIR_RTLDDIR([lib32], [lib32])
127  ;;
128esac
129
130libc_cv_gcc_unwind_find_fde=yes
131
132if 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
136fi
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.
144AC_CACHE_CHECK([whether the compiler must use executable stack],
145        libc_cv_mips_force_execstack, [dnl
146libc_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
160libc_mips_has_gnustack=$libc_cv_as_noexecstack
161
162if 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])
165fi
166
167LIBC_CONFIG_VAR([mips-force-execstack],[${libc_cv_mips_force_execstack}])
168LIBC_CONFIG_VAR([mips-has-gnustack],[${libc_mips_has_gnustack}])
169