configure: Add user-flags configure option

configure.ac adds by optimization and debug flags by default. This is
not always intended so conifgure option is added.

Support for using this option in specfile is added too.

Also fix GDB_CFLAGS typo. GDB_FLAGS (without C)
is the correct name of variable to print in the summary.

Signed-off-by: Jan Friesse <jfriesse@redhat.com>
This commit is contained in:
Jan Friesse 2019-06-10 10:25:42 +02:00
parent b560db5fa4
commit c6548f4079
3 changed files with 22 additions and 1 deletions

View File

@ -110,6 +110,11 @@ $(SPEC): $(SPEC).in
-e "s#@DIRTY@#$$dirty#g" \
-e "s#@date@#$$date#g" \
$< > $@-t
if BUILD_USERFLAGS
sed -i -e "s#@bcond_userflags@#bcond_without#g" $@-t
else
sed -i -e "s#@bcond_userflags@#bcond_with#g" $@-t
endif
if BUILD_RUNAUTOGEN
sed -i -e "s#@bcond_runautogen@#bcond_without#g" $@-t
else

View File

@ -136,6 +136,11 @@ AC_ARG_ENABLE([secure-build],
[],
[enable_secure_build="yes"])
AC_ARG_ENABLE([user-flags],
[ --enable-user-flags : rely on user environment. ],
[ default="no" ])
AM_CONDITIONAL(BUILD_USERFLAGS, test x$enable_user_flags = xyes)
AC_ARG_ENABLE([systemd],
[ --enable-systemd : Build with libsystemd and install systemd service files],,
[ enable_systemd="no" ])
@ -244,6 +249,13 @@ else
WERROR_CFLAGS=""
fi
# don't add addtional cflags
if test "x${enable_user_flags}" = xyes; then
OPT_CFLAGS=""
GDB_FLAGS=""
EXTRA_WARNINGS=""
fi
if test "x${enable_secure_build}" = xyes; then
# stolen from apache configure snippet
AC_CACHE_CHECK([whether $CC accepts PIE flags], [ap_cv_cc_pie], [
@ -358,7 +370,7 @@ AC_MSG_RESULT([ Features = ${PACKAGE_FEATURES}])
AC_MSG_RESULT([])
AC_MSG_RESULT([$PACKAGE build info:])
AC_MSG_RESULT([ Default optimization = ${OPT_CFLAGS}])
AC_MSG_RESULT([ Default debug options = ${GDB_CFLAGS}])
AC_MSG_RESULT([ Default debug options = ${GDB_FLAGS}])
AC_MSG_RESULT([ Extra compiler warnings = ${EXTRA_WARNING}])
AC_MSG_RESULT([ Env. defined CFLAG = ${ENV_CFLAGS}])
AC_MSG_RESULT([ Env. defined CPPFLAGS = ${ENV_CPPFLAGS}])

View File

@ -5,6 +5,7 @@
# Conditionals
# Invoke "rpmbuild --without <feature>" or "rpmbuild --with <feature>"
# to disable or enable specific features
%@bcond_userflags@ userflags
%@bcond_runautogen@ runautogen
%@bcond_systemd@ systemd
@ -64,6 +65,9 @@ BuildRequires: autoconf automake libtool
%endif
%{configure} \
%if %{with userflags}
--enable-user-flags \
%endif
%if %{with systemd}
--enable-systemd \
%endif