Solved Tracking of build dependencies


Scenario: I just fixed a port I created quite some time ago after receiving "pkg-fallout" mails and it turned out a build dependency was missing for the DOCS option. As the port was accepted back then, I assume this problem came to existence only later, maybe due to some reorganization, but that's not really important -- point is, it really took me some time to identify the problem because the port was building fine on my machine, obviously just because I had this dependency installed by accident.

Question: How to properly identify all build dependencies with a given set of build options for a port? I guess I'm not the only/first one confronted with this kind of (slightly annoying) problem, so maybe there are some common strategies, tools, guidelines, ...? Thanks!

edit: I'm NOT talking about runtime dependencies, because I think they are easily identified, as they are most of the time just shared libraries ...
Something like:

make -C /usr/ports/category/port build-depends-list __MAKE_CONF=/dev/null OPTIONS_SET=DOCS

The __MAKE_CONF part is not needed if you don't have an /etc/make.conf file. If you have one the settings in the file always override the command line which is kind of unfortunate.

Edit: I haven't tested what happens if you have saved options under /var/db/ports so that might not work if there are saved options.
Probably the best way to test is on a clean machine. But not everybody has a spare lying around. Alternatives are VMs (bhyve, VirtualBox, etc) or even a basic jail(8) will do for testing.
Thanks, I'll give the different suggestions a try soon! It's pretty obvious that a clean jail/VM will do, but I'd like to avoid the manual work linked with that ;)
Yep, thanks again, I'll definitely look into one of these, so next time I'm creating or updating a port, I'll have a reliable test environment. I guess with all these alternatives, a "solved" here is appropriate.