First-principles theory for the equations of state of minerals at high pressures and temperatures: Application to MgO