1dnl
2dnl GCC_CET_FLAGS
3dnl    (SHELL-CODE_HANDLER)
4dnl
5AC_DEFUN([GCC_CET_FLAGS],[dnl
6GCC_ENABLE(cet, no, ,[enable Intel CET in target libraries],
7	   permit yes|no|auto)
8AC_MSG_CHECKING([for CET support])
9
10case "$host" in
11  i[[34567]]86-*-linux* | x86_64-*-linux*)
12    case "$enable_cet" in
13      auto)
14	# Check if target supports multi-byte NOPs
15	# and if assembler supports CET insn.
16	AC_COMPILE_IFELSE(
17	 [AC_LANG_PROGRAM(
18	  [],
19	  [
20#if !defined(__SSE2__)
21#error target does not support multi-byte NOPs
22#else
23asm ("setssbsy");
24#endif
25	  ])],
26	 [enable_cet=yes],
27	 [enable_cet=no])
28	;;
29      yes)
30	# Check if assembler supports CET.
31	AC_COMPILE_IFELSE(
32	 [AC_LANG_PROGRAM(
33	  [],
34	  [asm ("setssbsy");])],
35	 [],
36	 [AC_MSG_ERROR([assembler with CET support is required for --enable-cet])])
37	;;
38    esac
39    ;;
40  *)
41    enable_cet=no
42    ;;
43esac
44if test x$enable_cet = xyes; then
45  $1="-fcf-protection -mshstk"
46  AC_MSG_RESULT([yes])
47else
48  AC_MSG_RESULT([no])
49fi
50])
51