many textbooks tell me that Hamiltonians are constructed from Lagrangians like $$L=L(q,\dot{q})$$ with a Legendre transformation to obtain the Hamiltonian as $$H=\dot{q}\frac{\partial L}{\partial \dot{q}}-L$$ but none of the textbooks explain how this is done.
My specific problem is that I have Lagrangians that do not depend on $\dot{q}$ and therefore should have $\frac{\partial L}{\partial \dot{q}}=0$, hence $H=-L$. But my impression from the clues I have is that it is not that simple.
Let's say the Lagrangian is $$L(q)=\ln(q)-(2q-10)\lambda$$ Now as far as I know the Legendre transformation should give a function $f^*(p)=\sup(pq-L(q))$ (this implies $p=\frac{\partial L}{\partial q}$) which is obtained by substituting the stationary point $q_s$ of $\sup(pq-L(q))$ into $pq-L(q)$ thus getting $f^*(p)=pq_s-L(q_s)$ (for instance wikipedia's Legendre Transformation page explains this). Doing this for the example above: $$\frac{\partial (pq-L(q))}{\partial q}=\frac{\partial (pq-\ln(q)+(2q-10)\lambda)}{\partial q}=p-\frac{1}{q}+2\lambda$$ must be 0 for a stationary point, thus $q_s=1/(p+2\lambda)$. And hence the transformation should be $$f^*(p)=p\frac{1}{p+2\lambda}-\ln(\frac{1}{p+2\lambda})+(2\frac{1}{p+2\lambda}-10)\lambda$$
and this should be the Hamiltonian.
But this equation does obviously have nothing to do with the textbook Hamiltonian. Rather, an answer to another question has in a similar case treated $L(q)$ as being dependent on $\dot{q}$ implicitly (Writing $\dot{q}$ in terms of $p$ in the Hamiltonian formulation ... answer by Qmechanic). It mentions using the Dirac-Bergmann method for obtaining the Legendre transform.
Trying something along the lines of this other question the above example seems to give $$p=\frac{\partial L}{\partial \dot{q}}=0$$ and $$p \approx 0$$ (an equality modulo constraint as the answer to the question linked above says). And then $H=\dot{q}p-L$.
The difference seems to be that the Legendre transform is done with respect to two different variables, $q$ and $\dot{q}$ - but it was my understanding that it had to be done with respect to all variables the Lagrangian depends on. So how does the $qp_q$ term vanish if we have only the $\dot{q}p_{\dot{q}}$ term left?
Thanks.
edit: changed ln to \ln as Plane Waves suggested, and sup to \sup. And yes, sup is the supremum over all q, as Vibert said, sorry for forgetting to mention that.