Installing the S38 (M5) into the wagon is a rather large undertaking - far more involved than a simple drop-in swap, not to mention the particulars with that specific engine in regards to maintenance. You could get some more grunt by doing a forced-induction setup on the M50 or an S50/S52 swap. They'll run you about the same amount of $. The M50 has been proven to handle more than a fair amount of boost with no problems. It's not uncommon to see 300 RWHP - on-par with an M5, for about 1/2 the cost and none of the maintenance.
The transmission conversion is quite common and well within the realm of a skilled DIY'er. Attack Eagle is doing a conversion now, and a few others (myself included) on another forum have done it as well. The 6 speed is a little more involved, but nothing is impossible as long as your bank account can handle it.
This link has a writeup, as well as links to an S52 swap and an M30 swap.
Swapping Auto to manual in my m50 525iT - Bimmerforums - The Ultimate BMW Forum