Measure the length of the bookcase with a tape measure. Lay the two boards flat on a work surface. Mark the boards to the measurement with a pencil.
Cut the boards to the marked measurement with a miter saw. Place one board at a time flat on the table of the miter saw. Slide the board along the table until the pencil mark lines up with the outside edge of the saw blade. Pull the trigger and guide the saw through the wood until the cut is complete. Guide the saw back to the start position and release the trigger.
Adjust the blade on the table saw to cut a 45-degree angle. Adjust the height to cut through the 2-inch thickness of the 2-by-4-inch boards and lock it in place. Slide the fence over so that it will cut a complete 45-degree angle from the 4-inch side of the board and lock it in place.
Turn the table saw on. Lay one board at a time flat on the table of the saw. Push one 2-inch side flat against the fence. Guide the saw along the table to cut the 45-degree angle on the board. Move the board through the saw in a steady motion, just fast enough for the blade to cut the wood. Lift the board from the table when the cut is complete.
Slide a stud finder across the wall at the approximate height for the top of the bookcase. Mark the location of each wall stud with a pencil.
Hold one board with the 4-inch side flat against the wall. The tip of the angled edge should be on the outside 4-inch side of the board. The 45-degree angle edge should be facing up. The angle should slope down toward the wall from the tip.
Place a level across the top edge of the board and adjust its positioning until it is level. Drive two evenly spaced screws through the board into the wall at each stud marking using a screw gun.
Position the remaining board across the back of the bookcase approximately 3 inches down from top edge. The tip of the angled edge should be facing down. The angled edge should slope upward toward the back of the bookcase so that it fits into the angled edge on the wall-mounted board and interlocks. Drive two evenly spaced screws through the board into the back of the bookcase every 4 to 6 inches along the entire length of the board.
Lift the bookcase into position on the wall, interlocking the 45-degree angles on the board attached to the wall and the board attached to the back of the bookshelf.