configure.ac: fix nested functions in checks

This is a combination of these commits from master:

  9362a1b2d987125a8aa0723b916d29aaaece329a
  20e709d8b92e28d162c78b147afe4040e3a48b85
  e15ba53cdab91587721a38efa4eeea9acf871860
build: also unset LIBS when LDFLAGS is unset

On OpenBSD, libintl is installed under /usr/local/lib. When configure
checks unset LDFLAGS, LIBS should also be unset otherwise we end up with
-lintl which cannot be found resulting to the compile check to fail.

https://bugzilla.gnome.org/show_bug.cgi?id=727939