Let M be a point mass producing gravitational field. We want to find potential at point P.
A test mass m0 is taken from P towards infinite. At some position in this course, force on it is given by

If the displacement be dx, the work done by Fx is given by

Now the total work done in moving it from p to Wis given by integration. That is,
