build system refactoring in preparation for allowing packages to do host-build steps
[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 HOST_BUILD_DIR:=$(KERNEL_BUILD_DIR)/linux-$(LINUX_VERSION)
25 PKG_MD5SUM:=$(LINUX_KERNEL_MD5SUM)
26 LINUX_DIR := $(HOST_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 ifeq ($(strip $(call CompareKernelPatchVer,$(KERNEL_PATCHVER),ge,2.6.18)),1)
36 LINUX_HAS_HEADERS_INSTALL:=y
37 endif
38
39 KMAKE := $(MAKE) -C $(HOST_BUILD_DIR) \
40 ARCH=$(LINUX_KARCH) \
41 KBUILD_HAVE_NLS=no \
42 CONFIG_SHELL=$(BASH)
43
44 define Host/Prepare/pre/cris
45 ln -sf $(HOST_BUILD_DIR)/include/asm-cris/arch-v10 $(HOST_BUILD_DIR)/include/asm-cris/arch
46 ln -sf $(HOST_BUILD_DIR)/include/asm-cris/arch-v10 $(HOST_BUILD_DIR)/arch/cris/arch
47 endef
48
49 define Host/Prepare/pre/powerpc
50 if [ -d $(HOST_BUILD_DIR)/include/asm-ppc ]; then \
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/usr
60 $(KMAKE) \
61 CROSS_COMPILE=$(TARGET_CROSS) \
62 INSTALL_HDR_PATH="$(BUILD_DIR_TOOLCHAIN)/linux-dev/usr/" \
63 headers_install
64 endef
65 else
66 define Host/Prepare/all
67 mkdir -p $(BUILD_DIR_TOOLCHAIN)/linux-dev/usr/include
68 cp -pLR \
69 $(HOST_BUILD_DIR)/include/asm \
70 $(HOST_BUILD_DIR)/include/asm-generic \
71 $(HOST_BUILD_DIR)/include/asm-$(LINUX_KARCH) \
72 $(HOST_BUILD_DIR)/include/linux \
73 $(BUILD_DIR_TOOLCHAIN)/linux-dev/usr/include/
74 endef
75 endif
76
77 # XXX: the following is needed to build lzma-loader
78 define Host/Prepare/lzma
79 $(CP) \
80 $(HOST_BUILD_DIR)/include/asm-mips/asm.h \
81 $(HOST_BUILD_DIR)/include/asm-mips/regdef.h \
82 $(BUILD_DIR_TOOLCHAIN)/linux-dev/usr/include/asm/
83 endef
84
85 # XXX: the following are needed to build a cris toolchain
86 define Host/Prepare/post/cris
87 $(CP) \
88 $(HOST_BUILD_DIR)/include/linux/user.h \
89 $(BUILD_DIR_TOOLCHAIN)/linux-dev/usr/include/linux/
90 $(CP) \
91 $(HOST_BUILD_DIR)/include/asm-cris/elf.h \
92 $(HOST_BUILD_DIR)/include/asm-cris/page.h \
93 $(HOST_BUILD_DIR)/include/asm-cris/user.h \
94 $(BUILD_DIR_TOOLCHAIN)/linux-dev/usr/include/asm/
95 mkdir -p $(BUILD_DIR_TOOLCHAIN)/linux-dev/usr/include/asm/arch
96 $(CP) \
97 $(HOST_BUILD_DIR)/include/asm-cris/arch/elf.h \
98 $(HOST_BUILD_DIR)/include/asm-cris/arch/page.h \
99 $(HOST_BUILD_DIR)/include/asm-cris/arch/ptrace.h \
100 $(HOST_BUILD_DIR)/include/asm-cris/arch/user.h \
101 $(BUILD_DIR_TOOLCHAIN)/linux-dev/usr/include/asm/arch/
102 $(CP) \
103 $(HOST_BUILD_DIR)/include/asm-generic/memory_model.h \
104 $(HOST_BUILD_DIR)/include/asm-generic/page.h \
105 $(BUILD_DIR_TOOLCHAIN)/linux-dev/usr/include/asm-generic/
106 endef
107
108 define Host/Prepare/post/mips
109 $(call Host/Prepare/lzma)
110 endef
111
112 define Host/Prepare/post/mipsel
113 $(call Host/Prepare/lzma)
114 endef
115
116 define Host/Prepare
117 $(call Kernel/Prepare/Default)
118 ln -sf linux-$(LINUX_VERSION) $(BUILD_DIR_TOOLCHAIN)/linux
119 $(SED) 's/@expr length/@-expr length/' $(HOST_BUILD_DIR)/Makefile
120 yes '' | $(KMAKE) oldconfig
121 $(KMAKE) include/linux/version.h include/asm
122 if [ -d $(HOST_BUILD_DIR)/arch/$(LINUX_KARCH)/include/asm ]; then \
123 $(CP) \
124 $(HOST_BUILD_DIR)/arch/$(LINUX_KARCH)/include/asm/. \
125 $(HOST_BUILD_DIR)/include/asm-$(LINUX_KARCH)/; \
126 fi
127 $(call Host/Prepare/pre/$(ARCH))
128 $(call Host/Prepare/all)
129 $(call Host/Prepare/post/$(ARCH))
130 endef
131
132 define Host/Configure
133 endef
134
135 define Host/Compile
136 endef
137
138 define Host/Install
139 $(CP) $(BUILD_DIR_TOOLCHAIN)/linux-dev/* $(TOOLCHAIN_DIR)/
140 endef
141
142 define Host/Clean
143 rm -rf \
144 $(HOST_BUILD_DIR) \
145 $(BUILD_DIR_TOOLCHAIN)/linux \
146 $(BUILD_DIR_TOOLCHAIN)/linux-dev
147 endef
148
149 $(eval $(call HostBuild))