Improve zlib detection logic (#7430)

Current logic expects zlib is in /usr or /usr/local or a path manually
specified, and it doesn't pass -lz to a linker if zlib is not in any of them.

macOS doesn't have zlib (or libz) in /usr or /usr/local but in another place,
and you don't have to explicitly specify the path because it's the standard path.
In other words, just passing -lz to clang/gcc works without -I nor -L.

New logic passes -lz if zlib is available without additional path information.
1 file changed