A universal LDA-type density functional describing the electronic correlati
ons in superconductors is developed from first principles. The functional i
s constructed from the exchange-correlation free-energy density, f(xc)(hom)
, of a homogeneous electron gas exposed to an external translationally inva
riant pairing field. The quantity f(xc)(hom), which is a function of the de
nsity and a functional of the induced order parameter, is calculated by man
y-body perturbation theory.