Fix zlib and lzma libraries check via command line

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

add save, change and restore LDFLAGS before AC_CHECK_LIB call
when functions gzread and lzma_code are searching inside action-if-found
of AC_CHECK_HEADERS
Parser error on repeated recursive entity expansion containing &lt;

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

basically a weird side effect and a failure
to properly parenthesize a boolean expression led to this bug