The evolution of protostars. I - Global formulation and results