| 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_SOURCE_URL:=$(LINUX_SITE) |
| 21 | HOST_BUILD_DIR:=$(KERNEL_BUILD_DIR)/linux-$(LINUX_VERSION) |
| 22 | PKG_MD5SUM:=$(LINUX_KERNEL_MD5SUM) |
| 23 | LINUX_DIR := $(HOST_BUILD_DIR) |
| 24 | FILES_DIR := |
| 25 | PATCH_DIR := ./patches$(if $(wildcard ./patches-$(KERNEL_PATCHVER)),-$(KERNEL_PATCHVER)) |
| 26 | |
| 27 | include $(INCLUDE_DIR)/toolchain-build.mk |
| 28 | include $(INCLUDE_DIR)/kernel-defaults.mk |
| 29 | |
| 30 | ifeq ($(strip $(BOARD)),uml) |
| 31 | LINUX_KARCH:=$(subst x86_64,x86,$(subst i386,x86,$(ARCH))) |
| 32 | endif |
| 33 | |
| 34 | HOST_EXTRACFLAGS= |
| 35 | |
| 36 | LINUX_HAS_HEADERS_INSTALL:=y |
| 37 | |
| 38 | KMAKE := $(MAKE) -C $(HOST_BUILD_DIR) \ |
| 39 | ARCH=$(LINUX_KARCH) \ |
| 40 | CC="$(KERNEL_CC)" \ |
| 41 | CFLAGS="$(TARGET_CFLAGS)" \ |
| 42 | CROSS_COMPILE=$(TARGET_CROSS) \ |
| 43 | KBUILD_HAVE_NLS=no \ |
| 44 | CONFIG_SHELL=$(BASH) |
| 45 | |
| 46 | define Host/Configure/all |
| 47 | mkdir -p $(BUILD_DIR_TOOLCHAIN)/linux-dev |
| 48 | $(KMAKE) \ |
| 49 | INSTALL_HDR_PATH="$(BUILD_DIR_TOOLCHAIN)/linux-dev/" \ |
| 50 | headers_install |
| 51 | endef |
| 52 | |
| 53 | # XXX: the following is needed to build lzma-loader |
| 54 | ifneq ($(CONFIG_mips)$(CONFIG_mipsel),) |
| 55 | define Host/Configure/lzma |
| 56 | $(CP) \ |
| 57 | $(HOST_BUILD_DIR)/arch/mips/include/asm/asm.h \ |
| 58 | $(HOST_BUILD_DIR)/arch/mips/include/asm/regdef.h \ |
| 59 | $(BUILD_DIR_TOOLCHAIN)/linux-dev/include/asm/ |
| 60 | endef |
| 61 | endif |
| 62 | |
| 63 | define Host/Configure/post/cris |
| 64 | $(CP) \ |
| 65 | $(HOST_BUILD_DIR)/include/linux/user.h \ |
| 66 | $(BUILD_DIR_TOOLCHAIN)/linux-dev/include/linux/ |
| 67 | ln -snf $(BUILD_DIR_TOOLCHAIN)/linux-dev/include/arch-v10/arch \ |
| 68 | $(BUILD_DIR_TOOLCHAIN)/linux-dev/include/arch |
| 69 | $(SED) '/#include <asm\/page\.h>/d' $(BUILD_DIR_TOOLCHAIN)/linux-dev/include/asm/user.h |
| 70 | endef |
| 71 | |
| 72 | define Host/Configure/post/ubicom32 |
| 73 | $(CP) \ |
| 74 | $(HOST_BUILD_DIR)/arch/ubicom32/include/asm/elf.h \ |
| 75 | $(HOST_BUILD_DIR)/arch/ubicom32/include/asm/user.h \ |
| 76 | $(HOST_BUILD_DIR)/arch/ubicom32/include/asm/page.h \ |
| 77 | $(HOST_BUILD_DIR)/arch/ubicom32/include/asm/page_offset.h \ |
| 78 | $(BUILD_DIR_TOOLCHAIN)/linux-dev/include/asm/ |
| 79 | endef |
| 80 | |
| 81 | define Host/Configure/post/mips |
| 82 | $(call Host/Configure/lzma) |
| 83 | endef |
| 84 | |
| 85 | define Host/Configure/post/mipsel |
| 86 | $(call Host/Configure/lzma) |
| 87 | endef |
| 88 | |
| 89 | define Host/Prepare |
| 90 | $(call Kernel/Prepare/Default) |
| 91 | ln -sf linux-$(LINUX_VERSION) $(BUILD_DIR_TOOLCHAIN)/linux |
| 92 | $(SED) 's/@expr length/@-expr length/' $(HOST_BUILD_DIR)/Makefile |
| 93 | endef |
| 94 | |
| 95 | define Host/Configure |
| 96 | env |
| 97 | yes '' | $(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)) |
| 117 | |