Nucleon and pion gluon parton distribution function from lattice QCD calculation