Skip to content

Commit

Permalink
Move m4 wget_ functions to m4/
Browse files Browse the repository at this point in the history
* .gitignore: Add exception m4/wget_manywarnings.m4
* configure.ac: Remove manywarnings m4 code
* m4/wget_manywarnings.m4: Add manywarnings m4 code here
  • Loading branch information
rockdaboot committed Nov 11, 2016
1 parent f877389 commit f68819c
Show file tree
Hide file tree
Showing 3 changed files with 91 additions and 102 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@ libwget.pc
libwget/css_tokenizer.c
libwget/test_linking
ltmain.sh
m4
m4/*
!m4/wget_manywarnings.m4
missing
nbproject
snippet
Expand Down
101 changes: 0 additions & 101 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -103,107 +103,6 @@ AC_PROG_INSTALL
AC_PROG_LN_S
AM_PROG_CC_C_O

#
# gl_GCC_VERSION_IFELSE([major], [minor], [run-if-found], [run-if-not-found])
# ------------------------------------------------
# If $CPP is gcc-MAJOR.MINOR or newer, then run RUN-IF-FOUND.
# Otherwise, run RUN-IF-NOT-FOUND.
AC_DEFUN([gl_GCC_VERSION_IFELSE],
[AC_PREPROC_IFELSE(
[AC_LANG_PROGRAM(
[[
#if ($1) < __GNUC__ || (($1) == __GNUC__ && ($2) <= __GNUC_MINOR__)
/* ok */
#else
# error "your version of gcc is older than $1.$2"
#endif
]]),
], [$3], [$4])
]
)

# wget_WORD_SET(RESULT, SET, WORDS)
# --------------------------------------------------
# Add each word in WORDS to SET if not already there.
# 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.
# 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])
CCNAME=$($CC --version | {
IFS=' -' read name x _
if test "$x" = clang; then
echo $x
else
echo $name
fi
})
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" "$(gcc $wget_WARN_CFLAGS -Q --help=warning,$wget_LANGUAGE|\
awk '{ if (([$]2 == "[[disabled]]" || [$]2 == "") && [$]1!~/=/ && [$]1~/^-W/&& [$]1!="-Wall") print [$]1 }')
wget_WARN_CFLAGS=$wget_WARN_CFLAGS" -Warray-bounds=2 -Wnormalized=nfc -Wshift-overflow=2 -Wunused-const-variable=2"
elif test "$CCNAME" = "clang"; then
# set all warn flags on
wget_WORD_SET([wget_WARN_CFLAGS], [$CFLAGS], ["-Weverything"])
fi
$1=$wget_WARN_CFLAGS
fi
])

# enable all possible compiler warnings in WARN_FLAGS
#
# to enable by default: create a file '.manywarnings'
Expand Down
89 changes: 89 additions & 0 deletions m4/wget_manywarnings.m4
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
# wget_manywarnings.m4 serial 1
dnl Copyright (C) 2016 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])
CCNAME=$($CC --version | {
IFS=' -' read name x _
if test "$x" = clang; then
echo $x
else
echo $name
fi
})
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" "$(gcc $wget_WARN_CFLAGS -Q --help=warning,$wget_LANGUAGE|\
awk '{ if (([$]2 == "[[disabled]]" || [$]2 == "") && [$]1!~/=/ && [$]1~/^-W/&& [$]1!="-Wall") print [$]1 }')
wget_WARN_CFLAGS=$wget_WARN_CFLAGS" -Warray-bounds=2 -Wnormalized=nfc -Wshift-overflow=2 -Wunused-const-variable=2"
elif test "$CCNAME" = "clang"; then
# set all warn flags on
wget_WORD_SET([wget_WARN_CFLAGS], [$CFLAGS], ["-Weverything"])
fi
$1=$wget_WARN_CFLAGS
fi
])

0 comments on commit f68819c

Please sign in to comment.