Skip to content

Commit

Permalink
build-sys: add -U_FORTIFY_SOURCE to $PYTHON_CFLAGS when necessary
Browse files Browse the repository at this point in the history
This patch only adds one line, but moves python detection
after cflags detection, so the result of the latter can
be used in the former.

$PYTHON_CFLAGS usually includes -D_FORTIFY_SOURCE, which will generate
a warning when compiling without optimization. Avoid by undefining
_FORTIFY_SOURCE.
  • Loading branch information
keszybz committed Feb 11, 2013
1 parent ff47c89 commit c937e0d
Showing 1 changed file with 34 additions and 30 deletions.
64 changes: 34 additions & 30 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -93,36 +93,6 @@ if test -z "$GPERF" ; then
AC_MSG_ERROR([*** gperf not found])
fi

# we use python to build the man page index, and for systemd-python
have_python=no
have_python_devel=no

AC_ARG_WITH([python],
[AS_HELP_STRING([--without-python], [Disable building the man page index and systemd-python (default: test)])])

AS_IF([test "x$with_python" != "xno"], [
AM_PATH_PYTHON(,, [:])
AS_IF([test "$PYTHON" != :], [have_python=yes])
])
AM_CONDITIONAL([HAVE_PYTHON], [test "x$have_python" = "xyes"])
AS_IF([test "x$PYTHON_BINARY" = "x"],
[AS_IF([test "x$have_python" = "xyes"],
[PYTHON_BINARY="`which "$PYTHON"`"],
[PYTHON_BINARY=/usr/bin/python])])
AC_ARG_VAR(PYTHON_BINARY, [Python binary used to launch installed scripts])

AS_IF([test "x$with_python" != "xno"], [
AC_PATH_PROG(PYTHON_CONFIG, python${PYTHON_VERSION}-config)
AS_IF([test -n "$PYTHON_CONFIG"], [
have_python_devel=yes
PYTHON_CFLAGS="`$PYTHON_CONFIG --cflags`"
PYTHON_LIBS="`$PYTHON_CONFIG --ldflags`"
AC_SUBST(PYTHON_CFLAGS)
AC_SUBST(PYTHON_LIBS)
])
])
AM_CONDITIONAL([HAVE_PYTHON_DEVEL], [test "$have_python_devel" = "yes"])

CC_CHECK_FLAGS_APPEND([with_cflags], [CFLAGS], [\
-pipe \
-Wall \
Expand Down Expand Up @@ -168,6 +138,7 @@ AC_SUBST([OUR_CFLAGS], $with_cflags)
AS_CASE([$CFLAGS], [*-O[[12345\ ]]*], [
CC_CHECK_FLAGS_APPEND([with_cppflags], [CPPFLAGS], [\
-Wp,-D_FORTIFY_SOURCE=2])], [
python_extra_cflags=-Wp,-U_FORTIFY_SOURCE
AC_MSG_RESULT([skipping -D_FORTIFY_SOURCE, optimization not enabled])])
AC_SUBST([OUR_CPPFLAGS], $with_cppflags)

Expand All @@ -178,6 +149,39 @@ CC_CHECK_FLAGS_APPEND([with_ldflags], [LDFLAGS], [\
-Wl,-z,now])
AC_SUBST([OUR_LDFLAGS], $with_ldflags)

# ------------------------------------------------------------------------------
# we use python to build the man page index, and for systemd-python
have_python=no
have_python_devel=no

AC_ARG_WITH([python],
[AS_HELP_STRING([--without-python], [Disable building the man page index and systemd-python (default: test)])])

AS_IF([test "x$with_python" != "xno"], [
AM_PATH_PYTHON(,, [:])
AS_IF([test "$PYTHON" != :], [have_python=yes])
])
AM_CONDITIONAL([HAVE_PYTHON], [test "x$have_python" = "xyes"])
AS_IF([test "x$PYTHON_BINARY" = "x"],
[AS_IF([test "x$have_python" = "xyes"],
[PYTHON_BINARY="`which "$PYTHON"`"],
[PYTHON_BINARY=/usr/bin/python])])
AC_ARG_VAR(PYTHON_BINARY, [Python binary used to launch installed scripts])

AS_IF([test "x$with_python" != "xno"], [
AC_PATH_PROG(PYTHON_CONFIG, python${PYTHON_VERSION}-config)
AS_IF([test -n "$PYTHON_CONFIG"], [
have_python_devel=yes
PYTHON_CFLAGS="`$PYTHON_CONFIG --cflags` $python_extra_cflags"
PYTHON_LIBS="`$PYTHON_CONFIG --ldflags`"
AC_SUBST(PYTHON_CFLAGS)
AC_SUBST(PYTHON_LIBS)
])
])
AM_CONDITIONAL([HAVE_PYTHON_DEVEL], [test "$have_python_devel" = "yes"])

# ------------------------------------------------------------------------------

AC_SEARCH_LIBS([mq_open], [rt], [], [AC_MSG_ERROR([*** POSIX RT library not found])])
AC_SEARCH_LIBS([dlsym], [dl], [], [AC_MSG_ERROR([*** Dynamic linking loader library not found])])

Expand Down

0 comments on commit c937e0d

Please sign in to comment.