about summary refs log tree commit diff
path: root/sysdeps/csky/preconfigure.ac
diff options
context:
space:
mode:
authorMaciej W. Rozycki <macro@embecosm.com>2022-05-13 17:07:23 +0100
committerMaciej W. Rozycki <macro@embecosm.com>2022-05-13 17:07:23 +0100
commit7c20479d082eb85ac1179df0411ef3e4a0634298 (patch)
tree9e3585841d3fd377c65b7d1343678d4ef58126d3 /sysdeps/csky/preconfigure.ac
parentf39ff483f320878b2a2950353d05747eae623216 (diff)
downloadglibc-7c20479d082eb85ac1179df0411ef3e4a0634298.tar.gz
glibc-7c20479d082eb85ac1179df0411ef3e4a0634298.tar.xz
glibc-7c20479d082eb85ac1179df0411ef3e4a0634298.zip
C-SKY: Use an autoconf template to produce `preconfigure'
Avoid fiddling with autoconf internals and use AC_DEFINE_UNQUOTED to
define macros in the configuration headers rather than handcoding an
equivalent shell sequence with the use of the `as_echo' undocumented
variable.

Switch to using AC_MSG_ERROR rather than `echo' and `exit' directly for
error handling.  Owing to the lack of any kind of error annotation it
makes it difficult to spot the message in the flood in a parallel build
and neither it is logged in `config.log'.
Diffstat (limited to 'sysdeps/csky/preconfigure.ac')
-rw-r--r--sysdeps/csky/preconfigure.ac55
1 files changed, 55 insertions, 0 deletions
diff --git a/sysdeps/csky/preconfigure.ac b/sysdeps/csky/preconfigure.ac
new file mode 100644
index 0000000000..332c0f1cab
--- /dev/null
+++ b/sysdeps/csky/preconfigure.ac
@@ -0,0 +1,55 @@
+GLIBC_PROVIDES[]dnl See aclocal.m4 in the top level source directory.
+# Local preconfigure fragment for sysdeps/csky
+
+case "$machine" in
+csky*)
+    abi=`$CC $CFLAGS $CPPFLAGS -E -dM -xc /dev/null |
+      sed -n 's/^#define __CSKYABI__ \(.*\)/\1/p'`
+    hard_float=`$CC $CFLAGS $CPPFLAGS -E -dM -xc /dev/null |
+      sed -n 's/^#define __CSKY_HARD_FLOAT__ \(.*\)/\1/p'`
+    hard_float_sf=`$CC $CFLAGS $CPPFLAGS -E -dM -xc /dev/null |
+      sed -n 's/^#define __CSKY_HARD_FLOAT_FPU_SF__ \(.*\)/\1/p'`
+    hard_float_abi=`$CC $CFLAGS $CPPFLAGS -E -dM -xc /dev/null |
+      sed -n 's/^#define __CSKY_HARD_FLOAT_ABI__ \(.*\)/\1/p'`
+
+    case "$abi" in
+    1)
+	AC_MSG_ERROR([glibc does not support abiv1 yet], [1])
+	;;
+    2)
+	machine=abiv2
+	;;
+    *)
+	AC_MSG_ERROR([Unknown abi], [1])
+	;;
+    esac
+
+    # __CSKY_HARD_FLOAT_ABI__ was added on gcc 11 to specify whether
+    # -mfloat-abi=hard is set.  On older gcc, the float ABI is defined solely
+    # with __CSKY_HARD_FLOAT__.  If __CSKY_HARD_FLOAT__ is set, it can be
+    # either a hard-float ABI (gcc older than 11, or gcc11 -mfloat-abi=hard
+    # (__CSKY_HARD_FLOAT_ABI__ is set) or -mfloat-abi=softfp
+    # (__CSKY_HARD_FLOAT_ABI__ is not set). To be compatible with older gcc,
+    # use __CSKY_HARD_FLOAT_FPU_SF__ identify if -mfloat-abi is supported,
+    # because it is added to gcc at the same time as -mfloat-abi.
+    if test -n "$hard_float"; then
+	if test -z "$hard_float_sf"; then
+	    with_fp_cond=1
+	else
+	    if test -n "$hard_float_abi"; then
+		with_fp_cond=1
+	    else
+		with_fp_cond=0
+	    fi
+	fi
+    else
+	with_fp_cond=0
+    fi
+
+    base_machine=csky
+    machine=csky/$machine
+
+    AC_DEFINE_UNQUOTED([CSKYABI], [$abi])
+    AC_DEFINE_UNQUOTED([CSKY_HARD_FLOAT], [$with_fp_cond])
+    ;;
+esac