Adaptive crystal optics for undulator beamlines