2014-07-04 13:36:40 +08:00
|
|
|
dnl Common configure.ac fragment
|
2012-12-18 00:56:12 +08:00
|
|
|
dnl
|
2017-01-02 11:36:43 +08:00
|
|
|
dnl Copyright (C) 2012-2017 Free Software Foundation, Inc.
|
2012-12-18 00:56:12 +08:00
|
|
|
dnl
|
|
|
|
dnl This file is free software; you can redistribute it and/or modify
|
|
|
|
dnl it under the terms of the GNU General Public License as published by
|
|
|
|
dnl the Free Software Foundation; either version 3 of the License, or
|
|
|
|
dnl (at your option) any later version.
|
2015-08-12 19:32:43 +08:00
|
|
|
dnl
|
2012-12-18 00:56:12 +08:00
|
|
|
dnl This program is distributed in the hope that it will be useful,
|
|
|
|
dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
dnl GNU General Public License for more details.
|
2015-08-12 19:32:43 +08:00
|
|
|
dnl
|
2012-12-18 00:56:12 +08:00
|
|
|
dnl You should have received a copy of the GNU General Public License
|
|
|
|
dnl along with this program; see the file COPYING3. If not see
|
|
|
|
dnl <http://www.gnu.org/licenses/>.
|
|
|
|
dnl
|
2005-04-14 13:26:44 +08:00
|
|
|
|
2016-09-26 23:36:08 +08:00
|
|
|
# AC_EGREP_CPP_FOR_BUILD(PATTERN, PROGRAM,
|
|
|
|
# [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
|
|
|
|
# ------------------------------------------------------
|
|
|
|
AC_DEFUN([AC_EGREP_CPP_FOR_BUILD],
|
|
|
|
[AC_LANG_PREPROC_REQUIRE()dnl
|
|
|
|
AC_REQUIRE([AC_PROG_EGREP])dnl
|
|
|
|
AC_LANG_CONFTEST([AC_LANG_SOURCE([[$2]])])
|
|
|
|
AS_IF([dnl eval is necessary to expand ac_cpp.
|
|
|
|
dnl Ultrix and Pyramid sh refuse to redirect output of eval, so use subshell.
|
|
|
|
(eval "$ac_cpp_for_build conftest.$ac_ext") 2>&AS_MESSAGE_LOG_FD |
|
|
|
|
dnl Quote $1 to prevent m4 from eating character classes
|
|
|
|
$EGREP "[$1]" >/dev/null 2>&1],
|
|
|
|
[$3],
|
|
|
|
[$4])
|
|
|
|
rm -f conftest*
|
|
|
|
])# AC_EGREP_CPP_FOR_BUILD
|
|
|
|
|
|
|
|
|
2005-04-14 13:26:44 +08:00
|
|
|
AC_DEFUN([AM_BINUTILS_WARNINGS],[
|
Make it easy to make --disable-werror the default for both binutils and gdb
The goal of this patch is to provide an easy way to make
--disable-werror the default when building binutils, or the parts
of binutils that need to get built when building GDB. In development
mode, we want to continue making -Werror the default with GCC.
But, when making releases, I think we want to make it as easy as
possible for regular users to successfully build from sources.
GDB already has this kind of feature to turn -Werror as well as
the use of the libmcheck library. As GDB Release Manager, I take
advantage of it to turn those off after having cut the branch.
I'd like to be able to do the same for the binutils bits. And
perhaps Tristan will want to do the same for his releases too
(not sure, binutils builders might be a little savvier than GDB
builders).
This patch introduces a new file, called development.sh, which
just sets a variable called $development. In our development branches
(Eg. "master"), it's set to true. But setting it to false would allow
us to change the default behavior of various development-related
features to be turned off; in this case, it turns off the use of
-Werror by default (use --enable-werror to turn it back on).
bfd/ChangeLog:
* development.sh: New file.
* warning.m4 (AM_BINUTILS_WARNINGS): Source bfd/development.sh.
Make -Werror the default with GCC only if DEVELOPMENT is true.
* Makefile.am (CONFIG_STATUS_DEPENDENCIES): Add
$(srcdir)/development.sh.
* Makefile.in, configure: Regenerate.
binutils/ChangeLog:
* Makefile.am (CONFIG_STATUS_DEPENDENCIES): Add dependency on
bfd's development.sh.
* Makefile.in, configure: Regenerate.
gas/ChangeLog:
* Makefile.am (CONFIG_STATUS_DEPENDENCIES): Add dependency on
bfd's development.sh.
* Makefile.in, configure: Regenerate.
gold/ChangeLog:
* Makefile.am (CONFIG_STATUS_DEPENDENCIES): New.
* Makefile.in, configure: Regenerate.
gprof/ChangeLog:
* Makefile.am (CONFIG_STATUS_DEPENDENCIES): Add dependency on
bfd's development.sh.
* Makefile.in, configure: Regenerate.
ld/ChangeLog:
* Makefile.am (CONFIG_STATUS_DEPENDENCIES): Add dependency on
bfd's development.sh.
* Makefile.in, configure: Regenerate.
opcodes/ChangeLog:
* Makefile.am (CONFIG_STATUS_DEPENDENCIES): Add dependency on
bfd's development.sh.
* Makefile.in, configure: Regenerate.
gdb/ChangeLog:
* development.sh: Delete.
* Makefile.in (config.status): Adjust dependency on development.sh.
* configure.ac: Adjust development.sh source call.
* configure: Regenerate.
gdb/gdbserver/ChangeLog:
* configure.ac: Adjust development.sh source call.
* Makefile.in (config.status): Adjust dependency on development.sh.
* configure: Regenerate.
Tested on x86_64-linux by building two ways: One with DEVELOPMENT
set to true, and one with DEVELOPMENT set to false. In the first
case, I could see the use of -Werror, while it disappeared in
the second case.
2014-05-20 05:46:01 +08:00
|
|
|
# Set the 'development' global.
|
|
|
|
. $srcdir/../bfd/development.sh
|
|
|
|
|
2016-09-26 23:36:08 +08:00
|
|
|
# Set acp_cpp_for_build variable
|
|
|
|
ac_cpp_for_build="$CC_FOR_BUILD -E $CPPFLAGS_FOR_BUILD"
|
|
|
|
|
2016-03-22 17:41:16 +08:00
|
|
|
# Default set of GCC warnings to enable.
|
2010-04-07 15:19:02 +08:00
|
|
|
GCC_WARN_CFLAGS="-W -Wall -Wstrict-prototypes -Wmissing-prototypes"
|
2016-09-26 23:36:08 +08:00
|
|
|
GCC_WARN_CFLAGS_FOR_BUILD="-W -Wall -Wstrict-prototypes -Wmissing-prototypes"
|
2016-03-22 17:41:16 +08:00
|
|
|
|
|
|
|
# Add -Wshadow if the compiler is a sufficiently recent version of GCC.
|
2010-04-07 15:19:02 +08:00
|
|
|
AC_EGREP_CPP([^[0-3]$],[__GNUC__],,GCC_WARN_CFLAGS="$GCC_WARN_CFLAGS -Wshadow")
|
2005-04-14 13:26:44 +08:00
|
|
|
|
2016-03-22 17:41:16 +08:00
|
|
|
# Add -Wstack-usage if the compiler is a sufficiently recent version of GCC.
|
|
|
|
AC_EGREP_CPP([^[0-4]$],[__GNUC__],,GCC_WARN_CFLAGS="$GCC_WARN_CFLAGS -Wstack-usage=262144")
|
|
|
|
|
2016-03-20 09:48:35 +08:00
|
|
|
# Set WARN_WRITE_STRINGS if the compiler supports -Wwrite-strings.
|
|
|
|
WARN_WRITE_STRINGS=""
|
|
|
|
AC_EGREP_CPP([^[0-3]$],[__GNUC__],,WARN_WRITE_STRINGS="-Wwrite-strings")
|
2016-03-22 17:41:16 +08:00
|
|
|
|
2016-11-22 23:43:03 +08:00
|
|
|
# Verify CC_FOR_BUILD to be compatible with warning flags
|
2016-09-26 23:36:08 +08:00
|
|
|
|
|
|
|
# Add -Wshadow if the compiler is a sufficiently recent version of GCC.
|
|
|
|
AC_EGREP_CPP_FOR_BUILD([^[0-3]$],[__GNUC__],,GCC_WARN_CFLAGS_FOR_BUILD="$GCC_WARN_CFLAGS_FOR_BUILD -Wshadow")
|
|
|
|
|
|
|
|
# Add -Wstack-usage if the compiler is a sufficiently recent version of GCC.
|
|
|
|
AC_EGREP_CPP_FOR_BUILD([^[0-4]$],[__GNUC__],,GCC_WARN_CFLAGS_FOR_BUILD="$GCC_WARN_CFLAGS_FOR_BUILD -Wstack-usage=262144")
|
|
|
|
|
2005-04-14 13:26:44 +08:00
|
|
|
AC_ARG_ENABLE(werror,
|
2006-04-19 10:06:15 +08:00
|
|
|
[ --enable-werror treat compile warnings as errors],
|
2005-04-14 13:26:44 +08:00
|
|
|
[case "${enableval}" in
|
|
|
|
yes | y) ERROR_ON_WARNING="yes" ;;
|
|
|
|
no | n) ERROR_ON_WARNING="no" ;;
|
|
|
|
*) AC_MSG_ERROR(bad value ${enableval} for --enable-werror) ;;
|
|
|
|
esac])
|
|
|
|
|
2010-04-07 15:19:02 +08:00
|
|
|
# Disable -Wformat by default when using gcc on mingw
|
2008-02-05 03:43:51 +08:00
|
|
|
case "${host}" in
|
|
|
|
*-*-mingw32*)
|
|
|
|
if test "${GCC}" = yes -a -z "${ERROR_ON_WARNING}" ; then
|
|
|
|
GCC_WARN_CFLAGS="$GCC_WARN_CFLAGS -Wno-format"
|
2016-09-26 23:36:08 +08:00
|
|
|
GCC_WARN_CFLAGS_FOR_BUILD="$GCC_WARN_CFLAGS_FOR_BUILD -Wno-format"
|
2008-02-05 03:43:51 +08:00
|
|
|
fi
|
|
|
|
;;
|
|
|
|
*) ;;
|
|
|
|
esac
|
|
|
|
|
Make it easy to make --disable-werror the default for both binutils and gdb
The goal of this patch is to provide an easy way to make
--disable-werror the default when building binutils, or the parts
of binutils that need to get built when building GDB. In development
mode, we want to continue making -Werror the default with GCC.
But, when making releases, I think we want to make it as easy as
possible for regular users to successfully build from sources.
GDB already has this kind of feature to turn -Werror as well as
the use of the libmcheck library. As GDB Release Manager, I take
advantage of it to turn those off after having cut the branch.
I'd like to be able to do the same for the binutils bits. And
perhaps Tristan will want to do the same for his releases too
(not sure, binutils builders might be a little savvier than GDB
builders).
This patch introduces a new file, called development.sh, which
just sets a variable called $development. In our development branches
(Eg. "master"), it's set to true. But setting it to false would allow
us to change the default behavior of various development-related
features to be turned off; in this case, it turns off the use of
-Werror by default (use --enable-werror to turn it back on).
bfd/ChangeLog:
* development.sh: New file.
* warning.m4 (AM_BINUTILS_WARNINGS): Source bfd/development.sh.
Make -Werror the default with GCC only if DEVELOPMENT is true.
* Makefile.am (CONFIG_STATUS_DEPENDENCIES): Add
$(srcdir)/development.sh.
* Makefile.in, configure: Regenerate.
binutils/ChangeLog:
* Makefile.am (CONFIG_STATUS_DEPENDENCIES): Add dependency on
bfd's development.sh.
* Makefile.in, configure: Regenerate.
gas/ChangeLog:
* Makefile.am (CONFIG_STATUS_DEPENDENCIES): Add dependency on
bfd's development.sh.
* Makefile.in, configure: Regenerate.
gold/ChangeLog:
* Makefile.am (CONFIG_STATUS_DEPENDENCIES): New.
* Makefile.in, configure: Regenerate.
gprof/ChangeLog:
* Makefile.am (CONFIG_STATUS_DEPENDENCIES): Add dependency on
bfd's development.sh.
* Makefile.in, configure: Regenerate.
ld/ChangeLog:
* Makefile.am (CONFIG_STATUS_DEPENDENCIES): Add dependency on
bfd's development.sh.
* Makefile.in, configure: Regenerate.
opcodes/ChangeLog:
* Makefile.am (CONFIG_STATUS_DEPENDENCIES): Add dependency on
bfd's development.sh.
* Makefile.in, configure: Regenerate.
gdb/ChangeLog:
* development.sh: Delete.
* Makefile.in (config.status): Adjust dependency on development.sh.
* configure.ac: Adjust development.sh source call.
* configure: Regenerate.
gdb/gdbserver/ChangeLog:
* configure.ac: Adjust development.sh source call.
* Makefile.in (config.status): Adjust dependency on development.sh.
* configure: Regenerate.
Tested on x86_64-linux by building two ways: One with DEVELOPMENT
set to true, and one with DEVELOPMENT set to false. In the first
case, I could see the use of -Werror, while it disappeared in
the second case.
2014-05-20 05:46:01 +08:00
|
|
|
# Enable -Werror by default when using gcc. Turn it off for releases.
|
|
|
|
if test "${GCC}" = yes -a -z "${ERROR_ON_WARNING}" -a "$development" = true ; then
|
2005-04-14 13:26:44 +08:00
|
|
|
ERROR_ON_WARNING=yes
|
|
|
|
fi
|
|
|
|
|
|
|
|
NO_WERROR=
|
|
|
|
if test "${ERROR_ON_WARNING}" = yes ; then
|
2016-03-22 17:41:16 +08:00
|
|
|
GCC_WARN_CFLAGS="$GCC_WARN_CFLAGS -Werror"
|
2016-09-26 23:36:08 +08:00
|
|
|
GCC_WARN_CFLAGS_FOR_BUILD="$GCC_WARN_CFLAGS_FOR_BUILD -Werror"
|
2005-04-14 13:26:44 +08:00
|
|
|
NO_WERROR="-Wno-error"
|
|
|
|
fi
|
2015-08-12 19:32:43 +08:00
|
|
|
|
2005-11-08 06:14:12 +08:00
|
|
|
if test "${GCC}" = yes ; then
|
|
|
|
WARN_CFLAGS="${GCC_WARN_CFLAGS}"
|
2016-09-26 23:36:08 +08:00
|
|
|
WARN_CFLAGS_FOR_BUILD="${GCC_WARN_CFLAGS_FOR_BUILD}"
|
2005-11-08 06:14:12 +08:00
|
|
|
fi
|
|
|
|
|
2005-04-14 13:26:44 +08:00
|
|
|
AC_ARG_ENABLE(build-warnings,
|
2006-04-19 10:06:15 +08:00
|
|
|
[ --enable-build-warnings enable build-time compiler warnings],
|
2005-04-14 13:26:44 +08:00
|
|
|
[case "${enableval}" in
|
2016-09-26 23:36:08 +08:00
|
|
|
yes) WARN_CFLAGS="${GCC_WARN_CFLAGS}"
|
|
|
|
WARN_CFLAGS_FOR_BUILD="${GCC_WARN_CFLAGS_FOR_BUILD}";;
|
2005-11-08 06:14:12 +08:00
|
|
|
no) if test "${GCC}" = yes ; then
|
|
|
|
WARN_CFLAGS="-w"
|
2016-09-26 23:36:08 +08:00
|
|
|
WARN_CFLAGS_FOR_BUILD="-w"
|
2005-11-08 06:14:12 +08:00
|
|
|
fi;;
|
2005-04-14 13:26:44 +08:00
|
|
|
,*) t=`echo "${enableval}" | sed -e "s/,/ /g"`
|
2016-09-26 23:36:08 +08:00
|
|
|
WARN_CFLAGS="${GCC_WARN_CFLAGS} ${t}"
|
|
|
|
WARN_CFLAGS_FOR_BUILD="${GCC_WARN_CFLAGS_FOR_BUILD} ${t}";;
|
2005-04-14 13:26:44 +08:00
|
|
|
*,) t=`echo "${enableval}" | sed -e "s/,/ /g"`
|
2016-09-26 23:36:08 +08:00
|
|
|
WARN_CFLAGS="${t} ${GCC_WARN_CFLAGS}"
|
|
|
|
WARN_CFLAGS_FOR_BUILD="${t} ${GCC_WARN_CFLAGS_FOR_BUILD}";;
|
|
|
|
*) WARN_CFLAGS=`echo "${enableval}" | sed -e "s/,/ /g"`
|
|
|
|
WARN_CFLAGS_FOR_BUILD=`echo "${enableval}" | sed -e "s/,/ /g"`;;
|
2005-04-14 13:26:44 +08:00
|
|
|
esac])
|
|
|
|
|
|
|
|
if test x"$silent" != x"yes" && test x"$WARN_CFLAGS" != x""; then
|
|
|
|
echo "Setting warning flags = $WARN_CFLAGS" 6>&1
|
|
|
|
fi
|
|
|
|
|
|
|
|
AC_SUBST(WARN_CFLAGS)
|
2016-09-26 23:36:08 +08:00
|
|
|
AC_SUBST(WARN_CFLAGS_FOR_BUILD)
|
2005-04-14 13:26:44 +08:00
|
|
|
AC_SUBST(NO_WERROR)
|
2016-03-20 09:48:35 +08:00
|
|
|
AC_SUBST(WARN_WRITE_STRINGS)
|
2005-04-14 13:26:44 +08:00
|
|
|
])
|