build: rewrite most of configure using new macros
Most of the checks are now a single macro call, making the configure
script much easier to read.
The use of --enable and --with flags has been streamlined. Optional
libraries use --with-foo, some of them accepting the value 'dyn' to
activate runtime dynamic loading. The optional formats use --enable,
again with the value 'dyn' enabling dynamic loading.
As before, the default behaviour is to detect libraries and enable
support for available ones. If an explicitly enabled feature has a
dependency that is missing or disabled, an error is reported.