I think we also need to fix one other thing. Right now, for LZ4 support we test HAVE_LIBLZ4, but TOAST and XLOG compression are testing USE_LZ4, so I think we should be doing the same here. And similarly I think we should be testing USE_ZSTD not HAVE_LIBZSTD.
I reviewed the patch, and it seems to be capturing and replacing all the
places of HAVE_LIB* with USE_* correctly.
Just curious, apart from consistency, do you see other problems as well