There are some tools in side the kernel,
<kernel source root directory>/tools
perf is one of them.
In ubuntu I think the tools inside this folder is available as package linux-tools
How can I compile it form source and install it and run it?
what's wrong with the following?
make -C <kernel source root directory>/tools/perf
I wanted to compile for a different architecture and this seems to work. I had hosttools from buildroot in the output/host/bin directory. Most people will have it there if using buildroot. I had to specify the LD and CC flag. So substitute with appropriate path and is the prefix for toolchain name.
make CC=<buildroot-dir>/output/host/bin/<arch>-gcc LD=<buildroot-dir>/output/host/bin/<arch>-ld -C tools/gpio/