Makefile 2.4 KB

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