kernel-build.mk 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. #
  2. # Copyright (C) 2006-2007 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 $(INCLUDE_DIR)/host.mk
  8. include $(INCLUDE_DIR)/prereq.mk
  9. ifneq ($(DUMP),1)
  10. all: compile
  11. endif
  12. STAMP_PREPARED:=$(LINUX_DIR)/.prepared
  13. STAMP_CONFIGURED:=$(LINUX_DIR)/.configured
  14. include $(INCLUDE_DIR)/download.mk
  15. include $(INCLUDE_DIR)/quilt.mk
  16. include $(INCLUDE_DIR)/kernel-defaults.mk
  17. define Kernel/Prepare
  18. $(call Kernel/Prepare/Default)
  19. endef
  20. define Kernel/Configure
  21. $(call Kernel/Configure/Default)
  22. endef
  23. define Kernel/CompileModules
  24. $(call Kernel/CompileModules/Default)
  25. endef
  26. define Kernel/CompileImage
  27. $(call Kernel/CompileImage/Default)
  28. endef
  29. define Kernel/Clean
  30. $(call Kernel/Clean/Default)
  31. endef
  32. define Download/kernel
  33. URL:=$(LINUX_SITE)
  34. FILE:=$(LINUX_SOURCE)
  35. MD5SUM:=$(LINUX_KERNEL_MD5SUM)
  36. endef
  37. define BuildKernel
  38. $(if $(QUILT),$(Build/Quilt))
  39. $(if $(LINUX_SITE),$(call Download,kernel))
  40. $(STAMP_PREPARED): $(DL_DIR)/$(LINUX_SOURCE)
  41. -rm -rf $(KERNEL_BUILD_DIR)
  42. -mkdir -p $(KERNEL_BUILD_DIR)
  43. $(Kernel/Prepare)
  44. touch $$@
  45. $(STAMP_CONFIGURED): $(STAMP_PREPARED) $(LINUX_CONFIG) $(GENERIC_LINUX_CONFIG) $(TOPDIR)/.config
  46. $(Kernel/Configure)
  47. touch $$@
  48. $(LINUX_DIR)/.modules: $(STAMP_CONFIGURED) $(LINUX_DIR)/.config FORCE
  49. $(Kernel/CompileModules)
  50. touch $$@
  51. $(LINUX_DIR)/.image: $(STAMP_CONFIGURED) FORCE
  52. $(Kernel/CompileImage)
  53. touch $$@
  54. mostlyclean: FORCE
  55. $(Kernel/Clean)
  56. define BuildKernel
  57. endef
  58. download: $(DL_DIR)/$(LINUX_SOURCE)
  59. prepare: $(STAMP_CONFIGURED)
  60. compile: $(LINUX_DIR)/.modules
  61. $(MAKE) -C image compile TARGET_BUILD=
  62. oldconfig menuconfig: $(STAMP_PREPARED) FORCE
  63. [ -e "$(LINUX_CONFIG)" ] || touch "$(LINUX_CONFIG)"
  64. $(LINUX_CONFCMD) > $(LINUX_DIR)/.config
  65. touch $(LINUX_CONFIG)
  66. $(MAKE) -C $(LINUX_DIR) $(KERNEL_MAKEOPTS) $$@
  67. $(SCRIPT_DIR)/kconfig.pl '>' $(GENERIC_LINUX_CONFIG) $(LINUX_DIR)/.config > $(LINUX_CONFIG)
  68. $(Kernel/Configure)
  69. install: $(LINUX_DIR)/.image
  70. TARGET_BUILD="" $(MAKE) -C image compile install
  71. clean: FORCE
  72. rm -rf $(KERNEL_BUILD_DIR)
  73. rebuild: FORCE
  74. @$(MAKE) mostlyclean
  75. @if [ -f $(LINUX_KERNEL) ]; then \
  76. $(MAKE) clean; \
  77. fi
  78. @$(MAKE) compile
  79. image-prereq:
  80. @$(NO_TRACE_MAKE) -s -C image prereq TARGET_BUILD=
  81. prereq: image-prereq
  82. endef