bluez/acinclude.m4
Anderson Lizardo 6a0e5bc087 build: Fix --disable-optimization configure option
On commit cc9e4e7cae, this flag was
mistakenly replaced with the behavior of the old --enable-fortify
option.

This patch restores the "-O0" flag when --disable-optimization is used.

Unfortunately, this is not enough to disable build optimization. By
default, autoconf adds -O2 to CFLAGS if the compiler is GCC. AM_CFLAGS
(where -O0 is added with --disable-optimization) is passed as argument
to GCC before autoconf CFLAGS, so it is not possible to override the
default -O2. One solution is to use:

CFLAGS= ./configure --disable-optimization

i.e. remove -O2 from CFLAGS, and let autoconf add -O0.
2013-01-10 16:06:42 -08:00

56 lines
1.7 KiB
Plaintext

AC_DEFUN([AC_PROG_CC_PIE], [
AC_CACHE_CHECK([whether ${CC-cc} accepts -fPIE], ac_cv_prog_cc_pie, [
echo 'void f(){}' > conftest.c
if test -z "`${CC-cc} -fPIE -pie -c conftest.c 2>&1`"; then
ac_cv_prog_cc_pie=yes
else
ac_cv_prog_cc_pie=no
fi
rm -rf conftest*
])
])
AC_DEFUN([COMPILER_FLAGS], [
with_cflags=""
if (test "$USE_MAINTAINER_MODE" = "yes"); then
with_cflags="$with_cflags -Wall -Werror -Wextra"
with_cflags="$with_cflags -Wno-unused-parameter"
with_cflags="$with_cflags -Wno-missing-field-initializers"
with_cflags="$with_cflags -Wdeclaration-after-statement"
with_cflags="$with_cflags -Wmissing-declarations"
with_cflags="$with_cflags -Wredundant-decls"
with_cflags="$with_cflags -Wcast-align"
with_cflags="$with_cflags -DG_DISABLE_DEPRECATED"
fi
AC_SUBST([WARNING_CFLAGS], $with_cflags)
])
AC_DEFUN([MISC_FLAGS], [
misc_cflags=""
misc_ldflags=""
AC_ARG_ENABLE(optimization, AC_HELP_STRING([--disable-optimization],
[disable code optimization through compiler]), [
if (test "${enableval}" = "no"); then
misc_cflags="$misc_cflags -O0"
fi
])
AC_ARG_ENABLE(debug, AC_HELP_STRING([--enable-debug],
[enable compiling with debugging information]), [
if (test "${enableval}" = "yes" &&
test "${ac_cv_prog_cc_g}" = "yes"); then
misc_cflags="$misc_cflags -g"
fi
])
AC_ARG_ENABLE(pie, AC_HELP_STRING([--enable-pie],
[enable position independent executables flag]), [
if (test "${enableval}" = "yes" &&
test "${ac_cv_prog_cc_pie}" = "yes"); then
misc_cflags="$misc_cflags -fPIC"
misc_ldflags="$misc_ldflags -pie"
fi
])
AC_SUBST([MISC_CFLAGS], $misc_cflags)
AC_SUBST([MISC_LDFLAGS], $misc_ldflags)
])