Necessary conditions for singular extremals in the calculus of variations