Makefile 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  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. ifneq ($(call qstrip,$(CONFIG_KERNEL_GIT_CLONE_URI)),)
  17. PKG_SOURCE_PROTO:=git
  18. PKG_SOURCE_URL:=$(call qstrip,$(CONFIG_KERNEL_GIT_CLONE_URI))
  19. PKG_SOURCE_VERSION:=$(call qstrip,$(CONFIG_KERNEL_GIT_REF))
  20. PKG_MIRROR_HASH:=$(call qstrip,$(CONFIG_KERNEL_GIT_MIRROR_HASH))
  21. ifdef CHECK
  22. PLATFORM_DIR:=$(firstword $(wildcard $(TOPDIR)/target/linux/feeds/$(BOARD) $(TOPDIR)/target/linux/$(BOARD)))
  23. include $(PLATFORM_DIR)/Makefile
  24. include $(INCLUDE_DIR)/kernel-version.mk
  25. include $(INCLUDE_DIR)/kernel-build.mk
  26. PKG_VERSION:=$(LINUX_VERSION)
  27. else
  28. PKG_SOURCE:=$(LINUX_SOURCE)
  29. endif
  30. else
  31. PKG_SOURCE:=$(LINUX_SOURCE)
  32. PKG_SOURCE_URL:=$(LINUX_SITE)
  33. endif
  34. HOST_BUILD_DIR:=$(KERNEL_BUILD_DIR)/linux-$(LINUX_VERSION)
  35. PKG_HASH:=$(LINUX_KERNEL_HASH)
  36. LINUX_DIR := $(HOST_BUILD_DIR)
  37. FILES_DIR :=
  38. PATCH_DIR := ./patches$(if $(wildcard ./patches-$(LINUX_VERSION)),-$(LINUX_VERSION))
  39. include $(INCLUDE_DIR)/toolchain-build.mk
  40. include $(INCLUDE_DIR)/kernel-defaults.mk
  41. ifeq ($(strip $(BOARD)),uml)
  42. LINUX_KARCH:=$(subst x86_64,x86,$(subst i386,x86,$(ARCH)))
  43. endif
  44. HOST_EXTRACFLAGS=
  45. LINUX_HAS_HEADERS_INSTALL:=y
  46. HOST_KMAKE := $(MAKE) -C $(HOST_BUILD_DIR) \
  47. $(KERNEL_MAKE_FLAGS) \
  48. CC="$(KERNEL_CC)" \
  49. HOSTCFLAGS="$(HOST_CFLAGS)"
  50. define Host/Configure/all
  51. mkdir -p $(BUILD_DIR_TOOLCHAIN)/linux-dev
  52. $(HOST_KMAKE) \
  53. INSTALL_HDR_PATH="$(BUILD_DIR_TOOLCHAIN)/linux-dev/" \
  54. headers_install
  55. endef
  56. # XXX: the following is needed to build lzma-loader
  57. ifneq ($(CONFIG_mips)$(CONFIG_mipsel),)
  58. define Host/Configure/lzma
  59. $(CP) \
  60. $(HOST_BUILD_DIR)/arch/mips/include/asm/asm.h \
  61. $(HOST_BUILD_DIR)/arch/mips/include/asm/regdef.h \
  62. $(HOST_BUILD_DIR)/arch/mips/include/asm/asm-eva.h \
  63. $(HOST_BUILD_DIR)/arch/mips/include/asm/isa-rev.h \
  64. $(BUILD_DIR_TOOLCHAIN)/linux-dev/include/asm/
  65. endef
  66. endif
  67. define Host/Configure/post/mips
  68. $(call Host/Configure/lzma)
  69. endef
  70. define Host/Configure/post/mipsel
  71. $(call Host/Configure/lzma)
  72. endef
  73. define Host/Prepare
  74. rm -rf $(BUILD_DIR_TOOLCHAIN)/linux-*
  75. $(call Kernel/Prepare/Default)
  76. rm -f $(BUILD_DIR_TOOLCHAIN)/linux
  77. ln -s linux-$(LINUX_VERSION) $(BUILD_DIR_TOOLCHAIN)/linux
  78. $(SED) 's/@expr length/@-expr length/' $(HOST_BUILD_DIR)/Makefile
  79. endef
  80. define Host/Configure
  81. yes '' | $(HOST_KMAKE) oldconfig
  82. $(call Host/Configure/all)
  83. $(call Host/Configure/post/$(ARCH))
  84. endef
  85. define Host/Compile
  86. endef
  87. define Host/Install
  88. $(CP) $(BUILD_DIR_TOOLCHAIN)/linux-dev/* $(TOOLCHAIN_DIR)/
  89. endef
  90. define Host/Clean
  91. rm -rf \
  92. $(HOST_BUILD_DIR) \
  93. $(BUILD_DIR_TOOLCHAIN)/linux \
  94. $(BUILD_DIR_TOOLCHAIN)/linux-dev
  95. endef
  96. $(eval $(call HostBuild))