Spain plans to give half a million undocumented migrants legal status.