autotools is horrifying. I'm not claiming that there is an obviously better way to solve the problem that it tries to solve, but it is horrifying.
FTR, I have much more experience with cmake, which is also horrifying. (Maybe there is no non-horrifying way to solve this problem?)