There are two different kinds of gunpowder: black powder and smokeless powder, each is made entirely differently.
black powder - charcoal, potassium nitrate, and sulfur are separately ground and the resulting fine powders are blended by tumbling
smokeless powder - cellulose containing materials (e.g. cotton, wood, paper scrap) are dissolved in nitric acid making a cellulose nitrate paste; this paste is extruded to make pellets of desired size and shape; the pellets are dried (in some smokeless powder formulas other nitrate based explosive materials are added to the cellulose nitrate paste; e.g. nitroglycerin) Note: there are other smokeless powder manufacturing processes not involving extrusion, but they still make the powder from cellulose nitrate