Makefile 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  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. KERNEL_BUILD_DIR := $(BUILD_DIR_TOOLCHAIN)
  9. BUILD_DIR := $(KERNEL_BUILD_DIR)
  10. override QUILT:=
  11. override HOST_QUILT:=
  12. include $(INCLUDE_DIR)/kernel.mk
  13. PKG_NAME:=linux
  14. PKG_VERSION:=$(LINUX_VERSION)
  15. PKG_SOURCE:=$(LINUX_SOURCE)
  16. PKG_CPE_ID:=cpe:/o:linux:linux_kernel
  17. ifneq ($(call qstrip,$(CONFIG_KERNEL_GIT_CLONE_URI)),)
  18. PKG_SOURCE_PROTO:=git
  19. PKG_SOURCE_URL:=$(call qstrip,$(CONFIG_KERNEL_GIT_CLONE_URI))
  20. PKG_SOURCE_VERSION:=$(call qstrip,$(CONFIG_KERNEL_GIT_REF))
  21. PKG_MIRROR_HASH:=$(call qstrip,$(CONFIG_KERNEL_GIT_MIRROR_HASH))
  22. ifdef CHECK
  23. include $(INCLUDE_DIR)/kernel-version.mk
  24. PKG_VERSION:=$(LINUX_VERSION)
  25. else
  26. PKG_SOURCE:=$(LINUX_SOURCE)
  27. endif
  28. else
  29. PKG_SOURCE:=$(LINUX_SOURCE)
  30. PKG_SOURCE_URL:=$(LINUX_SITE)
  31. endif
  32. HOST_BUILD_DIR:=$(KERNEL_BUILD_DIR)/linux-$(LINUX_VERSION)
  33. PKG_HASH:=$(LINUX_KERNEL_HASH)
  34. LINUX_DIR := $(HOST_BUILD_DIR)
  35. FILES_DIR :=
  36. PATCH_DIR := ./patches$(if $(wildcard ./patches-$(LINUX_VERSION)),-$(LINUX_VERSION))
  37. include $(INCLUDE_DIR)/toolchain-build.mk
  38. include $(INCLUDE_DIR)/kernel-defaults.mk
  39. ifeq ($(strip $(BOARD)),uml)
  40. LINUX_KARCH:=$(subst x86_64,x86,$(subst i386,x86,$(ARCH)))
  41. endif
  42. HOST_EXTRACFLAGS=
  43. LINUX_HAS_HEADERS_INSTALL:=y
  44. HOST_KMAKE := $(MAKE) -C $(HOST_BUILD_DIR) \
  45. $(KERNEL_MAKE_FLAGS) \
  46. CC="$(KERNEL_CC)" \
  47. HOSTCFLAGS="$(HOST_CFLAGS)"
  48. define Host/Configure/all
  49. mkdir -p $(BUILD_DIR_TOOLCHAIN)/linux-dev
  50. $(HOST_KMAKE) \
  51. INSTALL_HDR_PATH="$(BUILD_DIR_TOOLCHAIN)/linux-dev/" \
  52. headers_install
  53. endef
  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. define Host/Configure/post/mips
  65. $(call Host/Configure/lzma)
  66. endef
  67. define Host/Configure/post/mipsel
  68. $(call Host/Configure/lzma)
  69. endef
  70. define Host/Prepare
  71. rm -rf $(BUILD_DIR_TOOLCHAIN)/linux-*
  72. $(call Kernel/Prepare/Default)
  73. rm -f $(BUILD_DIR_TOOLCHAIN)/linux
  74. ln -s linux-$(LINUX_VERSION) $(BUILD_DIR_TOOLCHAIN)/linux
  75. $(SED) 's/@expr length/@-expr length/' $(HOST_BUILD_DIR)/Makefile
  76. endef
  77. define Host/Configure
  78. env
  79. yes '' | $(HOST_KMAKE) oldconfig
  80. $(call Host/Configure/all)
  81. $(call Host/Configure/post/$(ARCH))
  82. endef
  83. define Host/Compile
  84. endef
  85. define Host/Install
  86. $(CP) $(BUILD_DIR_TOOLCHAIN)/linux-dev/* $(TOOLCHAIN_DIR)/
  87. endef
  88. define Host/Clean
  89. rm -rf \
  90. $(HOST_BUILD_DIR) \
  91. $(BUILD_DIR_TOOLCHAIN)/linux \
  92. $(BUILD_DIR_TOOLCHAIN)/linux-dev
  93. endef
  94. $(eval $(call HostBuild))