In ordered not to modify dozens of Makefiles, I have ended up using LDFLAGS
. The trick was to set it after the AC_PROG_CXX
macro:
AC_PROG_CXX
if test "$host_os" = cygwin
then
LDFLAGS="-no-undefined $LDFLAGS"
fi
AC_SUBST([LDFLAGS])
This way, the macro that tests for a C++ compiler succeeds because LDFLAGS is pristine; but the actual codebase uses the extra flag.
By putting the $LDFLAGS
substitution at the end, any user options from the environment take precedence at configure time; and overriding at make time with make LDFLAGS=...
is still possible.