meson: move sparse detection to Meson and rewrite check_sparse.py