Build him by feel
SevenSidedDie has an excellent answer about why there's no definitive Gandalf build, but I think we can talk constructively about how to go creating a Gandalf build.
You want to "recreate Gandalf from the books" "in D&D3.5 terms." You can't, not precisely. D&D isn't a good fit at all for actually recreating LotR scenarios or characters: it has a different mythos, a different philosophy toward magic, and is built with mechanical considerations that Tolkien didn't have to worry about.
But we can create D&D characters who are like LotR characters. This is going to require choosing what to keep or emphasize, and what isn't as important so it can be left behind or diminished. We won't be making a character who can accomplish exactly what Gandalf could accomplish --no more, no less-- in the novels. We'll be making a Gandalf who is Gandalf in essence rather than in detail.
What defines Gandalf to you?
Because of the limitations of D&D build options, you'll have to focus on one particular "kind" of Gandalf. Deciding what kind of Gandalf you want to design needs to be deliberate and purposeful, and you'll need to own that decision.
If you were asked to describe Gandalf in a phrase of five words or less, what would you say? If he's an "ancient, angelic guardian of hope," you're going to build him differently than if he's a "crafty and manipulative magical hobo." Both are absolutely true descriptions of him, but each emphasize a different element of his character.
What does this say about race and/or templates?
Gandalf could be a human, an aasimar, a half-celestial, or a number of other choices depending on what kind of Gandalf you've chosen to make. Don't be concerned about whether it's an accurate representation of a Maia clothed in mortal flesh; get the race or template that best reflects the phrase that describes your personal Gandalf.
What does this say about how he gets things done?
What are your Gandalf's goals and how does he accomplish them? Does he ride a white horse at dawn to bring hope to the hopeless, or does he throw flaming pinecones at wolves? Is he a self-sacrificial hero or a guy who pranks his friends by throwing a party at their house without telling them?
The answers to this question will tell you a lot about his class and build. I think of Gandalf as a guy who gets other people to do things, but can handle himself in a pinch, so I consider him a bard.
Don't be afraid to go off canon
If your Gandalf is a powerful spellcaster, forget trying to map his powers in the books to D&D spells. Make him a powerful spellcaster by D&D standards, so he is deserving of the proper eldritch respect.
This is the essence of my advice: Don't try to recreate what Gandalf can do. Recreate the essence of who he is and what he means. At the end of the day we don't remember him as the level 5 human wizard who cast shatter on a bridge; we remember him as the man who sacrificed himself to a terrible monster so his friends could get away.