It is always going to be cheaper to buy complete..... but......
If you are really particular about some of the big-ticket components (particularly wheels and fork), and will end up needed to upgrade/swap those parts, it can start to even out. Guess it depends how much you can re-sell the unused stuff for.
But all this is a bit beside the point with a $400 budget. At that price point you just need to find the best complete bike you can, and deal with what it comes equipped with.