There's no public information about how much of that was N64 profit and how much was Gameboy, but at least based on a private Nikkei investigation they said, "This success is attributed to the performance of the N64 and Game Boy, as well as its compatible software."
I couldn't find anything concrete about the Gamecube with a quick search [edit: Gamecube was also clearly profitable; see below link], but I just saw vague information that the Gamecube was profitable but less profitable than any other system up to that point.
Either way, it's common knowledge that Nintnedo sells all of its systems at a profit, so even only selling 20 million Gamecubes, it's unlikely it resulted in a loss, especially after you figure in the ridiculously high first-party software sales.
[1] http://ign64.ign.com/articles/062/062086p1.html
Edit: Here's some concrete information on Gamecube profits.
"GameCube sales leap doubles Nintendo Q2 profits."
From: [2] http://www.theregister.co.uk/2004/07/30/nintendo_q2_results/
(Just lets not mention the virtual boy...)