  We show that for any perfect fluid in a static spacetime, if the Einstein
constraint equation is satisfied and the temperature of the fluid obeys
Tolman's law, then the other components of Einstein's equation are implied by
the assumption that the total entropy of the fluid achieves an extremum for
fixed total particle number and for all variations of metric with certain
boundary conditions. Conversely, one can show that the extrema of the total
entropy of the fluid are implied by Einstein's equation. Compared to previous
works on this issue, we do not require spherical symmetry for the spacetime.
Our results suggest a general and solid connection between thermodynamics and
general relativity.
