In general, you can't, that information isn't stored anywhere.
Some programs' build systems are designed to store a copy of the
configure script invocation used to set up the build environment, but that behavior has to be written into the program. It doesn't get done automatically.
If you're desperate I suppose you could always try compiling the program with different combinations of flags and just hope to find one that reproduces the program you have. Or, if you have access to the source code and know what the different options and their effects are, you could invoke the program in ways that will get it to show you those effects. (e.g. if your program had an "enable-help" compilation option you could try running it with the
-h option to see if help had been enabled)