There has been tons of research into genetic algorithims that simulate evolution with the species striving for a common goal. So far, there have been issues with environment. How do you simulate the entire planet at the molecular level to provide the correct environment? Some have rejected that idea and simply made programs that duplicate again and again, but there is the issue of natural selection and how to weed out the bad. Some have taken the intellegent design approach and done it by hand, but that is near impossible to do, unless you are God himself, as it takes at least a minute or two to decide if a specific incarnation is fit to reproduce.
One of the more interesting ways of doing this is to create a physical machine that can build a copy of itself, with minor mutations, given enough raw supplies. People are constatnly trying to do this, but so far it hasn't been possible to make a machine that can make circut boards
Anyway, there is no way a program will somehow become selfaware unless we program it in or evolution takes care of it. The reason animals are self-aware is because it benefits them in natural selection and those that arn't self aware die off quickly. As with all engineering, I think we should look to nature for an answer, as she's had a few billion years to think of it before us.