This helps in creating canonical names for cross tool versions which may contain lib in their name. In Yocto this is common when creating multilib versions that lib32/lib/lib64 is added to canonical name to indicate multilib variant. This fails if we do not check the toolname to be at the end of string.
In multilib(lib32) case, the arm-pokymllib32-linux-gnueabi-llvm-ar (${TARGET_PREFIX}llvm-ar) gives:
qc: no such file or directory
Which is because when the llvm-ar symbol link's name contains "lib", it would be considered as llvm-lib: