gen_config: respect dependencies (fixes out-of-tree builds)