The optical potential of halo and weakly bound nuclei has a long range part due to the coupling to breakup that damps the elastic scattering angular distributions. In order to describe correctly the breakup channel in the case of scattering on a heavy target, core recoil effects have to be taken into account. We show here that core recoil and nuclear breakup of the valence nucleon can be consistently taken into account. A microscopic absorptive potential is obtained within a semiclassical approach and its characteristics can be understood in terms of the properties of the halo wave function and of the reaction mechanism. Results for the case of medium to high energy reactions are presented.