Measure across the top of the doorway, side to side, from one upper corner to the other. Transfer the measurement to a piece of trim, putting two marks on the trim and leaving 6 inches or more of space on the outer edge of each mark.
Set the trim on your miter saw, with the face up and the bottom edge pressed against the back rail (closest to the blade). Line up either one of the marks with the blade. Swivel the blade to 45 degrees, pointing away from the measured span of the trim. Make the cut.
Move the trim so the other mark is in line with the blade. Swivel the blade 45 degrees to the other side. Make the cut.
Hold the cut piece of trim over the upper edge of the doorway, so the bottom edge of the piece is along the top edge of the door opening. Position it so the two angled cuts on either end meet the two corners, flaring up and out from there.
Nail the trim in place with a trim nail gun, shooting in the nails every 10 to 12 inches along the top and bottom edges of the piece.
Cut the two pieces for the two sides in the same manner as the top piece, except make the bottom end of each piece a straight cut (instead of 45 degrees).
Nail the two side pieces in place with the angled top ends pressed against the mitered ends of the horizontal piece, forming the corners and the straight-cut bottoms of the two side pieces sitting on the decking of the stoop or porch.
Run beads of caulk all around the trim. Allow the caulk to dry for 24 hours before painting the trim.