This paper explains
how to calculate, given the spectral composition of a light source, what
colour it will be perceived as by the human eye, and which red, green,
and blue intensities best approximate it on a computer monitor.
C source code
which implements the technique is included.