Off-axis illumination optics has being used in microlithography for projection printing since 90th. It increases resolution and depths of focus for certain layout patterns and design styles. First annular, then quadrupole, and lately dipole source shapes are getting deployed. The source shape can be formed by hard stop apertures or by diffractive optical elements (DOE). The former is advantageous because it preserves light energy on the way from a laser source to the mask (object). In addition, DOEs can form very complex source shapes, with smooth distribution of light across the aperture. This enables source tuning to print certain layout features with a high resolution. Though printing hardware is ready for complex shapes to be used, optimization methods are not well developed. In this study we first review existing source optimization methods. Lack of rigorous formulations motivates discussion of the optimization objectives and constraints. We stress importance of using weighted and so-called Sobolev norms. Second, we state the main optimization problem as a set of the optimization objectives in a form of functional norm integrals to maximize image fidelity, system throughput, and source smoothness. We show how to reduce this to a non-negative least square (NNLS) problem, which is solved by standard numerical methods. Third, we analyze solutions for important practical cases: alternating phase-shifting regular and SRAM cell. An actual DOE element was fabricated for one of the SRAM cells, which accurately reproduces a very complex off-axis illuminator light distribution. Finally we show how constraint optimization can be used to smooth strong off-axis quadrupole illuminations in order to achieve better image fidelity for some selected layout patterns.