+ dnl Use -v and some other options with SunStudio cc. lex produces
+ dnl code that causes unreachable-statement warnings. It might be
+ dnl better to use an autoconf test, except -v will probably succeed
+ dnl with many other compilers but have different meaning.
+ AS_CASE([`${CC} -V 2>&1`],
+ [cc:\ Sun\ C*], [CFLAGS=\
+"${CFLAGS:+$CFLAGS }-v -errtags=yes -erroff=E_STATEMENT_NOT_REACHED"])
+ fi
+
+ AC_CACHE_CHECK([whether compiler supports -Wall], [nmh_cv_has_wall],
+ [nmh_saved_cflags="$CFLAGS"
+ CFLAGS="$CFLAGS -Wall -Werror"
+ AC_TRY_COMPILE([],[],nmh_cv_has_wall=yes,nmh_cv_has_wall=no)
+ CFLAGS="$nmh_saved_cflags"])
+ test "$nmh_cv_has_wall" = "yes" && CFLAGS="${CFLAGS:+$CFLAGS }-Wall"
+
+ AC_CACHE_CHECK([whether compiler supports -Wextra], [nmh_cv_has_wextra],
+ [nmh_saved_cflags="$CFLAGS"
+ CFLAGS="$CFLAGS -Wextra -Werror"
+ AC_TRY_COMPILE([],[],nmh_cv_has_wextra=yes,
+ nmh_cv_has_wextra=no)
+ CFLAGS="$nmh_saved_cflags"])
+ test "$nmh_cv_has_wextra" = "yes" && CFLAGS="${CFLAGS:+$CFLAGS }-Wextra"
+fi
+
+dnl --------------
+dnl CUSTOMIZE LINK
+dnl --------------
+if test `uname` = OpenBSD; then
+ dnl Filter out "often/almost always misused" warnings from OpenBSD linker.
+ [POSTLINK="2>&1 | egrep -v ': [w]arning: s[a-z]+\(\) is \
+(almost always|often) misused, please use'; true"]
+fi
+AC_SUBST([POSTLINK])
+
+dnl -----------------
+dnl CUSTOMIZE LDFLAGS
+dnl -----------------
+if test "$GCC" = yes; then
+ dnl Disable clang complaint about unused -ansi when linking.
+ AC_CACHE_CHECK([whether linker supports -Qunused-arguments],
+ [nmh_cv_has_q_unused_arguments],
+ [nmh_saved_ldflags="$LDFLAGS"
+ LDFLAGS="$LDFLAGS -Qunused-arguments"
+ AC_TRY_LINK([],[],nmh_cv_has_q_unused_arguments=yes,
+ nmh_cv_has_q_unused_arguments=no)
+ LDFLAGS="$nmh_saved_ldflags"])
+ test "$nmh_cv_has_q_unused_arguments" = "yes" && \
+ LDFLAGS="${LDFLAGS:+$LDFLAGS }-Qunused-arguments"
+fi
+
+dnl This really shouldn't be necessary. And we really shouldn't add -s.
+if test x"$enable_debug" = x"yes"; then
+ test -z "$LDFLAGS" && LDFLAGS=-g
+else
+ if test -z "$LDFLAGS"; then
+ case "$build_os" in
+ darwin*) LDFLAGS= ;;
+ *) LDFLAGS=-s ;;
+ esac