target.mk 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  1. #
  2. # Copyright (C) 2007-2008 OpenWrt.org
  3. #
  4. # This is free software, licensed under the GNU General Public License v2.
  5. # See /LICENSE for more information.
  6. #
  7. ifneq ($(__target_inc),1)
  8. __target_inc=1
  9. # default device type
  10. DEVICE_TYPE?=router
  11. # Default packages - the really basic set
  12. DEFAULT_PACKAGES:=base-files libgcc uclibc busybox dropbear mtd uci
  13. # For router targets
  14. DEFAULT_PACKAGES.router:=dnsmasq iptables ppp ppp-mod-pppoe kmod-ipt-nathelper bridge
  15. # Additional packages for Linux 2.6
  16. ifneq ($(KERNEL),2.4)
  17. DEFAULT_PACKAGES += udevtrigger hotplug2
  18. endif
  19. # Add device specific packages
  20. DEFAULT_PACKAGES += $(DEFAULT_PACKAGES.$(DEVICE_TYPE))
  21. ifneq ($(DUMP),)
  22. all: dumpinfo
  23. endif
  24. target_conf=$(subst .,_,$(subst -,_,$(subst /,_,$(1))))
  25. ifeq ($(DUMP),)
  26. PLATFORM_DIR:=$(TOPDIR)/target/linux/$(BOARD)
  27. SUBTARGET:=$(strip $(foreach subdir,$(patsubst $(PLATFORM_DIR)/%/target.mk,%,$(wildcard $(PLATFORM_DIR)/*/target.mk)),$(if $(CONFIG_TARGET_$(call target_conf,$(BOARD)_$(subdir))),$(subdir))))
  28. else
  29. PLATFORM_DIR:=${CURDIR}
  30. endif
  31. TARGETID:=$(BOARD)$(if $(SUBTARGET),/$(SUBTARGET))
  32. PLATFORM_SUBDIR:=$(PLATFORM_DIR)$(if $(SUBTARGET),/$(SUBTARGET))
  33. ifneq ($(TARGET_BUILD),1)
  34. include $(PLATFORM_DIR)/Makefile
  35. ifneq ($(PLATFORM_DIR),$(PLATFORM_SUBDIR))
  36. include $(PLATFORM_SUBDIR)/target.mk
  37. endif
  38. else
  39. ifneq ($(SUBTARGET),)
  40. -include ./$(SUBTARGET)/target.mk
  41. endif
  42. endif
  43. define Profile/Default
  44. NAME:=
  45. PACKAGES:=
  46. endef
  47. ifndef Profile
  48. define Profile
  49. $(eval $(call Profile/Default))
  50. $(eval $(call Profile/$(1)))
  51. $(eval $(call shexport,Profile/$(1)/Config))
  52. $(eval $(call shexport,Profile/$(1)/Description))
  53. DUMPINFO += \
  54. echo "Target-Profile: $(1)"; \
  55. echo "Target-Profile-Name: $(NAME)"; \
  56. echo "Target-Profile-Packages: $(PACKAGES)"; \
  57. if [ -f ./config/profile-$(1) ]; then \
  58. echo "Target-Profile-Kconfig: yes"; \
  59. fi; \
  60. echo "Target-Profile-Config: "; \
  61. getvar "$(call shvar,Profile/$(1)/Config)"; \
  62. echo "@@"; \
  63. echo "Target-Profile-Description:"; \
  64. getvar "$(call shvar,Profile/$(1)/Description)"; \
  65. echo "@@"; \
  66. echo;
  67. ifeq ($(CONFIG_TARGET_$(call target_conf,$(BOARD)_$(if $(SUBTARGET),$(SUBTARGET)_)$(1))),y)
  68. PROFILE=$(1)
  69. endif
  70. endef
  71. endif
  72. ifneq ($(PLATFORM_DIR),$(PLATFORM_SUBDIR))
  73. define IncludeProfiles
  74. -include $(PLATFORM_DIR)/profiles/*.mk
  75. -include $(PLATFORM_SUBDIR)/profiles/*.mk
  76. endef
  77. else
  78. define IncludeProfiles
  79. -include $(PLATFORM_DIR)/profiles/*.mk
  80. endef
  81. endif
  82. ifeq ($(TARGET_BUILD),1)
  83. $(eval $(call IncludeProfiles))
  84. else
  85. ifeq ($(DUMP),)
  86. $(eval $(call IncludeProfiles))
  87. endif
  88. endif
  89. $(eval $(call shexport,Target/Description))
  90. include $(INCLUDE_DIR)/kernel-version.mk
  91. GENERIC_PLATFORM_DIR := $(TOPDIR)/target/linux/generic-$(KERNEL)
  92. GENERIC_PATCH_DIR := $(GENERIC_PLATFORM_DIR)/patches$(shell [ -d "$(GENERIC_PLATFORM_DIR)/patches-$(KERNEL_PATCHVER)" ] && printf -- "-$(KERNEL_PATCHVER)" || true )
  93. GENERIC_FILES_DIR := $(GENERIC_PLATFORM_DIR)/files$(shell [ -d "$(GENERIC_PLATFORM_DIR)/files-$(KERNEL_PATCHVER)" ] && printf -- "-$(KERNEL_PATCHVER)" || true )
  94. GENERIC_LINUX_CONFIG?=$(firstword $(wildcard $(GENERIC_PLATFORM_DIR)/config-$(KERNEL_PATCHVER) $(GENERIC_PLATFORM_DIR)/config-default))
  95. LINUX_CONFIG?=$(firstword $(wildcard $(foreach subdir,$(PLATFORM_DIR) $(PLATFORM_SUBDIR),$(subdir)/config-$(KERNEL_PATCHVER) $(subdir)/config-default)) $(PLATFORM_DIR)/config-$(KERNEL_PATCHVER))
  96. LINUX_SUBCONFIG?=$(firstword $(wildcard $(PLATFORM_SUBDIR)/config-$(KERNEL_PATCHVER) $(PLATFORM_SUBDIR)/config-default))
  97. ifeq ($(LINUX_CONFIG),$(LINUX_SUBCONFIG))
  98. LINUX_SUBCONFIG:=
  99. endif
  100. LINUX_CONFCMD=$(if $(LINUX_CONFIG),$(SCRIPT_DIR)/kconfig.pl + $(GENERIC_LINUX_CONFIG) $(if $(LINUX_SUBCONFIG),+ $(LINUX_CONFIG) $(LINUX_SUBCONFIG),$(LINUX_CONFIG)),true)
  101. ifeq ($(DUMP),1)
  102. BuildTarget=$(BuildTargets/DumpCurrent)
  103. ifneq ($(BOARD),)
  104. TMP_CONFIG:=$(TMP_DIR)/.kconfig-$(call target_conf,$(TARGETID))
  105. $(TMP_CONFIG): $(GENERIC_LINUX_CONFIG) $(LINUX_CONFIG) $(LINUX_SUBCONFIG)
  106. $(LINUX_CONFCMD) > $@ || rm -f $@
  107. -include $(TMP_CONFIG)
  108. .SILENT: $(TMP_CONFIG)
  109. .PRECIOUS: $(TMP_CONFIG)
  110. ifneq ($(CONFIG_GENERIC_GPIO),)
  111. FEATURES += gpio
  112. endif
  113. ifneq ($(CONFIG_PCI),)
  114. FEATURES += pci
  115. endif
  116. ifneq ($(CONFIG_USB),)
  117. FEATURES += usb
  118. endif
  119. ifneq ($(CONFIG_PCMCIA)$(CONFIG_PCCARD),)
  120. FEATURES += pcmcia
  121. endif
  122. ifneq ($(CONFIG_VGA_CONSOLE)$(CONFIG_FB),)
  123. FEATURES += display
  124. endif
  125. # remove duplicates
  126. FEATURES:=$(sort $(FEATURES))
  127. endif
  128. endif
  129. define BuildTargets/DumpCurrent
  130. .PHONY: dumpinfo
  131. dumpinfo:
  132. @echo 'Target: $(TARGETID)'; \
  133. echo 'Target-Board: $(BOARD)'; \
  134. echo 'Target-Kernel: $(KERNEL)'; \
  135. echo 'Target-Name: $(BOARDNAME)$(if $(SUBTARGET),, [$(KERNEL)])'; \
  136. echo 'Target-Path: $(subst $(TOPDIR)/,,$(PWD))'; \
  137. echo 'Target-Arch: $(ARCH)'; \
  138. echo 'Target-Features: $(FEATURES)'; \
  139. echo 'Target-Depends: $(DEPENDS)'; \
  140. echo 'Linux-Version: $(LINUX_VERSION)'; \
  141. echo 'Linux-Release: $(LINUX_RELEASE)'; \
  142. echo 'Linux-Kernel-Arch: $(LINUX_KARCH)'; \
  143. echo 'Target-Description:'; \
  144. getvar $(call shvar,Target/Description); \
  145. echo '@@'; \
  146. echo 'Default-Packages: $(DEFAULT_PACKAGES)'; \
  147. $(DUMPINFO)
  148. $(if $(SUBTARGET),,@$(foreach SUBTARGET,$(SUBTARGETS),$(SUBMAKE) -s DUMP=1 SUBTARGET=$(SUBTARGET); ))
  149. endef
  150. include $(INCLUDE_DIR)/kernel.mk
  151. ifeq ($(TARGET_BUILD),1)
  152. include $(INCLUDE_DIR)/kernel-build.mk
  153. BuildTarget?=$(BuildKernel)
  154. endif
  155. endif #__target_inc