+# -Werror cannot be passed to GCC in CFLAGS because configure will fail (it
+# checks the compiler with a program that generates a warning), add the
+# following option to deal with this
+AC_ARG_VAR(PNG_COPTS,
+ [additional flags for the C compiler, use this for options that would]
+ [cause configure itself to fail])
+AC_ARG_ENABLE(werror,
+ AS_HELP_STRING([[[--enable-werror[=OPT]]]],
+ [Pass -Werror or the given argument to the compiler if it is supported]),
+ [test "$enable_werror" = "yes" && enable_werror="-Werror"
+ if test "$enable_werror" != "no"; then
+ sav_CFLAGS="$CFLAGS"
+ CFLAGS="$enable_werror $CFLAGS"
+ AC_MSG_CHECKING([if the compiler allows $enable_werror])
+ AC_COMPILE_IFELSE(
+ [AC_LANG_SOURCE([
+ [int main(int argc, char **argv){]
+ [return argv[argc-1][0];]
+ [}]])],
+ AC_MSG_RESULT(yes)
+ PNG_COPTS="$PNG_COPTS $enable_werror",
+ AC_MSG_RESULT(no))
+ CFLAGS="$sav_CFLAGS"
+ fi],)
+