Skip to content

Commit

Permalink
configury: pass gl_WARN_ADD results to gcc
Browse files Browse the repository at this point in the history
gl_WARN_ADD results were not being substituted into Makefile.in
correctly. Add a --enable-gcc-warnings configure flag, and when
passed, compile with all the warning flags that were successfully
tested at configure time.
  • Loading branch information
gvvaughan committed Sep 1, 2011
1 parent 6769c87 commit 901341d
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 27 deletions.
1 change: 1 addition & 0 deletions Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
ACLOCAL_AMFLAGS = -I m4

AM_CPPFLAGS = $(LUA_INCLUDE)
AM_CFLAGS = $(WERROR_CFLAGS) $(WARN_CFLAGS)

lualib_LTLIBRARIES = curses.la

Expand Down
74 changes: 47 additions & 27 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -10,33 +10,53 @@ m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
dnl Check for programs
AC_PROG_CC
gl_EARLY
gl_MANYWARN_ALL_GCC([warnings])
# Set up the list of undesired warnings.
nw=
nw="$nw -Wsystem-headers" # Don’t let system headers trigger warnings
nw="$nw -Wundef" # All compiler preprocessors support #if UNDEF
nw="$nw -Wtraditional" # All compilers nowadays support ANSI C
nw="$nw -Wstrict-overflow" # Use a lower level (see below).
nw="$nw -Wconversion" # These warnings usually don’t point to mistakes.
nw="$nw -Wsign-conversion" # Likewise.
nw="$nw -Waggregate-return" # We do this on purpose.
nw="$nw -Wbad-function-cast" # FIXME: We do this on purpose (non-pointer list elements).
nw="$nw -Wtraditional-conversion" # Don't care.
nw="$nw -Wpadded" # Don't care.
nw="$nw -Wc++-compat" # Don't care.
nw="$nw -Woverlength-strings" # Don't care.
nw="$nw -Wmissing-format-attribute" # Don't care.
nw="$nw -Wunreachable-code" # Seems buggy.
# Enable all GCC warnings not in this list.
gl_MANYWARN_COMPLEMENT([warnings], [$warnings], [$nw])
for w in $warnings; do
gl_WARN_ADD([$w])
done
# Add an extra warning
gl_WARN_ADD([-Wstrict-overflow=1], [WARN_FLAGS])
# Add some more safety measures
gl_WARN_ADD([-D_FORTIFY_SOURCE=2], [WARN_FLAGS])
gl_WARN_ADD([-fmudflap], [WARN_FLAGS])

AC_ARG_ENABLE([gcc-warnings],
[AS_HELP_STRING([--enable-gcc-warnings],
[turn on lots of GCC warnings (for developers)])],
[case $enableval in
yes|no) ;;
*) AC_MSG_ERROR([bad value $enableval for gcc-warnings option]) ;;
esac
gl_gcc_warnings=$enableval],
[gl_gcc_warnings=no]
)

if test "$gl_gcc_warnings" = yes; then
gl_WARN_ADD([-Werror], [WERROR_CFLAGS])

# Set up the list of undesired warnings.
nw=
nw="$nw -Wsystem-headers" # Don’t let system headers trigger warnings
nw="$nw -Wundef" # All compiler preprocessors support #if UNDEF
nw="$nw -Wtraditional" # All compilers nowadays support ANSI C
nw="$nw -Wstrict-overflow" # Use a lower level (see below).
nw="$nw -Wconversion" # These warnings usually don’t point to mistakes.
nw="$nw -Wsign-conversion" # Likewise.
nw="$nw -Waggregate-return" # We do this on purpose.
nw="$nw -Wbad-function-cast" # FIXME: We do this on purpose (non-pointer list elements).
nw="$nw -Wtraditional-conversion" # Don't care.
nw="$nw -Wpadded" # Don't care.
nw="$nw -Wc++-compat" # Don't care.
nw="$nw -Woverlength-strings" # Don't care.
nw="$nw -Wmissing-format-attribute" # Don't care.
nw="$nw -Wunreachable-code" # Seems buggy.

gl_MANYWARN_ALL_GCC([warnings])

# Enable all GCC warnings not in this list.
gl_MANYWARN_COMPLEMENT([warnings], [$warnings], [$nw])
for w in $warnings; do
gl_WARN_ADD([$w])
done

# Add an extra warning
gl_WARN_ADD([-Wstrict-overflow=1])
# Add some more safety measures
gl_WARN_ADD([-D_FORTIFY_SOURCE=2])
gl_WARN_ADD([-fmudflap])
fi

AC_PROG_LIBTOOL
AC_SUBST(LIBTOOL_DEPS)

Expand Down

0 comments on commit 901341d

Please sign in to comment.