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