Remove existing old link before creating a new one
[openwrt/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 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 PATCH_DIR := ./patches$(if $(wildcard ./patches-$(LINUX_VERSION)),-$(LINUX_VERSION))
26
27 include $(INCLUDE_DIR)/toolchain-build.mk
28 include $(INCLUDE_DIR)/kernel-defaults.mk
29
30 ifeq ($(strip $(BOARD)),uml)
31 LINUX_KARCH:=$(subst x86_64,x86,$(subst i386,x86,$(ARCH)))
32 endif
33
34 HOST_EXTRACFLAGS=
35
36 LINUX_HAS_HEADERS_INSTALL:=y
37
38 KMAKE := $(MAKE) -C $(HOST_BUILD_DIR) \
39 HOSTCFLAGS="$(HOST_CFLAGS) -Wall -Wmissing-prototypes -Wstrict-prototypes" \
40 ARCH=$(LINUX_KARCH) \
41 CC="$(KERNEL_CC)" \
42 CFLAGS="$(TARGET_CFLAGS)" \
43 CROSS_COMPILE=$(TARGET_CROSS) \
44 KBUILD_HAVE_NLS=no \
45 CONFIG_SHELL=$(BASH)
46
47 define Host/Configure/all
48 mkdir -p $(BUILD_DIR_TOOLCHAIN)/linux-dev
49 $(KMAKE) \
50 INSTALL_HDR_PATH="$(BUILD_DIR_TOOLCHAIN)/linux-dev/" \
51 headers_install
52 endef
53
54 # XXX: the following is needed to build lzma-loader
55 ifneq ($(CONFIG_mips)$(CONFIG_mipsel),)
56 define Host/Configure/lzma
57 $(CP) \
58 $(HOST_BUILD_DIR)/arch/mips/include/asm/asm.h \
59 $(HOST_BUILD_DIR)/arch/mips/include/asm/regdef.h \
60 $(HOST_BUILD_DIR)/arch/mips/include/asm/asm-eva.h \
61 $(BUILD_DIR_TOOLCHAIN)/linux-dev/include/asm/
62 endef
63 endif
64
65 define Host/Configure/post/mips
66 $(call Host/Configure/lzma)
67 endef
68
69 define Host/Configure/post/mipsel
70 $(call Host/Configure/lzma)
71 endef
72
73 define Host/Prepare
74 $(call Kernel/Prepare/Default)
75 rm -f $(BUILD_DIR_TOOLCHAIN)/linux
76 ln -s linux-$(LINUX_VERSION) $(BUILD_DIR_TOOLCHAIN)/linux
77 $(SED) 's/@expr length/@-expr length/' $(HOST_BUILD_DIR)/Makefile
78 endef
79
80 define Host/Configure
81 env
82 yes '' | $(KMAKE) oldconfig
83 $(call Host/Configure/all)
84 $(call Host/Configure/post/$(ARCH))
85 endef
86
87 define Host/Compile
88 endef
89
90 define Host/Install
91 $(CP) $(BUILD_DIR_TOOLCHAIN)/linux-dev/* $(TOOLCHAIN_DIR)/
92 endef
93
94 define Host/Clean
95 rm -rf \
96 $(HOST_BUILD_DIR) \
97 $(BUILD_DIR_TOOLCHAIN)/linux \
98 $(BUILD_DIR_TOOLCHAIN)/linux-dev
99 endef
100
101 $(eval $(call HostBuild))