When installing something from source (say, Ruby 1.9.2), what command can I run to get a complete list of all the dependencies needed to install that application? Is this possible?
Short answer: not possible. The difficulty of getting the exact dependencies from a source distribution is the reason why package management is so popular on Linux (okay, one of several reasons). In fact, if you just need to get it done and don't care so much how, the most reliable way to get the dependencies will probably be to grab a distro package (gentoo ebuilds are easy to work with) and pull the list of dependencies from that.
Otherwise, if you're lucky, the maintainers will have created a listing of the dependencies in the README file or similar - that'd be the first place to check. Failing that, if it's a C project and you don't mind getting your hands dirty, you can look inside the configure script (or better yet the configure.ac or whatever it's generated from) and figure out the dependencies from that based on what it checks.
On the whole, I also can't give you a 100% solution, but for most sources using autotools, you can grep
The first argument of
The second argument to
Neither of those are perfect and this needn't give you a complete list of requirements, but ...
Building from source
There isn't any programmatic way that I'm aware of, I generally look through the release notes and/or software README files to get a general idea. This works out to be an iterative process where I might find a library or two that I don't have or missed and need to go get them.
Building using a package manager
If on the other hand you're using a package manager such as
apt based distros
yum based distros