mirror of
https://github.com/mirror/wget.git
synced 2026-08-22 19:03:27 +08:00
Add --enable-manywarnings from wget2
* .gitignore: Exclude /lib/Makefile.am * bootstrap.conf: Use --makefile-name=gnulib.mk with gnulib-tool * configure.ac: Use wget_MANYWARNINGS() * lib/Makefile.am: Define empty noinst_LIBRARIES and MAINTAINERCLEANFILES * m4/wget_manywarnings.m4: New file from GNU Wget2 * src/Makefile.am: Use WARN_CFLAGS for AM_CFLAGS
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -14,6 +14,7 @@
|
|||||||
/config.status
|
/config.status
|
||||||
/configure
|
/configure
|
||||||
/lib/
|
/lib/
|
||||||
|
!/lib/Makefile.am
|
||||||
/maint.mk
|
/maint.mk
|
||||||
# Wildcard Ignores
|
# Wildcard Ignores
|
||||||
*~
|
*~
|
||||||
|
|||||||
@@ -18,7 +18,7 @@
|
|||||||
|
|
||||||
# gnulib library name
|
# gnulib library name
|
||||||
gnulib_name=libgnu
|
gnulib_name=libgnu
|
||||||
gnulib_tool_option_extras=
|
gnulib_tool_option_extras="--makefile-name=gnulib.mk"
|
||||||
use_libtool=0
|
use_libtool=0
|
||||||
checkout_only_file=
|
checkout_only_file=
|
||||||
|
|
||||||
|
|||||||
109
configure.ac
109
configure.ac
@@ -48,7 +48,7 @@ AC_CONFIG_SRCDIR([src/wget.h])
|
|||||||
dnl
|
dnl
|
||||||
dnl Automake setup
|
dnl Automake setup
|
||||||
dnl
|
dnl
|
||||||
AM_INIT_AUTOMAKE([1.9])
|
AM_INIT_AUTOMAKE([subdir-objects])
|
||||||
|
|
||||||
dnl
|
dnl
|
||||||
dnl Get canonical host
|
dnl Get canonical host
|
||||||
@@ -324,6 +324,111 @@ case $host_os in
|
|||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
|
# enable all possible compiler warnings in WARN_FLAGS
|
||||||
|
#
|
||||||
|
# to enable by default: create a file '.manywarnings'
|
||||||
|
# enable explicitly : ./configure --enable-manywarnings
|
||||||
|
# disable explicitly: ./configure --disable-manywarnings
|
||||||
|
wget_MANYWARNINGS(WARN_CFLAGS, C)
|
||||||
|
|
||||||
|
if test -n "$WARN_CFLAGS"; then
|
||||||
|
if test "$CCNAME" = "gcc"; then
|
||||||
|
# Set up list of unwanted warnings
|
||||||
|
nw=
|
||||||
|
nw="$nw -Wsystem-headers" # System headers may trigger lot's of useless warnings
|
||||||
|
nw="$nw -Wvla" # This project is C99
|
||||||
|
nw="$nw -Wstack-protector"
|
||||||
|
nw="$nw -Wmissing-field-initializer"
|
||||||
|
nw="$nw -Wtraditional"
|
||||||
|
nw="$nw -Wtraditional-conversion"
|
||||||
|
nw="$nw -Wc++-compat"
|
||||||
|
nw="$nw -Wcast-qual"
|
||||||
|
nw="$nw -Wconversion"
|
||||||
|
nw="$nw -Wsign-conversion"
|
||||||
|
nw="$nw -Wunsuffixed-float-constants"
|
||||||
|
nw="$nw -Wdeclaration-after-statement" # C89 only, messing up gcc < 5
|
||||||
|
nw="$nw -Wcast-function-type" # gcc 8, very noisy
|
||||||
|
nw="$nw -Wabi" # gcc 8, very noisy
|
||||||
|
nw="$nw -Wunused-macros" # triggers in auto-generated lex css parser, #pragma doesn't work, conflicts with -Werror
|
||||||
|
if test "$cross_compiling" = yes; then
|
||||||
|
nw="$nw -Wformat"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# remove unwanted warn flags
|
||||||
|
wget_WORD_REMOVE([WARN_CFLAGS], [$WARN_CFLAGS], [$nw])
|
||||||
|
|
||||||
|
# add more flags as you like
|
||||||
|
if test $GCC_VERSION -ge 5; then
|
||||||
|
WARN_CFLAGS="$WARN_CFLAGS -fdiagnostics-color=always"
|
||||||
|
fi
|
||||||
|
if test "$cross_compiling" = yes; then
|
||||||
|
WARN_CFLAGS="$WARN_CFLAGS -Wno-format"
|
||||||
|
fi
|
||||||
|
if test $GCC_VERSION -ge 8; then
|
||||||
|
WARN_CFLAGS="$WARN_CFLAGS -Wno-cast-function-type"
|
||||||
|
fi
|
||||||
|
# WARN_CFLAGS="$WARN_CFLAGS -Werror"
|
||||||
|
|
||||||
|
# We use a slightly smaller set of warning options for lib/.
|
||||||
|
# Remove the following and save the result in GNULIB_WARN_CFLAGS.
|
||||||
|
# Removing is not enough if these switches are implicitly set by other
|
||||||
|
# flags like -Wall or -Wextra. We have to explicitly unset them
|
||||||
|
# with -Wno-....
|
||||||
|
nw=
|
||||||
|
nw="$nw -Wpedantic"
|
||||||
|
nw="$nw -Wsign-compare"
|
||||||
|
nw="$nw -Wunused-parameter"
|
||||||
|
nw="$nw -Wswitch-default"
|
||||||
|
nw="$nw -Wformat-nonliteral"
|
||||||
|
nw="$nw -Wsuggest-attribute=pure"
|
||||||
|
nw="$nw -Wunsafe-loop-optimizations"
|
||||||
|
nw="$nw -Wundef"
|
||||||
|
nw="$nw -Wswitch-enum"
|
||||||
|
nw="$nw -Wbad-function-cast"
|
||||||
|
nw="$nw -Wredundant-decls"
|
||||||
|
nw="$nw -Werror"
|
||||||
|
wget_WORD_REMOVE([GNULIB_WARN_CFLAGS], [$WARN_CFLAGS], [$nw])
|
||||||
|
wget_WORD_REMOVE([CFLAGS], [$CFLAGS], [-Werror])
|
||||||
|
|
||||||
|
# disable options implicitly set by other options
|
||||||
|
GNULIB_WARN_CFLAGS="-Wno-error $GNULIB_WARN_CFLAGS"
|
||||||
|
GNULIB_WARN_CFLAGS="$GNULIB_WARN_CFLAGS -Wno-sign-compare -Wno-unused-parameter -Wno-alloca"
|
||||||
|
GNULIB_WARN_CFLAGS="$GNULIB_WARN_CFLAGS -Wno-float-conversion -Wno-cast-function-type"
|
||||||
|
if test "$cross_compiling" = yes; then
|
||||||
|
GNULIB_WARN_CFLAGS="$GNULIB_WARN_CFLAGS -Wno-incompatible-pointer-types"
|
||||||
|
fi
|
||||||
|
|
||||||
|
elif test "$CCNAME" = "clang"; then
|
||||||
|
# setup flags for this project
|
||||||
|
WARN_CFLAGS="$WARN_CFLAGS -Wno-system-headers -Wno-vla -Wno-cast-qual -Wno-padded"
|
||||||
|
WARN_CFLAGS="$WARN_CFLAGS -Wno-reserved-id-macro -Wno-sign-conversion -Wno-disabled-macro-expansion"
|
||||||
|
WARN_CFLAGS="$WARN_CFLAGS -Wno-documentation -Wno-documentation-unknown-command"
|
||||||
|
WARN_CFLAGS="$WARN_CFLAGS -Wno-covered-switch-default -Wno-unused-macros"
|
||||||
|
WARN_CFLAGS="$WARN_CFLAGS -Wno-missing-field-initializers"
|
||||||
|
|
||||||
|
# remove all flags from WARN_FLAGS that are already in CFLAGS
|
||||||
|
# wget_WORD_REMOVE([WARN_CFLAGS], [$WARN_CFLAGS], [$CFLAGS])
|
||||||
|
|
||||||
|
wget_WORD_REMOVE([CFLAGS], [$CFLAGS], [-Werror])
|
||||||
|
|
||||||
|
# disable verbose options
|
||||||
|
GNULIB_WARN_CFLAGS="-Wno-error $GNULIB_WARN_CFLAGS"
|
||||||
|
GNULIB_WARN_CFLAGS="$WARN_CFLAGS -Wno-sign-compare -Wno-unused-parameter -Wno-undef -Wno-format-nonliteral"
|
||||||
|
GNULIB_WARN_CFLAGS="$GNULIB_WARN_CFLAGS -Wno-conversion -Wno-disabled-macro-expansion -Wno-c++98-compat"
|
||||||
|
GNULIB_WARN_CFLAGS="$GNULIB_WARN_CFLAGS -Wno-gnu-statement-expression -Wno-shorten-64-to-32 -Wno-switch-enum"
|
||||||
|
GNULIB_WARN_CFLAGS="$GNULIB_WARN_CFLAGS -Wno-unused-macros -Wno-missing-field-initializers"
|
||||||
|
GNULIB_WARN_CFLAGS="$GNULIB_WARN_CFLAGS -Wno-gnu-zero-variadic-macro-arguments -Wno-conditional-uninitialized"
|
||||||
|
GNULIB_WARN_CFLAGS="$GNULIB_WARN_CFLAGS -Wno-comma -Wno-assign-enum -Wno-unreachable-code -Wno-error"
|
||||||
|
GNULIB_WARN_CFLAGS="$GNULIB_WARN_CFLAGS -Wno-missing-field-initializers"
|
||||||
|
|
||||||
|
# remove all flags from GNULIB_WARN_FLAGS that are already in CFLAGS
|
||||||
|
# wget_WORD_REMOVE([GNULIB_WARN_CFLAGS], [$GNULIB_WARN_CFLAGS], [$CFLAGS])
|
||||||
|
fi
|
||||||
|
|
||||||
|
AC_SUBST([WARN_CFLAGS])
|
||||||
|
AC_SUBST([GNULIB_WARN_CFLAGS])
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
dnl
|
dnl
|
||||||
dnl Checks for libraries.
|
dnl Checks for libraries.
|
||||||
@@ -845,7 +950,7 @@ AC_MSG_NOTICE([Summary of build options:
|
|||||||
Host OS: $host_os
|
Host OS: $host_os
|
||||||
Install prefix: $prefix
|
Install prefix: $prefix
|
||||||
Compiler: $CC
|
Compiler: $CC
|
||||||
CFlags: $CFLAGS $CPPFLAGS
|
CFlags: $CFLAGS $CPPFLAGS $WARN_CFLAGS
|
||||||
LDFlags: $LDFLAGS
|
LDFlags: $LDFLAGS
|
||||||
Libs: $LIBS
|
Libs: $LIBS
|
||||||
SSL: $with_ssl
|
SSL: $with_ssl
|
||||||
|
|||||||
13
lib/Makefile.am
Normal file
13
lib/Makefile.am
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
MOSTLYCLEANFILES =
|
||||||
|
noinst_LTLIBRARIES =
|
||||||
|
EXTRA_DIST =
|
||||||
|
BUILT_SOURCES =
|
||||||
|
MOSTLYCLEANDIRS =
|
||||||
|
CLEANFILES =
|
||||||
|
SUFFIXES =
|
||||||
|
noinst_LIBRARIES =
|
||||||
|
MAINTAINERCLEANFILES =
|
||||||
|
|
||||||
|
AM_CFLAGS = $(GNULIB_WARN_CFLAGS) $(WERROR_CFLAGS)
|
||||||
|
|
||||||
|
include gnulib.mk
|
||||||
92
m4/wget_manywarnings.m4
Normal file
92
m4/wget_manywarnings.m4
Normal file
@@ -0,0 +1,92 @@
|
|||||||
|
# wget_manywarnings.m4 serial 1
|
||||||
|
dnl Copyright (C) 2016-2019 Free Software Foundation, Inc.
|
||||||
|
dnl This file is free software; the Free Software Foundation
|
||||||
|
dnl gives unlimited permission to copy and/or distribute it,
|
||||||
|
dnl with or without modifications, as long as this notice is preserved.
|
||||||
|
|
||||||
|
dnl From Tim Ruehsen
|
||||||
|
|
||||||
|
# wget_WORD_SET(RESULT, SET, WORDS)
|
||||||
|
# --------------------------------------------------
|
||||||
|
# Add each word in WORDS to SET if not already there and store in RESULT.
|
||||||
|
# Words separated by whitespace.
|
||||||
|
AC_DEFUN([wget_WORD_SET], [
|
||||||
|
ret=$2
|
||||||
|
words=" $2 "
|
||||||
|
for word in $3; do
|
||||||
|
if test "${words#*" $word "}" = "$words"; then ret="$ret $word"; fi
|
||||||
|
done
|
||||||
|
$1=$ret
|
||||||
|
])
|
||||||
|
|
||||||
|
# wget_WORD_REMOVE(RESULT, SET, WORDS)
|
||||||
|
# --------------------------------------------------
|
||||||
|
# Remove each word in WORDS from SET and store in RESULT.
|
||||||
|
# Words separated by whitespace.
|
||||||
|
AC_DEFUN([wget_WORD_REMOVE], [
|
||||||
|
ret=
|
||||||
|
words=" $3 "
|
||||||
|
for word in $2; do
|
||||||
|
if test "${words#*" $word "}" = "$words"; then ret="$ret $word"; fi
|
||||||
|
done
|
||||||
|
$1=$ret
|
||||||
|
])
|
||||||
|
|
||||||
|
# wget_MANYWARNINGS(VARIABLE, LANGUAGE)
|
||||||
|
# -----------------------------
|
||||||
|
# Add LANGUAGE related GCC warnings to VARIABLE.
|
||||||
|
# This only works for gcc >= 4.3.
|
||||||
|
AC_DEFUN([wget_MANYWARNINGS], [
|
||||||
|
#
|
||||||
|
# check if manywarnings is requested
|
||||||
|
#
|
||||||
|
AC_ARG_ENABLE([manywarnings],
|
||||||
|
[AS_HELP_STRING([--enable-manywarnings], [Turn on extra compiler warnings (for developers)])],
|
||||||
|
[case $enableval in
|
||||||
|
yes|no) ;;
|
||||||
|
*) AC_MSG_ERROR([Bad value $enableval for --enable-manywarnings option]) ;;
|
||||||
|
esac
|
||||||
|
wget_manywarnings=$enableval
|
||||||
|
], [
|
||||||
|
test -f .manywarnings && wget_manywarnings=yes || wget_manywarnings=no
|
||||||
|
]
|
||||||
|
)
|
||||||
|
|
||||||
|
$1=""
|
||||||
|
|
||||||
|
if test "$wget_manywarnings" = yes; then
|
||||||
|
# AC_PROG_CC sets $GCC to 'yes' if compiler is gcc
|
||||||
|
# AC_REQUIRE([AC_PROG_CC])
|
||||||
|
|
||||||
|
case $CC in
|
||||||
|
*gcc*) CCNAME="gcc";;
|
||||||
|
*clang*) CCNAME="clang";;
|
||||||
|
esac
|
||||||
|
|
||||||
|
if test "$CCNAME" = "gcc"; then
|
||||||
|
test -n "$2" && wget_LANGUAGE=$2 || wget_LANGUAGE=C
|
||||||
|
|
||||||
|
# add -Wall -Wextra to reduce number of warn flags
|
||||||
|
wget_WORD_SET([wget_WARN_CFLAGS], [$CFLAGS], ["-Wall -Wextra -Wformat=2"])
|
||||||
|
|
||||||
|
# collect all disabled warn flags in $WARN_CFLAGS
|
||||||
|
wget_WARN_CFLAGS=$wget_WARN_CFLAGS" "$($CC $wget_WARN_CFLAGS -Q --help=warning,$wget_LANGUAGE|\
|
||||||
|
awk '{ if (([$]2 == "[[disabled]]" || [$]2 == "")\
|
||||||
|
&& [$]1!~/=/ && [$]1~/^-W/ && [$]1!~/</ && [$]1!="-Wall") print [$]1 }')
|
||||||
|
|
||||||
|
GCC_VERSION=$($CC -dumpversion | cut -f1 -d.)
|
||||||
|
if test $GCC_VERSION -ge 6; then
|
||||||
|
wget_WARN_CFLAGS=$wget_WARN_CFLAGS" -Warray-bounds=2 -Wnormalized=nfc -Wshift-overflow=2 -Wunused-const-variable=2"
|
||||||
|
fi
|
||||||
|
if test $GCC_VERSION -ge 7; then
|
||||||
|
wget_WARN_CFLAGS=$wget_WARN_CFLAGS" -Wformat-overflow=2 -Wformat-truncation=1 -Wstringop-overflow=2"
|
||||||
|
fi
|
||||||
|
|
||||||
|
elif test "$CCNAME" = "clang"; then
|
||||||
|
# set all warn flags on
|
||||||
|
wget_WORD_SET([wget_WARN_CFLAGS], [$CFLAGS], ["-Weverything"])
|
||||||
|
fi
|
||||||
|
|
||||||
|
$1=$wget_WARN_CFLAGS
|
||||||
|
fi
|
||||||
|
])
|
||||||
@@ -67,7 +67,7 @@ LDADD = $(LIBOBJS) ../lib/libgnu.a $(GETADDRINFO_LIB) $(HOSTENT_LIB)\
|
|||||||
$(LIB_NANOSLEEP) $(LIB_POSIX_SPAWN) $(LIB_SELECT) $(LIBICONV) $(LIBINTL)\
|
$(LIB_NANOSLEEP) $(LIB_POSIX_SPAWN) $(LIB_SELECT) $(LIBICONV) $(LIBINTL)\
|
||||||
$(LIBTHREAD) $(LIBUNISTRING) $(SERVENT_LIB)
|
$(LIBTHREAD) $(LIBUNISTRING) $(SERVENT_LIB)
|
||||||
AM_CPPFLAGS = -I$(top_builddir)/lib -I$(top_srcdir)/lib
|
AM_CPPFLAGS = -I$(top_builddir)/lib -I$(top_srcdir)/lib
|
||||||
|
AM_CFLAGS = $(WERROR_CFLAGS) $(WARN_CFLAGS)
|
||||||
|
|
||||||
../lib/libgnu.a:
|
../lib/libgnu.a:
|
||||||
cd ../lib && $(MAKE) $(AM_MAKEFLAGS)
|
cd ../lib && $(MAKE) $(AM_MAKEFLAGS)
|
||||||
|
|||||||
Reference in New Issue
Block a user