Makefile 2.8 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. 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. include $(INCLUDE_DIR)/kernel-version.mk
  23. PKG_VERSION:=$(LINUX_VERSION)
  24. else
  25. PKG_SOURCE:=$(LINUX_SOURCE)
  26. endif
  27. else
  28. PKG_SOURCE:=$(LINUX_SOURCE)
  29. PKG_SOURCE_URL:=$(LINUX_SITE)
  30. endif
  31. HOST_BUILD_DIR:=$(KERNEL_BUILD_DIR)/linux-$(LINUX_VERSION)
  32. PKG_HASH:=$(LINUX_KERNEL_HASH)
  33. LINUX_DIR := $(HOST_BUILD_DIR)
  34. FILES_DIR :=
  35. PATCH_DIR := ./patches$(if $(wildcard ./patches-$(LINUX_VERSION)),-$(LINUX_VERSION))
  36. include $(INCLUDE_DIR)/toolchain-build.mk
  37. include $(INCLUDE_DIR)/kernel-defaults.mk
  38. ifeq ($(strip $(BOARD)),uml)
  39. LINUX_KARCH:=$(subst x86_64,x86,$(subst i386,x86,$(ARCH)))
  40. endif
  41. HOST_EXTRACFLAGS=
  42. LINUX_HAS_HEADERS_INSTALL:=y
  43. HOST_KMAKE := $(MAKE) -C $(HOST_BUILD_DIR) \
  44. $(KERNEL_MAKE_FLAGS) \
  45. CC="$(KERNEL_CC)" \
  46. HOSTCFLAGS="$(HOST_CFLAGS)"
  47. define Host/Configure/all
  48. mkdir -p $(BUILD_DIR_TOOLCHAIN)/linux-dev
  49. $(HOST_KMAKE) \
  50. INSTALL_HDR_PATH="$(BUILD_DIR_TOOLCHAIN)/linux-dev/" \
  51. headers_install
  52. endef
  53. # XXX: the following is needed to build lzma-loader
  54. ifneq ($(CONFIG_mips)$(CONFIG_mipsel),)
  55. define Host/Configure/lzma
  56. $(CP) \
  57. $(HOST_BUILD_DIR)/arch/mips/include/asm/asm.h \
  58. $(HOST_BUILD_DIR)/arch/mips/include/asm/regdef.h \
  59. $(HOST_BUILD_DIR)/arch/mips/include/asm/asm-eva.h \
  60. $(HOST_BUILD_DIR)/arch/mips/include/asm/isa-rev.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))