Massive gravity: a general analysis