target.mk 5.5 KB

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