Improve the cross-compile support

These changes will help build ktap under e.g. OpenEmbedded.

Signed-off-by: Anders Darander <anders@chargestorm.se>
Signed-off-by: zhangwei(Jovi) <jovi.zhangwei@huawei.com>