Legendre–Galerkin spectral methods for optimal control problems with integral constraint for state in one dimension