b.liu | e958203 | 2025-04-17 19:18:16 +0800 | [diff] [blame] | 1 | # |
| 2 | # Copyright (C) 2006-2009 OpenWrt.org |
| 3 | # |
| 4 | # This is free software, licensed under the GNU General Public License v2. |
| 5 | # See /LICENSE for more information. |
| 6 | # |
| 7 | include $(TOPDIR)/rules.mk |
| 8 | |
| 9 | KERNEL_BUILD_DIR := $(BUILD_DIR_TOOLCHAIN) |
| 10 | BUILD_DIR := $(KERNEL_BUILD_DIR) |
| 11 | |
| 12 | override QUILT:= |
| 13 | override HOST_QUILT:= |
| 14 | |
| 15 | include $(INCLUDE_DIR)/kernel.mk |
| 16 | |
| 17 | PKG_NAME:=linux |
| 18 | PKG_VERSION:=$(LINUX_VERSION) |
| 19 | PKG_SOURCE:=$(LINUX_SOURCE) |
| 20 | PKG_CPE_ID:=cpe:/o:linux:linux_kernel |
| 21 | ifneq ($(call qstrip,$(CONFIG_KERNEL_GIT_CLONE_URI)),) |
| 22 | PKG_SOURCE_PROTO:=git |
| 23 | PKG_SOURCE_URL:=$(call qstrip,$(CONFIG_KERNEL_GIT_CLONE_URI)) |
| 24 | PKG_SOURCE_VERSION:=$(call qstrip,$(CONFIG_KERNEL_GIT_REF)) |
| 25 | PKG_MIRROR_HASH:=$(call qstrip,$(CONFIG_KERNEL_GIT_MIRROR_HASH)) |
| 26 | ifdef CHECK |
| 27 | PLATFORM_DIR:=$(firstword $(wildcard $(TOPDIR)/target/linux/feeds/$(BOARD) $(TOPDIR)/target/linux/$(BOARD))) |
| 28 | include $(PLATFORM_DIR)/Makefile |
| 29 | include $(INCLUDE_DIR)/kernel-version.mk |
| 30 | include $(INCLUDE_DIR)/kernel-build.mk |
| 31 | PKG_VERSION:=$(LINUX_VERSION) |
| 32 | else |
| 33 | PKG_SOURCE:=$(LINUX_SOURCE) |
| 34 | endif |
| 35 | else |
| 36 | PKG_SOURCE:=$(LINUX_SOURCE) |
| 37 | PKG_SOURCE_URL:=$(LINUX_SITE) |
| 38 | endif |
| 39 | HOST_BUILD_DIR:=$(KERNEL_BUILD_DIR)/linux-$(LINUX_VERSION) |
| 40 | PKG_HASH:=$(LINUX_KERNEL_HASH) |
| 41 | LINUX_DIR := $(HOST_BUILD_DIR) |
| 42 | FILES_DIR := |
| 43 | PATCH_DIR := ./patches$(if $(wildcard ./patches-$(LINUX_VERSION)),-$(LINUX_VERSION)) |
| 44 | |
| 45 | include $(INCLUDE_DIR)/toolchain-build.mk |
| 46 | include $(INCLUDE_DIR)/kernel-defaults.mk |
| 47 | |
| 48 | ifeq ($(strip $(BOARD)),uml) |
| 49 | LINUX_KARCH:=$(subst x86_64,x86,$(subst i386,x86,$(ARCH))) |
| 50 | endif |
| 51 | |
| 52 | HOST_EXTRACFLAGS= |
| 53 | |
| 54 | LINUX_HAS_HEADERS_INSTALL:=y |
| 55 | |
| 56 | HOST_KMAKE := $(MAKE) -C $(HOST_BUILD_DIR) \ |
| 57 | $(KERNEL_MAKE_FLAGS) \ |
| 58 | CC="$(KERNEL_CC)" \ |
| 59 | HOSTCFLAGS="$(HOST_CFLAGS)" |
| 60 | |
| 61 | define Host/Configure/all |
| 62 | mkdir -p $(BUILD_DIR_TOOLCHAIN)/linux-dev |
| 63 | $(HOST_KMAKE) \ |
| 64 | INSTALL_HDR_PATH="$(BUILD_DIR_TOOLCHAIN)/linux-dev/" \ |
| 65 | headers_install |
| 66 | endef |
| 67 | |
| 68 | # XXX: the following is needed to build lzma-loader |
| 69 | ifneq ($(CONFIG_mips)$(CONFIG_mipsel),) |
| 70 | define Host/Configure/lzma |
| 71 | $(CP) \ |
| 72 | $(HOST_BUILD_DIR)/arch/mips/include/asm/asm.h \ |
| 73 | $(HOST_BUILD_DIR)/arch/mips/include/asm/regdef.h \ |
| 74 | $(HOST_BUILD_DIR)/arch/mips/include/asm/asm-eva.h \ |
| 75 | $(HOST_BUILD_DIR)/arch/mips/include/asm/isa-rev.h \ |
| 76 | $(BUILD_DIR_TOOLCHAIN)/linux-dev/include/asm/ |
| 77 | endef |
| 78 | endif |
| 79 | |
| 80 | define Host/Configure/post/mips |
| 81 | $(call Host/Configure/lzma) |
| 82 | endef |
| 83 | |
| 84 | define Host/Configure/post/mipsel |
| 85 | $(call Host/Configure/lzma) |
| 86 | endef |
| 87 | |
| 88 | define Host/Prepare |
| 89 | rm -rf $(BUILD_DIR_TOOLCHAIN)/linux-* |
| 90 | $(call Kernel/Prepare/Default) |
| 91 | rm -f $(BUILD_DIR_TOOLCHAIN)/linux |
| 92 | ln -s linux-$(LINUX_VERSION) $(BUILD_DIR_TOOLCHAIN)/linux |
| 93 | $(SED) 's/@expr length/@-expr length/' $(HOST_BUILD_DIR)/Makefile |
| 94 | endef |
| 95 | |
| 96 | define Host/Configure |
| 97 | yes '' | $(HOST_KMAKE) oldconfig |
| 98 | $(call Host/Configure/all) |
| 99 | $(call Host/Configure/post/$(ARCH)) |
| 100 | endef |
| 101 | |
| 102 | define Host/Compile |
| 103 | endef |
| 104 | |
| 105 | define Host/Install |
| 106 | $(CP) $(BUILD_DIR_TOOLCHAIN)/linux-dev/* $(TOOLCHAIN_DIR)/ |
| 107 | endef |
| 108 | |
| 109 | define Host/Clean |
| 110 | rm -rf \ |
| 111 | $(HOST_BUILD_DIR) \ |
| 112 | $(BUILD_DIR_TOOLCHAIN)/linux \ |
| 113 | $(BUILD_DIR_TOOLCHAIN)/linux-dev |
| 114 | endef |
| 115 | |
| 116 | $(eval $(call HostBuild)) |