perf tools: Add kbuild support into Makefile.kbuild

Adding kbuild support into Makefile.kbuild. The 'legacy'
Makefile still stays untouched as it was.

It's possible to use kbuild by running 'make -f Makefile.kbuild'
with any option supported by 'legacy' Makefile.

We now have 2 config files:
  '.config' - user configured setup
  '.config-detected' - system detected setup

The '.config-detected' affects '.config' and if there's
configured feature in '.config' which was not detected
it is automatically disabled.

The '.config-detected' is re/created if:
  - there's no '.config-detected'
  - '.config' was changed

In a cleaned tree the perf is built with 'allyesconfig'
having disabled all non-detected features, just as it is
done now.

You can change '.config' via:
  make -f Makefile.kbuild menuconfig

There's difference for O=DIR build. The DIR is populated
based on kernel source tree, so the final binary is created
under DIR/tools/perf.

This commit was originally created by Jiri Olsa in February 2013; a
few changes were necessary to fit the perf version of June 2014:
* Add missing CFLAGS for specific .o targets
* Update Kbuild files (new source files, ...)
* Fix recursive invocation of config/features-checks
* Store .config-detected missing variables (libdir, ...)
* Fix missing dependencies between Kconfig options
* Fix installation of traceevent plugins
* Fix missing cleanings of feature-check binaries
* CROSS_COMPILE was not used to define AS, CC, ...
* CROSS_COMPILE was not stored in .config-detected
* Take into account DESTDIR and prefix set in the command line
* Add missing Kbuild files for non-x86 architectures
  (powerpc, arm, arm64, sh, s390, sparc)
* Move perf-time-to-tsc.c into x86-specific tests directory

Signed-off-by: Jiri Olsa <jolsa@redhat.com>
Cc: Arnaldo Carvalho de Melo <acme@ghostprotocols.net>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Corey Ashford <cjashfor@linux.vnet.ibm.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Michal Marek <mmarek@suse.cz>
Cc: linux-kbuild@vger.kernel.org
Cc: Stephane Eranian <eranian@google.com>
perf kbuild: remove Makefile.perf

The file Makefile.perf contained legacy build rules. It is replaced by
Makefile.kbuild which relies on Kbuild. Consequently, some minor
points need updates:
* The constant CONFIG_KBUILD can be removed
* The main Makefile wrapper now call Makefile.kbuild instead of
  Makefile.perf
perf kbuild: remove legacy tui/gui-related build variables

Remove NO_SLANG (replaced by CONFIG_LIBSLANG)
Remove HAVE_SLANG_SUPPORT from CFLAGS (replaced by CONFIG_LIBSLANG)
Remove NO_GTK2 (replaced by CONFIG_LIBGTK2 or CONFIG_GTK2)
Remove HAVE_GTK2_SUPPORT from CFLAGS (replaced by CONFIG_LIBGTK2)
Remove HAVE_GTK_INFO_BAR_SUPPORT from CFLAGS (replaced by
CONFIG_LIBGTK2_INFOBAR)
perf kbuild: remove legacy demangle-related build variables

Remove NO_DEMANGLE (replaced by CONFIG_DEMANGLE)
Remove HAVE_LIBBFD_SUPPORT (replaced by CONFIG_LIBBFD)
Remove HAVE_CPLUS_DEMANGLE_SUPPORT (replaced by CONFIG_LIBIBERTY_ONLY)
perf kbuild: cross-compilation variables are now handled in Kconfig

The variable CONFIG_ARCH and CONFIG_CROSS_COMPILE were added.
perf kbuild: remove legacy misc build variables

Remove NO_LIBAUDIT (replaced by CONFIG_LIBAUDIT)
Remove HAVE_LIBAUDIT_SUPPORT from CFLAGS (replaced by CONFIG_LIBAUDIT)
Remove HAVE_TIMERFD_SUPPORT (replaced by CONFIG_TIMERFD)
Remove HAVE_ON_EXIT_SUPPORT (replaced by CONFIG_ON_EXIT)
Remove HAVE_BACKTRACE_SUPPORT (replaced by CONFIG_BACKTRACE)
Remove HAVE_LIBNUMA_SUPPORT (replaced by CONFIG_LIBNUMA)
Remove NO_BIONIC (replaced by CONFIG_BIONIC)
Remove NO_PERF_REGS (replaced by CONFIG_PERF_REGS)
perf kbuild: remove legacy libelf-related build variables

Remove NO_LIBELF (replaced by CONFIG_LIBELF)
Remove HAVE_LIBELF_SUPPORT (replaced by CONFIG_LIBELF)
Remove HAVE_LIBELF_MMAP_SUPPORT (replaced by CONFIG_LIBELF_MMAP)
Remove HAVE_LIBELF_GETPHDRNUM__SUPPORT (replaced by
CONFIG_LIBELF_GETPHDRNUM_)
perf kbuild: remove legacy libdwarf-related build variables

* Remove NO_DWARF (replaced by CONFIG_LIBDWARF)
* Remove HAVE_DWARF_SUPPORT (replaced by CONFIG_LIBDWARF)
* Remove the useless variable PERF_HAVE_DWARF_REGS
* fix compilation issues if PERF_REGS is disabled
perf kbuild: remove legacy script-related build variables

Remove NO_LIBPERL (replaced by CONFIG_LIBPERL)
Remove NO_LIBPYTHON (replaced by CONFIG_LIBPYTHON)
perf kbuild: final cosmetic changes

* Correctly rename internal makefile variables
* Remove makefiles in tools/perf/config which became empty and useless
* Remove builtin-cmds.h
* Remove arch/x86/Makefile
* Improve outputs of clean and install targets
* Remove creation of PERF-FEATURES file which is redundant with the
  .config file generated by Kconfig.
* replace HAVE_KVM_STAT_SUPPORT by a Kconfig option
* replace HAVE_SKIP_CALLCHAIN_IDX by a Kconfig option
perf kbuild: add generated Kconfig build-test cases

Thanks to the python module kconfiglib, we were able to generate build
configurations. The set is, of course, not exhaustive but for each
option, all the possible states are tested.
perf: replace _BSD_SOURCE macro by _DEFAULT_SOURCE

Starting from glibc-2.20, the macro _BSD_SOURCE is deprecated and
should be replaced by _DEFAULT_SOURCE.