I think you misunderstand this. The code is checking to see if
libexecdir contains a literal string of '${exec_prefix}' (an
unresolved variable, in other words). If so, it just expands
the variable for you. Otherwise you get an invalid directory.
If you actually set libexecdir to something by using the
--libexecdir flag, then the value you specify will be used.
No, that's exactly what I'm driving at. My example wasn't clear
enough. What we're trying to workaround is the fact that there may be
a variable referencing a variable and we need that to be resolved to
get a full path. The ssh_libexec example only supports the case there
the referenced variable is ${exec_prefix}, but what if it was
something else like ${datadir}?
I believe if you move all the AS_AC_EXPAND calls to the beginning, you
can then reference $LIBEXECDIR and you'll have it fully expanded.
Actually, I use AS_AC_EXPAND in a different project of mine, and I've
come to decide that it's a hack for the reason above (it only handles
the case where the referenced variable is $prefix or $exec_prefix).
The only way to reliably do this is to do the substitutions in make
where they will be fully resolved. But that's beyond the scope of this
change, so I'll send you a cleanup patch so that the AS_AC_EXPANDed
vars are used throughout configure.ac.