Bootstrap consistency for general semiparametric $M$-estimation