[3.5.x] Back-port configure.ac changes to make 3.5.x build

Sudhir was asked to build 3.5.x and the configure script failed to make sense of libxml2.
After some debugging and git-archeology, I found the relevant changes in master's history that (we hope) restore 3.5.x to a build-able state.  Currently awaiting test build.
This part is not appropriate for 3.5 I believe. ``configure_flags.env`` doesn't exist there.