Suppose we have a differential equation of the form
$$ L[f(x)] = a(x)f''(x) + b(x)f'(x) + c(x)f(x) = g(x) $$
where $a, b, c$ and $g$ satisfy the regularity conditions demanded in Sturm-Liouville theory. I have been looking for the motivation of the adjoint operator of $L$, denoted by $L^*$. The book I am following defines it as
$$ L^*[f] := af'' + (2a' - b)f + (a''-b'+c)f $$
where I have dropped the $x$ dependence to simplify notation. As far as I know, the adjoint operator $L^*$ of an operator $L$ is defined by the property
$$ \langle L[f], g \rangle = \langle f, L^*[g] \rangle $$
where, for sufficiently regular functions $f$ and $g$ on an interval $[x_1, x_2]$, $\langle f, g \rangle = \int_{x_1}^{x_2} f(x) g(x) \, dx $.
Using the first equation defining $L[f(x)]$, I have found that
$$ \langle L[f], g \rangle = \left[ af'g - (ag)'f + bfg \right]_{x_1}^{x_2} + \int_{x_1}^{x_2} f \left[ ag'' + (2a'-b)g' + (a''-b'+c)g \right] \,dx $$
Even though $L^*[g]$ is appearing in the integrand on the RHS, I do not see how defining $L^*$ this way the property $ \langle L[f], g \rangle = \langle f, L^*[g] \rangle $ is satisfied.