Typically, it would be cheaper to buy a bike if its from mid range quality to lower quality and a lot cheaper to the lowest quality. Bike shops online and local usually stock decent components, so you can't buy entry components easily. If you add them up without the labor, the whole bike still wins out.
You could be able to build a bike cheaper, if its more in the upper range in quality. But, it will take time as you have to do the research and waiting for the parts to be on clearance, or even having to order overseas.
Now that I read my answer a little more in detail, this really only applies to road bikes, or hardtail/29'ers, since full suspension bike designs are very propriety and the frame would already cost you bulk of the whole bike's price.
What you could do, is research online and get a bike with a decent frame, but has cheaper components to keep the price lower, and upgrade specific parts that you like. Or, as the part wears out, buy the next level part for it and the bike becomes a much better bike.