I've just made little command line open source tool NcxGen
(.NET 4) to create NCX, OPF and html table of contents from an XHTML file, following (as much as possible) the Amazon Publishing Guidelines. The tools has few options right now but if it is of some interest to the community I'm available to any suggestion. See the Getting Started
wiki page for the available commands.
One thing that I can't found in Calibre is the ability to "collapse" the desired amount of levels in the NCX, keeping the proper indentation in the html ToC, that's why I started writing this tool.
The tool will modify the "id" attribute of some tags, so if you have already a TOC and want to generate just the ncx file, there may be a chance that you broke the hrefs links in the original TOC. (This is a solution that works for me... but if it is a problem I can try to find another solution)
Also, consider the tool slightly buggy, so always keep a backup of your original files!
I hope it can be helpful