tryflag () {
printf "checking whether compiler accepts %s... " "$2"
echo "typedef int x;" > "$tmpc"
-if $CC $2 -c -o /dev/null "$tmpc" >/dev/null 2>&1 ; then
+if $CC $CFLAGS_TRY $2 -c -o /dev/null "$tmpc" >/dev/null 2>&1 ; then
printf "yes\n"
eval "$1=\"\${$1} \$2\""
eval "$1=\${$1# }"
tryldflag () {
printf "checking whether linker accepts %s... " "$2"
echo "typedef int x;" > "$tmpc"
-if $CC -nostdlib -shared "$2" -o /dev/null "$tmpc" >/dev/null 2>&1 ; then
+if $CC $LDFLAGS_TRY -nostdlib -shared "$2" -o /dev/null "$tmpc" >/dev/null 2>&1 ; then
printf "yes\n"
eval "$1=\"\${$1} \$2\""
eval "$1=\${$1# }"
CFLAGS_AUTO=
CFLAGS_MEMOPS=
CFLAGS_NOSSP=
+CFLAGS_TRY=
LDFLAGS_AUTO=
+LDFLAGS_TRY=
OPTIMIZE_GLOBS=
prefix=/usr/local/musl
exec_prefix='$(prefix)'
exit 1
fi
+#
+# Figure out options to force errors on unknown flags.
+#
+tryflag CFLAGS_TRY -Werror=unknown-warning-option
+tryflag CFLAGS_TRY -Werror=unused-command-line-argument
+tryldflag LDFLAGS_TRY -Werror=unknown-warning-option
+tryldflag LDFLAGS_TRY -Werror=unused-command-line-argument
+
#
# Need to know if the compiler is gcc to decide whether to build the
# musl-gcc wrapper, and for critical bug detection in some gcc versions.
tryflag CFLAGS_AUTO -Wno-pointer-to-int-cast
fi
-if test "x$visibility" == xauto ; then
+if test "x$visibility" = xauto ; then
# This test checks toolchain support for several things:
# - the -include option
# - the attributes/pragmas used in vis.h
printf "%s\n" "$visibility"
fi
-if test "x$visibility" == xyes ; then
+if test "x$visibility" = xyes ; then
CFLAGS_AUTO="$CFLAGS_AUTO -include vis.h"
CFLAGS_AUTO="${CFLAGS_AUTO# }"
fi