[massive] add support for alternative C libraries (currently only glibc/eglibc)
[10.03/openwrt.git] / toolchain / kernel-headers / Makefile
1
2 # Copyright (C) 2006-2008 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                 $(BUILD_DIR_TOOLCHAIN)/linux/include/asm \
66                 $(BUILD_DIR_TOOLCHAIN)/linux/include/asm-generic \
67                 $(BUILD_DIR_TOOLCHAIN)/linux/include/asm-$(LINUX_KARCH) \
68                 $(BUILD_DIR_TOOLCHAIN)/linux/include/linux \
69                 $(BUILD_DIR_TOOLCHAIN)/linux-dev/usr/include/
70   endef
71 endif
72
73 define Build/Prepare
74         $(call Kernel/Prepare/Default)
75         $(SED) 's/@expr length/@-expr length/' $(PKG_BUILD_DIR)/Makefile
76         ln -sf linux-$(LINUX_VERSION) $(LINUX_HEADERS_DIR)
77         yes '' | $(KMAKE) oldconfig
78         $(KMAKE) include/linux/version.h include/asm
79         if [ -d $(PKG_BUILD_DIR)/arch/$(LINUX_KARCH)/include/asm ]; then \
80                 $(CP) \
81                         $(PKG_BUILD_DIR)/arch/$(LINUX_KARCH)/include/asm/. \
82                         $(PKG_BUILD_DIR)/include/asm-$(LINUX_KARCH)/; \
83         fi
84         $(call Build/Prepare/pre/$(ARCH))
85         $(call Build/Prepare/all)
86 endef
87
88 define Build/Configure
89 endef
90
91 define Build/Compile
92 endef
93
94 define Build/Install/all
95         mkdir -p $(TOOLCHAIN_DIR)/usr/include
96         $(CP) \
97                 $(BUILD_DIR_TOOLCHAIN)/linux-dev/usr/include/* \
98                 $(TOOLCHAIN_DIR)/usr/include/
99 endef
100
101 # XXX: the following is needed to build lzma-loader
102 define Build/Install/post/lzma
103         $(CP) \
104                 $(BUILD_DIR_TOOLCHAIN)/linux/include/asm-mips/asm.h \
105                 $(BUILD_DIR_TOOLCHAIN)/linux/include/asm-mips/regdef.h \
106                 $(TOOLCHAIN_DIR)/usr/include/asm/
107 endef
108
109 define Build/Install/post/mips
110         $(call Build/Install/post/lzma)
111 endef
112
113 define Build/Install/post/mipsel
114         $(call Build/Install/post/lzma)
115 endef
116
117 define Build/Install
118         $(call Build/Install/all)
119         $(call Build/Install/post/$(ARCH))
120 endef
121
122 define Build/Clean
123         rm -rf \
124                 $(PKG_BUILD_DIR) \
125                 $(BUILD_DIR_TOOLCHAIN)/linux \
126                 $(BUILD_DIR_TOOLCHAIN)/linux-dev
127 endef
128
129 $(eval $(call HostBuild))