/usr/lib/gcc/x86_64-pc-linux-gnu/4.7.3/../../../../x86_64-pc-linux-gnu/bin/ld: cm.o: undefined reference to symbol 'tgoto'
/lib64/libtinfo.so.5: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
GNUmakefile:139: recipe for target 'xemacs' failed
Created attachment 368358 [details]
Created attachment 368360 [details]
This sounds as a problem with ncurses built with use flag tinfo causing two separate libraries to be created. The workaround is not to build ncurses with that use flag (but of course other packages might require it.) See bug 494518 with some discussion about it.
Odd enough I have earlier tried to recreate this problem but with no luck. I will give it another try.
I was able to recreate the problem by rebuilding ncurses with the use flag tinfo set.
A new ebuild xemacs-21.5.34-r1 is available that fixes the problem.
Since ncurses is required by xemacs-21.5 in gentoo the patch lets configure find what libs to link with using pkg-config.
Fixed in xemacs-21.5.34-r1.