package/zic: bump version to 2016c
[buildroot-gz.git] / linux / linux.mk
blob7e202559564fd92f8a40a301f883f9b0ab9e3e6d
1 ################################################################################
3 # Linux kernel target
5 ################################################################################
7 LINUX_VERSION = $(call qstrip,$(BR2_LINUX_KERNEL_VERSION))
8 LINUX_LICENSE = GPLv2
9 LINUX_LICENSE_FILES = COPYING
11 # Compute LINUX_SOURCE and LINUX_SITE from the configuration
12 ifeq ($(BR2_LINUX_KERNEL_CUSTOM_TARBALL),y)
13 LINUX_TARBALL = $(call qstrip,$(BR2_LINUX_KERNEL_CUSTOM_TARBALL_LOCATION))
14 LINUX_SITE = $(patsubst %/,%,$(dir $(LINUX_TARBALL)))
15 LINUX_SOURCE = $(notdir $(LINUX_TARBALL))
16 BR_NO_CHECK_HASH_FOR += $(LINUX_SOURCE)
17 else ifeq ($(BR2_LINUX_KERNEL_CUSTOM_LOCAL),y)
18 LINUX_SITE = $(call qstrip,$(BR2_LINUX_KERNEL_CUSTOM_LOCAL_PATH))
19 LINUX_SITE_METHOD = local
20 else ifeq ($(BR2_LINUX_KERNEL_CUSTOM_GIT),y)
21 LINUX_SITE = $(call qstrip,$(BR2_LINUX_KERNEL_CUSTOM_REPO_URL))
22 LINUX_SITE_METHOD = git
23 else ifeq ($(BR2_LINUX_KERNEL_CUSTOM_HG),y)
24 LINUX_SITE = $(call qstrip,$(BR2_LINUX_KERNEL_CUSTOM_REPO_URL))
25 LINUX_SITE_METHOD = hg
26 else
27 LINUX_SOURCE = linux-$(LINUX_VERSION).tar.xz
28 ifeq ($(BR2_LINUX_KERNEL_CUSTOM_VERSION),y)
29 BR_NO_CHECK_HASH_FOR += $(LINUX_SOURCE)
30 endif
31 # In X.Y.Z, get X and Y. We replace dots and dashes by spaces in order
32 # to use the $(word) function. We support versions such as 4.0, 3.1,
33 # 2.6.32, 2.6.32-rc1, 3.0-rc6, etc.
34 ifeq ($(findstring x2.6.,x$(LINUX_VERSION)),x2.6.)
35 LINUX_SITE = $(BR2_KERNEL_MIRROR)/linux/kernel/v2.6
36 else ifeq ($(findstring x3.,x$(LINUX_VERSION)),x3.)
37 LINUX_SITE = $(BR2_KERNEL_MIRROR)/linux/kernel/v3.x
38 else ifeq ($(findstring x4.,x$(LINUX_VERSION)),x4.)
39 LINUX_SITE = $(BR2_KERNEL_MIRROR)/linux/kernel/v4.x
40 endif
41 # release candidates are in testing/ subdir
42 ifneq ($(findstring -rc,$(LINUX_VERSION)),)
43 LINUX_SITE := $(LINUX_SITE)/testing
44 endif # -rc
45 endif
47 LINUX_PATCHES = $(call qstrip,$(BR2_LINUX_KERNEL_PATCH))
49 # We rely on the generic package infrastructure to download and apply
50 # remote patches (downloaded from ftp, http or https). For local
51 # patches, we can't rely on that infrastructure, because there might
52 # be directories in the patch list (unlike for other packages).
53 LINUX_PATCH = $(filter ftp://% http://% https://%,$(LINUX_PATCHES))
55 LINUX_INSTALL_IMAGES = YES
56 LINUX_DEPENDENCIES += host-kmod
58 # host tools needed for kernel compression
59 ifeq ($(BR2_LINUX_KERNEL_LZ4),y)
60 LINUX_DEPENDENCIES += host-lz4
61 else ifeq ($(BR2_LINUX_KERNEL_LZMA),y)
62 LINUX_DEPENDENCIES += host-lzma
63 else ifeq ($(BR2_LINUX_KERNEL_LZO),y)
64 LINUX_DEPENDENCIES += host-lzop
65 else ifeq ($(BR2_LINUX_KERNEL_XZ),y)
66 LINUX_DEPENDENCIES += host-xz
67 endif
68 LINUX_COMPRESSION_OPT_$(BR2_LINUX_KERNEL_GZIP) = CONFIG_KERNEL_GZIP
69 LINUX_COMPRESSION_OPT_$(BR2_LINUX_KERNEL_LZ4) = CONFIG_KERNEL_LZ4
70 LINUX_COMPRESSION_OPT_$(BR2_LINUX_KERNEL_LZMA) = CONFIG_KERNEL_LZMA
71 LINUX_COMPRESSION_OPT_$(BR2_LINUX_KERNEL_LZO) = CONFIG_KERNEL_LZO
72 LINUX_COMPRESSION_OPT_$(BR2_LINUX_KERNEL_XZ) = CONFIG_KERNEL_XZ
74 ifeq ($(BR2_LINUX_KERNEL_UBOOT_IMAGE),y)
75 LINUX_DEPENDENCIES += host-uboot-tools
76 endif
78 LINUX_MAKE_FLAGS = \
79 HOSTCC="$(HOSTCC)" \
80 HOSTCFLAGS="$(HOSTCFLAGS)" \
81 ARCH=$(KERNEL_ARCH) \
82 INSTALL_MOD_PATH=$(TARGET_DIR) \
83 CROSS_COMPILE="$(TARGET_CROSS)" \
84 DEPMOD=$(HOST_DIR)/sbin/depmod
86 LINUX_MAKE_ENV = \
87 $(TARGET_MAKE_ENV) \
88 BR_BINARIES_DIR=$(BINARIES_DIR)
90 # Get the real Linux version, which tells us where kernel modules are
91 # going to be installed in the target filesystem.
92 LINUX_VERSION_PROBED = `$(MAKE) $(LINUX_MAKE_FLAGS) -C $(LINUX_DIR) --no-print-directory -s kernelrelease 2>/dev/null`
94 ifeq ($(BR2_LINUX_KERNEL_USE_INTREE_DTS),y)
95 KERNEL_DTS_NAME = $(call qstrip,$(BR2_LINUX_KERNEL_INTREE_DTS_NAME))
96 else ifeq ($(BR2_LINUX_KERNEL_USE_CUSTOM_DTS),y)
97 # We keep only the .dts files, so that the user can specify both .dts
98 # and .dtsi files in BR2_LINUX_KERNEL_CUSTOM_DTS_PATH. Both will be
99 # copied to arch/<arch>/boot/dts, but only the .dts files will
100 # actually be generated as .dtb.
101 KERNEL_DTS_NAME = $(basename $(filter %.dts,$(notdir $(call qstrip,$(BR2_LINUX_KERNEL_CUSTOM_DTS_PATH)))))
102 endif
104 KERNEL_DTBS = $(addsuffix .dtb,$(KERNEL_DTS_NAME))
106 ifeq ($(BR2_LINUX_KERNEL_IMAGE_TARGET_CUSTOM),y)
107 LINUX_IMAGE_NAME = $(call qstrip,$(BR2_LINUX_KERNEL_IMAGE_NAME))
108 LINUX_TARGET_NAME = $(call qstrip,$(BR2_LINUX_KERNEL_IMAGE_TARGET_NAME))
109 ifeq ($(LINUX_IMAGE_NAME),)
110 LINUX_IMAGE_NAME = $(LINUX_TARGET_NAME)
111 endif
112 else
113 ifeq ($(BR2_LINUX_KERNEL_UIMAGE),y)
114 LINUX_IMAGE_NAME = uImage
115 else ifeq ($(BR2_LINUX_KERNEL_APPENDED_UIMAGE),y)
116 LINUX_IMAGE_NAME = uImage
117 else ifeq ($(BR2_LINUX_KERNEL_BZIMAGE),y)
118 LINUX_IMAGE_NAME = bzImage
119 else ifeq ($(BR2_LINUX_KERNEL_ZIMAGE),y)
120 LINUX_IMAGE_NAME = zImage
121 else ifeq ($(BR2_LINUX_KERNEL_ZIMAGE_EPAPR),y)
122 LINUX_IMAGE_NAME = zImage.epapr
123 else ifeq ($(BR2_LINUX_KERNEL_APPENDED_ZIMAGE),y)
124 LINUX_IMAGE_NAME = zImage
125 else ifeq ($(BR2_LINUX_KERNEL_CUIMAGE),y)
126 LINUX_IMAGE_NAME = cuImage.$(KERNEL_DTS_NAME)
127 else ifeq ($(BR2_LINUX_KERNEL_SIMPLEIMAGE),y)
128 LINUX_IMAGE_NAME = simpleImage.$(KERNEL_DTS_NAME)
129 else ifeq ($(BR2_LINUX_KERNEL_IMAGE),y)
130 LINUX_IMAGE_NAME = Image
131 else ifeq ($(BR2_LINUX_KERNEL_LINUX_BIN),y)
132 LINUX_IMAGE_NAME = linux.bin
133 else ifeq ($(BR2_LINUX_KERNEL_VMLINUX_BIN),y)
134 LINUX_IMAGE_NAME = vmlinux.bin
135 else ifeq ($(BR2_LINUX_KERNEL_VMLINUX),y)
136 LINUX_IMAGE_NAME = vmlinux
137 else ifeq ($(BR2_LINUX_KERNEL_VMLINUZ),y)
138 LINUX_IMAGE_NAME = vmlinuz
139 else ifeq ($(BR2_LINUX_KERNEL_VMLINUZ_BIN),y)
140 LINUX_IMAGE_NAME = vmlinuz.bin
141 endif
142 # The if-else blocks above are all the image types we know of, and all
143 # come from a Kconfig choice, so we know we have LINUX_IMAGE_NAME set
144 # to something
145 LINUX_TARGET_NAME = $(LINUX_IMAGE_NAME)
146 endif
148 LINUX_KERNEL_UIMAGE_LOADADDR = $(call qstrip,$(BR2_LINUX_KERNEL_UIMAGE_LOADADDR))
149 ifneq ($(LINUX_KERNEL_UIMAGE_LOADADDR),)
150 LINUX_MAKE_FLAGS += LOADADDR="$(LINUX_KERNEL_UIMAGE_LOADADDR)"
151 endif
153 # Compute the arch path, since i386 and x86_64 are in arch/x86 and not
154 # in arch/$(KERNEL_ARCH). Even if the kernel creates symbolic links
155 # for bzImage, arch/i386 and arch/x86_64 do not exist when copying the
156 # defconfig file.
157 ifeq ($(KERNEL_ARCH),i386)
158 KERNEL_ARCH_PATH = $(LINUX_DIR)/arch/x86
159 else ifeq ($(KERNEL_ARCH),x86_64)
160 KERNEL_ARCH_PATH = $(LINUX_DIR)/arch/x86
161 else
162 KERNEL_ARCH_PATH = $(LINUX_DIR)/arch/$(KERNEL_ARCH)
163 endif
165 ifeq ($(BR2_LINUX_KERNEL_VMLINUX),y)
166 LINUX_IMAGE_PATH = $(LINUX_DIR)/$(LINUX_IMAGE_NAME)
167 else ifeq ($(BR2_LINUX_KERNEL_VMLINUZ),y)
168 LINUX_IMAGE_PATH = $(LINUX_DIR)/$(LINUX_IMAGE_NAME)
169 else ifeq ($(BR2_LINUX_KERNEL_VMLINUZ_BIN),y)
170 LINUX_IMAGE_PATH = $(LINUX_DIR)/$(LINUX_IMAGE_NAME)
171 else
172 LINUX_IMAGE_PATH = $(KERNEL_ARCH_PATH)/boot/$(LINUX_IMAGE_NAME)
173 endif # BR2_LINUX_KERNEL_VMLINUX
175 define LINUX_APPLY_LOCAL_PATCHES
176 for p in $(filter-out ftp://% http://% https://%,$(LINUX_PATCHES)) ; do \
177 if test -d $$p ; then \
178 $(APPLY_PATCHES) $(@D) $$p \*.patch || exit 1 ; \
179 else \
180 $(APPLY_PATCHES) $(@D) `dirname $$p` `basename $$p` || exit 1; \
181 fi \
182 done
183 endef
185 LINUX_POST_PATCH_HOOKS += LINUX_APPLY_LOCAL_PATCHES
187 # Older linux kernels use deprecated perl constructs in timeconst.pl
188 # that were removed for perl 5.22+ so it breaks on newer distributions
189 # Try a dry-run patch to see if this applies, if it does go ahead
190 define LINUX_TRY_PATCH_TIMECONST
191 @if patch -p1 --dry-run -f -s -d $(@D) <$(LINUX_PKGDIR)/0001-timeconst.pl-Eliminate-Perl-warning.patch.conditional >/dev/null ; then \
192 $(APPLY_PATCHES) $(@D) $(LINUX_PKGDIR) 0001-timeconst.pl-Eliminate-Perl-warning.patch.conditional ; \
194 endef
195 LINUX_POST_PATCH_HOOKS += LINUX_TRY_PATCH_TIMECONST
197 ifeq ($(BR2_LINUX_KERNEL_USE_DEFCONFIG),y)
198 LINUX_KCONFIG_DEFCONFIG = $(call qstrip,$(BR2_LINUX_KERNEL_DEFCONFIG))_defconfig
199 else ifeq ($(BR2_LINUX_KERNEL_USE_CUSTOM_CONFIG),y)
200 LINUX_KCONFIG_FILE = $(call qstrip,$(BR2_LINUX_KERNEL_CUSTOM_CONFIG_FILE))
201 endif
202 LINUX_KCONFIG_FRAGMENT_FILES = $(call qstrip,$(BR2_LINUX_KERNEL_CONFIG_FRAGMENT_FILES))
203 LINUX_KCONFIG_EDITORS = menuconfig xconfig gconfig nconfig
204 LINUX_KCONFIG_OPTS = $(LINUX_MAKE_FLAGS)
206 # If no package has yet set it, set it from the Kconfig option
207 LINUX_NEEDS_MODULES ?= $(BR2_LINUX_NEEDS_MODULES)
209 define LINUX_KCONFIG_FIXUP_CMDS
210 $(if $(LINUX_NEEDS_MODULES),
211 $(call KCONFIG_ENABLE_OPT,CONFIG_MODULES,$(@D)/.config))
212 $(call KCONFIG_ENABLE_OPT,$(LINUX_COMPRESSION_OPT_y),$(@D)/.config)
213 $(foreach opt, $(LINUX_COMPRESSION_OPT_),
214 $(call KCONFIG_DISABLE_OPT,$(opt),$(@D)/.config)
216 $(if $(BR2_arm)$(BR2_armeb),
217 $(call KCONFIG_ENABLE_OPT,CONFIG_AEABI,$(@D)/.config))
218 $(if $(BR2_TARGET_ROOTFS_CPIO),
219 $(call KCONFIG_ENABLE_OPT,CONFIG_BLK_DEV_INITRD,$(@D)/.config))
220 # As the kernel gets compiled before root filesystems are
221 # built, we create a fake cpio file. It'll be
222 # replaced later by the real cpio archive, and the kernel will be
223 # rebuilt using the linux-rebuild-with-initramfs target.
224 $(if $(BR2_TARGET_ROOTFS_INITRAMFS),
225 touch $(BINARIES_DIR)/rootfs.cpio
226 $(call KCONFIG_SET_OPT,CONFIG_INITRAMFS_SOURCE,"$${BR_BINARIES_DIR}/rootfs.cpio",$(@D)/.config)
227 $(call KCONFIG_SET_OPT,CONFIG_INITRAMFS_ROOT_UID,0,$(@D)/.config)
228 $(call KCONFIG_SET_OPT,CONFIG_INITRAMFS_ROOT_GID,0,$(@D)/.config))
229 $(if $(BR2_ROOTFS_DEVICE_CREATION_STATIC),,
230 $(call KCONFIG_ENABLE_OPT,CONFIG_DEVTMPFS,$(@D)/.config)
231 $(call KCONFIG_ENABLE_OPT,CONFIG_DEVTMPFS_MOUNT,$(@D)/.config))
232 $(if $(BR2_ROOTFS_DEVICE_CREATION_DYNAMIC_EUDEV),
233 $(call KCONFIG_ENABLE_OPT,CONFIG_INOTIFY_USER,$(@D)/.config))
234 $(if $(BR2_PACKAGE_KTAP),
235 $(call KCONFIG_ENABLE_OPT,CONFIG_DEBUG_FS,$(@D)/.config)
236 $(call KCONFIG_ENABLE_OPT,CONFIG_ENABLE_DEFAULT_TRACERS,$(@D)/.config)
237 $(call KCONFIG_ENABLE_OPT,CONFIG_PERF_EVENTS,$(@D)/.config)
238 $(call KCONFIG_ENABLE_OPT,CONFIG_FUNCTION_TRACER,$(@D)/.config))
239 $(if $(BR2_PACKAGE_SYSTEMD),
240 $(call KCONFIG_ENABLE_OPT,CONFIG_CGROUPS,$(@D)/.config)
241 $(call KCONFIG_ENABLE_OPT,CONFIG_INOTIFY_USER,$(@D)/.config)
242 $(call KCONFIG_ENABLE_OPT,CONFIG_FHANDLE,$(@D)/.config)
243 $(call KCONFIG_ENABLE_OPT,CONFIG_AUTOFS4_FS,$(@D)/.config)
244 $(call KCONFIG_ENABLE_OPT,CONFIG_TMPFS_POSIX_ACL,$(@D)/.config)
245 $(call KCONFIG_ENABLE_OPT,CONFIG_TMPFS_POSIX_XATTR,$(@D)/.config))
246 $(if $(BR2_PACKAGE_SMACK),
247 $(call KCONFIG_ENABLE_OPT,CONFIG_SECURITY,$(@D)/.config)
248 $(call KCONFIG_ENABLE_OPT,CONFIG_SECURITY_SMACK,$(@D)/.config)
249 $(call KCONFIG_ENABLE_OPT,CONFIG_SECURITY_NETWORK,$(@D)/.config))
250 $(if $(BR2_PACKAGE_IPTABLES),
251 $(call KCONFIG_ENABLE_OPT,CONFIG_IP_NF_IPTABLES,$(@D)/.config)
252 $(call KCONFIG_ENABLE_OPT,CONFIG_IP_NF_FILTER,$(@D)/.config)
253 $(call KCONFIG_ENABLE_OPT,CONFIG_NETFILTER,$(@D)/.config)
254 $(call KCONFIG_ENABLE_OPT,CONFIG_NETFILTER_XTABLES,$(@D)/.config))
255 $(if $(BR2_PACKAGE_XTABLES_ADDONS),
256 $(call KCONFIG_ENABLE_OPT,CONFIG_NETFILTER_ADVANCED,$(@D)/.config)
257 $(call KCONFIG_ENABLE_OPT,CONFIG_NF_CONNTRACK,$(@D)/.config)
258 $(call KCONFIG_ENABLE_OPT,CONFIG_NF_CONNTRACK_MARK,$(@D)/.config))
259 $(if $(BR2_LINUX_KERNEL_APPENDED_DTB),
260 $(call KCONFIG_ENABLE_OPT,CONFIG_ARM_APPENDED_DTB,$(@D)/.config))
261 $(if $(BR2_PACKAGE_KERNEL_MODULE_IMX_GPU_VIV),
262 $(call KCONFIG_DISABLE_OPT,CONFIG_MXC_GPU_VIV,$(@D)/.config))
263 endef
265 ifeq ($(BR2_LINUX_KERNEL_DTS_SUPPORT),y)
266 ifeq ($(BR2_LINUX_KERNEL_DTB_IS_SELF_BUILT),)
267 define LINUX_BUILD_DTB
268 $(LINUX_MAKE_ENV) $(MAKE) $(LINUX_MAKE_FLAGS) -C $(@D) $(KERNEL_DTBS)
269 endef
270 ifeq ($(BR2_LINUX_KERNEL_APPENDED_DTB),)
271 define LINUX_INSTALL_DTB
272 # dtbs moved from arch/<ARCH>/boot to arch/<ARCH>/boot/dts since 3.8-rc1
273 cp $(addprefix \
274 $(KERNEL_ARCH_PATH)/boot/$(if $(wildcard \
275 $(addprefix $(KERNEL_ARCH_PATH)/boot/dts/,$(KERNEL_DTBS))),dts/),$(KERNEL_DTBS)) \
276 $(1)
277 endef
278 endif # BR2_LINUX_KERNEL_APPENDED_DTB
279 endif # BR2_LINUX_KERNEL_DTB_IS_SELF_BUILT
280 endif # BR2_LINUX_KERNEL_DTS_SUPPORT
282 ifeq ($(BR2_LINUX_KERNEL_APPENDED_DTB),y)
283 # dtbs moved from arch/$ARCH/boot to arch/$ARCH/boot/dts since 3.8-rc1
284 define LINUX_APPEND_DTB
285 (cd $(KERNEL_ARCH_PATH)/boot; \
286 for dtb in $(KERNEL_DTS_NAME); do \
287 if test -e $${dtb}.dtb ; then \
288 dtbpath=$${dtb}.dtb ; \
289 else \
290 dtbpath=dts/$${dtb}.dtb ; \
291 fi ; \
292 cat zImage $${dtbpath} > zImage.$${dtb} || exit 1; \
293 done)
294 endef
295 ifeq ($(BR2_LINUX_KERNEL_APPENDED_UIMAGE),y)
296 # We need to generate a new u-boot image that takes into
297 # account the extra-size added by the device tree at the end
298 # of the image. To do so, we first need to retrieve both load
299 # address and entry point for the kernel from the already
300 # generate uboot image before using mkimage -l.
301 LINUX_APPEND_DTB += ; \
302 MKIMAGE_ARGS=`$(MKIMAGE) -l $(LINUX_IMAGE_PATH) |\
303 sed -n -e 's/Image Name:[ ]*\(.*\)/-n \1/p' -e 's/Load Address:/-a/p' -e 's/Entry Point:/-e/p'`; \
304 for dtb in $(KERNEL_DTS_NAME); do \
305 $(MKIMAGE) -A $(MKIMAGE_ARCH) -O linux \
306 -T kernel -C none $${MKIMAGE_ARGS} \
307 -d $(KERNEL_ARCH_PATH)/boot/zImage.$${dtb} $(LINUX_IMAGE_PATH).$${dtb}; \
308 done
309 endif
310 endif
312 # Compilation. We make sure the kernel gets rebuilt when the
313 # configuration has changed.
314 define LINUX_BUILD_CMDS
315 $(if $(BR2_LINUX_KERNEL_USE_CUSTOM_DTS),
316 cp -f $(call qstrip,$(BR2_LINUX_KERNEL_CUSTOM_DTS_PATH)) $(KERNEL_ARCH_PATH)/boot/dts/)
317 $(LINUX_MAKE_ENV) $(MAKE) $(LINUX_MAKE_FLAGS) -C $(@D) $(LINUX_TARGET_NAME)
318 @if grep -q "CONFIG_MODULES=y" $(@D)/.config; then \
319 $(LINUX_MAKE_ENV) $(MAKE) $(LINUX_MAKE_FLAGS) -C $(@D) modules ; \
321 $(LINUX_BUILD_DTB)
322 $(LINUX_APPEND_DTB)
323 endef
325 ifeq ($(BR2_LINUX_KERNEL_APPENDED_DTB),y)
326 # When a DTB was appended, install the potential several images with
327 # appended DTBs.
328 define LINUX_INSTALL_IMAGE
329 mkdir -p $(1)
330 cp $(KERNEL_ARCH_PATH)/boot/$(LINUX_IMAGE_NAME).* $(1)
331 endef
332 else
333 # Otherwise, just install the unique image generated by the kernel
334 # build process.
335 define LINUX_INSTALL_IMAGE
336 $(INSTALL) -m 0644 -D $(LINUX_IMAGE_PATH) $(1)/$(LINUX_IMAGE_NAME)
337 endef
338 endif
340 ifeq ($(BR2_LINUX_KERNEL_INSTALL_TARGET),y)
341 define LINUX_INSTALL_KERNEL_IMAGE_TO_TARGET
342 $(call LINUX_INSTALL_IMAGE,$(TARGET_DIR)/boot)
343 $(call LINUX_INSTALL_DTB,$(TARGET_DIR)/boot)
344 endef
345 endif
347 define LINUX_INSTALL_HOST_TOOLS
348 # Installing dtc (device tree compiler) as host tool, if selected
349 if grep -q "CONFIG_DTC=y" $(@D)/.config; then \
350 $(INSTALL) -D -m 0755 $(@D)/scripts/dtc/dtc $(HOST_DIR)/usr/bin/linux-dtc ; \
352 endef
355 define LINUX_INSTALL_IMAGES_CMDS
356 $(call LINUX_INSTALL_IMAGE,$(BINARIES_DIR))
357 $(call LINUX_INSTALL_DTB,$(BINARIES_DIR))
358 endef
360 define LINUX_INSTALL_TARGET_CMDS
361 $(LINUX_INSTALL_KERNEL_IMAGE_TO_TARGET)
362 # Install modules and remove symbolic links pointing to build
363 # directories, not relevant on the target
364 @if grep -q "CONFIG_MODULES=y" $(@D)/.config; then \
365 $(LINUX_MAKE_ENV) $(MAKE1) $(LINUX_MAKE_FLAGS) -C $(@D) modules_install; \
366 rm -f $(TARGET_DIR)/lib/modules/$(LINUX_VERSION_PROBED)/build ; \
367 rm -f $(TARGET_DIR)/lib/modules/$(LINUX_VERSION_PROBED)/source ; \
369 $(LINUX_INSTALL_HOST_TOOLS)
370 endef
372 # Include all our extensions and tools definitions.
374 # Note: our package infrastructure uses the full-path of the last-scanned
375 # Makefile to determine what package we're currently defining, using the
376 # last directory component in the path. As such, including other Makefile,
377 # like below, before we call one of the *-package macro is usally not
378 # working.
379 # However, since the files we include here are in the same directory as
380 # the current Makefile, we are OK. But this is a hard requirement: files
381 # included here *must* be in the same directory!
382 include $(sort $(wildcard linux/linux-ext-*.mk))
383 include $(sort $(wildcard linux/linux-tool-*.mk))
385 LINUX_PATCH_DEPENDENCIES += $(foreach ext,$(LINUX_EXTENSIONS),\
386 $(if $(BR2_LINUX_KERNEL_EXT_$(call UPPERCASE,$(ext))),$(ext)))
388 LINUX_PRE_PATCH_HOOKS += $(foreach ext,$(LINUX_EXTENSIONS),\
389 $(if $(BR2_LINUX_KERNEL_EXT_$(call UPPERCASE,$(ext))),\
390 $(call UPPERCASE,$(ext))_PREPARE_KERNEL))
392 # Install Linux kernel tools in the staging directory since some tools
393 # may install shared libraries and headers (e.g. cpupower). The kernel
394 # image is NOT installed in the staging directory.
395 LINUX_INSTALL_STAGING = YES
397 LINUX_DEPENDENCIES += $(foreach tool,$(LINUX_TOOLS),\
398 $(if $(BR2_LINUX_KERNEL_TOOL_$(call UPPERCASE,$(tool))),\
399 $($(call UPPERCASE,$(tool))_DEPENDENCIES)))
401 LINUX_POST_BUILD_HOOKS += $(foreach tool,$(LINUX_TOOLS),\
402 $(if $(BR2_LINUX_KERNEL_TOOL_$(call UPPERCASE,$(tool))),\
403 $(call UPPERCASE,$(tool))_BUILD_CMDS))
405 LINUX_POST_INSTALL_STAGING_HOOKS += $(foreach tool,$(LINUX_TOOLS),\
406 $(if $(BR2_LINUX_KERNEL_TOOL_$(call UPPERCASE,$(tool))),\
407 $(call UPPERCASE,$(tool))_INSTALL_STAGING_CMDS))
409 LINUX_POST_INSTALL_TARGET_HOOKS += $(foreach tool,$(LINUX_TOOLS),\
410 $(if $(BR2_LINUX_KERNEL_TOOL_$(call UPPERCASE,$(tool))),\
411 $(call UPPERCASE,$(tool))_INSTALL_TARGET_CMDS))
413 # Checks to give errors that the user can understand
414 ifeq ($(BR_BUILDING),y)
416 ifeq ($(BR2_LINUX_KERNEL_USE_DEFCONFIG),y)
417 # We must use the user-supplied kconfig value, because
418 # LINUX_KCONFIG_DEFCONFIG will at least contain the
419 # trailing _defconfig
420 ifeq ($(call qstrip,$(BR2_LINUX_KERNEL_DEFCONFIG)),)
421 $(error No kernel defconfig name specified, check your BR2_LINUX_KERNEL_DEFCONFIG setting)
422 endif
423 endif
425 ifeq ($(BR2_LINUX_KERNEL_USE_CUSTOM_CONFIG),y)
426 ifeq ($(LINUX_KCONFIG_FILE),)
427 $(error No kernel configuration file specified, check your BR2_LINUX_KERNEL_CUSTOM_CONFIG_FILE setting)
428 endif
429 endif
431 ifeq ($(BR2_LINUX_KERNEL_DTS_SUPPORT)$(KERNEL_DTS_NAME),y)
432 $(error No kernel device tree source specified, check your \
433 BR2_LINUX_KERNEL_USE_INTREE_DTS / BR2_LINUX_KERNEL_USE_CUSTOM_DTS settings)
434 endif
436 endif # BR_BUILDING
438 $(eval $(kconfig-package))
440 # Support for rebuilding the kernel after the cpio archive has
441 # been generated in $(BINARIES_DIR)/rootfs.cpio.
442 $(LINUX_DIR)/.stamp_initramfs_rebuilt: $(LINUX_DIR)/.stamp_target_installed $(LINUX_DIR)/.stamp_images_installed $(BINARIES_DIR)/rootfs.cpio
443 @$(call MESSAGE,"Rebuilding kernel with initramfs")
444 # Build the kernel.
445 $(LINUX_MAKE_ENV) $(MAKE) $(LINUX_MAKE_FLAGS) -C $(@D) $(LINUX_TARGET_NAME)
446 $(LINUX_APPEND_DTB)
447 # Copy the kernel image to its final destination
448 cp $(LINUX_IMAGE_PATH) $(BINARIES_DIR)
449 # If there is a .ub file copy it to the final destination
450 test ! -f $(LINUX_IMAGE_PATH).ub || cp $(LINUX_IMAGE_PATH).ub $(BINARIES_DIR)
451 $(Q)touch $@
453 # The initramfs building code must make sure this target gets called
454 # after it generated the initramfs list of files.
455 linux-rebuild-with-initramfs: $(LINUX_DIR)/.stamp_initramfs_rebuilt