Fix macros requiring last check result.

Fixes #4981
Link libase against libdl.

Fixes #4994