Configurations/common.tmpl: Rework dependency resolution
The dependency resolution is made uniquely to resolve proper library
order when linking a program, a module or a shared library.
resolvedepends() did a little too much at once, so it's now reduced to
only collect dependencies (and is renamed to collectdepends()), while
a new function, expanddepends(), expands a list of dependency to
insure that dependent libraries are present after depending libraries,
and finally there is reducedepends() which removes unnecessary
duplicates, leaving only the last one.
resolvedepends() is now a simple utility routine that calls the three
mentioned above in correct order.
As part of this, we implement weak dependencies through the 'weak'
build.info attribute. This is meant to cause a specific order between
libraries without requiring that they are all present.
Reviewed-by: Matt Caswell <matt@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/10088)