In Hamilton's "on a general method in dynamics", he starts with varying the function $U$ and writes the equation: $$\delta U=\sum m(\ddot x\delta x+\ddot y\delta y+\ddot z\delta z)$$ Then he defines $T$ to be: $$T=\frac{1}{2}\sum m (\dot x^2+\dot y^2+\dot z^2)$$ Then by $dT=dU$, he writes: $$T=U+H$$ Then he varies T and writes: $$\delta T= \delta U+\delta H$$ note that he is also varying in the initial conditions, that's why he did not omit the term $\delta H$. Hamilton then multiplies this expression by dt and integrates and writes it as: $$\int\sum m(dx \delta \dot x+dy \delta \dot y+dz \delta \dot z)=\int\sum m(d \dot x \delta x+d \dot y \delta y+d \dot z \delta z)+\int\delta H dt$$
Then comes the part where I got confused. He says "that is, by the principles of the calculus of variations" and writes:
$$\delta V=\sum m(\dot x \delta x+\dot y \delta y+\dot z \delta z)-\sum m(\dot a \delta a+\dot b \delta b+\dot c \delta c)+\delta H t$$
where (x,y,z) and (a,b,c) are final and initial conditions then he denotes V by the integral:
$$V=\int\sum m(\dot x \delta x+\dot y \delta y+\dot z \delta z)$$
My questions are as follows:
1-how did he get $\delta V$, what "principle of the calculus of variations" did he use?
2-then how from that did he get the integral $V$?