The design of freeform optical surfaces is an inverse problem in illumination optics. Combining the laws of geometrical optics and energy conservation gives rise to a generalized Monge-Ampère equation. The underlying mathematical structure of some optical systems allows for an optimal-transport formulation of the problem with an associated cost function. This motivates the design of optimal-transport-based numerical algorithms. However, not all optical systems can be cast in the framework of optimal transport. In this paper, we derive a formulation in terms of generating functions where the generalized Monge-Amp\'ere equation becomes a generated Jacobian equation. We present an iterative least-squares algorithm that can be used to solve gen...