Add .gitignore and .hgignore.
Merge.
-ldl is only needed on Linux, not on the *BSDs.