This page has all the information you need to get your development environment set up and ready to hack on Thunderbird.
Thunderbird is built on the Mozilla platform, the same base that Firefox is built from. As such the two projects share a lot of code and much of the documentation for one will apply, in many ways, to the other. If at any point you are looking for answers that you can't find here, try looking at Firefox Source Tree Documentation.
Get the latest Mozilla source code from Mozilla's
mozilla-centralMercurial code repository, and check it out into a local directory
source(or however you want to call it). Then, get the latest Thunderbird source code from Mozilla's
comm-centralMercurial code repository. It now needs to be placed inside the Mozilla source code, in a directory named
hg clone https://hg.mozilla.org/mozilla-central source/
hg clone https://hg.mozilla.org/comm-central comm/
Mozilla-central will build Firefox without the comm-central repo present and a few options set (detailed on the Building Thunderbird page). Mozilla-central is the Firefox codebase and comm-central features the additions that turn Firefox into Thunderbird.
Let's build the latest Thunderbird: