  Within the framework of $k_t$-factorization, we compute the differential
cross section for the production of $B$ and $D$ mesons, using a general-mass
variable-flavor-number scheme. Our calculations include all relevant $2\to 2$
processes. We explain how to include the $2\to 1$ process in our calculations,
but argue this is not (numerically) relevant at moderate transverse momentum
due to its cancellation with the subtraction term. We apply this formalism to
$pp$ collisions and compare our results with ALICE and LHCb data at central and
forward rapidity.
