Archaic spelling of "jail". Read it with a soft g and a long a and it makes a little more sense. There's also the derivative "gaoler".
(American here, but that's one I've come across before.)
(American here, but that's one I've come across before.)
Also, if gaol can have a soft g, then so can gif? :-)