kernel-build.mk 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  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. KERNEL_BUILD:=1
  8. include $(INCLUDE_DIR)/kernel-version.mk
  9. include $(INCLUDE_DIR)/host.mk
  10. include $(INCLUDE_DIR)/kernel.mk
  11. include $(INCLUDE_DIR)/prereq.mk
  12. LINUX_CONFIG ?= ./config/default
  13. -include $(TOPDIR)/target/linux/generic-$(KERNEL)/config-template
  14. -include $(LINUX_CONFIG)
  15. ifneq ($(CONFIG_ATM),)
  16. FEATURES += atm
  17. endif
  18. ifneq ($(CONFIG_PCI),)
  19. FEATURES += pci
  20. endif
  21. ifneq ($(CONFIG_USB),)
  22. FEATURES += usb
  23. endif
  24. ifneq ($(CONFIG_PCMCIA)$(CONFIG_PCCARD),)
  25. FEATURES += pcmcia
  26. endif
  27. ifneq ($(CONFIG_VIDEO_DEV),)
  28. FEATURES += video
  29. endif
  30. # remove duplicates
  31. FEATURES:=$(sort $(FEATURES))
  32. ifeq ($(DUMP),1)
  33. all: dumpinfo
  34. else
  35. all: compile
  36. endif
  37. ifneq (,$(findstring uml,$(BOARD)))
  38. LINUX_KARCH:=um
  39. else
  40. LINUX_KARCH:=$(shell echo $(ARCH) | sed -e 's/i[3-9]86/i386/' \
  41. -e 's/mipsel/mips/' \
  42. -e 's/mipseb/mips/' \
  43. -e 's/powerpc/ppc/' \
  44. -e 's/sh[234]/sh/' \
  45. -e 's/armeb/arm/' \
  46. )
  47. endif
  48. include $(INCLUDE_DIR)/kernel-defaults.mk
  49. define Kernel/Prepare
  50. $(call Kernel/Prepare/Default)
  51. endef
  52. define Kernel/Configure
  53. $(call Kernel/Configure/Default)
  54. endef
  55. define Kernel/CompileModules
  56. $(call Kernel/CompileModules/Default)
  57. endef
  58. define Kernel/CompileImage
  59. $(call Kernel/CompileImage/Default)
  60. endef
  61. define Kernel/Clean
  62. $(call Kernel/Clean/Default)
  63. endef
  64. define BuildKernel
  65. ifneq ($(LINUX_SITE),)
  66. $(DL_DIR)/$(LINUX_SOURCE):
  67. -mkdir -p $(DL_DIR)
  68. $(SCRIPT_DIR)/download.pl $(DL_DIR) $(LINUX_SOURCE) $(LINUX_KERNEL_MD5SUM) $(LINUX_SITE)
  69. endif
  70. $(LINUX_DIR)/.prepared: $(DL_DIR)/$(LINUX_SOURCE)
  71. -rm -rf $(KERNEL_BUILD_DIR)
  72. -mkdir -p $(KERNEL_BUILD_DIR)
  73. $(call Kernel/Prepare)
  74. touch $$@
  75. $(LINUX_DIR)/.configured: $(LINUX_DIR)/.prepared $(LINUX_CONFIG)
  76. $(call Kernel/Configure)
  77. touch $$@
  78. $(LINUX_DIR)/.modules: $(LINUX_DIR)/.configured $(LINUX_DIR)/.config FORCE
  79. $(call Kernel/CompileModules)
  80. touch $$@
  81. $(LINUX_DIR)/.image: $(LINUX_DIR)/.configured FORCE
  82. $(call Kernel/CompileImage)
  83. touch $$@
  84. mostlyclean: FORCE
  85. $(call Kernel/Clean)
  86. ifeq ($(DUMP),1)
  87. dumpinfo:
  88. @echo 'Target: $(BOARD)-$(KERNEL)'
  89. @echo 'Target-Name: $(BOARDNAME) [$(KERNEL)]'
  90. @echo 'Target-Path: $(subst $(TOPDIR)/,,$(PWD))'
  91. @echo 'Target-Arch: $(ARCH)'
  92. @echo 'Target-Features: $(FEATURES)'
  93. @echo 'Linux-Version: $(LINUX_VERSION)'
  94. @echo 'Linux-Release: $(LINUX_RELEASE)'
  95. @echo 'Linux-Kernel-Arch: $(LINUX_KARCH)'
  96. @echo 'Target-Description:'
  97. @getvar $(call shvar,Target/Description)
  98. @echo '@@'
  99. @echo 'Default-Packages: $(DEFAULT_PACKAGES)'
  100. ifneq ($(DUMPINFO),)
  101. @$(DUMPINFO)
  102. endif
  103. endif
  104. define BuildKernel
  105. endef
  106. endef
  107. define Profile/Default
  108. NAME:=
  109. PACKAGES:=
  110. endef
  111. confname=$(subst .,_,$(subst -,_,$(1)))
  112. define Profile
  113. $(eval $(call Profile/Default))
  114. $(eval $(call Profile/$(1)))
  115. $(eval $(call shexport,Profile/$(1)/Config))
  116. $(eval $(call shexport,Profile/$(1)/Description))
  117. DUMPINFO += \
  118. echo "Target-Profile: $(1)"; \
  119. echo "Target-Profile-Name: $(NAME)"; \
  120. echo "Target-Profile-Packages: $(PACKAGES)"; \
  121. if [ -f ./config/profile-$(1) ]; then \
  122. echo "Target-Profile-Kconfig: yes"; \
  123. fi; \
  124. echo "Target-Profile-Config: "; \
  125. getvar "$(call shvar,Profile/$(1)/Config)"; \
  126. echo "@@"; \
  127. echo "Target-Profile-Description:"; \
  128. getvar "$(call shvar,Profile/$(1)/Description)"; \
  129. echo "@@"; \
  130. echo;
  131. ifeq ($(CONFIG_LINUX_$(call confname,$(KERNEL)_$(1))),y)
  132. PROFILE=$(1)
  133. endif
  134. endef
  135. $(eval $(call shexport,Target/Description))
  136. download: $(DL_DIR)/$(LINUX_SOURCE)
  137. prepare: $(LINUX_DIR)/.configured
  138. compile: $(LINUX_DIR)/.modules
  139. menuconfig: $(LINUX_DIR)/.prepared FORCE
  140. $(call Kernel/Configure)
  141. $(SCRIPT_DIR)/config.pl '+' $(GENERIC_PLATFORM_DIR)/config-template $(LINUX_CONFIG) > $(LINUX_DIR)/.config
  142. $(MAKE) -C $(LINUX_DIR) $(KERNEL_MAKEOPTS) menuconfig
  143. $(SCRIPT_DIR)/config.pl '>' $(GENERIC_PLATFORM_DIR)/config-template $(LINUX_DIR)/.config > $(LINUX_CONFIG)
  144. install: $(LINUX_DIR)/.image
  145. clean: FORCE
  146. rm -f $(STAMP_DIR)/.linux-compile
  147. rm -rf $(KERNEL_BUILD_DIR)
  148. rebuild: FORCE
  149. @$(MAKE) mostlyclean
  150. @if [ -f $(LINUX_KERNEL) ]; then \
  151. $(MAKE) clean; \
  152. fi
  153. @$(MAKE) compile