These are all valid points. But my attempt above was a proof-of-concept of
a different solution focused on pkg-config. It's nowhere near production-ready.
Still, your email got me thinking that we seem to be making this too
complicated. Since the hard-coded libdir path is the problem, wouldn't be
it better to make the libdir output dynamic?
A very quick hack (without handling -mXX, $CFLAGS or PATH):
#!/bin/sh
env_cc=$(printenv CC)
case $env_cc in
"gcc")
triplet=`$CC -print-multiarch`
;;
*"-gcc"*)
triplet=`$CC -print-multiarch`
;;
"clang")
triplet=`$CC -dumpmachine | sed 's/-pc//'`
;;
*)
echo "FIXME..."
esac
echo "-L/usr/lib/$triplet/mit-krb5"
This allows 'gcc', 'clang' or long gcc binaries (e.g. x86_64-linux-gnu or
arm-linux-gnueabi-gcc-7)
to output a usable libdir.
Ultimately, such a solution, if expanded, is temporary until we can move to
pkg-config
(if that is desired, of course).