You've got two ways to go.
One depends on your age/physical condition and carpentry, plumbing, electrical and so forth skills are. I would say you're going to have $5,000 into it using your own labor.
The other one depends on how strong your wallet is. This will run you $15,000+. It will cost a lot of hours for a shop to take the walls and roof apart to fix the rot. The water might have even gotten down into the floor. (100 hrs of labor (minimum) at $100 per hour and $5000 for materials.)
Bill