Density functional theory as thermodynamics