Compact and weakly compact homomorphisms between algebras of differentiable functions