We analyze the dynamical equations obeyed by a classical system with
position-dependent mass. It is shown that there is a non-conservative force
quadratic in the velocity associated to the variable mass. We construct the
Lagrangian and the Hamiltonian for this system and find the modifications
required in the Euler-Lagrange and Hamilton's equations to reproduce the
appropriate Newton's dynamical law. Since the Hamiltonian is not time
invariant, we get a constant of motion suited to write the dynamical equations
in the form of the Hamilton's ones. The time-dependent first integrals of
motion are then obtained from the factorization of such a constant. A canonical
transformation is found to map the variable mass equations to those of a
constant mass. As particular cases, we recover some recent results for which
the dependence of the mass on the position was already unnoticed, and find new
solvable potentials of the P\"oschl-Teller form which seem to be new. The
latter are associated to either the su(1,1) or the su(2) Lie algebras depending
on the sign of the Hamiltonian