  The phonon dispersion relations and elastic constants for ferromagnetic
Ni$_2$MnGa in the cubic and tetragonally distorted Heusler structures are
computed using density-functional and density-functional perturbation theory
within the spin-polarized generalized-gradient approximation. For
$0.9<c/a<1.06$, the TA$_2$ tranverse acoustic branch along $[110]$ and
symmetry-related directions displays a dynamical instability at a wavevector
that depends on $c/a$. Through examination of the Fermi-surface nesting and
electron-phonon coupling, this is identified as a Kohn anomaly. In the parent
cubic phase the computed tetragonal shear elastic constant,
C$^\prime$=(C$_{11}-$C$_{12}$)/2, is close to zero, indicating a marginal
elastic instability towards a uniform tetragonal distortion. We conclude that
the cubic Heusler structure is unstable against a family of energy-lowering
distortions produced by the coupling between a uniform tetragonal distortion
and the corresponding $[110]$ modulation. The computed relation between the
$c/a$ ratio and the modulation wavevector is in excellent agreement with
structural data on the premartensitic ($c/a$ = 1) and martensitic ($c/a$ =
0.94) phases of Ni$_2$MnGa.
