From b2c043b29a9de15a3f0c4be1275653adc42400c2 Mon Sep 17 00:00:00 2001 From: Markus Mayer Date: Tue, 18 Jul 2017 11:11:37 -0700 Subject: package/linux-tools: change method for including linux-tool sub-makefiles Make inclusion ordering of all linux-tool-*.mk sub-makefiles explicit instead of relying on alphabetical sort order. This is done by renaming the Linux tools sub-makefiles to the format linux-tool-*.mk.in. This causes the top-level Makefile to ignore the Linux tools sub-makefiles. Until now, the main Makefile included all linux-tool-*.mk files, as well as linux-tools.mk, and it relied on alphabetical sorting to include them in the proper order (linux-tool-*.mk before linux-tools.mk). Signed-off-by: Markus Mayer Acked-by: "Yann E. MORIN" [Thomas: improve comment in the code as suggested by Yann.] Signed-off-by: Thomas Petazzoni --- package/linux-tools/linux-tool-cpupower.mk | 41 -------- package/linux-tools/linux-tool-cpupower.mk.in | 41 ++++++++ package/linux-tools/linux-tool-gpio.mk | 28 ------ package/linux-tools/linux-tool-gpio.mk.in | 28 ++++++ package/linux-tools/linux-tool-iio.mk | 27 ----- package/linux-tools/linux-tool-iio.mk.in | 27 +++++ package/linux-tools/linux-tool-perf.mk | 134 ------------------------- package/linux-tools/linux-tool-perf.mk.in | 134 +++++++++++++++++++++++++ package/linux-tools/linux-tool-selftests.mk | 46 --------- package/linux-tools/linux-tool-selftests.mk.in | 46 +++++++++ package/linux-tools/linux-tools.mk | 17 ++-- 11 files changed, 284 insertions(+), 285 deletions(-) delete mode 100644 package/linux-tools/linux-tool-cpupower.mk create mode 100644 package/linux-tools/linux-tool-cpupower.mk.in delete mode 100644 package/linux-tools/linux-tool-gpio.mk create mode 100644 package/linux-tools/linux-tool-gpio.mk.in delete mode 100644 package/linux-tools/linux-tool-iio.mk create mode 100644 package/linux-tools/linux-tool-iio.mk.in delete mode 100644 package/linux-tools/linux-tool-perf.mk create mode 100644 package/linux-tools/linux-tool-perf.mk.in delete mode 100644 package/linux-tools/linux-tool-selftests.mk create mode 100644 package/linux-tools/linux-tool-selftests.mk.in (limited to 'package/linux-tools') diff --git a/package/linux-tools/linux-tool-cpupower.mk b/package/linux-tools/linux-tool-cpupower.mk deleted file mode 100644 index 2a2d3e01dd..0000000000 --- a/package/linux-tools/linux-tool-cpupower.mk +++ /dev/null @@ -1,41 +0,0 @@ -################################################################################ -# -# cpupower -# -################################################################################ - -LINUX_TOOLS += cpupower - -CPUPOWER_DEPENDENCIES = pciutils $(TARGET_NLS_DEPENDENCIES) - -CPUPOWER_MAKE_OPTS = CROSS=$(TARGET_CROSS) \ - CPUFREQ_BENCH=false \ - NLS=false \ - LDFLAGS=$(TARGET_NLS_LIBS) \ - DEBUG=false - -define CPUPOWER_BUILD_CMDS - $(Q)if test ! -f $(LINUX_DIR)/tools/power/cpupower/Makefile ; then \ - echo "Your kernel version is too old and does not have the cpupower tool." ; \ - echo "At least kernel 3.4 must be used." ; \ - exit 1 ; \ - fi - - $(TARGET_MAKE_ENV) $(MAKE) -C $(LINUX_DIR)/tools \ - $(CPUPOWER_MAKE_OPTS) \ - cpupower -endef - -define CPUPOWER_INSTALL_STAGING_CMDS - $(TARGET_MAKE_ENV) $(MAKE) -C $(LINUX_DIR)/tools \ - $(CPUPOWER_MAKE_OPTS) \ - DESTDIR=$(STAGING_DIR) \ - cpupower_install -endef - -define CPUPOWER_INSTALL_TARGET_CMDS - $(TARGET_MAKE_ENV) $(MAKE) -C $(LINUX_DIR)/tools \ - $(CPUPOWER_MAKE_OPTS) \ - DESTDIR=$(TARGET_DIR) \ - cpupower_install -endef diff --git a/package/linux-tools/linux-tool-cpupower.mk.in b/package/linux-tools/linux-tool-cpupower.mk.in new file mode 100644 index 0000000000..2a2d3e01dd --- /dev/null +++ b/package/linux-tools/linux-tool-cpupower.mk.in @@ -0,0 +1,41 @@ +################################################################################ +# +# cpupower +# +################################################################################ + +LINUX_TOOLS += cpupower + +CPUPOWER_DEPENDENCIES = pciutils $(TARGET_NLS_DEPENDENCIES) + +CPUPOWER_MAKE_OPTS = CROSS=$(TARGET_CROSS) \ + CPUFREQ_BENCH=false \ + NLS=false \ + LDFLAGS=$(TARGET_NLS_LIBS) \ + DEBUG=false + +define CPUPOWER_BUILD_CMDS + $(Q)if test ! -f $(LINUX_DIR)/tools/power/cpupower/Makefile ; then \ + echo "Your kernel version is too old and does not have the cpupower tool." ; \ + echo "At least kernel 3.4 must be used." ; \ + exit 1 ; \ + fi + + $(TARGET_MAKE_ENV) $(MAKE) -C $(LINUX_DIR)/tools \ + $(CPUPOWER_MAKE_OPTS) \ + cpupower +endef + +define CPUPOWER_INSTALL_STAGING_CMDS + $(TARGET_MAKE_ENV) $(MAKE) -C $(LINUX_DIR)/tools \ + $(CPUPOWER_MAKE_OPTS) \ + DESTDIR=$(STAGING_DIR) \ + cpupower_install +endef + +define CPUPOWER_INSTALL_TARGET_CMDS + $(TARGET_MAKE_ENV) $(MAKE) -C $(LINUX_DIR)/tools \ + $(CPUPOWER_MAKE_OPTS) \ + DESTDIR=$(TARGET_DIR) \ + cpupower_install +endef diff --git a/package/linux-tools/linux-tool-gpio.mk b/package/linux-tools/linux-tool-gpio.mk deleted file mode 100644 index ba75ab4c3f..0000000000 --- a/package/linux-tools/linux-tool-gpio.mk +++ /dev/null @@ -1,28 +0,0 @@ -################################################################################ -# -# gpio -# -################################################################################ - -LINUX_TOOLS += gpio - -GPIO_MAKE_OPTS = $(LINUX_MAKE_FLAGS) - -define GPIO_BUILD_CMDS - $(Q)if ! grep install $(LINUX_DIR)/tools/gpio/Makefile >/dev/null 2>&1 ; then \ - echo "Your kernel version is too old and does not have the gpio tools." ; \ - echo "At least kernel 4.8 must be used." ; \ - exit 1 ; \ - fi - - $(TARGET_MAKE_ENV) $(MAKE) -C $(LINUX_DIR)/tools \ - $(GPIO_MAKE_OPTS) \ - gpio -endef - -define GPIO_INSTALL_TARGET_CMDS - $(TARGET_MAKE_ENV) $(MAKE) -C $(LINUX_DIR)/tools \ - $(GPIO_MAKE_OPTS) \ - DESTDIR=$(TARGET_DIR) \ - gpio_install -endef diff --git a/package/linux-tools/linux-tool-gpio.mk.in b/package/linux-tools/linux-tool-gpio.mk.in new file mode 100644 index 0000000000..ba75ab4c3f --- /dev/null +++ b/package/linux-tools/linux-tool-gpio.mk.in @@ -0,0 +1,28 @@ +################################################################################ +# +# gpio +# +################################################################################ + +LINUX_TOOLS += gpio + +GPIO_MAKE_OPTS = $(LINUX_MAKE_FLAGS) + +define GPIO_BUILD_CMDS + $(Q)if ! grep install $(LINUX_DIR)/tools/gpio/Makefile >/dev/null 2>&1 ; then \ + echo "Your kernel version is too old and does not have the gpio tools." ; \ + echo "At least kernel 4.8 must be used." ; \ + exit 1 ; \ + fi + + $(TARGET_MAKE_ENV) $(MAKE) -C $(LINUX_DIR)/tools \ + $(GPIO_MAKE_OPTS) \ + gpio +endef + +define GPIO_INSTALL_TARGET_CMDS + $(TARGET_MAKE_ENV) $(MAKE) -C $(LINUX_DIR)/tools \ + $(GPIO_MAKE_OPTS) \ + DESTDIR=$(TARGET_DIR) \ + gpio_install +endef diff --git a/package/linux-tools/linux-tool-iio.mk b/package/linux-tools/linux-tool-iio.mk deleted file mode 100644 index 60d6249d2f..0000000000 --- a/package/linux-tools/linux-tool-iio.mk +++ /dev/null @@ -1,27 +0,0 @@ -################################################################################ -# -# iio -# -################################################################################ - -LINUX_TOOLS += iio - -IIO_MAKE_OPTS = $(LINUX_MAKE_FLAGS) - -define IIO_BUILD_CMDS - $(Q)if ! grep install $(LINUX_DIR)/tools/iio/Makefile >/dev/null 2>&1 ; then \ - echo "Your kernel version is too old and does not have install section in the iio tools." ; \ - echo "At least kernel 4.7 must be used." ; \ - exit 1 ; \ - fi - - $(TARGET_MAKE_ENV) $(MAKE) -C $(LINUX_DIR)/tools/iio \ - $(IIO_MAKE_OPTS) -endef - -define IIO_INSTALL_TARGET_CMDS - $(TARGET_MAKE_ENV) $(MAKE) -C $(LINUX_DIR)/tools/iio \ - $(IIO_MAKE_OPTS) \ - INSTALL_ROOT=$(TARGET_DIR) \ - install -endef diff --git a/package/linux-tools/linux-tool-iio.mk.in b/package/linux-tools/linux-tool-iio.mk.in new file mode 100644 index 0000000000..60d6249d2f --- /dev/null +++ b/package/linux-tools/linux-tool-iio.mk.in @@ -0,0 +1,27 @@ +################################################################################ +# +# iio +# +################################################################################ + +LINUX_TOOLS += iio + +IIO_MAKE_OPTS = $(LINUX_MAKE_FLAGS) + +define IIO_BUILD_CMDS + $(Q)if ! grep install $(LINUX_DIR)/tools/iio/Makefile >/dev/null 2>&1 ; then \ + echo "Your kernel version is too old and does not have install section in the iio tools." ; \ + echo "At least kernel 4.7 must be used." ; \ + exit 1 ; \ + fi + + $(TARGET_MAKE_ENV) $(MAKE) -C $(LINUX_DIR)/tools/iio \ + $(IIO_MAKE_OPTS) +endef + +define IIO_INSTALL_TARGET_CMDS + $(TARGET_MAKE_ENV) $(MAKE) -C $(LINUX_DIR)/tools/iio \ + $(IIO_MAKE_OPTS) \ + INSTALL_ROOT=$(TARGET_DIR) \ + install +endef diff --git a/package/linux-tools/linux-tool-perf.mk b/package/linux-tools/linux-tool-perf.mk deleted file mode 100644 index 16f3a58cc4..0000000000 --- a/package/linux-tools/linux-tool-perf.mk +++ /dev/null @@ -1,134 +0,0 @@ -################################################################################ -# -# perf -# -################################################################################ - -LINUX_TOOLS += perf - -PERF_DEPENDENCIES = host-flex host-bison - -ifeq ($(KERNEL_ARCH),x86_64) -PERF_ARCH=x86 -else -PERF_ARCH=$(KERNEL_ARCH) -endif - -PERF_MAKE_FLAGS = \ - $(LINUX_MAKE_FLAGS) \ - JOBS=$(PARALLEL_JOBS) \ - ARCH=$(PERF_ARCH) \ - DESTDIR=$(TARGET_DIR) \ - prefix=/usr \ - WERROR=0 \ - NO_LIBAUDIT=1 \ - NO_NEWT=1 \ - NO_GTK2=1 \ - NO_LIBPERL=1 \ - NO_LIBPYTHON=1 \ - NO_LIBBIONIC=1 - -# We need to pass an argument to ld for setting the endianness when -# building it for MIPS architecture, otherwise the default one will -# always be used (which is big endian) and the compilation for little -# endian will always fail showing an error like this one: -# LD foo.o -# mips-linux-gnu-ld: foo.o: compiled for a little endian system and -# target is big endian -ifeq ($(BR2_mips)$(BR2_mips64),y) -PERF_MAKE_FLAGS += LD="$(TARGET_LD) -EB" -else ifeq ($(BR2_mipsel)$(BR2_mips64el),y) -PERF_MAKE_FLAGS += LD="$(TARGET_LD) -EL" -endif - -# The call to backtrace() function fails for ARC, because for some -# reason the unwinder from libgcc returns early. Thus the usage of -# backtrace() should be disabled in perf explicitly: at build time -# backtrace() appears to be available, but it fails at runtime: the -# backtrace will contain only several functions from the top of stack, -# instead of the complete backtrace. -ifeq ($(BR2_arc),y) -PERF_MAKE_FLAGS += NO_BACKTRACE=1 -endif - -ifeq ($(BR2_PACKAGE_SLANG),y) -PERF_DEPENDENCIES += slang -else -PERF_MAKE_FLAGS += NO_SLANG=1 -endif - -ifeq ($(BR2_PACKAGE_LIBUNWIND),y) -PERF_DEPENDENCIES += libunwind -else -PERF_MAKE_FLAGS += NO_LIBUNWIND=1 -endif - -ifeq ($(BR2_PACKAGE_NUMACTL),y) -PERF_DEPENDENCIES += numactl -else -PERF_MAKE_FLAGS += NO_LIBNUMA=1 -endif - -ifeq ($(BR2_PACKAGE_ELFUTILS),y) -PERF_DEPENDENCIES += elfutils -else -PERF_MAKE_FLAGS += NO_LIBELF=1 NO_DWARF=1 -endif - -ifeq ($(BR2_PACKAGE_ZLIB),y) -PERF_DEPENDENCIES += zlib -else -PERF_MAKE_FLAGS += NO_ZLIB=1 -endif - -# lzma is provided by xz -ifeq ($(BR2_PACKAGE_XZ),y) -PERF_DEPENDENCIES += xz -else -PERF_MAKE_FLAGS += NO_LZMA=1 -endif - -# We really do not want to build the perf documentation, because it -# has stringent requirement on the documentation generation tools, -# like xmlto and asciidoc), which may be lagging behind on some -# distributions. -# We name it 'GNUmakefile' so that GNU make will use it instead of -# the existing 'Makefile'. -define PERF_DISABLE_DOCUMENTATION - if [ -f $(LINUX_DIR)/tools/perf/Documentation/Makefile ]; then \ - printf "%%:\n\t@:\n" >$(LINUX_DIR)/tools/perf/Documentation/GNUmakefile; \ - fi -endef -LINUX_POST_PATCH_HOOKS += PERF_DISABLE_DOCUMENTATION - -# O must be redefined here to overwrite the one used by Buildroot for -# out of tree build. We build perf in $(LINUX_DIR)/tools/perf/ and not just -# $(LINUX_DIR) so that it isn't built in the root directory of the kernel -# sources. -define PERF_BUILD_CMDS - $(Q)if test ! -f $(LINUX_DIR)/tools/perf/Makefile ; then \ - echo "Your kernel version is too old and does not have the perf tool." ; \ - echo "At least kernel 2.6.31 must be used." ; \ - exit 1 ; \ - fi - $(Q)if test "$(BR2_PACKAGE_ELFUTILS)" = "" ; then \ - if ! grep -q NO_LIBELF $(LINUX_DIR)/tools/perf/Makefile* ; then \ - if ! test -r $(LINUX_DIR)/tools/perf/config/Makefile ; then \ - echo "The perf tool in your kernel cannot be built without libelf." ; \ - echo "Either upgrade your kernel to >= 3.7, or enable the elfutils package." ; \ - exit 1 ; \ - fi \ - fi \ - fi - $(TARGET_MAKE_ENV) $(MAKE1) $(PERF_MAKE_FLAGS) \ - -C $(LINUX_DIR)/tools/perf O=$(LINUX_DIR)/tools/perf/ -endef - -# After installation, we remove the Perl and Python scripts from the -# target. -define PERF_INSTALL_TARGET_CMDS - $(TARGET_MAKE_ENV) $(MAKE1) $(PERF_MAKE_FLAGS) \ - -C $(LINUX_DIR)/tools/perf O=$(LINUX_DIR)/tools/perf/ install - $(RM) -rf $(TARGET_DIR)/usr/libexec/perf-core/scripts/ - $(RM) -rf $(TARGET_DIR)/usr/libexec/perf-core/tests/ -endef diff --git a/package/linux-tools/linux-tool-perf.mk.in b/package/linux-tools/linux-tool-perf.mk.in new file mode 100644 index 0000000000..16f3a58cc4 --- /dev/null +++ b/package/linux-tools/linux-tool-perf.mk.in @@ -0,0 +1,134 @@ +################################################################################ +# +# perf +# +################################################################################ + +LINUX_TOOLS += perf + +PERF_DEPENDENCIES = host-flex host-bison + +ifeq ($(KERNEL_ARCH),x86_64) +PERF_ARCH=x86 +else +PERF_ARCH=$(KERNEL_ARCH) +endif + +PERF_MAKE_FLAGS = \ + $(LINUX_MAKE_FLAGS) \ + JOBS=$(PARALLEL_JOBS) \ + ARCH=$(PERF_ARCH) \ + DESTDIR=$(TARGET_DIR) \ + prefix=/usr \ + WERROR=0 \ + NO_LIBAUDIT=1 \ + NO_NEWT=1 \ + NO_GTK2=1 \ + NO_LIBPERL=1 \ + NO_LIBPYTHON=1 \ + NO_LIBBIONIC=1 + +# We need to pass an argument to ld for setting the endianness when +# building it for MIPS architecture, otherwise the default one will +# always be used (which is big endian) and the compilation for little +# endian will always fail showing an error like this one: +# LD foo.o +# mips-linux-gnu-ld: foo.o: compiled for a little endian system and +# target is big endian +ifeq ($(BR2_mips)$(BR2_mips64),y) +PERF_MAKE_FLAGS += LD="$(TARGET_LD) -EB" +else ifeq ($(BR2_mipsel)$(BR2_mips64el),y) +PERF_MAKE_FLAGS += LD="$(TARGET_LD) -EL" +endif + +# The call to backtrace() function fails for ARC, because for some +# reason the unwinder from libgcc returns early. Thus the usage of +# backtrace() should be disabled in perf explicitly: at build time +# backtrace() appears to be available, but it fails at runtime: the +# backtrace will contain only several functions from the top of stack, +# instead of the complete backtrace. +ifeq ($(BR2_arc),y) +PERF_MAKE_FLAGS += NO_BACKTRACE=1 +endif + +ifeq ($(BR2_PACKAGE_SLANG),y) +PERF_DEPENDENCIES += slang +else +PERF_MAKE_FLAGS += NO_SLANG=1 +endif + +ifeq ($(BR2_PACKAGE_LIBUNWIND),y) +PERF_DEPENDENCIES += libunwind +else +PERF_MAKE_FLAGS += NO_LIBUNWIND=1 +endif + +ifeq ($(BR2_PACKAGE_NUMACTL),y) +PERF_DEPENDENCIES += numactl +else +PERF_MAKE_FLAGS += NO_LIBNUMA=1 +endif + +ifeq ($(BR2_PACKAGE_ELFUTILS),y) +PERF_DEPENDENCIES += elfutils +else +PERF_MAKE_FLAGS += NO_LIBELF=1 NO_DWARF=1 +endif + +ifeq ($(BR2_PACKAGE_ZLIB),y) +PERF_DEPENDENCIES += zlib +else +PERF_MAKE_FLAGS += NO_ZLIB=1 +endif + +# lzma is provided by xz +ifeq ($(BR2_PACKAGE_XZ),y) +PERF_DEPENDENCIES += xz +else +PERF_MAKE_FLAGS += NO_LZMA=1 +endif + +# We really do not want to build the perf documentation, because it +# has stringent requirement on the documentation generation tools, +# like xmlto and asciidoc), which may be lagging behind on some +# distributions. +# We name it 'GNUmakefile' so that GNU make will use it instead of +# the existing 'Makefile'. +define PERF_DISABLE_DOCUMENTATION + if [ -f $(LINUX_DIR)/tools/perf/Documentation/Makefile ]; then \ + printf "%%:\n\t@:\n" >$(LINUX_DIR)/tools/perf/Documentation/GNUmakefile; \ + fi +endef +LINUX_POST_PATCH_HOOKS += PERF_DISABLE_DOCUMENTATION + +# O must be redefined here to overwrite the one used by Buildroot for +# out of tree build. We build perf in $(LINUX_DIR)/tools/perf/ and not just +# $(LINUX_DIR) so that it isn't built in the root directory of the kernel +# sources. +define PERF_BUILD_CMDS + $(Q)if test ! -f $(LINUX_DIR)/tools/perf/Makefile ; then \ + echo "Your kernel version is too old and does not have the perf tool." ; \ + echo "At least kernel 2.6.31 must be used." ; \ + exit 1 ; \ + fi + $(Q)if test "$(BR2_PACKAGE_ELFUTILS)" = "" ; then \ + if ! grep -q NO_LIBELF $(LINUX_DIR)/tools/perf/Makefile* ; then \ + if ! test -r $(LINUX_DIR)/tools/perf/config/Makefile ; then \ + echo "The perf tool in your kernel cannot be built without libelf." ; \ + echo "Either upgrade your kernel to >= 3.7, or enable the elfutils package." ; \ + exit 1 ; \ + fi \ + fi \ + fi + $(TARGET_MAKE_ENV) $(MAKE1) $(PERF_MAKE_FLAGS) \ + -C $(LINUX_DIR)/tools/perf O=$(LINUX_DIR)/tools/perf/ +endef + +# After installation, we remove the Perl and Python scripts from the +# target. +define PERF_INSTALL_TARGET_CMDS + $(TARGET_MAKE_ENV) $(MAKE1) $(PERF_MAKE_FLAGS) \ + -C $(LINUX_DIR)/tools/perf O=$(LINUX_DIR)/tools/perf/ install + $(RM) -rf $(TARGET_DIR)/usr/libexec/perf-core/scripts/ + $(RM) -rf $(TARGET_DIR)/usr/libexec/perf-core/tests/ +endef diff --git a/package/linux-tools/linux-tool-selftests.mk b/package/linux-tools/linux-tool-selftests.mk deleted file mode 100644 index c4e5bf0fea..0000000000 --- a/package/linux-tools/linux-tool-selftests.mk +++ /dev/null @@ -1,46 +0,0 @@ -################################################################################ -# -# selftests -# -################################################################################ - -LINUX_TOOLS += selftests - -ifeq ($(KERNEL_ARCH),x86_64) -SELFTESTS_ARCH=x86 -else -ifeq ($(KERNEL_ARCH),i386) -SELFTESTS_ARCH=x86 -else -SELFTESTS_ARCH=$(KERNEL_ARCH) -endif -endif - -SELFTESTS_DEPENDENCIES = libcap-ng popt - -SELFTESTS_MAKE_FLAGS = \ - $(LINUX_MAKE_FLAGS) \ - ARCH=$(SELFTESTS_ARCH) - -# O must be redefined here to overwrite the one used by Buildroot for -# out of tree build. We build the selftests in $(LINUX_DIR)/tools/selftests and -# not just $(LINUX_DIR) so that it isn't built in the root directory of the kernel -# sources. -# -# The headers_install step here is important as some kernel selftests use a -# hardcoded CFLAGS to find kernel headers e.g: -# CFLAGS += -I../../../../usr/include/ -# The headers_install target will install the kernel headers locally inside -# the Linux build dir -define SELFTESTS_BUILD_CMDS - $(TARGET_MAKE_ENV) $(MAKE1) -C $(LINUX_DIR) $(SELFTESTS_MAKE_FLAGS) \ - headers_install - $(TARGET_MAKE_ENV) $(MAKE1) -C $(LINUX_DIR)/tools/testing/selftests \ - $(SELFTESTS_MAKE_FLAGS) O=$(LINUX_DIR)/tools/testing/selftests -endef - -define SELFTESTS_INSTALL_TARGET_CMDS - $(TARGET_MAKE_ENV) $(MAKE1) -C $(LINUX_DIR)/tools/testing/selftests \ - $(SELFTESTS_MAKE_FLAGS) O=$(LINUX_DIR)/tools/testing/selftests \ - INSTALL_PATH=$(TARGET_DIR)/usr/lib/kselftests install -endef diff --git a/package/linux-tools/linux-tool-selftests.mk.in b/package/linux-tools/linux-tool-selftests.mk.in new file mode 100644 index 0000000000..c4e5bf0fea --- /dev/null +++ b/package/linux-tools/linux-tool-selftests.mk.in @@ -0,0 +1,46 @@ +################################################################################ +# +# selftests +# +################################################################################ + +LINUX_TOOLS += selftests + +ifeq ($(KERNEL_ARCH),x86_64) +SELFTESTS_ARCH=x86 +else +ifeq ($(KERNEL_ARCH),i386) +SELFTESTS_ARCH=x86 +else +SELFTESTS_ARCH=$(KERNEL_ARCH) +endif +endif + +SELFTESTS_DEPENDENCIES = libcap-ng popt + +SELFTESTS_MAKE_FLAGS = \ + $(LINUX_MAKE_FLAGS) \ + ARCH=$(SELFTESTS_ARCH) + +# O must be redefined here to overwrite the one used by Buildroot for +# out of tree build. We build the selftests in $(LINUX_DIR)/tools/selftests and +# not just $(LINUX_DIR) so that it isn't built in the root directory of the kernel +# sources. +# +# The headers_install step here is important as some kernel selftests use a +# hardcoded CFLAGS to find kernel headers e.g: +# CFLAGS += -I../../../../usr/include/ +# The headers_install target will install the kernel headers locally inside +# the Linux build dir +define SELFTESTS_BUILD_CMDS + $(TARGET_MAKE_ENV) $(MAKE1) -C $(LINUX_DIR) $(SELFTESTS_MAKE_FLAGS) \ + headers_install + $(TARGET_MAKE_ENV) $(MAKE1) -C $(LINUX_DIR)/tools/testing/selftests \ + $(SELFTESTS_MAKE_FLAGS) O=$(LINUX_DIR)/tools/testing/selftests +endef + +define SELFTESTS_INSTALL_TARGET_CMDS + $(TARGET_MAKE_ENV) $(MAKE1) -C $(LINUX_DIR)/tools/testing/selftests \ + $(SELFTESTS_MAKE_FLAGS) O=$(LINUX_DIR)/tools/testing/selftests \ + INSTALL_PATH=$(TARGET_DIR)/usr/lib/kselftests install +endef diff --git a/package/linux-tools/linux-tools.mk b/package/linux-tools/linux-tools.mk index 7fa8d194c6..ac4da59b17 100644 --- a/package/linux-tools/linux-tools.mk +++ b/package/linux-tools/linux-tools.mk @@ -10,15 +10,14 @@ # # So, all tools refer to $(LINUX_DIR) instead of $(@D). -# Note: we need individual tools .mk files to be included *before* this one -# to guarantee that each tool has a chance to register itself before we build -# the list of build and install hooks, below. -# -# This is currently guaranteed by the naming of each file: -# - they get included by the top-level Makefile, with $(sort $(wildcard ...)) -# - make's $(sort) function will aways sort in the C locale -# - the files names correctly sort out in the C locale so that each tool's -# .mk file is included before this one. +# Note: we need individual tools makefiles to be included *before* we build +# the list of build and install hooks below to guarantee that each tool has +# a chance to register itself once, and only once. Therefore, the makefiles +# are named linux-tool-*.mk.in, so they won't be picked up by the top-level +# Makefile, but can be included here, guaranteeing the single inclusion and +# the proper ordering. + +include $(sort $(wildcard package/linux-tools/*.mk.in)) # We only need the kernel to be extracted, not actually built LINUX_TOOLS_PATCH_DEPENDENCIES = linux -- cgit v1.2.3