1 ################################################################################
5 ################################################################################
7 LINUX_VERSION
= $(call qstrip
,$(BR2_LINUX_KERNEL_VERSION
))
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
34 LINUX_SOURCE
= linux-
$(LINUX_VERSION
).
tar.xz
35 ifeq ($(BR2_LINUX_KERNEL_CUSTOM_VERSION
),y
)
36 BR_NO_CHECK_HASH_FOR
+= $(LINUX_SOURCE
)
38 # In X.Y.Z, get X and Y. We replace dots and dashes by spaces in order
39 # to use the $(word) function. We support versions such as 4.0, 3.1,
40 # 2.6.32, 2.6.32-rc1, 3.0-rc6, etc.
41 ifeq ($(findstring x2.6.
,x
$(LINUX_VERSION
)),x2.6.
)
42 LINUX_SITE
= $(BR2_KERNEL_MIRROR
)/linux
/kernel
/v2.6
43 else ifeq ($(findstring x3.
,x
$(LINUX_VERSION
)),x3.
)
44 LINUX_SITE
= $(BR2_KERNEL_MIRROR
)/linux
/kernel
/v3.x
45 else ifeq ($(findstring x4.
,x
$(LINUX_VERSION
)),x4.
)
46 LINUX_SITE
= $(BR2_KERNEL_MIRROR
)/linux
/kernel
/v4.x
48 # release candidates are in testing/ subdir
49 ifneq ($(findstring -rc
,$(LINUX_VERSION
)),)
50 LINUX_SITE
:= $(LINUX_SITE
)/testing
54 LINUX_PATCHES
= $(call qstrip
,$(BR2_LINUX_KERNEL_PATCH
))
56 # We rely on the generic package infrastructure to download and apply
57 # remote patches (downloaded from ftp, http or https). For local
58 # patches, we can't rely on that infrastructure, because there might
59 # be directories in the patch list (unlike for other packages).
60 LINUX_PATCH
= $(filter ftp
://% http
://% https
://%,$(LINUX_PATCHES
))
62 LINUX_INSTALL_IMAGES
= YES
63 LINUX_DEPENDENCIES
+= host-kmod
65 # host tools needed for kernel compression
66 ifeq ($(BR2_LINUX_KERNEL_LZ4
),y
)
67 LINUX_DEPENDENCIES
+= host-lz4
68 else ifeq ($(BR2_LINUX_KERNEL_LZMA
),y
)
69 LINUX_DEPENDENCIES
+= host-lzma
70 else ifeq ($(BR2_LINUX_KERNEL_LZO
),y
)
71 LINUX_DEPENDENCIES
+= host-lzop
72 else ifeq ($(BR2_LINUX_KERNEL_XZ
),y
)
73 LINUX_DEPENDENCIES
+= host-xz
75 LINUX_COMPRESSION_OPT_
$(BR2_LINUX_KERNEL_GZIP
) = CONFIG_KERNEL_GZIP
76 LINUX_COMPRESSION_OPT_
$(BR2_LINUX_KERNEL_LZ4
) = CONFIG_KERNEL_LZ4
77 LINUX_COMPRESSION_OPT_
$(BR2_LINUX_KERNEL_LZMA
) = CONFIG_KERNEL_LZMA
78 LINUX_COMPRESSION_OPT_
$(BR2_LINUX_KERNEL_LZO
) = CONFIG_KERNEL_LZO
79 LINUX_COMPRESSION_OPT_
$(BR2_LINUX_KERNEL_XZ
) = CONFIG_KERNEL_XZ
81 ifeq ($(BR2_LINUX_KERNEL_UBOOT_IMAGE
),y
)
82 LINUX_DEPENDENCIES
+= host-uboot-tools
87 HOSTCFLAGS
="$(HOSTCFLAGS)" \
89 INSTALL_MOD_PATH
=$(TARGET_DIR
) \
90 CROSS_COMPILE
="$(TARGET_CROSS)" \
91 DEPMOD
=$(HOST_DIR
)/sbin
/depmod
95 BR_BINARIES_DIR
=$(BINARIES_DIR
)
97 # Get the real Linux version, which tells us where kernel modules are
98 # going to be installed in the target filesystem.
99 LINUX_VERSION_PROBED
= `$(MAKE) $(LINUX_MAKE_FLAGS) -C $(LINUX_DIR) --no-print-directory -s kernelrelease 2>/dev/null`
101 ifeq ($(BR2_LINUX_KERNEL_USE_INTREE_DTS
),y
)
102 KERNEL_DTS_NAME
= $(call qstrip
,$(BR2_LINUX_KERNEL_INTREE_DTS_NAME
))
103 else ifeq ($(BR2_LINUX_KERNEL_USE_CUSTOM_DTS
),y
)
104 # We keep only the .dts files, so that the user can specify both .dts
105 # and .dtsi files in BR2_LINUX_KERNEL_CUSTOM_DTS_PATH. Both will be
106 # copied to arch/<arch>/boot/dts, but only the .dts files will
107 # actually be generated as .dtb.
108 KERNEL_DTS_NAME
= $(basename $(filter %.dts
,$(notdir $(call qstrip
,$(BR2_LINUX_KERNEL_CUSTOM_DTS_PATH
)))))
111 KERNEL_DTBS
= $(addsuffix .dtb
,$(KERNEL_DTS_NAME
))
113 ifeq ($(BR2_LINUX_KERNEL_IMAGE_TARGET_CUSTOM
),y
)
114 LINUX_IMAGE_NAME
= $(call qstrip
,$(BR2_LINUX_KERNEL_IMAGE_NAME
))
115 LINUX_TARGET_NAME
= $(call qstrip
,$(BR2_LINUX_KERNEL_IMAGE_TARGET_NAME
))
116 ifeq ($(LINUX_IMAGE_NAME
),)
117 LINUX_IMAGE_NAME
= $(LINUX_TARGET_NAME
)
120 ifeq ($(BR2_LINUX_KERNEL_UIMAGE
),y
)
121 LINUX_IMAGE_NAME
= uImage
122 else ifeq ($(BR2_LINUX_KERNEL_APPENDED_UIMAGE
),y
)
123 LINUX_IMAGE_NAME
= uImage
124 else ifeq ($(BR2_LINUX_KERNEL_BZIMAGE
),y
)
125 LINUX_IMAGE_NAME
= bzImage
126 else ifeq ($(BR2_LINUX_KERNEL_ZIMAGE
),y
)
127 LINUX_IMAGE_NAME
= zImage
128 else ifeq ($(BR2_LINUX_KERNEL_ZIMAGE_EPAPR
),y
)
129 LINUX_IMAGE_NAME
= zImage.epapr
130 else ifeq ($(BR2_LINUX_KERNEL_APPENDED_ZIMAGE
),y
)
131 LINUX_IMAGE_NAME
= zImage
132 else ifeq ($(BR2_LINUX_KERNEL_CUIMAGE
),y
)
133 LINUX_IMAGE_NAME
= cuImage.
$(KERNEL_DTS_NAME
)
134 else ifeq ($(BR2_LINUX_KERNEL_SIMPLEIMAGE
),y
)
135 LINUX_IMAGE_NAME
= simpleImage.
$(KERNEL_DTS_NAME
)
136 else ifeq ($(BR2_LINUX_KERNEL_IMAGE
),y
)
137 LINUX_IMAGE_NAME
= Image
138 else ifeq ($(BR2_LINUX_KERNEL_LINUX_BIN
),y
)
139 LINUX_IMAGE_NAME
= linux.bin
140 else ifeq ($(BR2_LINUX_KERNEL_VMLINUX_BIN
),y
)
141 LINUX_IMAGE_NAME
= vmlinux.bin
142 else ifeq ($(BR2_LINUX_KERNEL_VMLINUX
),y
)
143 LINUX_IMAGE_NAME
= vmlinux
144 else ifeq ($(BR2_LINUX_KERNEL_VMLINUZ
),y
)
145 LINUX_IMAGE_NAME
= vmlinuz
146 else ifeq ($(BR2_LINUX_KERNEL_VMLINUZ_BIN
),y
)
147 LINUX_IMAGE_NAME
= vmlinuz.bin
149 # The if-else blocks above are all the image types we know of, and all
150 # come from a Kconfig choice, so we know we have LINUX_IMAGE_NAME set
152 LINUX_TARGET_NAME
= $(LINUX_IMAGE_NAME
)
155 LINUX_KERNEL_UIMAGE_LOADADDR
= $(call qstrip
,$(BR2_LINUX_KERNEL_UIMAGE_LOADADDR
))
156 ifneq ($(LINUX_KERNEL_UIMAGE_LOADADDR
),)
157 LINUX_MAKE_FLAGS
+= LOADADDR
="$(LINUX_KERNEL_UIMAGE_LOADADDR)"
160 # Compute the arch path, since i386 and x86_64 are in arch/x86 and not
161 # in arch/$(KERNEL_ARCH). Even if the kernel creates symbolic links
162 # for bzImage, arch/i386 and arch/x86_64 do not exist when copying the
164 ifeq ($(KERNEL_ARCH
),i386
)
165 KERNEL_ARCH_PATH
= $(LINUX_DIR
)/arch
/x86
166 else ifeq ($(KERNEL_ARCH
),x86_64
)
167 KERNEL_ARCH_PATH
= $(LINUX_DIR
)/arch
/x86
169 KERNEL_ARCH_PATH
= $(LINUX_DIR
)/arch
/$(KERNEL_ARCH
)
172 ifeq ($(BR2_LINUX_KERNEL_VMLINUX
),y
)
173 LINUX_IMAGE_PATH
= $(LINUX_DIR
)/$(LINUX_IMAGE_NAME
)
174 else ifeq ($(BR2_LINUX_KERNEL_VMLINUZ
),y
)
175 LINUX_IMAGE_PATH
= $(LINUX_DIR
)/$(LINUX_IMAGE_NAME
)
176 else ifeq ($(BR2_LINUX_KERNEL_VMLINUZ_BIN
),y
)
177 LINUX_IMAGE_PATH
= $(LINUX_DIR
)/$(LINUX_IMAGE_NAME
)
179 LINUX_IMAGE_PATH
= $(KERNEL_ARCH_PATH
)/boot
/$(LINUX_IMAGE_NAME
)
180 endif # BR2_LINUX_KERNEL_VMLINUX
182 define LINUX_APPLY_LOCAL_PATCHES
183 for p in
$(filter-out ftp
://% http
://% https
://%,$(LINUX_PATCHES
)) ; do \
184 if
test -d
$$p ; then \
185 $(APPLY_PATCHES
) $(@D
) $$p \
*.patch || exit
1 ; \
187 $(APPLY_PATCHES
) $(@D
) `dirname $$p` `basename $$p` || exit
1; \
192 LINUX_POST_PATCH_HOOKS
+= LINUX_APPLY_LOCAL_PATCHES
194 # Older linux kernels use deprecated perl constructs in timeconst.pl
195 # that were removed for perl 5.22+ so it breaks on newer distributions
196 # Try a dry-run patch to see if this applies, if it does go ahead
197 define LINUX_TRY_PATCH_TIMECONST
198 @if patch
-p1
--dry-run
-f
-s
-d
$(@D
) <$(LINUX_PKGDIR
)/0001-timeconst.pl-Eliminate-Perl-warning.patch.conditional
>/dev
/null
; then \
199 $(APPLY_PATCHES
) $(@D
) $(LINUX_PKGDIR
) 0001-timeconst.pl-Eliminate-Perl-warning.patch.conditional
; \
202 LINUX_POST_PATCH_HOOKS
+= LINUX_TRY_PATCH_TIMECONST
204 ifeq ($(BR2_LINUX_KERNEL_USE_DEFCONFIG
),y
)
205 LINUX_KCONFIG_DEFCONFIG
= $(call qstrip
,$(BR2_LINUX_KERNEL_DEFCONFIG
))_defconfig
206 else ifeq ($(BR2_LINUX_KERNEL_USE_ARCH_DEFAULT_CONFIG
),y
)
207 LINUX_KCONFIG_DEFCONFIG
= defconfig
208 else ifeq ($(BR2_LINUX_KERNEL_USE_CUSTOM_CONFIG
),y
)
209 LINUX_KCONFIG_FILE
= $(call qstrip
,$(BR2_LINUX_KERNEL_CUSTOM_CONFIG_FILE
))
211 LINUX_KCONFIG_FRAGMENT_FILES
= $(call qstrip
,$(BR2_LINUX_KERNEL_CONFIG_FRAGMENT_FILES
))
212 LINUX_KCONFIG_EDITORS
= menuconfig xconfig gconfig nconfig
213 LINUX_KCONFIG_OPTS
= $(LINUX_MAKE_FLAGS
)
215 # If no package has yet set it, set it from the Kconfig option
216 LINUX_NEEDS_MODULES ?
= $(BR2_LINUX_NEEDS_MODULES
)
218 # Make sure the Linux kernel is built with the right endianness. Not
219 # all architectures support
220 # CONFIG_CPU_BIG_ENDIAN/CONFIG_CPU_LITTLE_ENDIAN in Linux, but the
221 # option will be thrown away and ignored if it doesn't exist.
222 ifeq ($(BR2_ENDIAN
),"BIG")
223 define LINUX_FIXUP_CONFIG_ENDIANNESS
224 $(call KCONFIG_ENABLE_OPT
,CONFIG_CPU_BIG_ENDIAN
,$(@D
)/.config
)
227 define LINUX_FIXUP_CONFIG_ENDIANNESS
228 $(call KCONFIG_ENABLE_OPT
,CONFIG_CPU_LITTLE_ENDIAN
,$(@D
)/.config
)
232 define LINUX_KCONFIG_FIXUP_CMDS
233 $(if
$(LINUX_NEEDS_MODULES
),
234 $(call KCONFIG_ENABLE_OPT
,CONFIG_MODULES
,$(@D
)/.config
))
235 $(call KCONFIG_ENABLE_OPT
,$(LINUX_COMPRESSION_OPT_y
),$(@D
)/.config
)
236 $(foreach opt
, $(LINUX_COMPRESSION_OPT_
),
237 $(call KCONFIG_DISABLE_OPT
,$(opt
),$(@D
)/.config
)
239 $(LINUX_FIXUP_CONFIG_ENDIANNESS
)
240 $(if
$(BR2_arm
)$(BR2_armeb
),
241 $(call KCONFIG_ENABLE_OPT
,CONFIG_AEABI
,$(@D
)/.config
))
242 $(if
$(BR2_TARGET_ROOTFS_CPIO
),
243 $(call KCONFIG_ENABLE_OPT
,CONFIG_BLK_DEV_INITRD
,$(@D
)/.config
))
244 # As the kernel gets compiled before root filesystems are
245 # built, we create a fake cpio file. It'll be
246 # replaced later by the real cpio archive, and the kernel will be
247 # rebuilt using the linux-rebuild-with-initramfs target.
248 $(if
$(BR2_TARGET_ROOTFS_INITRAMFS
),
249 touch
$(BINARIES_DIR
)/rootfs.cpio
250 $(call KCONFIG_SET_OPT
,CONFIG_INITRAMFS_SOURCE
,"$${BR_BINARIES_DIR}/rootfs.cpio",$(@D
)/.config
)
251 $(call KCONFIG_SET_OPT
,CONFIG_INITRAMFS_ROOT_UID
,0,$(@D
)/.config
)
252 $(call KCONFIG_SET_OPT
,CONFIG_INITRAMFS_ROOT_GID
,0,$(@D
)/.config
))
253 $(if
$(BR2_ROOTFS_DEVICE_CREATION_STATIC
),,
254 $(call KCONFIG_ENABLE_OPT
,CONFIG_DEVTMPFS
,$(@D
)/.config
)
255 $(call KCONFIG_ENABLE_OPT
,CONFIG_DEVTMPFS_MOUNT
,$(@D
)/.config
))
256 $(if
$(BR2_ROOTFS_DEVICE_CREATION_DYNAMIC_EUDEV
),
257 $(call KCONFIG_ENABLE_OPT
,CONFIG_INOTIFY_USER
,$(@D
)/.config
))
258 $(if
$(BR2_PACKAGE_KTAP
),
259 $(call KCONFIG_ENABLE_OPT
,CONFIG_DEBUG_FS
,$(@D
)/.config
)
260 $(call KCONFIG_ENABLE_OPT
,CONFIG_ENABLE_DEFAULT_TRACERS
,$(@D
)/.config
)
261 $(call KCONFIG_ENABLE_OPT
,CONFIG_PERF_EVENTS
,$(@D
)/.config
)
262 $(call KCONFIG_ENABLE_OPT
,CONFIG_FUNCTION_TRACER
,$(@D
)/.config
))
263 $(if
$(BR2_PACKAGE_SYSTEMD
),
264 $(call KCONFIG_ENABLE_OPT
,CONFIG_CGROUPS
,$(@D
)/.config
)
265 $(call KCONFIG_ENABLE_OPT
,CONFIG_INOTIFY_USER
,$(@D
)/.config
)
266 $(call KCONFIG_ENABLE_OPT
,CONFIG_FHANDLE
,$(@D
)/.config
)
267 $(call KCONFIG_ENABLE_OPT
,CONFIG_AUTOFS4_FS
,$(@D
)/.config
)
268 $(call KCONFIG_ENABLE_OPT
,CONFIG_TMPFS_POSIX_ACL
,$(@D
)/.config
)
269 $(call KCONFIG_ENABLE_OPT
,CONFIG_TMPFS_POSIX_XATTR
,$(@D
)/.config
))
270 $(if
$(BR2_PACKAGE_SMACK
),
271 $(call KCONFIG_ENABLE_OPT
,CONFIG_SECURITY
,$(@D
)/.config
)
272 $(call KCONFIG_ENABLE_OPT
,CONFIG_SECURITY_SMACK
,$(@D
)/.config
)
273 $(call KCONFIG_ENABLE_OPT
,CONFIG_SECURITY_NETWORK
,$(@D
)/.config
))
274 $(if
$(BR2_PACKAGE_IPTABLES
),
275 $(call KCONFIG_ENABLE_OPT
,CONFIG_IP_NF_IPTABLES
,$(@D
)/.config
)
276 $(call KCONFIG_ENABLE_OPT
,CONFIG_IP_NF_FILTER
,$(@D
)/.config
)
277 $(call KCONFIG_ENABLE_OPT
,CONFIG_NETFILTER
,$(@D
)/.config
)
278 $(call KCONFIG_ENABLE_OPT
,CONFIG_NETFILTER_XTABLES
,$(@D
)/.config
))
279 $(if
$(BR2_PACKAGE_XTABLES_ADDONS
),
280 $(call KCONFIG_ENABLE_OPT
,CONFIG_NETFILTER_ADVANCED
,$(@D
)/.config
)
281 $(call KCONFIG_ENABLE_OPT
,CONFIG_NF_CONNTRACK
,$(@D
)/.config
)
282 $(call KCONFIG_ENABLE_OPT
,CONFIG_NF_CONNTRACK_MARK
,$(@D
)/.config
))
283 $(if
$(BR2_LINUX_KERNEL_APPENDED_DTB
),
284 $(call KCONFIG_ENABLE_OPT
,CONFIG_ARM_APPENDED_DTB
,$(@D
)/.config
))
285 $(if
$(BR2_PACKAGE_KERNEL_MODULE_IMX_GPU_VIV
),
286 $(call KCONFIG_DISABLE_OPT
,CONFIG_MXC_GPU_VIV
,$(@D
)/.config
))
289 ifeq ($(BR2_LINUX_KERNEL_DTS_SUPPORT
),y
)
290 ifeq ($(BR2_LINUX_KERNEL_DTB_IS_SELF_BUILT
),)
291 define LINUX_BUILD_DTB
292 $(LINUX_MAKE_ENV
) $(MAKE
) $(LINUX_MAKE_FLAGS
) -C
$(@D
) $(KERNEL_DTBS
)
294 ifeq ($(BR2_LINUX_KERNEL_APPENDED_DTB
),)
295 define LINUX_INSTALL_DTB
296 # dtbs moved from arch/<ARCH>/boot to arch/<ARCH>/boot/dts since 3.8-rc1
298 $(KERNEL_ARCH_PATH
)/boot
/$(if
$(wildcard \
299 $(addprefix $(KERNEL_ARCH_PATH
)/boot
/dts
/,$(KERNEL_DTBS
))),dts
/),$(KERNEL_DTBS
)) \
302 endif # BR2_LINUX_KERNEL_APPENDED_DTB
303 endif # BR2_LINUX_KERNEL_DTB_IS_SELF_BUILT
304 endif # BR2_LINUX_KERNEL_DTS_SUPPORT
306 ifeq ($(BR2_LINUX_KERNEL_APPENDED_DTB
),y
)
307 # dtbs moved from arch/$ARCH/boot to arch/$ARCH/boot/dts since 3.8-rc1
308 define LINUX_APPEND_DTB
309 (cd
$(KERNEL_ARCH_PATH
)/boot
; \
310 for dtb in
$(KERNEL_DTS_NAME
); do \
311 if
test -e
$${dtb}.dtb
; then \
312 dtbpath
=$${dtb}.dtb
; \
314 dtbpath
=dts
/$${dtb}.dtb
; \
316 cat zImage
$${dtbpath} > zImage.
$${dtb} || exit
1; \
319 ifeq ($(BR2_LINUX_KERNEL_APPENDED_UIMAGE
),y
)
320 # We need to generate a new u-boot image that takes into
321 # account the extra-size added by the device tree at the end
322 # of the image. To do so, we first need to retrieve both load
323 # address and entry point for the kernel from the already
324 # generate uboot image before using mkimage -l.
325 LINUX_APPEND_DTB
+= ; \
326 MKIMAGE_ARGS
=`$(MKIMAGE) -l $(LINUX_IMAGE_PATH) |\
327 sed -n -e 's/Image Name:[ ]*\(.*\)/-n \1/p' -e 's/Load Address:/-a/p' -e 's/Entry Point:/-e/p'`; \
328 for dtb in
$(KERNEL_DTS_NAME
); do \
329 $(MKIMAGE
) -A
$(MKIMAGE_ARCH
) -O linux \
330 -T kernel
-C none
$${MKIMAGE_ARGS} \
331 -d
$(KERNEL_ARCH_PATH
)/boot
/zImage.
$${dtb} $(LINUX_IMAGE_PATH
).
$${dtb}; \
336 # Compilation. We make sure the kernel gets rebuilt when the
337 # configuration has changed.
338 define LINUX_BUILD_CMDS
339 $(if
$(BR2_LINUX_KERNEL_USE_CUSTOM_DTS
),
340 cp
-f
$(call qstrip
,$(BR2_LINUX_KERNEL_CUSTOM_DTS_PATH
)) $(KERNEL_ARCH_PATH
)/boot
/dts
/)
341 $(LINUX_MAKE_ENV
) $(MAKE
) $(LINUX_MAKE_FLAGS
) -C
$(@D
) $(LINUX_TARGET_NAME
)
342 @if grep
-q
"CONFIG_MODULES=y" $(@D
)/.config
; then \
343 $(LINUX_MAKE_ENV
) $(MAKE
) $(LINUX_MAKE_FLAGS
) -C
$(@D
) modules
; \
349 ifeq ($(BR2_LINUX_KERNEL_APPENDED_DTB
),y
)
350 # When a DTB was appended, install the potential several images with
352 define LINUX_INSTALL_IMAGE
354 cp
$(KERNEL_ARCH_PATH
)/boot
/$(LINUX_IMAGE_NAME
).
* $(1)
357 # Otherwise, just install the unique image generated by the kernel
359 define LINUX_INSTALL_IMAGE
360 $(INSTALL
) -m
0644 -D
$(LINUX_IMAGE_PATH
) $(1)/$(LINUX_IMAGE_NAME
)
364 ifeq ($(BR2_LINUX_KERNEL_INSTALL_TARGET
),y
)
365 define LINUX_INSTALL_KERNEL_IMAGE_TO_TARGET
366 $(call LINUX_INSTALL_IMAGE
,$(TARGET_DIR
)/boot
)
367 $(call LINUX_INSTALL_DTB
,$(TARGET_DIR
)/boot
)
371 define LINUX_INSTALL_HOST_TOOLS
372 # Installing dtc (device tree compiler) as host tool, if selected
373 if grep
-q
"CONFIG_DTC=y" $(@D
)/.config
; then \
374 $(INSTALL
) -D
-m
0755 $(@D
)/scripts
/dtc
/dtc
$(HOST_DIR
)/usr
/bin
/linux-dtc
; \
375 if
[ ! -e
$(HOST_DIR
)/usr
/bin
/dtc
]; then \
376 ln
-sf linux-dtc
$(HOST_DIR
)/usr
/bin
/dtc
; \
382 define LINUX_INSTALL_IMAGES_CMDS
383 $(call LINUX_INSTALL_IMAGE
,$(BINARIES_DIR
))
384 $(call LINUX_INSTALL_DTB
,$(BINARIES_DIR
))
387 ifeq ($(BR2_STRIP_strip
),y
)
388 LINUX_MAKE_FLAGS
+= INSTALL_MOD_STRIP
=1
391 define LINUX_INSTALL_TARGET_CMDS
392 $(LINUX_INSTALL_KERNEL_IMAGE_TO_TARGET
)
393 # Install modules and remove symbolic links pointing to build
394 # directories, not relevant on the target
395 @if grep
-q
"CONFIG_MODULES=y" $(@D
)/.config
; then \
396 $(LINUX_MAKE_ENV
) $(MAKE1
) $(LINUX_MAKE_FLAGS
) -C
$(@D
) modules_install
; \
397 rm -f
$(TARGET_DIR
)/lib
/modules
/$(LINUX_VERSION_PROBED
)/build
; \
398 rm -f
$(TARGET_DIR
)/lib
/modules
/$(LINUX_VERSION_PROBED
)/source
; \
400 $(LINUX_INSTALL_HOST_TOOLS
)
403 # Include all our extensions.
405 # Note: our package infrastructure uses the full-path of the last-scanned
406 # Makefile to determine what package we're currently defining, using the
407 # last directory component in the path. As such, including other Makefile,
408 # like below, before we call one of the *-package macro is usally not
410 # However, since the files we include here are in the same directory as
411 # the current Makefile, we are OK. But this is a hard requirement: files
412 # included here *must* be in the same directory!
413 include $(sort $(wildcard linux
/linux-ext-
*.mk
))
415 LINUX_PATCH_DEPENDENCIES
+= $(foreach ext
,$(LINUX_EXTENSIONS
),\
416 $(if
$(BR2_LINUX_KERNEL_EXT_
$(call UPPERCASE
,$(ext
))),$(ext
)))
418 LINUX_PRE_PATCH_HOOKS
+= $(foreach ext
,$(LINUX_EXTENSIONS
),\
419 $(if
$(BR2_LINUX_KERNEL_EXT_
$(call UPPERCASE
,$(ext
))),\
420 $(call UPPERCASE
,$(ext
))_PREPARE_KERNEL
))
422 # Checks to give errors that the user can understand
423 ifeq ($(BR_BUILDING
),y
)
425 ifeq ($(BR2_LINUX_KERNEL_USE_DEFCONFIG
),y
)
426 # We must use the user-supplied kconfig value, because
427 # LINUX_KCONFIG_DEFCONFIG will at least contain the
428 # trailing _defconfig
429 ifeq ($(call qstrip
,$(BR2_LINUX_KERNEL_DEFCONFIG
)),)
430 $(error No kernel defconfig name specified
, check your BR2_LINUX_KERNEL_DEFCONFIG setting
)
434 ifeq ($(BR2_LINUX_KERNEL_USE_CUSTOM_CONFIG
),y
)
435 ifeq ($(LINUX_KCONFIG_FILE
),)
436 $(error No kernel configuration file specified
, check your BR2_LINUX_KERNEL_CUSTOM_CONFIG_FILE setting
)
440 ifeq ($(BR2_LINUX_KERNEL_DTS_SUPPORT
)$(KERNEL_DTS_NAME
),y
)
441 $(error No kernel device tree source specified
, check your \
442 BR2_LINUX_KERNEL_USE_INTREE_DTS
/ BR2_LINUX_KERNEL_USE_CUSTOM_DTS settings
)
447 $(eval
$(kconfig-package
))
449 # Support for rebuilding the kernel after the cpio archive has
450 # been generated in $(BINARIES_DIR)/rootfs.cpio.
451 $(LINUX_DIR
)/.stamp_initramfs_rebuilt
: $(LINUX_DIR
)/.stamp_target_installed
$(LINUX_DIR
)/.stamp_images_installed
$(BINARIES_DIR
)/rootfs.cpio
452 @
$(call MESSAGE
,"Rebuilding kernel with initramfs")
454 $(LINUX_MAKE_ENV
) $(MAKE
) $(LINUX_MAKE_FLAGS
) -C
$(@D
) $(LINUX_TARGET_NAME
)
456 # Copy the kernel image(s) to its(their) final destination
457 $(call LINUX_INSTALL_IMAGE
,$(BINARIES_DIR
))
458 # If there is a .ub file copy it to the final destination
459 test ! -f
$(LINUX_IMAGE_PATH
).ub || cp
$(LINUX_IMAGE_PATH
).ub
$(BINARIES_DIR
)
462 # The initramfs building code must make sure this target gets called
463 # after it generated the initramfs list of files.
464 linux-rebuild-with-initramfs
: $(LINUX_DIR
)/.stamp_initramfs_rebuilt