First-principles optical properties of silicon and germanium nanowires