Primitive or modern?
Primitive, they used two main methods. One, wrap strips of iron/steel around a mandrel and forge weld it together into a bbl. Two, forge a long rod and then drill it out, IIRC they just heated it red hot and then drove a rod thru it followed by a reamer. Later, steel mills figured out how to produce hollow hexagonal rods and Gunsmiths rejoiced!
Modern, just buy some thick walled tube.
Rifling at home is possible with the cut rifling method, same as it was done on the originals. A long bar with a pocket on the end has a single point cutter stuck in the pocket and the bar is pulled thru the bbl at a steady twist rate. After each pass, a shim is placed under the cutter to deepen the cut. When one groove is cut to depth, the bbl and/or bar is indexed to the next groove and the process repeated. The machine used can be as simple as a frame with a screw type drawbar and a cutter bar with a spiral groove in it that rides on a pin. Some of the original setups were mainly wood.
Colonial Williamsburg produced some documentaries about their Gunsmithing program, if you can find one they do show some bbl making like it was done back in the day.