We extend our previous density functional theory of homopolymers to block copolymers. The constraints on the relative number densities of the different types of monomers comprising the block copolymers alter the ideal free energy compared to that of homopolymers and of polymer blends. As in our previous work, the second-order functional derivatives of the nonideal free energy with respect to monomer densities are simply related to monomer-monomer direct correlation functions. When applied to incompressible diblock copolymers, this formalism reduces to quasi-one-component form and reproduces the Landau theory of near symmetric diblock copolymers. For homogeneous liquids, we recover the Flory-Huggins ideal free energy of mixing of block copolymers. The present theory, however, permits the treatment of compressible systems and therefore of more strongly first-order microphase separations. It also provides a rigorous formulation for developing improved density functional models for block copolymer systems.