Magnetic field generation by ablation waves or shocks propagating in inhomogeneous plasma