Don't promise you can get this to work in a way that suits your needs, but you might be able to rig something up with ParseDepends
. That method reads an external dependency file to add dependency relationships, and by default just skips it if the dep file isn't there. However, it would be an additional file you have to create if the dot file you want to optionally depend on exists, because the dep file itself has to be in a specific format (target: dep1 dep2... depN
). See if this gives you any ideas:
https://scons.org/doc/production/HTML/scons-user.html#id1330
(sorry that's one of the User Guide chapters that hasn't yet been converted to named section anchors, so it's kind of a funky link).