We present a geometric proof of Bernsteins second adjointness for a reductive $p$-adic group. Our approach is based on geometry of the wonderful compactification and related varieties. Considering asymptotic behavior of a function on the group in a neighborhood of a boundary stratum of the compactification, we get a co-specialization map between spaces of functions on various varieties with $Gtimes G$ action. These maps can be viewed as maps of bimodules for the Hecke algebra, and the corresponding natural transformations of functors lead to the second adjointness. We also get a formula for the co-specialization map expressing it as a composition of the orishperic transform and inverse intertwining operator; a parallel result for $D$-modules was obtained in arXiv:0902.1493. As a byproduct we obtain a formula for the Plancherel functional restricted to a certain commutative subalgebra in the Hecke algebra, generalizing a result by Opdam.