[toolchain] move all arch fixups from Install to Prepare stage, so that fixed headers...
[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 STAGING_DIR_HOST:=$(TOOLCHAIN_DIR)
13 BUILD_DIR_HOST:=$(BUILD_DIR_TOOLCHAIN)
14
15 override QUILT:=
16 override CONFIG_AUTOREBUILD=
17
18 include $(INCLUDE_DIR)/kernel.mk
19
20 PKG_NAME:=linux
21 PKG_VERSION:=$(LINUX_VERSION)
22 PKG_SOURCE:=$(LINUX_SOURCE)
23 PKG_SOURCE_URL:=$(LINUX_SITE)
24 PKG_BUILD_DIR:=$(KERNEL_BUILD_DIR)/linux-$(LINUX_VERSION)
25 PKG_MD5SUM:=$(LINUX_KERNEL_MD5SUM)
26 LINUX_DIR := $(PKG_BUILD_DIR)
27
28 include $(INCLUDE_DIR)/host-build.mk
29 include $(INCLUDE_DIR)/kernel-defaults.mk
30
31 ifeq ($(strip $(BOARD)),uml)
32 LINUX_KARCH:=$(ARCH)
33 endif
34
35 KMAKE := $(MAKE) -C $(PKG_BUILD_DIR) \
36 ARCH=$(LINUX_KARCH) \
37 KBUILD_HAVE_NLS=no \
38 CONFIG_SHELL=$(BASH)
39
40 define Build/Prepare/pre/cris
41 ln -sf $(PKG_BUILD_DIR)/include/asm-cris/arch-v10 $(PKG_BUILD_DIR)/include/asm-cris/arch
42 ln -sf $(PKG_BUILD_DIR)/include/asm-cris/arch-v10 $(PKG_BUILD_DIR)/arch/cris/arch
43 endef
44
45 define Build/Prepare/pre/powerpc
46 if [ -d $(PKG_BUILD_DIR)/include/asm-ppc ]; then \
47 $(CP) $(PKG_BUILD_DIR)/include/asm-ppc/* $(PKG_BUILD_DIR)/include/asm-powerpc/; \
48 rm -rf $(PKG_BUILD_DIR)/include/asm-ppc; \
49 ln -s $(PKG_BUILD_DIR)/include/asm-powerpc $(PKG_BUILD_DIR)/include/asm-ppc; \
50 fi
51 endef
52
53 ifeq ($(strip $(call CompareKernelPatchVer,$(KERNEL_PATCHVER),ge,2.6.18)),1)
54 define Build/Prepare/all
55 mkdir -p $(BUILD_DIR_TOOLCHAIN)/linux-dev/usr
56 $(KMAKE) \
57 CROSS_COMPILE=$(TARGET_CROSS) \
58 INSTALL_HDR_PATH="$(BUILD_DIR_TOOLCHAIN)/linux-dev/usr/" \
59 headers_install
60 endef
61 else
62 define Build/Prepare/all
63 mkdir -p $(BUILD_DIR_TOOLCHAIN)/linux-dev/usr/include
64 cp -pLR \
65 $(PKG_BUILD_DIR)/include/asm \
66 $(PKG_BUILD_DIR)/include/asm-generic \
67 $(PKG_BUILD_DIR)/include/asm-$(LINUX_KARCH) \
68 $(PKG_BUILD_DIR)/include/linux \
69 $(BUILD_DIR_TOOLCHAIN)/linux-dev/usr/include/
70 endef
71 endif
72
73 # XXX: the following is needed to build lzma-loader
74 define Build/Prepare/lzma
75 $(CP) \
76 $(PKG_BUILD_DIR)/include/asm-mips/asm.h \
77 $(PKG_BUILD_DIR)/include/asm-mips/regdef.h \
78 $(BUILD_DIR_TOOLCHAIN)/linux-dev/usr/include/asm/
79 endef
80
81 # XXX: the following is needed to build final gcc on cris
82 define Build/Prepare/post/cris
83 mkdir -p $(BUILD_DIR_TOOLCHAIN)/linux-dev/usr/include/asm/arch
84 $(CP) \
85 $(PKG_BUILD_DIR)/include/asm-cris/arch/ptrace.h \
86 $(BUILD_DIR_TOOLCHAIN)/linux-dev/usr/include/asm/arch/
87 endef
88
89 define Build/Prepare/post/mips
90 $(call Build/Prepare/lzma)
91 endef
92
93 define Build/Prepare/post/mipsel
94 $(call Build/Prepare/lzma)
95 endef
96
97 define Build/Prepare
98 $(call Kernel/Prepare/Default)
99 ln -sf linux-$(LINUX_VERSION) $(BUILD_DIR_TOOLCHAIN)/linux
100 $(SED) 's/@expr length/@-expr length/' $(PKG_BUILD_DIR)/Makefile
101 yes '' | $(KMAKE) oldconfig
102 $(KMAKE) include/linux/version.h include/asm
103 if [ -d $(PKG_BUILD_DIR)/arch/$(LINUX_KARCH)/include/asm ]; then \
104 $(CP) \
105 $(PKG_BUILD_DIR)/arch/$(LINUX_KARCH)/include/asm/. \
106 $(PKG_BUILD_DIR)/include/asm-$(LINUX_KARCH)/; \
107 fi
108 $(call Build/Prepare/pre/$(ARCH))
109 $(call Build/Prepare/all)
110 $(call Build/Prepare/post/$(ARCH))
111 endef
112
113 define Build/Configure
114 endef
115
116 define Build/Compile
117 endef
118
119 define Build/Install
120 $(CP) $(BUILD_DIR_TOOLCHAIN)/linux-dev/* $(TOOLCHAIN_DIR)/
121 endef
122
123 define Build/Clean
124 rm -rf \
125 $(PKG_BUILD_DIR) \
126 $(BUILD_DIR_TOOLCHAIN)/linux \
127 $(BUILD_DIR_TOOLCHAIN)/linux-dev
128 endef
129
130 $(eval $(call HostBuild))