A cellular process that results in the biosynthesis of constituent macromolecules, assembly, and arrangement of constituent parts of a cell wall. Includes biosynthesis of constituent macromolecules, such as proteins and polysaccharides, and those macromolecular modifications that are involved in synthesis or assembly of the cellular component. A cell wall is the rigid or semi-rigid envelope lying outside the cell membrane of plant, fungal and most prokaryotic cells, maintaining their shape and protecting them from osmotic lysis.