8e3324816bfad3640b49475d3e48659420ef096e
[openwrt/staging/jow.git] / toolchain / kernel-headers / Makefile
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 ifneq ($(call qstrip,$(CONFIG_KERNEL_GIT_CLONE_URI)),)
21 PKG_SOURCE_PROTO:=git
22 PKG_SOURCE_URL:=$(call qstrip,$(CONFIG_KERNEL_GIT_CLONE_URI))
23 PKG_SOURCE_VERSION:=$(call qstrip,$(CONFIG_KERNEL_GIT_REF))
24 PKG_MIRROR_HASH:=$(call qstrip,$(CONFIG_KERNEL_GIT_MIRROR_HASH))
25 ifdef CHECK
26 PLATFORM_DIR:=$(firstword $(wildcard $(TOPDIR)/target/linux/feeds/$(BOARD) $(TOPDIR)/target/linux/$(BOARD)))
27 include $(PLATFORM_DIR)/Makefile
28 include $(INCLUDE_DIR)/kernel-version.mk
29 include $(INCLUDE_DIR)/kernel-build.mk
30 PKG_VERSION:=$(LINUX_VERSION)
31 else
32 PKG_SOURCE:=$(LINUX_SOURCE)
33 endif
34 else
35 PKG_SOURCE:=$(LINUX_SOURCE)
36 PKG_SOURCE_URL:=$(LINUX_SITE)
37 endif
38 HOST_BUILD_DIR:=$(KERNEL_BUILD_DIR)/linux-$(LINUX_VERSION)
39 PKG_HASH:=$(LINUX_KERNEL_HASH)
40 LINUX_DIR := $(HOST_BUILD_DIR)
41 FILES_DIR :=
42 PATCH_DIR := ./patches$(if $(wildcard ./patches-$(LINUX_VERSION)),-$(LINUX_VERSION))
43
44 include $(INCLUDE_DIR)/toolchain-build.mk
45 include $(INCLUDE_DIR)/kernel-defaults.mk
46
47 ifeq ($(strip $(BOARD)),uml)
48 LINUX_KARCH:=$(subst x86_64,x86,$(subst i386,x86,$(ARCH)))
49 endif
50
51 HOST_EXTRACFLAGS=
52
53 LINUX_HAS_HEADERS_INSTALL:=y
54
55 HOST_KMAKE := $(MAKE) -C $(HOST_BUILD_DIR) \
56 $(KERNEL_MAKE_FLAGS) \
57 CC="$(KERNEL_CC)" \
58 HOSTCFLAGS="$(HOST_CFLAGS)"
59
60 define Host/Configure/all
61 mkdir -p $(BUILD_DIR_TOOLCHAIN)/linux-dev
62 $(HOST_KMAKE) \
63 INSTALL_HDR_PATH="$(BUILD_DIR_TOOLCHAIN)/linux-dev/" \
64 headers_install
65 endef
66
67 # XXX: the following is needed to build lzma-loader
68 ifneq ($(CONFIG_mips)$(CONFIG_mipsel),)
69 define Host/Configure/lzma
70 $(CP) \
71 $(HOST_BUILD_DIR)/arch/mips/include/asm/asm.h \
72 $(HOST_BUILD_DIR)/arch/mips/include/asm/regdef.h \
73 $(HOST_BUILD_DIR)/arch/mips/include/asm/asm-eva.h \
74 $(HOST_BUILD_DIR)/arch/mips/include/asm/isa-rev.h \
75 $(BUILD_DIR_TOOLCHAIN)/linux-dev/include/asm/
76 endef
77 endif
78
79 define Host/Configure/post/mips
80 $(call Host/Configure/lzma)
81 endef
82
83 define Host/Configure/post/mipsel
84 $(call Host/Configure/lzma)
85 endef
86
87 define Host/Prepare
88 rm -rf $(BUILD_DIR_TOOLCHAIN)/linux-*
89 $(call Kernel/Prepare/Default)
90 rm -f $(BUILD_DIR_TOOLCHAIN)/linux
91 ln -s 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 yes '' | $(HOST_KMAKE) oldconfig
97 $(call Host/Configure/all)
98 $(call Host/Configure/post/$(ARCH))
99 endef
100
101 define Host/Compile
102 endef
103
104 define Host/Install
105 $(CP) $(BUILD_DIR_TOOLCHAIN)/linux-dev/* $(TOOLCHAIN_DIR)/
106 endef
107
108 define Host/Clean
109 rm -rf \
110 $(HOST_BUILD_DIR) \
111 $(BUILD_DIR_TOOLCHAIN)/linux \
112 $(BUILD_DIR_TOOLCHAIN)/linux-dev
113 endef
114
115 $(eval $(call HostBuild))