The thermodynamic behaviour of self-gravitating N -body systems has been worked out by borrowing a standard method from Molecular Dynamics : the time averages of suitable quantities are numerically computed along the dynamical trajectories to yield thermodynamic observables . The link between dynamics and thermodynamics is made in the microcanonical ensemble of statistical mechanics . The dynamics of self-gravitating N -body systems has been computed using two different kinds of regularization of the newtonian interaction : the usual softening and a truncation of the Fourier expansion series of the two-body potential . N particles of equal masses are constrained in a finite three dimensional volume . Through the computation of basic thermodynamic observables and of the equation of state in the P - V plane , new evidence is given of the existence of a second order phase transition from a homogeneous phase to a clustered phase . This corresponds to a crossover from a polytrope of index n = 3 , i.e . p = KV ^ { -4 / 3 } , to a perfect gas law p = KV ^ { -1 } , as is shown by the isoenergetic curves on the P - V plane . The dynamical-microcanonical averages are compared to their corresponding canonical ensemble averages , obtained through standard Monte Carlo computations . A major disagreement is found , because the canonical ensemble seems to have completely lost any information about the phase transition . The microcanonical ensemble appears as the only reliable statistical framework to tackle self-gravitating systems . Finally , our results – obtained in a “ microscopic ” framework – are compared with some existing theoretical predictions – obtained in a “ macroscopic ” ( thermodynamic ) framework : qualitative and quantitative agreement is found , with an interesting exception .