In some papers about hydrodynamics in droplets, the following ODE
$g(h) + \frac{d^2 h}{dx^2} = p$
is commonly integrated to give
$f(h) + \frac{1}{2}\left(\frac{dh}{dx}\right)^2 = ph + c$
where $h=h(x)$, $g(h)=df/dh$, $p$ and $c$ are constants.
How is the second equation obtained from the first? Basically I'm quite sure how to integrate $h_{xx}$ to get $h_x^2/2$. How to do this properly/rigorously and what are the assumptions behind the steps?
Multiply the first equation with $\frac{dh}{dx}$ then integrate over $x$: