A magnitude-7.8 earthquake struck New Zealand's South Island, shaking awake residents, causing damage to buildings and prompting emergency services to warn people to move to safe ground.