kernel-build.mk 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  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. STAMP_PREPARED:=$(LINUX_DIR)/.prepared
  49. STAMP_CONFIGURED:=$(LINUX_DIR)/.configured
  50. include $(INCLUDE_DIR)/quilt.mk
  51. include $(INCLUDE_DIR)/kernel-defaults.mk
  52. define Kernel/Prepare
  53. $(call Kernel/Prepare/Default)
  54. endef
  55. define Kernel/Configure
  56. $(call Kernel/Configure/Default)
  57. endef
  58. define Kernel/CompileModules
  59. $(call Kernel/CompileModules/Default)
  60. endef
  61. define Kernel/CompileImage
  62. $(call Kernel/CompileImage/Default)
  63. endef
  64. define Kernel/Clean
  65. $(call Kernel/Clean/Default)
  66. endef
  67. define BuildKernel
  68. ifneq ($(LINUX_SITE),)
  69. $(DL_DIR)/$(LINUX_SOURCE):
  70. -mkdir -p $(DL_DIR)
  71. $(SCRIPT_DIR)/download.pl $(DL_DIR) $(LINUX_SOURCE) $(LINUX_KERNEL_MD5SUM) $(LINUX_SITE)
  72. endif
  73. $(STAMP_PREPARED): $(DL_DIR)/$(LINUX_SOURCE)
  74. -rm -rf $(KERNEL_BUILD_DIR)
  75. -mkdir -p $(KERNEL_BUILD_DIR)
  76. $(call Kernel/Prepare)
  77. touch $$@
  78. $(STAMP_CONFIGURED): $(LINUX_DIR)/.prepared $(LINUX_CONFIG)
  79. $(call Kernel/Configure)
  80. touch $$@
  81. $(LINUX_DIR)/.modules: $(LINUX_DIR)/.configured $(LINUX_DIR)/.config FORCE
  82. $(call Kernel/CompileModules)
  83. touch $$@
  84. $(LINUX_DIR)/.image: $(LINUX_DIR)/.configured FORCE
  85. $(call Kernel/CompileImage)
  86. touch $$@
  87. mostlyclean: FORCE
  88. $(call Kernel/Clean)
  89. ifeq ($(DUMP),1)
  90. dumpinfo:
  91. @echo 'Target: $(BOARD)-$(KERNEL)'
  92. @echo 'Target-Name: $(BOARDNAME) [$(KERNEL)]'
  93. @echo 'Target-Path: $(subst $(TOPDIR)/,,$(PWD))'
  94. @echo 'Target-Arch: $(ARCH)'
  95. @echo 'Target-Features: $(FEATURES)'
  96. @echo 'Linux-Version: $(LINUX_VERSION)'
  97. @echo 'Linux-Release: $(LINUX_RELEASE)'
  98. @echo 'Linux-Kernel-Arch: $(LINUX_KARCH)'
  99. @echo 'Target-Description:'
  100. @getvar $(call shvar,Target/Description)
  101. @echo '@@'
  102. @echo 'Default-Packages: $(DEFAULT_PACKAGES)'
  103. ifneq ($(DUMPINFO),)
  104. @$(DUMPINFO)
  105. endif
  106. endif
  107. define BuildKernel
  108. endef
  109. endef
  110. define Profile/Default
  111. NAME:=
  112. PACKAGES:=
  113. endef
  114. confname=$(subst .,_,$(subst -,_,$(1)))
  115. define Profile
  116. $(eval $(call Profile/Default))
  117. $(eval $(call Profile/$(1)))
  118. $(eval $(call shexport,Profile/$(1)/Config))
  119. $(eval $(call shexport,Profile/$(1)/Description))
  120. DUMPINFO += \
  121. echo "Target-Profile: $(1)"; \
  122. echo "Target-Profile-Name: $(NAME)"; \
  123. echo "Target-Profile-Packages: $(PACKAGES)"; \
  124. if [ -f ./config/profile-$(1) ]; then \
  125. echo "Target-Profile-Kconfig: yes"; \
  126. fi; \
  127. echo "Target-Profile-Config: "; \
  128. getvar "$(call shvar,Profile/$(1)/Config)"; \
  129. echo "@@"; \
  130. echo "Target-Profile-Description:"; \
  131. getvar "$(call shvar,Profile/$(1)/Description)"; \
  132. echo "@@"; \
  133. echo;
  134. ifeq ($(CONFIG_LINUX_$(call confname,$(KERNEL)_$(1))),y)
  135. PROFILE=$(1)
  136. endif
  137. endef
  138. $(eval $(call shexport,Target/Description))
  139. download: $(DL_DIR)/$(LINUX_SOURCE)
  140. prepare: $(LINUX_DIR)/.configured
  141. compile: $(LINUX_DIR)/.modules
  142. menuconfig: $(LINUX_DIR)/.prepared FORCE
  143. $(call Kernel/Configure)
  144. $(SCRIPT_DIR)/config.pl '+' $(GENERIC_PLATFORM_DIR)/config-template $(LINUX_CONFIG) > $(LINUX_DIR)/.config
  145. $(MAKE) -C $(LINUX_DIR) $(KERNEL_MAKEOPTS) menuconfig
  146. $(SCRIPT_DIR)/config.pl '>' $(GENERIC_PLATFORM_DIR)/config-template $(LINUX_DIR)/.config > $(LINUX_CONFIG)
  147. install: $(LINUX_DIR)/.image
  148. clean: FORCE
  149. rm -f $(STAMP_DIR)/.linux-compile
  150. rm -rf $(KERNEL_BUILD_DIR)
  151. rebuild: FORCE
  152. @$(MAKE) mostlyclean
  153. @if [ -f $(LINUX_KERNEL) ]; then \
  154. $(MAKE) clean; \
  155. fi
  156. @$(MAKE) compile