]> www.ginac.de Git - cln.git/blob - m4/cc.m4
build: switch to ordinary auto* tools system.
[cln.git] / m4 / cc.m4
1 dnl Checks whether the stack can be marked nonexecutable by passing an option
2 dnl to the C-compiler when acting on .s files. Appends that option to ASFLAGS.
3 dnl This macro is adapted from one found in GLIBC-2.3.5.
4 AC_DEFUN([CL_AS_NOEXECSTACK],[
5 AC_REQUIRE([AC_PROG_CC])
6 AC_REQUIRE([AM_PROG_AS])
7 AC_CACHE_CHECK([whether --noexecstack is desirable for .s files], cl_cv_as_noexecstack, [dnl
8   cat > conftest.c <<EOF
9 void foo() {}
10 EOF
11   if AC_TRY_COMMAND([${CCAS} $CFLAGS $CPPFLAGS
12                      -S -o conftest.s conftest.c >/dev/null]) \
13      && grep -q .note.GNU-stack conftest.s \
14      && AC_TRY_COMMAND([${CCAS} $CFLAGS $CPPFLAGS -Wa,--noexecstack
15                        -c -o conftest.o conftest.s >/dev/null])
16   then
17     cl_cv_as_noexecstack=yes
18   else
19     cl_cv_as_noexecstack=no
20   fi
21   rm -f conftest*])
22   if test "$cl_cv_as_noexecstack" = yes; then
23     CCASFLAGS="$CCASFLAGS -Wa,--noexecstack"
24   fi
25 ])
26
27
28 dnl Checks whether the compiler supports __attribute__((flatten)).
29 AC_DEFUN([CL_ATTRIBUTE_FLATTEN],[
30 AC_REQUIRE([AC_PROG_CXX])
31 AC_CACHE_CHECK([whether the compiler supports __attribute__((flatten))], cl_cv_have_attr_flatten, [dnl
32   cat > conftest.cc <<EOF
33 void f() __attribute__((flatten));
34 EOF
35 if AC_TRY_COMMAND(${CXX-g++} $CXXFLAGS -c conftest.cc >/dev/null 2>conftest.stderr)
36 then
37   if grep -i "warning" conftest.stderr > /dev/null; then
38     cl_cv_have_attr_flatten=no
39   else
40     cl_cv_have_attr_flatten=yes
41   fi
42 else
43   cl_cv_have_attr_flatten=no
44 fi
45 rm -f conftest*
46 ])
47 if test $cl_cv_have_attr_flatten = yes; then
48   AC_DEFINE(CL_HAVE_ATTRIBUTE_FLATTEN, ,[Define if compiler supports __attribute__((flatten))])
49 fi
50 ])