1dnl Defines PY_NOOPT_CFLAGS to either '' or -O1
2dnl
3
4dnl This is necessary because on some systems setup.py includes
5dnl -D_FORTIFY_SOURCE but have a -D_FORTIFY_SOURCE which breaks
6dnl with -O0.  On those systems we arrange to use -O1 for debug
7dnl builds instead.
8
9AC_DEFUN([AX_CHECK_PYTHON_FORTIFY_NOOPT], [
10    AC_CACHE_CHECK([whether Python setup.py brokenly enables -D_FORTIFY_SOURCE],
11                   [ax_cv_python_fortify],[
12        ax_cv_python_fortify=no
13        for arg in $($PYTHON-config --cflags); do
14            case "$arg" in
15            -D_FORTIFY_SOURCE=0) ax_cv_python_fortify=no ;;
16            -D_FORTIFY_SOURCE=*) ax_cv_python_fortify=yes ;;
17            -Wp,-D_FORTIFY_SOURCE=0) ax_cv_python_fortify=no ;;
18            -Wp,-D_FORTIFY_SOURCE=*) ax_cv_python_fortify=yes ;;
19            *) ;;
20            esac
21        done
22    ])
23
24    AS_IF([test x$ax_cv_python_fortify = xyes],[
25        PY_NOOPT_CFLAGS=-O1
26    ], [
27        PY_NOOPT_CFLAGS=''
28    ])
29
30    AC_SUBST(PY_NOOPT_CFLAGS)
31])
32