Measurements of gamma-ray background spectra at spallation neutron source beamlines