Improve support for tool-specific dependencies

Previous patches has added preliminary support for adding
extra dependencies based on whish simulator that is used. This
patch improves the support by centralizing the code and handling
recursive dependencies better