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