I believe guix and nix have largely solved that by writing build scripts for everything they're willing to bring into scope. Debian seems to be a mix of patching upstream source and build script changes.
A few projects compile to C and ship that one program.c file - sqlite comes to mind - but editing that one source file may not be easy if it was built by a build system that did lots of surprising things.
I'm mostly interested in llvm and we try to make it easy to build on a variety of systems, so it could totally be worse, but it's not easy either. And that's partly by DIY'ing a bunch of stuff that could be library dependencies.
I've no idea what to do about this. It feels like a lot of engineering effort is lost to chasing build weirdness. Open to suggestions!
p.s. I blame cmake for a lot of build complexity in the C++ world, and npm for whatever the hell is going on over in JavaScript. Random node projects from GitHub never run for me.