Ab-initio energetics of graphite and multilayer graphene: stability of Bernal versus rhombohedral stacking