Nonholonomic and constrained variational mechanics