Determination of optimal feedback terminal controllers for general boundary conditions using generating functions