1 ################################################################################
5 ################################################################################
7 LINUX_VERSION = $(call qstrip,$(BR2_LINUX_KERNEL_VERSION))
8 LINUX_LICENSE = GPL-2.0
9 LINUX_LICENSE_FILES = COPYING
11 define LINUX_HELP_CMDS
12 @echo ' linux-menuconfig - Run Linux kernel menuconfig'
13 @echo ' linux-savedefconfig - Run Linux kernel savedefconfig'
14 @echo ' linux-update-defconfig - Save the Linux configuration to the path specified'
15 @echo ' by BR2_LINUX_KERNEL_CUSTOM_CONFIG_FILE'
18 # Compute LINUX_SOURCE and LINUX_SITE from the configuration
19 ifeq ($(BR2_LINUX_KERNEL_CUSTOM_TARBALL),y)
20 LINUX_TARBALL = $(call qstrip,$(BR2_LINUX_KERNEL_CUSTOM_TARBALL_LOCATION))
21 LINUX_SITE = $(patsubst %/,%,$(dir $(LINUX_TARBALL)))
22 LINUX_SOURCE = $(notdir $(LINUX_TARBALL))
23 BR_NO_CHECK_HASH_FOR += $(LINUX_SOURCE)
24 else ifeq ($(BR2_LINUX_KERNEL_CUSTOM_GIT),y)
25 LINUX_SITE = $(call qstrip,$(BR2_LINUX_KERNEL_CUSTOM_REPO_URL))
26 LINUX_SITE_METHOD = git
27 else ifeq ($(BR2_LINUX_KERNEL_CUSTOM_HG),y)
28 LINUX_SITE = $(call qstrip,$(BR2_LINUX_KERNEL_CUSTOM_REPO_URL))
29 LINUX_SITE_METHOD = hg
30 else ifeq ($(BR2_LINUX_KERNEL_CUSTOM_SVN),y)
31 LINUX_SITE = $(call qstrip,$(BR2_LINUX_KERNEL_CUSTOM_REPO_URL))
32 LINUX_SITE_METHOD = svn
33 else ifeq ($(BR2_LINUX_KERNEL_LATEST_CIP_VERSION),y)
34 LINUX_SITE = git://git.kernel.org/pub/scm/linux/kernel/git/bwh/linux-cip.git
36 LINUX_SOURCE = linux-$(LINUX_VERSION).tar.xz
37 ifeq ($(BR2_LINUX_KERNEL_CUSTOM_VERSION),y)
38 BR_NO_CHECK_HASH_FOR += $(LINUX_SOURCE)
40 # In X.Y.Z, get X and Y. We replace dots and dashes by spaces in order
41 # to use the $(word) function. We support versions such as 4.0, 3.1,
42 # 2.6.32, 2.6.32-rc1, 3.0-rc6, etc.
43 ifeq ($(findstring x2.6.,x$(LINUX_VERSION)),x2.6.)
44 LINUX_SITE = $(BR2_KERNEL_MIRROR)/linux/kernel/v2.6
45 else ifeq ($(findstring x3.,x$(LINUX_VERSION)),x3.)
46 LINUX_SITE = $(BR2_KERNEL_MIRROR)/linux/kernel/v3.x
47 else ifeq ($(findstring x4.,x$(LINUX_VERSION)),x4.)
48 LINUX_SITE = $(BR2_KERNEL_MIRROR)/linux/kernel/v4.x
50 # release candidates are in testing/ subdir
51 ifneq ($(findstring -rc,$(LINUX_VERSION)),)
52 LINUX_SITE := $(LINUX_SITE)/testing
56 LINUX_PATCHES = $(call qstrip,$(BR2_LINUX_KERNEL_PATCH))
58 # We rely on the generic package infrastructure to download and apply
59 # remote patches (downloaded from ftp, http or https). For local
60 # patches, we can't rely on that infrastructure, because there might
61 # be directories in the patch list (unlike for other packages).
62 LINUX_PATCH = $(filter ftp://% http://% https://%,$(LINUX_PATCHES))
64 LINUX_INSTALL_IMAGES = YES
65 LINUX_DEPENDENCIES += host-kmod
67 # host tools needed for kernel compression
68 ifeq ($(BR2_LINUX_KERNEL_LZ4),y)
69 LINUX_DEPENDENCIES += host-lz4
70 else ifeq ($(BR2_LINUX_KERNEL_LZMA),y)
71 LINUX_DEPENDENCIES += host-lzma
72 else ifeq ($(BR2_LINUX_KERNEL_LZO),y)
73 LINUX_DEPENDENCIES += host-lzop
74 else ifeq ($(BR2_LINUX_KERNEL_XZ),y)
75 LINUX_DEPENDENCIES += host-xz
77 LINUX_COMPRESSION_OPT_$(BR2_LINUX_KERNEL_GZIP) = CONFIG_KERNEL_GZIP
78 LINUX_COMPRESSION_OPT_$(BR2_LINUX_KERNEL_LZ4) = CONFIG_KERNEL_LZ4
79 LINUX_COMPRESSION_OPT_$(BR2_LINUX_KERNEL_LZMA) = CONFIG_KERNEL_LZMA
80 LINUX_COMPRESSION_OPT_$(BR2_LINUX_KERNEL_LZO) = CONFIG_KERNEL_LZO
81 LINUX_COMPRESSION_OPT_$(BR2_LINUX_KERNEL_XZ) = CONFIG_KERNEL_XZ
83 ifeq ($(BR2_LINUX_KERNEL_UBOOT_IMAGE),y)
84 LINUX_DEPENDENCIES += host-uboot-tools
89 HOSTCFLAGS="$(HOSTCFLAGS)" \
91 INSTALL_MOD_PATH=$(TARGET_DIR) \
92 CROSS_COMPILE="$(TARGET_CROSS)" \
93 DEPMOD=$(HOST_DIR)/sbin/depmod
97 BR_BINARIES_DIR=$(BINARIES_DIR)
99 ifeq ($(BR2_REPRODUCIBLE),y)
101 KBUILD_BUILD_VERSION=1 \
102 KBUILD_BUILD_USER=buildroot \
103 KBUILD_BUILD_HOST=buildroot \
104 KBUILD_BUILD_TIMESTAMP="$(shell LC_ALL=C date -d @$(SOURCE_DATE_EPOCH))"
107 # Get the real Linux version, which tells us where kernel modules are
108 # going to be installed in the target filesystem.
109 LINUX_VERSION_PROBED = `$(MAKE) $(LINUX_MAKE_FLAGS) -C $(LINUX_DIR) --no-print-directory -s kernelrelease 2>/dev/null`
111 ifeq ($(BR2_LINUX_KERNEL_USE_INTREE_DTS),y)
112 KERNEL_DTS_NAME = $(call qstrip,$(BR2_LINUX_KERNEL_INTREE_DTS_NAME))
113 else ifeq ($(BR2_LINUX_KERNEL_USE_CUSTOM_DTS),y)
114 # We keep only the .dts files, so that the user can specify both .dts
115 # and .dtsi files in BR2_LINUX_KERNEL_CUSTOM_DTS_PATH. Both will be
116 # copied to arch/<arch>/boot/dts, but only the .dts files will
117 # actually be generated as .dtb.
118 KERNEL_DTS_NAME = $(basename $(filter %.dts,$(notdir $(call qstrip,$(BR2_LINUX_KERNEL_CUSTOM_DTS_PATH)))))
121 KERNEL_DTBS = $(addsuffix .dtb,$(KERNEL_DTS_NAME))
123 ifeq ($(BR2_LINUX_KERNEL_IMAGE_TARGET_CUSTOM),y)
124 LINUX_IMAGE_NAME = $(call qstrip,$(BR2_LINUX_KERNEL_IMAGE_NAME))
125 LINUX_TARGET_NAME = $(call qstrip,$(BR2_LINUX_KERNEL_IMAGE_TARGET_NAME))
126 ifeq ($(LINUX_IMAGE_NAME),)
127 LINUX_IMAGE_NAME = $(LINUX_TARGET_NAME)
130 ifeq ($(BR2_LINUX_KERNEL_UIMAGE),y)
131 LINUX_IMAGE_NAME = uImage
132 else ifeq ($(BR2_LINUX_KERNEL_APPENDED_UIMAGE),y)
133 LINUX_IMAGE_NAME = uImage
134 else ifeq ($(BR2_LINUX_KERNEL_BZIMAGE),y)
135 LINUX_IMAGE_NAME = bzImage
136 else ifeq ($(BR2_LINUX_KERNEL_ZIMAGE),y)
137 LINUX_IMAGE_NAME = zImage
138 else ifeq ($(BR2_LINUX_KERNEL_ZIMAGE_EPAPR),y)
139 LINUX_IMAGE_NAME = zImage.epapr
140 else ifeq ($(BR2_LINUX_KERNEL_APPENDED_ZIMAGE),y)
141 LINUX_IMAGE_NAME = zImage
142 else ifeq ($(BR2_LINUX_KERNEL_CUIMAGE),y)
143 LINUX_IMAGE_NAME = cuImage.$(KERNEL_DTS_NAME)
144 else ifeq ($(BR2_LINUX_KERNEL_SIMPLEIMAGE),y)
145 LINUX_IMAGE_NAME = simpleImage.$(KERNEL_DTS_NAME)
146 else ifeq ($(BR2_LINUX_KERNEL_IMAGE),y)
147 LINUX_IMAGE_NAME = Image
148 else ifeq ($(BR2_LINUX_KERNEL_LINUX_BIN),y)
149 LINUX_IMAGE_NAME = linux.bin
150 else ifeq ($(BR2_LINUX_KERNEL_VMLINUX_BIN),y)
151 LINUX_IMAGE_NAME = vmlinux.bin
152 else ifeq ($(BR2_LINUX_KERNEL_VMLINUX),y)
153 LINUX_IMAGE_NAME = vmlinux
154 else ifeq ($(BR2_LINUX_KERNEL_VMLINUZ),y)
155 LINUX_IMAGE_NAME = vmlinuz
156 else ifeq ($(BR2_LINUX_KERNEL_VMLINUZ_BIN),y)
157 LINUX_IMAGE_NAME = vmlinuz.bin
159 # The if-else blocks above are all the image types we know of, and all
160 # come from a Kconfig choice, so we know we have LINUX_IMAGE_NAME set
162 LINUX_TARGET_NAME = $(LINUX_IMAGE_NAME)
165 LINUX_KERNEL_UIMAGE_LOADADDR = $(call qstrip,$(BR2_LINUX_KERNEL_UIMAGE_LOADADDR))
166 ifneq ($(LINUX_KERNEL_UIMAGE_LOADADDR),)
167 LINUX_MAKE_FLAGS += LOADADDR="$(LINUX_KERNEL_UIMAGE_LOADADDR)"
170 # Compute the arch path, since i386 and x86_64 are in arch/x86 and not
171 # in arch/$(KERNEL_ARCH). Even if the kernel creates symbolic links
172 # for bzImage, arch/i386 and arch/x86_64 do not exist when copying the
174 ifeq ($(KERNEL_ARCH),i386)
175 KERNEL_ARCH_PATH = $(LINUX_DIR)/arch/x86
176 else ifeq ($(KERNEL_ARCH),x86_64)
177 KERNEL_ARCH_PATH = $(LINUX_DIR)/arch/x86
179 KERNEL_ARCH_PATH = $(LINUX_DIR)/arch/$(KERNEL_ARCH)
182 ifeq ($(BR2_LINUX_KERNEL_VMLINUX),y)
183 LINUX_IMAGE_PATH = $(LINUX_DIR)/$(LINUX_IMAGE_NAME)
184 else ifeq ($(BR2_LINUX_KERNEL_VMLINUZ),y)
185 LINUX_IMAGE_PATH = $(LINUX_DIR)/$(LINUX_IMAGE_NAME)
186 else ifeq ($(BR2_LINUX_KERNEL_VMLINUZ_BIN),y)
187 LINUX_IMAGE_PATH = $(LINUX_DIR)/$(LINUX_IMAGE_NAME)
189 LINUX_IMAGE_PATH = $(KERNEL_ARCH_PATH)/boot/$(LINUX_IMAGE_NAME)
190 endif # BR2_LINUX_KERNEL_VMLINUX
192 define LINUX_APPLY_LOCAL_PATCHES
193 for p in $(filter-out ftp://% http://% https://%,$(LINUX_PATCHES)) ; do \
194 if test -d $$p ; then \
195 $(APPLY_PATCHES) $(@D) $$p \*.patch || exit 1 ; \
197 $(APPLY_PATCHES) $(@D) `dirname $$p` `basename $$p` || exit 1; \
202 LINUX_POST_PATCH_HOOKS += LINUX_APPLY_LOCAL_PATCHES
204 # Older linux kernels use deprecated perl constructs in timeconst.pl
205 # that were removed for perl 5.22+ so it breaks on newer distributions
206 # Try a dry-run patch to see if this applies, if it does go ahead
207 define LINUX_TRY_PATCH_TIMECONST
208 @if patch -p1 --dry-run -f -s -d $(@D) <$(LINUX_PKGDIR)/0001-timeconst.pl-Eliminate-Perl-warning.patch.conditional >/dev/null ; then \
209 $(APPLY_PATCHES) $(@D) $(LINUX_PKGDIR) 0001-timeconst.pl-Eliminate-Perl-warning.patch.conditional ; \
212 LINUX_POST_PATCH_HOOKS += LINUX_TRY_PATCH_TIMECONST
214 ifeq ($(BR2_LINUX_KERNEL_USE_DEFCONFIG),y)
215 LINUX_KCONFIG_DEFCONFIG = $(call qstrip,$(BR2_LINUX_KERNEL_DEFCONFIG))_defconfig
216 else ifeq ($(BR2_LINUX_KERNEL_USE_ARCH_DEFAULT_CONFIG),y)
217 LINUX_KCONFIG_DEFCONFIG = defconfig
218 else ifeq ($(BR2_LINUX_KERNEL_USE_CUSTOM_CONFIG),y)
219 LINUX_KCONFIG_FILE = $(call qstrip,$(BR2_LINUX_KERNEL_CUSTOM_CONFIG_FILE))
221 LINUX_KCONFIG_FRAGMENT_FILES = $(call qstrip,$(BR2_LINUX_KERNEL_CONFIG_FRAGMENT_FILES))
222 LINUX_KCONFIG_EDITORS = menuconfig xconfig gconfig nconfig
223 LINUX_KCONFIG_OPTS = $(LINUX_MAKE_FLAGS)
225 # If no package has yet set it, set it from the Kconfig option
226 LINUX_NEEDS_MODULES ?= $(BR2_LINUX_NEEDS_MODULES)
228 # Make sure the Linux kernel is built with the right endianness. Not
229 # all architectures support
230 # CONFIG_CPU_BIG_ENDIAN/CONFIG_CPU_LITTLE_ENDIAN in Linux, but the
231 # option will be thrown away and ignored if it doesn't exist.
232 ifeq ($(BR2_ENDIAN),"BIG")
233 define LINUX_FIXUP_CONFIG_ENDIANNESS
234 $(call KCONFIG_ENABLE_OPT,CONFIG_CPU_BIG_ENDIAN,$(@D)/.config)
237 define LINUX_FIXUP_CONFIG_ENDIANNESS
238 $(call KCONFIG_ENABLE_OPT,CONFIG_CPU_LITTLE_ENDIAN,$(@D)/.config)
242 define LINUX_KCONFIG_FIXUP_CMDS
243 $(if $(LINUX_NEEDS_MODULES),
244 $(call KCONFIG_ENABLE_OPT,CONFIG_MODULES,$(@D)/.config))
245 $(call KCONFIG_ENABLE_OPT,$(LINUX_COMPRESSION_OPT_y),$(@D)/.config)
246 $(foreach opt, $(LINUX_COMPRESSION_OPT_),
247 $(call KCONFIG_DISABLE_OPT,$(opt),$(@D)/.config)
249 $(LINUX_FIXUP_CONFIG_ENDIANNESS)
250 $(if $(BR2_arm)$(BR2_armeb),
251 $(call KCONFIG_ENABLE_OPT,CONFIG_AEABI,$(@D)/.config))
252 $(if $(BR2_TARGET_ROOTFS_CPIO),
253 $(call KCONFIG_ENABLE_OPT,CONFIG_BLK_DEV_INITRD,$(@D)/.config))
254 # As the kernel gets compiled before root filesystems are
255 # built, we create a fake cpio file. It'll be
256 # replaced later by the real cpio archive, and the kernel will be
257 # rebuilt using the linux-rebuild-with-initramfs target.
258 $(if $(BR2_TARGET_ROOTFS_INITRAMFS),
259 touch $(BINARIES_DIR)/rootfs.cpio
260 $(call KCONFIG_SET_OPT,CONFIG_INITRAMFS_SOURCE,"$${BR_BINARIES_DIR}/rootfs.cpio",$(@D)/.config)
261 $(call KCONFIG_SET_OPT,CONFIG_INITRAMFS_ROOT_UID,0,$(@D)/.config)
262 $(call KCONFIG_SET_OPT,CONFIG_INITRAMFS_ROOT_GID,0,$(@D)/.config))
263 $(if $(BR2_ROOTFS_DEVICE_CREATION_STATIC),,
264 $(call KCONFIG_ENABLE_OPT,CONFIG_DEVTMPFS,$(@D)/.config)
265 $(call KCONFIG_ENABLE_OPT,CONFIG_DEVTMPFS_MOUNT,$(@D)/.config))
266 $(if $(BR2_ROOTFS_DEVICE_CREATION_DYNAMIC_EUDEV),
267 $(call KCONFIG_ENABLE_OPT,CONFIG_INOTIFY_USER,$(@D)/.config))
268 $(if $(BR2_PACKAGE_KTAP),
269 $(call KCONFIG_ENABLE_OPT,CONFIG_DEBUG_FS,$(@D)/.config)
270 $(call KCONFIG_ENABLE_OPT,CONFIG_ENABLE_DEFAULT_TRACERS,$(@D)/.config)
271 $(call KCONFIG_ENABLE_OPT,CONFIG_PERF_EVENTS,$(@D)/.config)
272 $(call KCONFIG_ENABLE_OPT,CONFIG_FUNCTION_TRACER,$(@D)/.config))
273 $(if $(BR2_PACKAGE_SYSTEMD),
274 $(call KCONFIG_ENABLE_OPT,CONFIG_CGROUPS,$(@D)/.config)
275 $(call KCONFIG_ENABLE_OPT,CONFIG_INOTIFY_USER,$(@D)/.config)
276 $(call KCONFIG_ENABLE_OPT,CONFIG_FHANDLE,$(@D)/.config)
277 $(call KCONFIG_ENABLE_OPT,CONFIG_AUTOFS4_FS,$(@D)/.config)
278 $(call KCONFIG_ENABLE_OPT,CONFIG_TMPFS_POSIX_ACL,$(@D)/.config)
279 $(call KCONFIG_ENABLE_OPT,CONFIG_TMPFS_POSIX_XATTR,$(@D)/.config))
280 $(if $(BR2_PACKAGE_SMACK),
281 $(call KCONFIG_ENABLE_OPT,CONFIG_SECURITY,$(@D)/.config)
282 $(call KCONFIG_ENABLE_OPT,CONFIG_SECURITY_SMACK,$(@D)/.config)
283 $(call KCONFIG_ENABLE_OPT,CONFIG_SECURITY_NETWORK,$(@D)/.config))
284 $(if $(BR2_PACKAGE_IPTABLES),
285 $(call KCONFIG_ENABLE_OPT,CONFIG_IP_NF_IPTABLES,$(@D)/.config)
286 $(call KCONFIG_ENABLE_OPT,CONFIG_IP_NF_FILTER,$(@D)/.config)
287 $(call KCONFIG_ENABLE_OPT,CONFIG_NETFILTER,$(@D)/.config)
288 $(call KCONFIG_ENABLE_OPT,CONFIG_NETFILTER_XTABLES,$(@D)/.config))
289 $(if $(BR2_PACKAGE_XTABLES_ADDONS),
290 $(call KCONFIG_ENABLE_OPT,CONFIG_NETFILTER_ADVANCED,$(@D)/.config)
291 $(call KCONFIG_ENABLE_OPT,CONFIG_NF_CONNTRACK,$(@D)/.config)
292 $(call KCONFIG_ENABLE_OPT,CONFIG_NF_CONNTRACK_MARK,$(@D)/.config))
293 $(if $(BR2_LINUX_KERNEL_APPENDED_DTB),
294 $(call KCONFIG_ENABLE_OPT,CONFIG_ARM_APPENDED_DTB,$(@D)/.config))
295 $(if $(BR2_PACKAGE_KERNEL_MODULE_IMX_GPU_VIV),
296 $(call KCONFIG_DISABLE_OPT,CONFIG_MXC_GPU_VIV,$(@D)/.config))
299 ifeq ($(BR2_LINUX_KERNEL_DTS_SUPPORT),y)
300 ifeq ($(BR2_LINUX_KERNEL_DTB_IS_SELF_BUILT),)
301 define LINUX_BUILD_DTB
302 $(LINUX_MAKE_ENV) $(MAKE) $(LINUX_MAKE_FLAGS) -C $(@D) $(KERNEL_DTBS)
304 ifeq ($(BR2_LINUX_KERNEL_APPENDED_DTB),)
305 define LINUX_INSTALL_DTB
306 # dtbs moved from arch/<ARCH>/boot to arch/<ARCH>/boot/dts since 3.8-rc1
308 $(KERNEL_ARCH_PATH)/boot/$(if $(wildcard \
309 $(addprefix $(KERNEL_ARCH_PATH)/boot/dts/,$(KERNEL_DTBS))),dts/),$(KERNEL_DTBS)) \
312 endif # BR2_LINUX_KERNEL_APPENDED_DTB
313 endif # BR2_LINUX_KERNEL_DTB_IS_SELF_BUILT
314 endif # BR2_LINUX_KERNEL_DTS_SUPPORT
316 ifeq ($(BR2_LINUX_KERNEL_APPENDED_DTB),y)
317 # dtbs moved from arch/$ARCH/boot to arch/$ARCH/boot/dts since 3.8-rc1
318 define LINUX_APPEND_DTB
319 (cd $(KERNEL_ARCH_PATH)/boot; \
320 for dtb in $(KERNEL_DTS_NAME); do \
321 if test -e $${dtb}.dtb ; then \
322 dtbpath=$${dtb}.dtb ; \
324 dtbpath=dts/$${dtb}.dtb ; \
326 cat zImage $${dtbpath} > zImage.$${dtb} || exit 1; \
329 ifeq ($(BR2_LINUX_KERNEL_APPENDED_UIMAGE),y)
330 # We need to generate a new u-boot image that takes into
331 # account the extra-size added by the device tree at the end
332 # of the image. To do so, we first need to retrieve both load
333 # address and entry point for the kernel from the already
334 # generate uboot image before using mkimage -l.
335 LINUX_APPEND_DTB += ; \
336 MKIMAGE_ARGS=`$(MKIMAGE) -l $(LINUX_IMAGE_PATH) |\
337 sed -n -e 's/Image Name:[ ]*\(.*\)/-n \1/p' -e 's/Load Address:/-a/p' -e 's/Entry Point:/-e/p'`; \
338 for dtb in $(KERNEL_DTS_NAME); do \
339 $(MKIMAGE) -A $(MKIMAGE_ARCH) -O linux \
340 -T kernel -C none $${MKIMAGE_ARGS} \
341 -d $(KERNEL_ARCH_PATH)/boot/zImage.$${dtb} $(LINUX_IMAGE_PATH).$${dtb}; \
346 # Compilation. We make sure the kernel gets rebuilt when the
347 # configuration has changed.
348 define LINUX_BUILD_CMDS
349 $(if $(BR2_LINUX_KERNEL_USE_CUSTOM_DTS),
350 cp -f $(call qstrip,$(BR2_LINUX_KERNEL_CUSTOM_DTS_PATH)) $(KERNEL_ARCH_PATH)/boot/dts/)
351 $(LINUX_MAKE_ENV) $(MAKE) $(LINUX_MAKE_FLAGS) -C $(@D) $(LINUX_TARGET_NAME)
352 @if grep -q "CONFIG_MODULES=y" $(@D)/.config; then \
353 $(LINUX_MAKE_ENV) $(MAKE) $(LINUX_MAKE_FLAGS) -C $(@D) modules ; \
359 ifeq ($(BR2_LINUX_KERNEL_APPENDED_DTB),y)
360 # When a DTB was appended, install the potential several images with
362 define LINUX_INSTALL_IMAGE
364 cp $(KERNEL_ARCH_PATH)/boot/$(LINUX_IMAGE_NAME).* $(1)
367 # Otherwise, just install the unique image generated by the kernel
369 define LINUX_INSTALL_IMAGE
370 $(INSTALL) -m 0644 -D $(LINUX_IMAGE_PATH) $(1)/$(LINUX_IMAGE_NAME)
374 ifeq ($(BR2_LINUX_KERNEL_INSTALL_TARGET),y)
375 define LINUX_INSTALL_KERNEL_IMAGE_TO_TARGET
376 $(call LINUX_INSTALL_IMAGE,$(TARGET_DIR)/boot)
377 $(call LINUX_INSTALL_DTB,$(TARGET_DIR)/boot)
381 define LINUX_INSTALL_HOST_TOOLS
382 # Installing dtc (device tree compiler) as host tool, if selected
383 if grep -q "CONFIG_DTC=y" $(@D)/.config; then \
384 $(INSTALL) -D -m 0755 $(@D)/scripts/dtc/dtc $(HOST_DIR)/usr/bin/linux-dtc ; \
385 if [ ! -e $(HOST_DIR)/usr/bin/dtc ]; then \
386 ln -sf linux-dtc $(HOST_DIR)/usr/bin/dtc ; \
392 define LINUX_INSTALL_IMAGES_CMDS
393 $(call LINUX_INSTALL_IMAGE,$(BINARIES_DIR))
394 $(call LINUX_INSTALL_DTB,$(BINARIES_DIR))
397 ifeq ($(BR2_STRIP_strip),y)
398 LINUX_MAKE_FLAGS += INSTALL_MOD_STRIP=1
401 define LINUX_INSTALL_TARGET_CMDS
402 $(LINUX_INSTALL_KERNEL_IMAGE_TO_TARGET)
403 # Install modules and remove symbolic links pointing to build
404 # directories, not relevant on the target
405 @if grep -q "CONFIG_MODULES=y" $(@D)/.config; then \
406 $(LINUX_MAKE_ENV) $(MAKE1) $(LINUX_MAKE_FLAGS) -C $(@D) modules_install; \
407 rm -f $(TARGET_DIR)/lib/modules/$(LINUX_VERSION_PROBED)/build ; \
408 rm -f $(TARGET_DIR)/lib/modules/$(LINUX_VERSION_PROBED)/source ; \
410 $(LINUX_INSTALL_HOST_TOOLS)
413 # Include all our extensions.
415 # Note: our package infrastructure uses the full-path of the last-scanned
416 # Makefile to determine what package we're currently defining, using the
417 # last directory component in the path. As such, including other Makefile,
418 # like below, before we call one of the *-package macro is usally not
420 # However, since the files we include here are in the same directory as
421 # the current Makefile, we are OK. But this is a hard requirement: files
422 # included here *must* be in the same directory!
423 include $(sort $(wildcard linux/linux-ext-*.mk))
425 LINUX_PATCH_DEPENDENCIES += $(foreach ext,$(LINUX_EXTENSIONS),\
426 $(if $(BR2_LINUX_KERNEL_EXT_$(call UPPERCASE,$(ext))),$(ext)))
428 LINUX_PRE_PATCH_HOOKS += $(foreach ext,$(LINUX_EXTENSIONS),\
429 $(if $(BR2_LINUX_KERNEL_EXT_$(call UPPERCASE,$(ext))),\
430 $(call UPPERCASE,$(ext))_PREPARE_KERNEL))
432 # Checks to give errors that the user can understand
434 # When a custom repository has been set, check for the repository version
435 ifeq ($(BR2_LINUX_KERNEL_CUSTOM_SVN)$(BR2_LINUX_KERNEL_CUSTOM_GIT)$(BR2_LINUX_KERNEL_CUSTOM_HG),y)
436 ifeq ($(call qstrip,$(BR2_LINUX_KERNEL_CUSTOM_REPO_VERSION)),)
437 $(error No custom repository version set. Check your BR2_LINUX_KERNEL_CUSTOM_REPO_VERSION setting)
439 ifeq ($(call qstrip,$(BR2_LINUX_KERNEL_CUSTOM_REPO_URL)),)
440 $(error No custom repo URL set. Check your BR2_LINUX_KERNEL_CUSTOM_REPO_URL setting)
444 ifeq ($(BR_BUILDING),y)
446 ifeq ($(BR2_LINUX_KERNEL_USE_DEFCONFIG),y)
447 # We must use the user-supplied kconfig value, because
448 # LINUX_KCONFIG_DEFCONFIG will at least contain the
449 # trailing _defconfig
450 ifeq ($(call qstrip,$(BR2_LINUX_KERNEL_DEFCONFIG)),)
451 $(error No kernel defconfig name specified, check your BR2_LINUX_KERNEL_DEFCONFIG setting)
455 ifeq ($(BR2_LINUX_KERNEL_USE_CUSTOM_CONFIG),y)
456 ifeq ($(LINUX_KCONFIG_FILE),)
457 $(error No kernel configuration file specified, check your BR2_LINUX_KERNEL_CUSTOM_CONFIG_FILE setting)
461 ifeq ($(BR2_LINUX_KERNEL_DTS_SUPPORT)$(KERNEL_DTS_NAME),y)
462 $(error No kernel device tree source specified, check your \
463 BR2_LINUX_KERNEL_USE_INTREE_DTS / BR2_LINUX_KERNEL_USE_CUSTOM_DTS settings)
468 $(eval $(kconfig-package))
470 # Support for rebuilding the kernel after the cpio archive has
471 # been generated in $(BINARIES_DIR)/rootfs.cpio.
472 $(LINUX_DIR)/.stamp_initramfs_rebuilt: $(LINUX_DIR)/.stamp_target_installed $(LINUX_DIR)/.stamp_images_installed $(BINARIES_DIR)/rootfs.cpio
473 @$(call MESSAGE,"Rebuilding kernel with initramfs")
475 $(LINUX_MAKE_ENV) $(MAKE) $(LINUX_MAKE_FLAGS) -C $(@D) $(LINUX_TARGET_NAME)
477 # Copy the kernel image(s) to its(their) final destination
478 $(call LINUX_INSTALL_IMAGE,$(BINARIES_DIR))
479 # If there is a .ub file copy it to the final destination
480 test ! -f $(LINUX_IMAGE_PATH).ub || cp $(LINUX_IMAGE_PATH).ub $(BINARIES_DIR)
483 # The initramfs building code must make sure this target gets called
484 # after it generated the initramfs list of files.
485 linux-rebuild-with-initramfs: $(LINUX_DIR)/.stamp_initramfs_rebuilt