Makefile 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  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_SOURCE_URL:=$(LINUX_SITE)
  17. HOST_BUILD_DIR:=$(KERNEL_BUILD_DIR)/linux-$(LINUX_VERSION)
  18. PKG_MD5SUM:=$(LINUX_KERNEL_MD5SUM)
  19. LINUX_DIR := $(HOST_BUILD_DIR)
  20. FILES_DIR :=
  21. PATCH_DIR := ./patches$(if $(wildcard ./patches-$(KERNEL_PATCHVER)),-$(KERNEL_PATCHVER))
  22. include $(INCLUDE_DIR)/toolchain-build.mk
  23. include $(INCLUDE_DIR)/kernel-defaults.mk
  24. ifeq ($(strip $(BOARD)),uml)
  25. LINUX_KARCH:=$(subst x86_64,x86,$(subst i386,x86,$(ARCH)))
  26. endif
  27. LINUX_HAS_HEADERS_INSTALL:=y
  28. KMAKE := $(MAKE) -C $(HOST_BUILD_DIR) \
  29. ARCH=$(LINUX_KARCH) \
  30. CC="$(KERNEL_CC)" \
  31. CFLAGS="$(TARGET_CFLAGS)" \
  32. CROSS_COMPILE=$(TARGET_CROSS) \
  33. KBUILD_HAVE_NLS=no \
  34. CONFIG_SHELL=$(BASH)
  35. define Host/Prepare/all
  36. mkdir -p $(BUILD_DIR_TOOLCHAIN)/linux-dev/usr
  37. $(KMAKE) \
  38. INSTALL_HDR_PATH="$(BUILD_DIR_TOOLCHAIN)/linux-dev/usr/" \
  39. headers_install
  40. if [ -d $(HOST_BUILD_DIR)/arch/$(LINUX_KARCH)/include/asm ]; then \
  41. mkdir -p $(HOST_BUILD_DIR)/include/asm-$(LINUX_KARCH); \
  42. $(CP) \
  43. $(HOST_BUILD_DIR)/arch/$(LINUX_KARCH)/include/asm/. \
  44. $(HOST_BUILD_DIR)/include/asm-$(LINUX_KARCH)/; \
  45. fi
  46. endef
  47. # XXX: the following is needed to build lzma-loader
  48. define Host/Prepare/lzma
  49. $(CP) \
  50. $(HOST_BUILD_DIR)/include/asm-mips/asm.h \
  51. $(HOST_BUILD_DIR)/include/asm-mips/regdef.h \
  52. $(BUILD_DIR_TOOLCHAIN)/linux-dev/usr/include/asm/
  53. endef
  54. define Host/Prepare/post/cris
  55. $(CP) \
  56. $(HOST_BUILD_DIR)/include/linux/user.h \
  57. $(BUILD_DIR_TOOLCHAIN)/linux-dev/usr/include/linux/
  58. ln -snf $(BUILD_DIR_TOOLCHAIN)/linux-dev/usr/include/arch-v10/arch \
  59. $(BUILD_DIR_TOOLCHAIN)/linux-dev/usr/include/arch
  60. $(SED) '/#include <asm\/page\.h>/d' $(BUILD_DIR_TOOLCHAIN)/linux-dev/usr/include/asm/user.h
  61. endef
  62. define Host/Prepare/post/ubicom32
  63. $(CP) \
  64. $(HOST_BUILD_DIR)/arch/ubicom32/include/asm/elf.h \
  65. $(HOST_BUILD_DIR)/arch/ubicom32/include/asm/user.h \
  66. $(HOST_BUILD_DIR)/arch/ubicom32/include/asm/page.h \
  67. $(HOST_BUILD_DIR)/arch/ubicom32/include/asm/page_offset.h \
  68. $(BUILD_DIR_TOOLCHAIN)/linux-dev/usr/include/asm/
  69. endef
  70. define Host/Prepare/post/mips
  71. $(call Host/Prepare/lzma)
  72. endef
  73. define Host/Prepare/post/mipsel
  74. $(call Host/Prepare/lzma)
  75. endef
  76. define Host/Prepare
  77. $(call Kernel/Prepare/Default)
  78. ln -sf linux-$(LINUX_VERSION) $(BUILD_DIR_TOOLCHAIN)/linux
  79. $(SED) 's/@expr length/@-expr length/' $(HOST_BUILD_DIR)/Makefile
  80. yes '' | $(KMAKE) oldconfig
  81. $(call Host/Prepare/all)
  82. $(call Host/Prepare/post/$(ARCH))
  83. endef
  84. define Host/Configure
  85. endef
  86. define Host/Compile
  87. endef
  88. define Host/Install
  89. $(CP) $(BUILD_DIR_TOOLCHAIN)/linux-dev/* $(TOOLCHAIN_DIR)/
  90. endef
  91. define Host/Clean
  92. rm -rf \
  93. $(HOST_BUILD_DIR) \
  94. $(BUILD_DIR_TOOLCHAIN)/linux \
  95. $(BUILD_DIR_TOOLCHAIN)/linux-dev
  96. endef
  97. $(eval $(call HostBuild))