The thermodynamics of martensitic transformation