Lattice Dynamics of Semiconductors from Density-Functional Perturbation Theory