simplify enable & with configure flags

Leverage the existing default logic & argument parsing that turn the
values yes/no into true/false to simplify the code so we don't create
duplicate variables.  This kills a lot of boilerplate.

Change-Id: Ib7c8e00f7b23e67ed05f3b35e523c235aed41129
Reviewed-on: https://chromium-review.googlesource.com/c/breakpad/breakpad/+/3734169
Reviewed-by: George Burgess <gbiv@chromium.org>
This commit is contained in:
Mike Frysinger 2022-06-28 22:12:34 -04:00
parent 593196225d
commit f9fcba812c
2 changed files with 66 additions and 203 deletions

129
configure vendored
View File

@ -5832,23 +5832,15 @@ fi
# Check whether --enable-m32 was given. # Check whether --enable-m32 was given.
if test "${enable_m32+set}" = set; then : if test "${enable_m32+set}" = set; then :
enableval=$enable_m32; case "${enableval}" in enableval=$enable_m32;
yes)
CFLAGS="${CFLAGS} -m32"
CXXFLAGS="${CXXFLAGS} -m32"
usem32=true
;;
no)
usem32=false
;;
*)
as_fn_error $? "bad value ${enableval} for --enable-m32" "$LINENO" 5
;;
esac
else else
usem32=false enable_m32=no
fi fi
if test "x$enable_m32" = xyes; then
CFLAGS="${CFLAGS} -m32"
CXXFLAGS="${CXXFLAGS} -m32"
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for grep that handles long lines and -e" >&5 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for grep that handles long lines and -e" >&5
@ -7584,22 +7576,12 @@ fi
# Check whether --enable-processor was given. # Check whether --enable-processor was given.
if test "${enable_processor+set}" = set; then : if test "${enable_processor+set}" = set; then :
enableval=$enable_processor; case "${enableval}" in enableval=$enable_processor;
yes)
disable_processor=false
;;
no)
disable_processor=true
;;
*)
as_fn_error $? "bad value ${enableval} for --disable-processor" "$LINENO" 5
;;
esac
else else
disable_processor=false enable_processor=yes
fi fi
if test x$disable_processor = xtrue; then if test "x$enable_processor" != xyes; then
DISABLE_PROCESSOR_TRUE= DISABLE_PROCESSOR_TRUE=
DISABLE_PROCESSOR_FALSE='#' DISABLE_PROCESSOR_FALSE='#'
else else
@ -7610,22 +7592,12 @@ fi
# Check whether --enable-tools was given. # Check whether --enable-tools was given.
if test "${enable_tools+set}" = set; then : if test "${enable_tools+set}" = set; then :
enableval=$enable_tools; case "${enableval}" in enableval=$enable_tools;
yes)
disable_tools=false
;;
no)
disable_tools=true
;;
*)
as_fn_error $? "bad value ${enableval} for --disable-tools" "$LINENO" 5
;;
esac
else else
disable_tools=false enable_tools=yes
fi fi
if test x$disable_tools = xtrue; then if test "x$enable_tools" != xyes; then
DISABLE_TOOLS_TRUE= DISABLE_TOOLS_TRUE=
DISABLE_TOOLS_FALSE='#' DISABLE_TOOLS_FALSE='#'
else else
@ -7634,28 +7606,18 @@ else
fi fi
if test x$LINUX_HOST = xfalse -a x$disable_processor = xtrue -a x$disable_tools = xtrue; then if test x$LINUX_HOST = xfalse -a "x$enable_processor" != xyes -a "x$enable_tools" != xyes; then
as_fn_error $? "--disable-processor and --disable-tools were specified, and not building for Linux. Nothing to build!" "$LINENO" 5 as_fn_error $? "--disable-processor and --disable-tools were specified, and not building for Linux. Nothing to build!" "$LINENO" 5
fi fi
# Check whether --enable-system-test-libs was given. # Check whether --enable-system-test-libs was given.
if test "${enable_system_test_libs+set}" = set; then : if test "${enable_system_test_libs+set}" = set; then :
enableval=$enable_system_test_libs; case "${enableval}" in enableval=$enable_system_test_libs;
yes)
system_test_libs=true
;;
no)
system_test_libs=false
;;
*)
as_fn_error $? "bad value ${enableval} for --enable-system-test-libs" "$LINENO" 5
;;
esac
else else
system_test_libs=false enable_system_test_libs=no
fi fi
if test x$system_test_libs = xtrue; then if test "x$enable_system_test_libs" = xyes; then
SYSTEM_TEST_LIBS_TRUE= SYSTEM_TEST_LIBS_TRUE=
SYSTEM_TEST_LIBS_FALSE='#' SYSTEM_TEST_LIBS_FALSE='#'
else else
@ -7668,7 +7630,7 @@ fi
if test x$system_test_libs = xtrue; then if test "x$enable_system_test_libs" = xyes; then
: "${GMOCK_CFLAGS:=-pthread}" : "${GMOCK_CFLAGS:=-pthread}"
: "${GMOCK_LIBS:=-lgmock -lgtest -pthread -lpthread}" : "${GMOCK_LIBS:=-lgmock -lgtest -pthread -lpthread}"
: "${GTEST_CFLAGS:=-pthread}" : "${GTEST_CFLAGS:=-pthread}"
@ -7677,22 +7639,12 @@ fi
# Check whether --enable-selftest was given. # Check whether --enable-selftest was given.
if test "${enable_selftest+set}" = set; then : if test "${enable_selftest+set}" = set; then :
enableval=$enable_selftest; case "${enableval}" in enableval=$enable_selftest;
yes)
selftest=true
;;
no)
selftest=false
;;
*)
as_fn_error $? "bad value ${enableval} for --enable-selftest" "$LINENO" 5
;;
esac
else else
selftest=false enable_selftest=no
fi fi
if test x$selftest = xtrue; then if test "x$enable_selftest" = xyes; then
SELFTEST_TRUE= SELFTEST_TRUE=
SELFTEST_FALSE='#' SELFTEST_FALSE='#'
else else
@ -7704,47 +7656,30 @@ fi
# Check whether --with-rustc-demangle was given. # Check whether --with-rustc-demangle was given.
if test "${with_rustc_demangle+set}" = set; then : if test "${with_rustc_demangle+set}" = set; then :
withval=$with_rustc_demangle; case "${withval}" in withval=$with_rustc_demangle;
yes)
as_fn_error $? "You must pass the path to the rustc-demangle crate for --with-rustc-demangle" "$LINENO" 5
;;
no)
rustc_demangle=false
;;
*)
if ! test -f "${withval}/Cargo.toml"; then
as_fn_error $? "You must pass the path to the rustc-demangle crate for --with-rustc-demangle" "$LINENO" 5
fi
RUSTC_DEMANGLE_CFLAGS="-DHAVE_RUSTC_DEMANGLE -I${withval}/crates/capi/include"
RUSTC_DEMANGLE_LIBS="-L${withval}/target/release -lrustc_demangle -lpthread -ldl"
;;
esac
else else
rustc_demangle=false with_rustc_demangle=no
fi fi
if test "x${with_rustc_demangle}" != xno; then
if ! test -f "${with_rustc_demangle}/Cargo.toml"; then
as_fn_error $? "You must pass the path to the rustc-demangle crate for --with-rustc-demangle" "$LINENO" 5
fi
RUSTC_DEMANGLE_CFLAGS="-DHAVE_RUSTC_DEMANGLE -I${with_rustc_demangle}/crates/capi/include"
RUSTC_DEMANGLE_LIBS="-L${with_rustc_demangle}/target/release -lrustc_demangle -lpthread -ldl"
fi
# Check whether --with-tests-as-root was given. # Check whether --with-tests-as-root was given.
if test "${with_tests_as_root+set}" = set; then : if test "${with_tests_as_root+set}" = set; then :
withval=$with_tests_as_root; case "${withval}" in withval=$with_tests_as_root;
yes)
tests_as_root=true
;;
no)
tests_as_root=false
;;
*)
as_fn_error $? "--with-tests-as-root can only be \"yes\" or \"no\"" "$LINENO" 5
;;
esac
else else
tests_as_root=false with_tests_as_root=no
fi fi
if test x$tests_as_root = xtrue; then if test "x$with_tests_as_root" = xyes; then
TESTS_AS_ROOT_TRUE= TESTS_AS_ROOT_TRUE=
TESTS_AS_ROOT_FALSE='#' TESTS_AS_ROOT_FALSE='#'
else else

View File

@ -53,21 +53,12 @@ dnl This must come before all the feature tests below.
AC_ARG_ENABLE(m32, AC_ARG_ENABLE(m32,
AS_HELP_STRING([--enable-m32], AS_HELP_STRING([--enable-m32],
[Compile/build with -m32] [Compile/build with -m32]
[(default is no)]), [(default is no)]),,
[case "${enableval}" in [enable_m32=no])
yes) if test "x$enable_m32" = xyes; then
CFLAGS="${CFLAGS} -m32" CFLAGS="${CFLAGS} -m32"
CXXFLAGS="${CXXFLAGS} -m32" CXXFLAGS="${CXXFLAGS} -m32"
usem32=true fi
;;
no)
usem32=false
;;
*)
AC_MSG_ERROR(bad value ${enableval} for --enable-m32)
;;
esac],
[usem32=false])
AC_HEADER_STDC AC_HEADER_STDC
AC_SYS_LARGEFILE AC_SYS_LARGEFILE
@ -134,66 +125,33 @@ AM_CONDITIONAL(X86_HOST, test x$X86_HOST = xtrue)
AC_ARG_ENABLE(processor, AC_ARG_ENABLE(processor,
AS_HELP_STRING([--disable-processor], AS_HELP_STRING([--disable-processor],
[Don't build processor library] [Don't build processor library]
[(default is no)]), [(default is no)]),,
[case "${enableval}" in [enable_processor=yes])
yes) AM_CONDITIONAL(DISABLE_PROCESSOR, test "x$enable_processor" != xyes)
disable_processor=false
;;
no)
disable_processor=true
;;
*)
AC_MSG_ERROR(bad value ${enableval} for --disable-processor)
;;
esac],
[disable_processor=false])
AM_CONDITIONAL(DISABLE_PROCESSOR, test x$disable_processor = xtrue)
AC_ARG_ENABLE(tools, AC_ARG_ENABLE(tools,
AS_HELP_STRING([--disable-tools], AS_HELP_STRING([--disable-tools],
[Don't build tool binaries] [Don't build tool binaries]
[(default is no)]), [(default is no)]),,
[case "${enableval}" in [enable_tools=yes])
yes) AM_CONDITIONAL(DISABLE_TOOLS, test "x$enable_tools" != xyes)
disable_tools=false
;;
no)
disable_tools=true
;;
*)
AC_MSG_ERROR(bad value ${enableval} for --disable-tools)
;;
esac],
[disable_tools=false])
AM_CONDITIONAL(DISABLE_TOOLS, test x$disable_tools = xtrue)
if test x$LINUX_HOST = xfalse -a x$disable_processor = xtrue -a x$disable_tools = xtrue; then if test x$LINUX_HOST = xfalse -a "x$enable_processor" != xyes -a "x$enable_tools" != xyes; then
AC_MSG_ERROR([--disable-processor and --disable-tools were specified, and not building for Linux. Nothing to build!]) AC_MSG_ERROR([--disable-processor and --disable-tools were specified, and not building for Linux. Nothing to build!])
fi fi
AC_ARG_ENABLE(system-test-libs, AC_ARG_ENABLE(system-test-libs,
AS_HELP_STRING([--enable-system-test-libs], AS_HELP_STRING([--enable-system-test-libs],
[Use gtest/gmock/etc... from the system instead ] [Use gtest/gmock/etc... from the system instead ]
[of the local copies (default is local)]), [of the local copies (default is local)]),,
[case "${enableval}" in [enable_system_test_libs=no])
yes) AM_CONDITIONAL(SYSTEM_TEST_LIBS, test "x$enable_system_test_libs" = xyes)
system_test_libs=true
;;
no)
system_test_libs=false
;;
*)
AC_MSG_ERROR(bad value ${enableval} for --enable-system-test-libs)
;;
esac],
[system_test_libs=false])
AM_CONDITIONAL(SYSTEM_TEST_LIBS, test x$system_test_libs = xtrue)
AC_ARG_VAR([GMOCK_CFLAGS], [Compiler flags for gmock]) AC_ARG_VAR([GMOCK_CFLAGS], [Compiler flags for gmock])
AC_ARG_VAR([GMOCK_LIBS], [Linker flags for gmock]) AC_ARG_VAR([GMOCK_LIBS], [Linker flags for gmock])
AC_ARG_VAR([GTEST_CFLAGS], [Compiler flags for gtest]) AC_ARG_VAR([GTEST_CFLAGS], [Compiler flags for gtest])
AC_ARG_VAR([GTEST_LIBS], [Linker flags for gtest]) AC_ARG_VAR([GTEST_LIBS], [Linker flags for gtest])
if test x$system_test_libs = xtrue; then if test "x$enable_system_test_libs" = xyes; then
: "${GMOCK_CFLAGS:=-pthread}" : "${GMOCK_CFLAGS:=-pthread}"
: "${GMOCK_LIBS:=-lgmock -lgtest -pthread -lpthread}" : "${GMOCK_LIBS:=-lgmock -lgtest -pthread -lpthread}"
: "${GTEST_CFLAGS:=-pthread}" : "${GTEST_CFLAGS:=-pthread}"
@ -204,43 +162,24 @@ AC_ARG_ENABLE(selftest,
AS_HELP_STRING([--enable-selftest], AS_HELP_STRING([--enable-selftest],
[Run extra tests with "make check" ] [Run extra tests with "make check" ]
[(may conflict with optimizations) ] [(may conflict with optimizations) ]
[(default is no)]), [(default is no)]),,
[case "${enableval}" in [enable_selftest=no])
yes) AM_CONDITIONAL(SELFTEST, test "x$enable_selftest" = xyes)
selftest=true
;;
no)
selftest=false
;;
*)
AC_MSG_ERROR(bad value ${enableval} for --enable-selftest)
;;
esac],
[selftest=false])
AM_CONDITIONAL(SELFTEST, test x$selftest = xtrue)
AC_ARG_WITH(rustc-demangle, AC_ARG_WITH(rustc-demangle,
AS_HELP_STRING([--with-rustc-demangle=/path/to/rustc-demangle], AS_HELP_STRING([--with-rustc-demangle=/path/to/rustc-demangle],
[Link against the rustc-demangle library] [Link against the rustc-demangle library]
[to demangle Rust language symbols during] [to demangle Rust language symbols during]
[symbol dumping (default is no)] [symbol dumping (default is no)]
[Pass the path to the crate root.]), [Pass the path to the crate root.]),,
[case "${withval}" in [with_rustc_demangle=no])
yes) if test "x${with_rustc_demangle}" != xno; then
AC_MSG_ERROR(You must pass the path to the rustc-demangle crate for --with-rustc-demangle) if ! test -f "${with_rustc_demangle}/Cargo.toml"; then
;;
no)
rustc_demangle=false
;;
*)
if ! test -f "${withval}/Cargo.toml"; then
AC_MSG_ERROR(You must pass the path to the rustc-demangle crate for --with-rustc-demangle) AC_MSG_ERROR(You must pass the path to the rustc-demangle crate for --with-rustc-demangle)
fi fi
RUSTC_DEMANGLE_CFLAGS="-DHAVE_RUSTC_DEMANGLE -I${withval}/crates/capi/include" RUSTC_DEMANGLE_CFLAGS="-DHAVE_RUSTC_DEMANGLE -I${with_rustc_demangle}/crates/capi/include"
RUSTC_DEMANGLE_LIBS="-L${withval}/target/release -lrustc_demangle -lpthread -ldl" RUSTC_DEMANGLE_LIBS="-L${with_rustc_demangle}/target/release -lrustc_demangle -lpthread -ldl"
;; fi
esac],
[rustc_demangle=false])
AC_ARG_VAR([RUSTC_DEMANGLE_CFLAGS], [Compiler flags for rustc-demangle]) AC_ARG_VAR([RUSTC_DEMANGLE_CFLAGS], [Compiler flags for rustc-demangle])
AC_ARG_VAR([RUSTC_DEMANGLE_LIBS], [Linker flags for rustc-demangle]) AC_ARG_VAR([RUSTC_DEMANGLE_LIBS], [Linker flags for rustc-demangle])
@ -248,20 +187,9 @@ AC_ARG_WITH(tests-as-root,
AS_HELP_STRING([--with-tests-as-root], AS_HELP_STRING([--with-tests-as-root],
[Run the tests as root. Use this on platforms] [Run the tests as root. Use this on platforms]
[like travis-ci.org that require root privileges] [like travis-ci.org that require root privileges]
[to use ptrace (default is no)]), [to use ptrace (default is no)]),,
[case "${withval}" in [with_tests_as_root=no])
yes) AM_CONDITIONAL(TESTS_AS_ROOT, test "x$with_tests_as_root" = xyes)
tests_as_root=true
;;
no)
tests_as_root=false
;;
*)
AC_MSG_ERROR(--with-tests-as-root can only be "yes" or "no")
;;
esac],
[tests_as_root=false])
AM_CONDITIONAL(TESTS_AS_ROOT, test x$tests_as_root = xtrue)
AC_CONFIG_FILES(m4_flatten([ AC_CONFIG_FILES(m4_flatten([
breakpad.pc breakpad.pc