Generalized elliptic integrals and the Legendre M-function