I grabbed the sources and tried to compile but gdbm/dynamic loading/malloc/linking/... failed. How do I make it work?

Read the INSTALL file, which is part of the source distribution. Therein is described, in loving detail, how to cope with most idiosyncracies that the Configure script can't work around for any given system or architecture.