Ameya Thakur | 300fae9 | 2016-08-10 11:33:55 -0700 | [diff] [blame] | 1 | #Android makefile to build kernel as a part of Android Build |
| 2 | PERL = perl |
| 3 | |
| 4 | KERNEL_TARGET := $(strip $(INSTALLED_KERNEL_TARGET)) |
| 5 | ifeq ($(KERNEL_TARGET),) |
| 6 | INSTALLED_KERNEL_TARGET := $(PRODUCT_OUT)/kernel |
| 7 | endif |
| 8 | |
Neeraj Upadhyay | 368def7 | 2018-06-04 13:56:28 +0530 | [diff] [blame] | 9 | INSTALLED_KERNEL_VM_TARGET := $(PRODUCT_OUT)/kernel_vm |
| 10 | |
Puja Gupta | e5df4f3 | 2017-02-24 14:21:40 -0800 | [diff] [blame] | 11 | TARGET_KERNEL_MAKE_ENV := $(strip $(TARGET_KERNEL_MAKE_ENV)) |
| 12 | ifeq ($(TARGET_KERNEL_MAKE_ENV),) |
| 13 | KERNEL_MAKE_ENV := |
| 14 | else |
| 15 | KERNEL_MAKE_ENV := $(TARGET_KERNEL_MAKE_ENV) |
| 16 | endif |
| 17 | |
Ameya Thakur | 300fae9 | 2016-08-10 11:33:55 -0700 | [diff] [blame] | 18 | TARGET_KERNEL_ARCH := $(strip $(TARGET_KERNEL_ARCH)) |
| 19 | ifeq ($(TARGET_KERNEL_ARCH),) |
| 20 | KERNEL_ARCH := arm |
| 21 | else |
| 22 | KERNEL_ARCH := $(TARGET_KERNEL_ARCH) |
| 23 | endif |
| 24 | |
| 25 | TARGET_KERNEL_HEADER_ARCH := $(strip $(TARGET_KERNEL_HEADER_ARCH)) |
| 26 | ifeq ($(TARGET_KERNEL_HEADER_ARCH),) |
| 27 | KERNEL_HEADER_ARCH := $(KERNEL_ARCH) |
| 28 | else |
| 29 | $(warning Forcing kernel header generation only for '$(TARGET_KERNEL_HEADER_ARCH)') |
| 30 | KERNEL_HEADER_ARCH := $(TARGET_KERNEL_HEADER_ARCH) |
| 31 | endif |
| 32 | |
| 33 | KERNEL_HEADER_DEFCONFIG := $(strip $(KERNEL_HEADER_DEFCONFIG)) |
| 34 | ifeq ($(KERNEL_HEADER_DEFCONFIG),) |
| 35 | KERNEL_HEADER_DEFCONFIG := $(KERNEL_DEFCONFIG) |
| 36 | endif |
| 37 | |
| 38 | # Force 32-bit binder IPC for 64bit kernel with 32bit userspace |
| 39 | ifeq ($(KERNEL_ARCH),arm64) |
| 40 | ifeq ($(TARGET_ARCH),arm) |
| 41 | KERNEL_CONFIG_OVERRIDE := CONFIG_ANDROID_BINDER_IPC_32BIT=y |
| 42 | endif |
| 43 | endif |
| 44 | |
| 45 | TARGET_KERNEL_CROSS_COMPILE_PREFIX := $(strip $(TARGET_KERNEL_CROSS_COMPILE_PREFIX)) |
| 46 | ifeq ($(TARGET_KERNEL_CROSS_COMPILE_PREFIX),) |
| 47 | KERNEL_CROSS_COMPILE := arm-eabi- |
| 48 | else |
Mukesh Ojha | 72378c44 | 2018-11-23 16:32:02 +0530 | [diff] [blame] | 49 | KERNEL_CROSS_COMPILE := $(TARGET_KERNEL_CROSS_COMPILE_PREFIX) |
Ameya Thakur | 300fae9 | 2016-08-10 11:33:55 -0700 | [diff] [blame] | 50 | endif |
| 51 | |
Raghavendra Rao Ananta | cea6fa8 | 2018-04-16 19:14:44 -0700 | [diff] [blame] | 52 | ifeq ($(KERNEL_LLVM_SUPPORT), true) |
| 53 | ifeq ($(KERNEL_SD_LLVM_SUPPORT), true) #Using sd-llvm compiler |
Raghavendra Rao Ananta | 4b0f86a | 2018-04-17 16:50:06 -0700 | [diff] [blame] | 54 | ifeq ($(shell echo $(SDCLANG_PATH) | head -c 1),/) |
| 55 | KERNEL_LLVM_BIN := $(SDCLANG_PATH)/clang |
Raghavendra Rao Ananta | cea6fa8 | 2018-04-16 19:14:44 -0700 | [diff] [blame] | 56 | else |
Divya Sharma | 9ad4116a | 2018-09-25 14:43:30 -0700 | [diff] [blame] | 57 | KERNEL_LLVM_BIN := $(shell pwd)/$(SDCLANG_PATH)/clang |
Raghavendra Rao Ananta | cea6fa8 | 2018-04-16 19:14:44 -0700 | [diff] [blame] | 58 | endif |
| 59 | $(warning "Using sdllvm" $(KERNEL_LLVM_BIN)) |
| 60 | else |
Divya Sharma | 9ad4116a | 2018-09-25 14:43:30 -0700 | [diff] [blame] | 61 | KERNEL_LLVM_BIN := $(shell pwd)/$(CLANG) #Using aosp-llvm compiler |
Raghavendra Rao Ananta | cea6fa8 | 2018-04-16 19:14:44 -0700 | [diff] [blame] | 62 | $(warning "Using aosp-llvm" $(KERNEL_LLVM_BIN)) |
| 63 | endif |
| 64 | endif |
| 65 | |
Ameya Thakur | 300fae9 | 2016-08-10 11:33:55 -0700 | [diff] [blame] | 66 | ifeq ($(TARGET_PREBUILT_KERNEL),) |
| 67 | |
| 68 | KERNEL_GCC_NOANDROID_CHK := $(shell (echo "int main() {return 0;}" | $(KERNEL_CROSS_COMPILE)gcc -E -mno-android - > /dev/null 2>&1 ; echo $$?)) |
Prasad Sodagudi | c8de0c8 | 2017-10-04 14:44:24 -0700 | [diff] [blame] | 69 | |
| 70 | real_cc := |
| 71 | ifeq ($(KERNEL_LLVM_SUPPORT),true) |
lijuang | 148fe3c | 2019-10-30 11:09:32 +0800 | [diff] [blame^] | 72 | ifeq ($(KERNEL_ARCH), arm64) |
| 73 | real_cc := REAL_CC=$(KERNEL_LLVM_BIN) CLANG_TRIPLE=aarch64-linux-gnu- |
| 74 | else |
| 75 | real_cc := REAL_CC=$(KERNEL_LLVM_BIN) CLANG_TRIPLE=arm-linux-gnueabihf |
| 76 | endif |
Prasad Sodagudi | c8de0c8 | 2017-10-04 14:44:24 -0700 | [diff] [blame] | 77 | else |
Ameya Thakur | 300fae9 | 2016-08-10 11:33:55 -0700 | [diff] [blame] | 78 | ifeq ($(strip $(KERNEL_GCC_NOANDROID_CHK)),0) |
| 79 | KERNEL_CFLAGS := KCFLAGS=-mno-android |
| 80 | endif |
Prasad Sodagudi | c8de0c8 | 2017-10-04 14:44:24 -0700 | [diff] [blame] | 81 | endif |
Ameya Thakur | 300fae9 | 2016-08-10 11:33:55 -0700 | [diff] [blame] | 82 | |
| 83 | mkfile_path := $(abspath $(lastword $(MAKEFILE_LIST))) |
| 84 | current_dir := $(notdir $(patsubst %/,%,$(dir $(mkfile_path)))) |
| 85 | TARGET_KERNEL := msm-$(TARGET_KERNEL_VERSION) |
| 86 | ifeq ($(TARGET_KERNEL),$(current_dir)) |
| 87 | # New style, kernel/msm-version |
| 88 | BUILD_ROOT_LOC := ../../ |
| 89 | TARGET_KERNEL_SOURCE := kernel/$(TARGET_KERNEL) |
| 90 | KERNEL_OUT := $(TARGET_OUT_INTERMEDIATES)/kernel/$(TARGET_KERNEL) |
| 91 | KERNEL_SYMLINK := $(TARGET_OUT_INTERMEDIATES)/KERNEL_OBJ |
| 92 | KERNEL_USR := $(KERNEL_SYMLINK)/usr |
Neeraj Upadhyay | 368def7 | 2018-06-04 13:56:28 +0530 | [diff] [blame] | 93 | KERNEL_VM_OUT := $(TARGET_OUT_INTERMEDIATES)/kernel_vm/$(TARGET_KERNEL) |
| 94 | KERNEL_VM_SYMLINK := $(TARGET_OUT_INTERMEDIATES)/KERNEL_VM_OBJ |
| 95 | KERNEL_VM_USR := $(KERNEL_VM_SYMLINK)/usr |
Ameya Thakur | 300fae9 | 2016-08-10 11:33:55 -0700 | [diff] [blame] | 96 | else |
| 97 | # Legacy style, kernel source directly under kernel |
| 98 | KERNEL_LEGACY_DIR := true |
| 99 | BUILD_ROOT_LOC := ../ |
| 100 | TARGET_KERNEL_SOURCE := kernel |
| 101 | KERNEL_OUT := $(TARGET_OUT_INTERMEDIATES)/KERNEL_OBJ |
Neeraj Upadhyay | 368def7 | 2018-06-04 13:56:28 +0530 | [diff] [blame] | 102 | KERNEL_VM_OUT := $(TARGET_OUT_INTERMEDIATES)/KERNEL_VM_OBJ |
Ameya Thakur | 300fae9 | 2016-08-10 11:33:55 -0700 | [diff] [blame] | 103 | endif |
| 104 | |
| 105 | KERNEL_CONFIG := $(KERNEL_OUT)/.config |
| 106 | |
| 107 | ifeq ($(KERNEL_DEFCONFIG)$(wildcard $(KERNEL_CONFIG)),) |
| 108 | $(error Kernel configuration not defined, cannot build kernel) |
| 109 | else |
| 110 | |
| 111 | ifeq ($(TARGET_USES_UNCOMPRESSED_KERNEL),true) |
| 112 | $(info Using uncompressed kernel) |
Neeraj Upadhyay | 368def7 | 2018-06-04 13:56:28 +0530 | [diff] [blame] | 113 | TARGET_PREBUILT_INT_KERNEL_ := arch/$(KERNEL_ARCH)/boot/Image |
Ameya Thakur | 300fae9 | 2016-08-10 11:33:55 -0700 | [diff] [blame] | 114 | else |
| 115 | ifeq ($(KERNEL_ARCH),arm64) |
Neeraj Upadhyay | 368def7 | 2018-06-04 13:56:28 +0530 | [diff] [blame] | 116 | TARGET_PREBUILT_INT_KERNEL_ := arch/$(KERNEL_ARCH)/boot/Image.gz |
Ameya Thakur | 300fae9 | 2016-08-10 11:33:55 -0700 | [diff] [blame] | 117 | else |
Neeraj Upadhyay | 368def7 | 2018-06-04 13:56:28 +0530 | [diff] [blame] | 118 | TARGET_PREBUILT_INT_KERNEL_ := arch/$(KERNEL_ARCH)/boot/zImage |
Ameya Thakur | 300fae9 | 2016-08-10 11:33:55 -0700 | [diff] [blame] | 119 | endif |
| 120 | endif |
| 121 | |
| 122 | ifeq ($(TARGET_KERNEL_APPEND_DTB), true) |
| 123 | $(info Using appended DTB) |
Neeraj Upadhyay | 368def7 | 2018-06-04 13:56:28 +0530 | [diff] [blame] | 124 | TARGET_PREBUILT_INT_KERNEL_ := $(TARGET_PREBUILT_INT_KERNEL_)-dtb |
Rahul Shahare | 95ab718 | 2019-06-26 15:45:29 +0530 | [diff] [blame] | 125 | else |
| 126 | $(info Using DTB Image) |
| 127 | INSTALLED_DTBIMAGE_TARGET := $(PRODUCT_OUT)/dtb.img |
Ameya Thakur | 300fae9 | 2016-08-10 11:33:55 -0700 | [diff] [blame] | 128 | endif |
| 129 | |
Rahul Shahare | 95ab718 | 2019-06-26 15:45:29 +0530 | [diff] [blame] | 130 | # Creating a dtb.img once the kernel is compiled if TARGET_KERNEL_APPEND_DTB is set to be false |
| 131 | $(INSTALLED_DTBIMAGE_TARGET): $(INSTALLED_KERNEL_TARGET) |
| 132 | cat $(KERNEL_OUT)/arch/$(KERNEL_ARCH)/boot/dts/qcom/*.dtb > $@ |
| 133 | |
Ameya Thakur | 300fae9 | 2016-08-10 11:33:55 -0700 | [diff] [blame] | 134 | KERNEL_HEADERS_INSTALL := $(KERNEL_OUT)/usr |
Puja Gupta | 4544540 | 2017-03-24 12:56:52 -0700 | [diff] [blame] | 135 | KERNEL_MODULES_INSTALL ?= system |
| 136 | KERNEL_MODULES_OUT ?= $(PRODUCT_OUT)/$(KERNEL_MODULES_INSTALL)/lib/modules |
Ameya Thakur | 300fae9 | 2016-08-10 11:33:55 -0700 | [diff] [blame] | 137 | |
Neeraj Upadhyay | 368def7 | 2018-06-04 13:56:28 +0530 | [diff] [blame] | 138 | TARGET_PREBUILT_INT_KERNEL := $(KERNEL_OUT)/$(TARGET_PREBUILT_INT_KERNEL_) |
Ameya Thakur | 300fae9 | 2016-08-10 11:33:55 -0700 | [diff] [blame] | 139 | TARGET_PREBUILT_KERNEL := $(TARGET_PREBUILT_INT_KERNEL) |
| 140 | |
Neeraj Upadhyay | 368def7 | 2018-06-04 13:56:28 +0530 | [diff] [blame] | 141 | KERNEL_VM_CONFIG := $(KERNEL_VM_OUT)/.config |
| 142 | KERNEL_VM_HEADERS_INSTALL := $(KERNEL_VM_OUT)/usr |
| 143 | TARGET_PREBUILT_INT_KERNEL_VM := $(KERNEL_VM_OUT)/$(TARGET_PREBUILT_INT_KERNEL_) |
| 144 | TARGET_PREBUILT_KERNEL_VM := $(TARGET_PREBUILT_INT_KERNEL_VM) |
| 145 | |
Ameya Thakur | 300fae9 | 2016-08-10 11:33:55 -0700 | [diff] [blame] | 146 | define mv-modules |
| 147 | mdpath=`find $(KERNEL_MODULES_OUT) -type f -name modules.dep`;\ |
| 148 | if [ "$$mdpath" != "" ];then\ |
| 149 | mpath=`dirname $$mdpath`;\ |
| 150 | ko=`find $$mpath/kernel -type f -name *.ko`;\ |
| 151 | for i in $$ko; do mv $$i $(KERNEL_MODULES_OUT)/; done;\ |
| 152 | fi |
| 153 | endef |
| 154 | |
| 155 | define clean-module-folder |
| 156 | mdpath=`find $(KERNEL_MODULES_OUT) -type f -name modules.dep`;\ |
| 157 | if [ "$$mdpath" != "" ];then\ |
| 158 | mpath=`dirname $$mdpath`; rm -rf $$mpath;\ |
| 159 | fi |
| 160 | endef |
| 161 | |
Neeraj Upadhyay | 368def7 | 2018-06-04 13:56:28 +0530 | [diff] [blame] | 162 | $(TARGET_PREBUILT_INT_KERNEL_VM): ; |
| 163 | |
Ameya Thakur | 300fae9 | 2016-08-10 11:33:55 -0700 | [diff] [blame] | 164 | ifneq ($(KERNEL_LEGACY_DIR),true) |
| 165 | $(KERNEL_USR): $(KERNEL_HEADERS_INSTALL) |
| 166 | rm -rf $(KERNEL_SYMLINK) |
| 167 | ln -s kernel/$(TARGET_KERNEL) $(KERNEL_SYMLINK) |
| 168 | |
| 169 | $(TARGET_PREBUILT_INT_KERNEL): $(KERNEL_USR) |
Neeraj Upadhyay | 368def7 | 2018-06-04 13:56:28 +0530 | [diff] [blame] | 170 | |
| 171 | ifneq ($(KERNEL_VM_DEFCONFIG),) |
| 172 | $(KERNEL_VM_USR): $(KERNEL_VM_HEADERS_INSTALL) |
| 173 | rm -rf $(KERNEL_VM_SYMLINK); |
| 174 | ln -s kernel_vm/$(TARGET_KERNEL) $(KERNEL_VM_SYMLINK); |
| 175 | |
| 176 | $(TARGET_PREBUILT_INT_KERNEL_VM): $(KERNEL_VM_USR) |
| 177 | endif |
| 178 | endif |
| 179 | |
| 180 | ifneq ($(KERNEL_VM_DEFCONFIG),) |
| 181 | $(KERNEL_VM_OUT): |
| 182 | mkdir -p $(KERNEL_VM_OUT); |
| 183 | |
| 184 | $(KERNEL_VM_CONFIG): $(KERNEL_VM_OUT) |
Prasad Sodagudi | c8de0c8 | 2017-10-04 14:44:24 -0700 | [diff] [blame] | 185 | $(MAKE) -C $(TARGET_KERNEL_SOURCE) O=$(BUILD_ROOT_LOC)$(KERNEL_VM_OUT) $(KERNEL_MAKE_ENV) ARCH=$(KERNEL_ARCH) CROSS_COMPILE=$(KERNEL_CROSS_COMPILE) $(real_cc) $(KERNEL_VM_DEFCONFIG); |
Neeraj Upadhyay | 368def7 | 2018-06-04 13:56:28 +0530 | [diff] [blame] | 186 | if [ ! -z "$(KERNEL_CONFIG_OVERRIDE)" ]; then \ |
| 187 | echo "Overriding kernel config with '$(KERNEL_CONFIG_OVERRIDE)'"; \ |
| 188 | echo $(KERNEL_CONFIG_OVERRIDE) >> $(KERNEL_VM_OUT)/.config; \ |
Prasad Sodagudi | c8de0c8 | 2017-10-04 14:44:24 -0700 | [diff] [blame] | 189 | $(MAKE) -C $(TARGET_KERNEL_SOURCE) O=$(BUILD_ROOT_LOC)$(KERNEL_VM_OUT) $(KERNEL_MAKE_ENV) ARCH=$(KERNEL_ARCH) CROSS_COMPILE=$(KERNEL_CROSS_COMPILE) $(real_cc) oldconfig; fi; |
Neeraj Upadhyay | 368def7 | 2018-06-04 13:56:28 +0530 | [diff] [blame] | 190 | |
| 191 | $(TARGET_PREBUILT_INT_KERNEL_VM): $(KERNEL_VM_OUT) $(KERNEL_VM_HEADERS_INSTALL) |
| 192 | echo "Building vm kernel..."; |
| 193 | rm -rf $(KERNEL_VM_OUT)/arch/$(KERNEL_ARCH)/boot/dts; |
Prasad Sodagudi | c8de0c8 | 2017-10-04 14:44:24 -0700 | [diff] [blame] | 194 | $(MAKE) -C $(TARGET_KERNEL_SOURCE) O=$(BUILD_ROOT_LOC)$(KERNEL_VM_OUT) $(KERNEL_MAKE_ENV) ARCH=$(KERNEL_ARCH) CROSS_COMPILE=$(KERNEL_CROSS_COMPILE) $(real_cc) $(KERNEL_CFLAGS); |
Neeraj Upadhyay | 368def7 | 2018-06-04 13:56:28 +0530 | [diff] [blame] | 195 | |
| 196 | $(KERNEL_VM_HEADERS_INSTALL): $(KERNEL_VM_OUT) |
| 197 | rm -f $(BUILD_ROOT_LOC)$(KERNEL_VM_CONFIG); |
Prasad Sodagudi | c8de0c8 | 2017-10-04 14:44:24 -0700 | [diff] [blame] | 198 | $(MAKE) -C $(TARGET_KERNEL_SOURCE) O=$(BUILD_ROOT_LOC)$(KERNEL_VM_OUT) $(KERNEL_MAKE_ENV) ARCH=$(KERNEL_HEADER_ARCH) CROSS_COMPILE=$(KERNEL_CROSS_COMPILE) $(real_cc) $(KERNEL_VM_DEFCONFIG); |
| 199 | $(MAKE) -C $(TARGET_KERNEL_SOURCE) O=$(BUILD_ROOT_LOC)$(KERNEL_VM_OUT) $(KERNEL_MAKE_ENV) ARCH=$(KERNEL_HEADER_ARCH) CROSS_COMPILE=$(KERNEL_CROSS_COMPILE) $(real_cc) headers_install; |
Neeraj Upadhyay | 368def7 | 2018-06-04 13:56:28 +0530 | [diff] [blame] | 200 | if [ -d "$(KERNEL_VM_HEADERS_INSTALL)/include/bringup_headers" ]; then \ |
| 201 | cp -Rf $(KERNEL_VM_HEADERS_INSTALL)/include/bringup_headers/* $(KERNEL_VM_HEADERS_INSTALL)/include/ ; fi ; |
| 202 | if [ ! -z "$(KERNEL_CONFIG_OVERRIDE)" ]; then \ |
| 203 | echo $(KERNEL_CONFIG_OVERRIDE) >> $(KERNEL_VM_OUT)/.config; \ |
Prasad Sodagudi | c8de0c8 | 2017-10-04 14:44:24 -0700 | [diff] [blame] | 204 | $(MAKE) -C $(TARGET_KERNEL_SOURCE) O=$(BUILD_ROOT_LOC)$(KERNEL_VM_OUT) $(KERNEL_MAKE_ENV) ARCH=$(KERNEL_ARCH) CROSS_COMPILE=$(KERNEL_CROSS_COMPILE) $(real_cc) oldconfig; fi; |
Ameya Thakur | 300fae9 | 2016-08-10 11:33:55 -0700 | [diff] [blame] | 205 | endif |
| 206 | |
| 207 | $(KERNEL_OUT): |
| 208 | mkdir -p $(KERNEL_OUT) |
| 209 | |
| 210 | $(KERNEL_CONFIG): $(KERNEL_OUT) |
Prasad Sodagudi | c8de0c8 | 2017-10-04 14:44:24 -0700 | [diff] [blame] | 211 | $(MAKE) -C $(TARGET_KERNEL_SOURCE) O=$(BUILD_ROOT_LOC)$(KERNEL_OUT) $(KERNEL_MAKE_ENV) ARCH=$(KERNEL_ARCH) CROSS_COMPILE=$(KERNEL_CROSS_COMPILE) $(real_cc) $(KERNEL_DEFCONFIG) |
Ameya Thakur | 300fae9 | 2016-08-10 11:33:55 -0700 | [diff] [blame] | 212 | $(hide) if [ ! -z "$(KERNEL_CONFIG_OVERRIDE)" ]; then \ |
| 213 | echo "Overriding kernel config with '$(KERNEL_CONFIG_OVERRIDE)'"; \ |
| 214 | echo $(KERNEL_CONFIG_OVERRIDE) >> $(KERNEL_OUT)/.config; \ |
Prasad Sodagudi | c8de0c8 | 2017-10-04 14:44:24 -0700 | [diff] [blame] | 215 | $(MAKE) -C $(TARGET_KERNEL_SOURCE) O=$(BUILD_ROOT_LOC)$(KERNEL_OUT) $(KERNEL_MAKE_ENV) ARCH=$(KERNEL_ARCH) CROSS_COMPILE=$(KERNEL_CROSS_COMPILE) $(real_cc) oldconfig; fi |
Ameya Thakur | 300fae9 | 2016-08-10 11:33:55 -0700 | [diff] [blame] | 216 | |
Tengfei Fan | 72dbad2 | 2019-07-17 09:17:53 +0800 | [diff] [blame] | 217 | ifeq ($(TARGET_KERNEL_APPEND_DTB), true) |
| 218 | TARGET_PREBUILT_INT_KERNEL_IMAGE := $(KERNEL_OUT)/arch/$(KERNEL_ARCH)/boot/Image |
| 219 | $(TARGET_PREBUILT_INT_KERNEL_IMAGE): $(KERNEL_USR) |
| 220 | $(TARGET_PREBUILT_INT_KERNEL_IMAGE): $(KERNEL_OUT) $(KERNEL_HEADERS_INSTALL) |
| 221 | $(hide) echo "Building kernel modules..." |
| 222 | $(MAKE) -C $(TARGET_KERNEL_SOURCE) O=$(BUILD_ROOT_LOC)$(KERNEL_OUT) $(KERNEL_MAKE_ENV) ARCH=$(KERNEL_ARCH) CROSS_COMPILE=$(KERNEL_CROSS_COMPILE) $(real_cc) $(KERNEL_CFLAGS) Image |
| 223 | $(MAKE) -C $(TARGET_KERNEL_SOURCE) O=$(BUILD_ROOT_LOC)$(KERNEL_OUT) $(KERNEL_MAKE_ENV) ARCH=$(KERNEL_ARCH) CROSS_COMPILE=$(KERNEL_CROSS_COMPILE) $(real_cc) $(KERNEL_CFLAGS) modules |
| 224 | $(MAKE) -C $(TARGET_KERNEL_SOURCE) O=$(BUILD_ROOT_LOC)$(KERNEL_OUT) INSTALL_MOD_PATH=$(BUILD_ROOT_LOC)../$(KERNEL_MODULES_INSTALL) INSTALL_MOD_STRIP=1 $(KERNEL_MAKE_ENV) ARCH=$(KERNEL_ARCH) CROSS_COMPILE=$(KERNEL_CROSS_COMPILE) $(real_cc) modules_install |
| 225 | $(mv-modules) |
| 226 | $(clean-module-folder) |
| 227 | |
| 228 | $(TARGET_PREBUILT_INT_KERNEL): $(TARGET_PREBUILT_INT_KERNEL_IMAGE) |
Ameya Thakur | 300fae9 | 2016-08-10 11:33:55 -0700 | [diff] [blame] | 229 | $(hide) echo "Building kernel..." |
| 230 | $(hide) rm -rf $(KERNEL_OUT)/arch/$(KERNEL_ARCH)/boot/dts |
Prasad Sodagudi | c8de0c8 | 2017-10-04 14:44:24 -0700 | [diff] [blame] | 231 | $(MAKE) -C $(TARGET_KERNEL_SOURCE) O=$(BUILD_ROOT_LOC)$(KERNEL_OUT) $(KERNEL_MAKE_ENV) ARCH=$(KERNEL_ARCH) CROSS_COMPILE=$(KERNEL_CROSS_COMPILE) $(real_cc) $(KERNEL_CFLAGS) |
Tengfei Fan | 72dbad2 | 2019-07-17 09:17:53 +0800 | [diff] [blame] | 232 | else |
| 233 | TARGET_PREBUILT_INT_KERNEL_IMAGE := $(TARGET_PREBUILT_INT_KERNEL) |
| 234 | $(TARGET_PREBUILT_INT_KERNEL): $(KERNEL_OUT) $(KERNEL_HEADERS_INSTALL) |
| 235 | $(hide) echo "Building kernel..." |
| 236 | $(MAKE) -C $(TARGET_KERNEL_SOURCE) O=$(BUILD_ROOT_LOC)$(KERNEL_OUT) $(KERNEL_MAKE_ENV) ARCH=$(KERNEL_ARCH) CROSS_COMPILE=$(KERNEL_CROSS_COMPILE) $(real_cc) $(KERNEL_CFLAGS) |
Prasad Sodagudi | c8de0c8 | 2017-10-04 14:44:24 -0700 | [diff] [blame] | 237 | $(MAKE) -C $(TARGET_KERNEL_SOURCE) O=$(BUILD_ROOT_LOC)$(KERNEL_OUT) $(KERNEL_MAKE_ENV) ARCH=$(KERNEL_ARCH) CROSS_COMPILE=$(KERNEL_CROSS_COMPILE) $(real_cc) $(KERNEL_CFLAGS) modules |
| 238 | $(MAKE) -C $(TARGET_KERNEL_SOURCE) O=$(BUILD_ROOT_LOC)$(KERNEL_OUT) INSTALL_MOD_PATH=$(BUILD_ROOT_LOC)../$(KERNEL_MODULES_INSTALL) INSTALL_MOD_STRIP=1 $(KERNEL_MAKE_ENV) ARCH=$(KERNEL_ARCH) CROSS_COMPILE=$(KERNEL_CROSS_COMPILE) $(real_cc) modules_install |
Ameya Thakur | 300fae9 | 2016-08-10 11:33:55 -0700 | [diff] [blame] | 239 | $(mv-modules) |
| 240 | $(clean-module-folder) |
Tengfei Fan | 72dbad2 | 2019-07-17 09:17:53 +0800 | [diff] [blame] | 241 | endif |
Ameya Thakur | 300fae9 | 2016-08-10 11:33:55 -0700 | [diff] [blame] | 242 | |
| 243 | $(KERNEL_HEADERS_INSTALL): $(KERNEL_OUT) |
| 244 | $(hide) if [ ! -z "$(KERNEL_HEADER_DEFCONFIG)" ]; then \ |
| 245 | rm -f $(BUILD_ROOT_LOC)$(KERNEL_CONFIG); \ |
Prasad Sodagudi | c8de0c8 | 2017-10-04 14:44:24 -0700 | [diff] [blame] | 246 | $(MAKE) -C $(TARGET_KERNEL_SOURCE) O=$(BUILD_ROOT_LOC)$(KERNEL_OUT) $(KERNEL_MAKE_ENV) ARCH=$(KERNEL_HEADER_ARCH) CROSS_COMPILE=$(KERNEL_CROSS_COMPILE) $(real_cc) $(KERNEL_HEADER_DEFCONFIG); \ |
| 247 | $(MAKE) -C $(TARGET_KERNEL_SOURCE) O=$(BUILD_ROOT_LOC)$(KERNEL_OUT) $(KERNEL_MAKE_ENV) ARCH=$(KERNEL_HEADER_ARCH) CROSS_COMPILE=$(KERNEL_CROSS_COMPILE) $(real_cc) headers_install;\ |
Ameya Thakur | 300fae9 | 2016-08-10 11:33:55 -0700 | [diff] [blame] | 248 | if [ -d "$(KERNEL_HEADERS_INSTALL)/include/bringup_headers" ]; then \ |
| 249 | cp -Rf $(KERNEL_HEADERS_INSTALL)/include/bringup_headers/* $(KERNEL_HEADERS_INSTALL)/include/ ;\ |
| 250 | fi ;\ |
| 251 | fi |
| 252 | $(hide) if [ "$(KERNEL_HEADER_DEFCONFIG)" != "$(KERNEL_DEFCONFIG)" ]; then \ |
| 253 | echo "Used a different defconfig for header generation"; \ |
| 254 | rm -f $(BUILD_ROOT_LOC)$(KERNEL_CONFIG); \ |
Prasad Sodagudi | c8de0c8 | 2017-10-04 14:44:24 -0700 | [diff] [blame] | 255 | $(MAKE) -C $(TARGET_KERNEL_SOURCE) O=$(BUILD_ROOT_LOC)$(KERNEL_OUT) $(KERNEL_MAKE_ENV) ARCH=$(KERNEL_ARCH) CROSS_COMPILE=$(KERNEL_CROSS_COMPILE) $(real_cc) $(KERNEL_DEFCONFIG); fi |
Ameya Thakur | 300fae9 | 2016-08-10 11:33:55 -0700 | [diff] [blame] | 256 | $(hide) if [ ! -z "$(KERNEL_CONFIG_OVERRIDE)" ]; then \ |
| 257 | echo "Overriding kernel config with '$(KERNEL_CONFIG_OVERRIDE)'"; \ |
| 258 | echo $(KERNEL_CONFIG_OVERRIDE) >> $(KERNEL_OUT)/.config; \ |
Prasad Sodagudi | c8de0c8 | 2017-10-04 14:44:24 -0700 | [diff] [blame] | 259 | $(MAKE) -C $(TARGET_KERNEL_SOURCE) O=$(BUILD_ROOT_LOC)$(KERNEL_OUT) $(KERNEL_MAKE_ENV) ARCH=$(KERNEL_ARCH) CROSS_COMPILE=$(KERNEL_CROSS_COMPILE) $(real_cc) oldconfig; fi |
Ameya Thakur | 300fae9 | 2016-08-10 11:33:55 -0700 | [diff] [blame] | 260 | |
Neeraj Upadhyay | eff89ac | 2018-10-16 15:44:24 +0530 | [diff] [blame] | 261 | .PHONY: kerneltags |
Ameya Thakur | 300fae9 | 2016-08-10 11:33:55 -0700 | [diff] [blame] | 262 | kerneltags: $(KERNEL_OUT) $(KERNEL_CONFIG) |
Prasad Sodagudi | c8de0c8 | 2017-10-04 14:44:24 -0700 | [diff] [blame] | 263 | $(MAKE) -C $(TARGET_KERNEL_SOURCE) O=$(BUILD_ROOT_LOC)$(KERNEL_OUT) $(KERNEL_MAKE_ENV) ARCH=$(KERNEL_ARCH) CROSS_COMPILE=$(KERNEL_CROSS_COMPILE) $(real_cc) tags |
Ameya Thakur | 300fae9 | 2016-08-10 11:33:55 -0700 | [diff] [blame] | 264 | |
Neeraj Upadhyay | eff89ac | 2018-10-16 15:44:24 +0530 | [diff] [blame] | 265 | .PHONY: kernelconfig |
Ameya Thakur | 300fae9 | 2016-08-10 11:33:55 -0700 | [diff] [blame] | 266 | kernelconfig: $(KERNEL_OUT) $(KERNEL_CONFIG) |
| 267 | env KCONFIG_NOTIMESTAMP=true \ |
Prasad Sodagudi | c8de0c8 | 2017-10-04 14:44:24 -0700 | [diff] [blame] | 268 | $(MAKE) -C $(TARGET_KERNEL_SOURCE) O=$(BUILD_ROOT_LOC)$(KERNEL_OUT) $(KERNEL_MAKE_ENV) ARCH=$(KERNEL_ARCH) CROSS_COMPILE=$(KERNEL_CROSS_COMPILE) $(real_cc) menuconfig |
Ameya Thakur | 300fae9 | 2016-08-10 11:33:55 -0700 | [diff] [blame] | 269 | env KCONFIG_NOTIMESTAMP=true \ |
Prasad Sodagudi | c8de0c8 | 2017-10-04 14:44:24 -0700 | [diff] [blame] | 270 | $(MAKE) -C $(TARGET_KERNEL_SOURCE) O=$(BUILD_ROOT_LOC)$(KERNEL_OUT) $(KERNEL_MAKE_ENV) ARCH=$(KERNEL_ARCH) CROSS_COMPILE=$(KERNEL_CROSS_COMPILE) $(real_cc) savedefconfig |
Ameya Thakur | 300fae9 | 2016-08-10 11:33:55 -0700 | [diff] [blame] | 271 | cp $(KERNEL_OUT)/defconfig $(TARGET_KERNEL_SOURCE)/arch/$(KERNEL_ARCH)/configs/$(KERNEL_DEFCONFIG) |
| 272 | |
| 273 | endif |
| 274 | endif |