[toolchain] kernel-headers: fix build error when run for the second time
[openwrt.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 HOST_QUILT:=
17 override CONFIG_AUTOREBUILD=
18
19 include $(INCLUDE_DIR)/kernel.mk
20
21 PKG_NAME:=linux
22 PKG_VERSION:=$(LINUX_VERSION)
23 PKG_SOURCE:=$(LINUX_SOURCE)
24 PKG_SOURCE_URL:=$(LINUX_SITE)
25 HOST_BUILD_DIR:=$(KERNEL_BUILD_DIR)/linux-$(LINUX_VERSION)
26 PKG_MD5SUM:=$(LINUX_KERNEL_MD5SUM)
27 LINUX_DIR := $(HOST_BUILD_DIR)
28
29 include $(INCLUDE_DIR)/host-build.mk
30 include $(INCLUDE_DIR)/kernel-defaults.mk
31
32 ifeq ($(strip $(BOARD)),uml)
33 LINUX_KARCH:=$(ARCH)
34 endif
35
36 ifeq ($(strip $(call CompareKernelPatchVer,$(KERNEL_PATCHVER),ge,2.6.18)),1)
37 LINUX_HAS_HEADERS_INSTALL:=y
38 endif
39
40 KMAKE := $(MAKE) -C $(HOST_BUILD_DIR) \
41 ARCH=$(LINUX_KARCH) \
42 KBUILD_HAVE_NLS=no \
43 CONFIG_SHELL=$(BASH)
44
45 define Host/Prepare/pre/cris
46 ln -sf $(HOST_BUILD_DIR)/include/asm-cris/arch-v10 $(HOST_BUILD_DIR)/include/asm-cris/arch
47 ln -sf $(HOST_BUILD_DIR)/include/asm-cris/arch-v10 $(HOST_BUILD_DIR)/arch/cris/arch
48 endef
49
50 define Host/Prepare/pre/powerpc
51 if [ -d $(HOST_BUILD_DIR)/include/asm-ppc ]; then \
52 $(CP) $(HOST_BUILD_DIR)/include/asm-ppc/* $(HOST_BUILD_DIR)/include/asm-powerpc/; \
53 rm -rf $(HOST_BUILD_DIR)/include/asm-ppc; \
54 ln -s $(HOST_BUILD_DIR)/include/asm-powerpc $(HOST_BUILD_DIR)/include/asm-ppc; \
55 fi
56 endef
57
58 ifneq ($(LINUX_HAS_HEADERS_INSTALL),)
59 define Host/Prepare/all
60 mkdir -p $(BUILD_DIR_TOOLCHAIN)/linux-dev/usr
61 $(KMAKE) \
62 CROSS_COMPILE=$(TARGET_CROSS) \
63 INSTALL_HDR_PATH="$(BUILD_DIR_TOOLCHAIN)/linux-dev/usr/" \
64 headers_install
65 endef
66 else
67 define Host/Prepare/all
68 mkdir -p $(BUILD_DIR_TOOLCHAIN)/linux-dev/usr/include
69 cp -pLR \
70 $(HOST_BUILD_DIR)/include/asm \
71 $(HOST_BUILD_DIR)/include/asm-generic \
72 $(HOST_BUILD_DIR)/include/asm-$(LINUX_KARCH) \
73 $(HOST_BUILD_DIR)/include/linux \
74 $(BUILD_DIR_TOOLCHAIN)/linux-dev/usr/include/
75 endef
76 endif
77
78 # XXX: the following is needed to build lzma-loader
79 define Host/Prepare/lzma
80 $(CP) \
81 $(HOST_BUILD_DIR)/include/asm-mips/asm.h \
82 $(HOST_BUILD_DIR)/include/asm-mips/regdef.h \
83 $(BUILD_DIR_TOOLCHAIN)/linux-dev/usr/include/asm/
84 endef
85
86 # XXX: the following are needed to build a cris toolchain
87 define Host/Prepare/post/cris
88 $(CP) \
89 $(HOST_BUILD_DIR)/include/linux/user.h \
90 $(BUILD_DIR_TOOLCHAIN)/linux-dev/usr/include/linux/
91 $(CP) \
92 $(HOST_BUILD_DIR)/include/asm-cris/elf.h \
93 $(HOST_BUILD_DIR)/include/asm-cris/page.h \
94 $(HOST_BUILD_DIR)/include/asm-cris/user.h \
95 $(BUILD_DIR_TOOLCHAIN)/linux-dev/usr/include/asm/
96 mkdir -p $(BUILD_DIR_TOOLCHAIN)/linux-dev/usr/include/asm/arch
97 $(CP) \
98 $(HOST_BUILD_DIR)/include/asm-cris/arch/elf.h \
99 $(HOST_BUILD_DIR)/include/asm-cris/arch/page.h \
100 $(HOST_BUILD_DIR)/include/asm-cris/arch/ptrace.h \
101 $(HOST_BUILD_DIR)/include/asm-cris/arch/user.h \
102 $(BUILD_DIR_TOOLCHAIN)/linux-dev/usr/include/asm/arch/
103 $(CP) \
104 $(HOST_BUILD_DIR)/include/asm-generic/memory_model.h \
105 $(HOST_BUILD_DIR)/include/asm-generic/page.h \
106 $(BUILD_DIR_TOOLCHAIN)/linux-dev/usr/include/asm-generic/
107 endef
108
109 define Host/Prepare/post/mips
110 $(call Host/Prepare/lzma)
111 endef
112
113 define Host/Prepare/post/mipsel
114 $(call Host/Prepare/lzma)
115 endef
116
117 define Host/Prepare
118 $(call Kernel/Prepare/Default)
119 ln -sf linux-$(LINUX_VERSION) $(BUILD_DIR_TOOLCHAIN)/linux
120 $(SED) 's/@expr length/@-expr length/' $(HOST_BUILD_DIR)/Makefile
121 yes '' | $(KMAKE) oldconfig
122 $(KMAKE) include/linux/version.h include/asm
123 if [ -d $(HOST_BUILD_DIR)/arch/$(LINUX_KARCH)/include/asm ]; then \
124 $(CP) \
125 $(HOST_BUILD_DIR)/arch/$(LINUX_KARCH)/include/asm/. \
126 $(HOST_BUILD_DIR)/include/asm-$(LINUX_KARCH)/; \
127 fi
128 $(call Host/Prepare/pre/$(ARCH))
129 $(call Host/Prepare/all)
130 $(call Host/Prepare/post/$(ARCH))
131 endef
132
133 define Host/Configure
134 endef
135
136 define Host/Compile
137 endef
138
139 define Host/Install
140 $(CP) $(BUILD_DIR_TOOLCHAIN)/linux-dev/* $(TOOLCHAIN_DIR)/
141 endef
142
143 define Host/Clean
144 rm -rf \
145 $(HOST_BUILD_DIR) \
146 $(BUILD_DIR_TOOLCHAIN)/linux \
147 $(BUILD_DIR_TOOLCHAIN)/linux-dev
148 endef
149
150 $(eval $(call HostBuild))
This page took 0.054532 seconds and 5 git commands to generate.