The GNU Stow documentation has a curious blind spot; it doesn't mention the DESTDIR convention for installing in a separate directory:
$ ./configure --prefix=/usr/local
$ make
$ make install DESTDIR=/usr/local/stow/whatever
Using "make prefix=..." is not the main mechanism for overriding the install location; DESTDIR is. DESTDIR is widely supported, and documented in the GNU Coding Standards, in the Makefile Conventions section of the Release Process chapter:
They serve two different purposes. DESTDIR places files in a staging directory, e.g. to be packaged into a tarball.
In your example, you will end up with the program at /usr/local/stow/whatever/usr/local/bin, which I'm guessing Stow is trying to avoid, because it's ugly and the extra directories are unnecessary. Not wrong, though. With their approach, it ends up at /usr/local/stow/whatever/bin.
Right. So if the package supports install time prefix with no hassle, it could be done with make DESTDIR=/usr/local/stow/whatever prefix=/ to get rid of the usr/local components. If the prefix override causes a problem, then just live with the extra components. I'm guessing that in that case you tell stow that your package root is at /usr/local/stow/whatever/usr/local. Stow doesn't care about the extra components; your package can be anywhere you like, right?
That's not right either. The --prefix needs to be /usr/local or /usr/local/stow/package-1.0, otherwise many packages won't find their own files. The prefix path will get compiled into the binary or configuration for a lot of packages, it's not just an install time thing.
Using --prefix=/usr/local/stow/package-1.0 is problematic whenever you have a package with plugins, themes or other stuff, as those go to /usr/local/share/package/... while the app is looking in /usr/local/stow/package-1.0/share/package/
Using DESTDIR and manually removing the usr/local from the directory tree is what I would consider the correct way, even if a bit annoying.
Either way, these days I would just recommend to use Nix instead, which is a much more complete solution for what stow tries to do.
I understand the compile-time prefix. But in some projects, you can override the configured prefix variable during "make install" without changing anything in the package; the install steps will just accept those paths, as a hack for shortening the paths, in packages where that works.
--prefix= exists to configure the install location, and you shouldn't use any other mechanism for that.
DESTDIR exists to add another prefix on top of what --prefix= specifies, for the purpose of temporarily copying the program into, for example for packaging. A lot of programs will not run from their DESTDIR location, and they must be copied out of DESTDIR to run.
For example, --prefix=/foo DESTDIR=/bar will install into /bar/foo, but running /bar/foo/bin/prog will not function properly, until you "mv /bar/foo /foo" and run it as /foo/bin/prog. There's a very limited set of programs that will try to figure out their prefix at runtime, by checking the location of the binary, but this is hard to do properly and comes with caveats, and the programs that support this are few and far between.
https://www.gnu.org/prep/standards/html_node/DESTDIR.html