If db1-devel is installed and db3-devel is not installed, including
<db1/ndbm.h> causes a compile error because <db.h> is not found.
If both db1-devel and db3-devel are installed, then there is no
compile error, but there is potential for bizarre run-time errors,
because both packages provide db.h, but the two files are very different.
This is how your shipped am-utils package is compiled, by the way.
The fix is simple: make ndbm.h include <db1/db.h>, not just <db.h>.
RH62 suffers from the same problem, except it never causes compile
errors because <db.h> and <db1/db.h> are part of the same package
Fixed in db1-1.85-5. Thanks for reporting.