linux: use BR2_MAKE

Since kernel version 6.2, the minimum GNU Make version is 3.82 [1]. We
have an optional host-make 4.0 minimum dependency, so we can use it as
is. It's a bit unfortunate that we have to apply this even to older
kernel versions, but make itself builds fairly fast compared to the
kernel.

Use BR2_MAKE and BR2_MAKE1 for linux, and depend on
BR2_MAKE_HOST_DEPENDENCY. In addition, we need to set LINUX_MAKE to
BR2_MAKE for use in the kconfig infrastructure.

Signed-off-by: Oleg Lyovin <ovlevin@sberdevices.ru>
Signed-off-by: Arnout Vandecappelle <arnout@mind.be>
This commit is contained in:
Oleg Lyovin
2023-04-07 17:19:30 +03:00
committed by Arnout Vandecappelle
parent 36bdfd29d8
commit 0b9efc991f

View File

@@ -70,7 +70,10 @@ LINUX_MAKE_ENV = \
BR_BINARIES_DIR=$(BINARIES_DIR) BR_BINARIES_DIR=$(BINARIES_DIR)
LINUX_INSTALL_IMAGES = YES LINUX_INSTALL_IMAGES = YES
LINUX_DEPENDENCIES = host-kmod LINUX_DEPENDENCIES = \
host-kmod \
$(BR2_MAKE_HOST_DEPENDENCY)
LINUX_MAKE = $(BR2_MAKE)
# The kernel CONFIG_EXTRA_FIRMWARE feature requires firmware files at build # The kernel CONFIG_EXTRA_FIRMWARE feature requires firmware files at build
# time. Make sure they are available before the kernel builds. # time. Make sure they are available before the kernel builds.
@@ -183,7 +186,7 @@ endif
# Get the real Linux version, which tells us where kernel modules are # Get the real Linux version, which tells us where kernel modules are
# going to be installed in the target filesystem. # going to be installed in the target filesystem.
# Filter out 'w' from MAKEFLAGS, to workaround a bug in make 4.1 (#13141) # Filter out 'w' from MAKEFLAGS, to workaround a bug in make 4.1 (#13141)
LINUX_VERSION_PROBED = `MAKEFLAGS='$(filter-out w,$(MAKEFLAGS))' $(MAKE) $(LINUX_MAKE_FLAGS) -C $(LINUX_DIR) --no-print-directory -s kernelrelease 2>/dev/null` LINUX_VERSION_PROBED = `MAKEFLAGS='$(filter-out w,$(MAKEFLAGS))' $(BR2_MAKE) $(LINUX_MAKE_FLAGS) -C $(LINUX_DIR) --no-print-directory -s kernelrelease 2>/dev/null`
LINUX_DTS_NAME += $(call qstrip,$(BR2_LINUX_KERNEL_INTREE_DTS_NAME)) LINUX_DTS_NAME += $(call qstrip,$(BR2_LINUX_KERNEL_INTREE_DTS_NAME))
@@ -433,7 +436,7 @@ LINUX_DEPENDENCIES += host-bison host-flex
ifeq ($(BR2_LINUX_KERNEL_DTB_IS_SELF_BUILT),) ifeq ($(BR2_LINUX_KERNEL_DTB_IS_SELF_BUILT),)
define LINUX_BUILD_DTB define LINUX_BUILD_DTB
$(LINUX_MAKE_ENV) $(MAKE) $(LINUX_MAKE_FLAGS) -C $(@D) $(LINUX_DTBS) $(LINUX_MAKE_ENV) $(BR2_MAKE) $(LINUX_MAKE_FLAGS) -C $(@D) $(LINUX_DTBS)
endef endef
ifeq ($(BR2_LINUX_KERNEL_APPENDED_DTB),) ifeq ($(BR2_LINUX_KERNEL_APPENDED_DTB),)
define LINUX_INSTALL_DTB define LINUX_INSTALL_DTB
@@ -481,7 +484,7 @@ endif
# Compilation. We make sure the kernel gets rebuilt when the # Compilation. We make sure the kernel gets rebuilt when the
# configuration has changed. We call the 'all' and # configuration has changed. We call the 'all' and
# '$(LINUX_TARGET_NAME)' targets separately because calling them in # '$(LINUX_TARGET_NAME)' targets separately because calling them in
# the same $(MAKE) invocation has shown to cause parallel build # the same $(BR2_MAKE) invocation has shown to cause parallel build
# issues. # issues.
# The call to disable gcc-plugins is a stop-gap measure: # The call to disable gcc-plugins is a stop-gap measure:
# http://lists.busybox.net/pipermail/buildroot/2020-May/282727.html # http://lists.busybox.net/pipermail/buildroot/2020-May/282727.html
@@ -490,8 +493,8 @@ define LINUX_BUILD_CMDS
$(foreach dts,$(call qstrip,$(BR2_LINUX_KERNEL_CUSTOM_DTS_PATH)), \ $(foreach dts,$(call qstrip,$(BR2_LINUX_KERNEL_CUSTOM_DTS_PATH)), \
cp -f $(dts) $(LINUX_ARCH_PATH)/boot/dts/ cp -f $(dts) $(LINUX_ARCH_PATH)/boot/dts/
) )
$(LINUX_MAKE_ENV) $(MAKE) $(LINUX_MAKE_FLAGS) -C $(@D) all $(LINUX_MAKE_ENV) $(BR2_MAKE) $(LINUX_MAKE_FLAGS) -C $(@D) all
$(LINUX_MAKE_ENV) $(MAKE) $(LINUX_MAKE_FLAGS) -C $(@D) $(LINUX_TARGET_NAME) $(LINUX_MAKE_ENV) $(BR2_MAKE) $(LINUX_MAKE_FLAGS) -C $(@D) $(LINUX_TARGET_NAME)
$(LINUX_BUILD_DTB) $(LINUX_BUILD_DTB)
$(LINUX_APPEND_DTB) $(LINUX_APPEND_DTB)
endef endef
@@ -540,7 +543,7 @@ define LINUX_INSTALL_TARGET_CMDS
# Install modules and remove symbolic links pointing to build # Install modules and remove symbolic links pointing to build
# directories, not relevant on the target # directories, not relevant on the target
@if grep -q "CONFIG_MODULES=y" $(@D)/.config; then \ @if grep -q "CONFIG_MODULES=y" $(@D)/.config; then \
$(LINUX_MAKE_ENV) $(MAKE1) $(LINUX_MAKE_FLAGS) -C $(@D) modules_install; \ $(LINUX_MAKE_ENV) $(BR2_MAKE1) $(LINUX_MAKE_FLAGS) -C $(@D) modules_install; \
rm -f $(TARGET_DIR)/lib/modules/$(LINUX_VERSION_PROBED)/build ; \ rm -f $(TARGET_DIR)/lib/modules/$(LINUX_VERSION_PROBED)/build ; \
rm -f $(TARGET_DIR)/lib/modules/$(LINUX_VERSION_PROBED)/source ; \ rm -f $(TARGET_DIR)/lib/modules/$(LINUX_VERSION_PROBED)/source ; \
fi fi
@@ -639,7 +642,7 @@ linux-rebuild-with-initramfs: rootfs-cpio
linux-rebuild-with-initramfs: linux-rebuild-with-initramfs:
@$(call MESSAGE,"Rebuilding kernel with initramfs") @$(call MESSAGE,"Rebuilding kernel with initramfs")
# Build the kernel. # Build the kernel.
$(LINUX_MAKE_ENV) $(MAKE) $(LINUX_MAKE_FLAGS) -C $(LINUX_DIR) $(LINUX_TARGET_NAME) $(LINUX_MAKE_ENV) $(BR2_MAKE) $(LINUX_MAKE_FLAGS) -C $(LINUX_DIR) $(LINUX_TARGET_NAME)
$(LINUX_APPEND_DTB) $(LINUX_APPEND_DTB)
# Copy the kernel image(s) to its(their) final destination # Copy the kernel image(s) to its(their) final destination
$(call LINUX_INSTALL_IMAGE,$(BINARIES_DIR)) $(call LINUX_INSTALL_IMAGE,$(BINARIES_DIR))