fix u-boot wiki urls
[openwrt/svn-archive/archive.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 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
25 include $(INCLUDE_DIR)/toolchain-build.mk
26 include $(INCLUDE_DIR)/kernel-defaults.mk
27
28 ifeq ($(strip $(BOARD)),uml)
29 LINUX_KARCH:=$(subst x86_64,x86,$(subst i386,x86,$(ARCH)))
30 endif
31
32 ifeq ($(strip $(call CompareKernelPatchVer,$(KERNEL_PATCHVER),ge,2.6.18)),1)
33 LINUX_HAS_HEADERS_INSTALL:=y
34 endif
35
36 ifeq ($(strip $(call CompareKernelPatchVer,$(KERNEL_PATCHVER),ge,2.6.33)),1)
37 LINUX_ASM_INCLUDES:=arch/$(LINUX_KARCH)/include/asm
38 else
39 LINUX_ASM_INCLUDES:=include/asm
40 endif
41
42 KMAKE := $(MAKE) -C $(HOST_BUILD_DIR) \
43 ARCH=$(LINUX_KARCH) \
44 KBUILD_HAVE_NLS=no \
45 CONFIG_SHELL=$(BASH)
46
47 define Host/Prepare/pre/powerpc
48 if [ -d $(HOST_BUILD_DIR)/include/asm-ppc ]; then \
49 mkdir -p $(PKG_BUILD_DIR)/include/asm-powerpc/; \
50 $(CP) $(HOST_BUILD_DIR)/include/asm-ppc/* $(HOST_BUILD_DIR)/include/asm-powerpc/; \
51 rm -rf $(HOST_BUILD_DIR)/include/asm-ppc; \
52 ln -s $(HOST_BUILD_DIR)/include/asm-powerpc $(HOST_BUILD_DIR)/include/asm-ppc; \
53 fi
54 endef
55
56 ifneq ($(LINUX_HAS_HEADERS_INSTALL),)
57 define Host/Prepare/all
58 mkdir -p $(BUILD_DIR_TOOLCHAIN)/linux-dev/usr
59 $(KMAKE) \
60 CROSS_COMPILE=$(TARGET_CROSS) \
61 INSTALL_HDR_PATH="$(BUILD_DIR_TOOLCHAIN)/linux-dev/usr/" \
62 headers_install
63 endef
64 else
65 define Host/Prepare/all
66 mkdir -p $(BUILD_DIR_TOOLCHAIN)/linux-dev/usr/include
67 cp -pLR $(HOST_BUILD_DIR)/include/asm $(BUILD_DIR_TOOLCHAIN)/linux-dev/usr/include/
68 cp -pLR $(HOST_BUILD_DIR)/include/asm-generic $(BUILD_DIR_TOOLCHAIN)/linux-dev/usr/include/
69 cp -pLR $(HOST_BUILD_DIR)/include/asm-$(LINUX_KARCH) $(BUILD_DIR_TOOLCHAIN)/linux-dev/usr/include/
70 cp -pLR $(HOST_BUILD_DIR)/include/linux $(BUILD_DIR_TOOLCHAIN)/linux-dev/usr/include/
71 endef
72 endif
73
74 # XXX: the following is needed to build lzma-loader
75 define Host/Prepare/lzma
76 $(CP) \
77 $(HOST_BUILD_DIR)/include/asm-mips/asm.h \
78 $(HOST_BUILD_DIR)/include/asm-mips/regdef.h \
79 $(BUILD_DIR_TOOLCHAIN)/linux-dev/usr/include/asm/
80 endef
81
82 define Host/Prepare/post/cris
83 $(CP) \
84 $(HOST_BUILD_DIR)/include/linux/user.h \
85 $(HOST_BUILD_DIR)/include/linux/autoconf.h \
86 $(BUILD_DIR_TOOLCHAIN)/linux-dev/usr/include/linux/
87 ln -snf $(BUILD_DIR_TOOLCHAIN)/linux-dev/usr/include/arch-v10/arch \
88 $(BUILD_DIR_TOOLCHAIN)/linux-dev/usr/include/arch
89 $(SED) '/#include <asm\/page\.h>/d' $(BUILD_DIR_TOOLCHAIN)/linux-dev/usr/include/asm/user.h
90 endef
91
92 define Host/Prepare/post/ubicom32
93 $(CP) \
94 $(HOST_BUILD_DIR)/arch/ubicom32/include/asm/elf.h \
95 $(HOST_BUILD_DIR)/arch/ubicom32/include/asm/user.h \
96 $(HOST_BUILD_DIR)/arch/ubicom32/include/asm/page.h \
97 $(HOST_BUILD_DIR)/arch/ubicom32/include/asm/page_offset.h \
98 $(BUILD_DIR_TOOLCHAIN)/linux-dev/usr/include/asm/
99 endef
100
101 define Host/Prepare/post/mips
102 $(call Host/Prepare/lzma)
103 endef
104
105 define Host/Prepare/post/mipsel
106 $(call Host/Prepare/lzma)
107 endef
108
109 define Host/Prepare
110 $(call Kernel/Prepare/Default)
111 ln -sf linux-$(LINUX_VERSION) $(BUILD_DIR_TOOLCHAIN)/linux
112 $(SED) 's/@expr length/@-expr length/' $(HOST_BUILD_DIR)/Makefile
113 yes '' | $(KMAKE) oldconfig
114 $(KMAKE) include/linux/version.h $(LINUX_ASM_INCLUDES)
115 if [ -d $(HOST_BUILD_DIR)/arch/$(LINUX_KARCH)/include/asm ]; then \
116 $(CP) \
117 $(HOST_BUILD_DIR)/arch/$(LINUX_KARCH)/include/asm/. \
118 $(HOST_BUILD_DIR)/include/asm-$(LINUX_KARCH)/; \
119 fi
120 $(call Host/Prepare/pre/$(ARCH))
121 $(call Host/Prepare/all)
122 $(call Host/Prepare/post/$(ARCH))
123 endef
124
125 define Host/Configure
126 endef
127
128 define Host/Compile
129 endef
130
131 define Host/Install
132 $(CP) $(BUILD_DIR_TOOLCHAIN)/linux-dev/* $(TOOLCHAIN_DIR)/
133 endef
134
135 define Host/Clean
136 rm -rf \
137 $(HOST_BUILD_DIR) \
138 $(BUILD_DIR_TOOLCHAIN)/linux \
139 $(BUILD_DIR_TOOLCHAIN)/linux-dev
140 endef
141
142 $(eval $(call HostBuild))