[Autotools] Rework the build target selection