First-principles study of elastic and phonon properties of the heavy fermion compound CeMg