  We consider solutions of Lagrangian variational problems with linear
constraints on the derivative. These solutions are given by curves $\gamma$ in
a differentiable manifold $M$ that are everywhere tangent to a smooth
distribution $\mathcal D$ on $M$; such curves are called horizontal. We study
the manifold structure of the set $\Omega_{P,Q}(M,\mathcal D)$ of horizontal
curves that join two submanifolds $P$ and $Q$ of $M$. We consider an action
functional $\mathcal L$ defined on $\Omega_{P,Q}(M,\mathcal D)$ associated to a
time-dependent Lagrangian defined on $\mathcal D$. If the Lagrangian satisfies
a suitable hyper-regularity assumption, it is shown how to construct an
associated degenerate Hamiltonian $H$ on $TM^*$ using a general notion of {\em
Legendre transform} for maps on vector bundles. We prove that the solutions of
the Hamilton equations of $H$ are precisely the critical points of $\mathcal
L$.
