2 # Copyright (C) 2007 OpenWrt.org
4 # This is free software, licensed under the GNU General Public License v2.
5 # See /LICENSE for more information.
12 ifneq ($(__target_inc),1)
15 target_conf=$(subst .,_,$(subst -,_,$(subst /,_,$(1))))
17 PLATFORM_DIR:=$(TOPDIR)/target/linux/$(BOARD)
18 SUBTARGET:=$(strip $(foreach subdir,$(patsubst $(PLATFORM_DIR)/%/target.mk,%,$(wildcard $(PLATFORM_DIR)/*/target.mk)),$(if $(CONFIG_TARGET_$(call target_conf,$(BOARD)_$(subdir))),$(subdir))))
20 PLATFORM_DIR:=${CURDIR}
23 TARGETID:=$(BOARD)$(if $(SUBTARGET),/$(SUBTARGET))
24 PLATFORM_SUBDIR:=$(PLATFORM_DIR)$(if $(SUBTARGET),/$(SUBTARGET))
30 BuildTarget=$$(BuildTargets/DumpAll)
35 ifneq ($(TARGET_BUILD),1)
36 include $(PLATFORM_DIR)/Makefile
37 ifneq ($(PLATFORM_DIR),$(PLATFORM_SUBDIR))
38 include $(PLATFORM_SUBDIR)/target.mk
42 -include ./$(SUBTARGET)/target.mk
46 define Profile/Default
52 $(eval $(call Profile/Default))
53 $(eval $(call Profile/$(1)))
54 $(eval $(call shexport,Profile/$(1)/Config))
55 $(eval $(call shexport,Profile/$(1)/Description))
57 echo "Target-Profile: $(1)"; \
58 echo "Target-Profile-Name: $(NAME)"; \
59 echo "Target-Profile-Packages: $(PACKAGES)"; \
60 if [ -f ./config/profile-$(1) ]; then \
61 echo "Target-Profile-Kconfig: yes"; \
63 echo "Target-Profile-Config: "; \
64 getvar "$(call shvar,Profile/$(1)/Config)"; \
66 echo "Target-Profile-Description:"; \
67 getvar "$(call shvar,Profile/$(1)/Description)"; \
70 ifeq ($(CONFIG_TARGET_$(call target_conf,$(BOARD)_$(if $(SUBTARGET),$(SUBTARGET)_)$(1))),y)
75 ifneq ($(PLATFORM_DIR),$(PLATFORM_SUBDIR))
76 define IncludeProfiles
77 -include $(PLATFORM_DIR)/profiles/*.mk
78 -include $(PLATFORM_SUBDIR)/profiles/*.mk
81 define IncludeProfiles
82 -include $(PLATFORM_DIR)/profiles/*.mk
86 ifeq ($(TARGET_BUILD),1)
87 $(eval $(call IncludeProfiles))
90 $(eval $(call IncludeProfiles))
94 $(eval $(call shexport,Target/Description))
96 include $(INCLUDE_DIR)/kernel-version.mk
98 GENERIC_PLATFORM_DIR := $(TOPDIR)/target/linux/generic-$(KERNEL)
99 GENERIC_PATCH_DIR := $(GENERIC_PLATFORM_DIR)/patches$(shell [ -d "$(GENERIC_PLATFORM_DIR)/patches-$(KERNEL_PATCHVER)" ] && printf -- "-$(KERNEL_PATCHVER)" || true )
101 GENERIC_LINUX_CONFIG?=$(firstword $(wildcard $(GENERIC_PLATFORM_DIR)/config-$(KERNEL_PATCHVER) $(GENERIC_PLATFORM_DIR)/config-default))
102 LINUX_CONFIG?=$(firstword $(wildcard $(foreach subdir,$(PLATFORM_DIR) $(PLATFORM_SUBDIR),$(subdir)/config-$(KERNEL_PATCHVER) $(subdir)/config-default)))
103 LINUX_SUBCONFIG?=$(firstword $(wildcard $(PLATFORM_SUBDIR)/config-$(KERNEL_PATCHVER) $(PLATFORM_SUBDIR)/config-default))
104 ifeq ($(LINUX_CONFIG),$(LINUX_SUBCONFIG))
107 LINUX_CONFCMD=$(if $(LINUX_CONFIG),$(SCRIPT_DIR)/kconfig.pl + $(GENERIC_LINUX_CONFIG) $(if $(LINUX_SUBCONFIG),+ $(LINUX_CONFIG) $(LINUX_SUBCONFIG),$(LINUX_CONFIG)),true)
110 BuildTarget=$(BuildTargets/DumpCurrent)
113 TMP_CONFIG:=$(TMP_DIR)/.kconfig-$(call target_conf,$(TARGETID))
114 $(TMP_CONFIG): $(GENERIC_LINUX_CONFIG) $(LINUX_CONFIG) $(LINUX_SUBCONFIG)
115 $(LINUX_CONFCMD) > $@ || rm -f $@
116 -include $(TMP_CONFIG)
117 .SILENT: $(TMP_CONFIG)
118 .PRECIOUS: $(TMP_CONFIG)
120 ifneq ($(CONFIG_PCI),)
123 ifneq ($(CONFIG_USB),)
126 ifneq ($(CONFIG_PCMCIA)$(CONFIG_PCCARD),)
131 FEATURES:=$(sort $(FEATURES))
135 define BuildTargets/DumpAll
137 @$(foreach SUBTARGET,$(KERNEL_TARGETS),$(SUBMAKE) -s DUMP=1 SUBTARGET=$(SUBTARGET); )
140 define BuildTargets/DumpCurrent
143 @echo 'Target: $(TARGETID)'; \
144 echo 'Target-Board: $(BOARD)'; \
145 echo 'Target-Kernel: $(KERNEL)'; \
146 echo 'Target-Name: $(BOARDNAME) [$(KERNEL)]'; \
147 echo 'Target-Path: $(subst $(TOPDIR)/,,$(PWD))'; \
148 echo 'Target-Arch: $(ARCH)'; \
149 echo 'Target-Features: $(FEATURES)'; \
150 echo 'Target-Depends: $(DEPENDS)'; \
151 echo 'Linux-Version: $(LINUX_VERSION)'; \
152 echo 'Linux-Release: $(LINUX_RELEASE)'; \
153 echo 'Linux-Kernel-Arch: $(LINUX_KARCH)'; \
154 echo 'Target-Description:'; \
155 getvar $(call shvar,Target/Description); \
157 echo 'Default-Packages: $(DEFAULT_PACKAGES)'; \
161 include $(INCLUDE_DIR)/kernel.mk
162 ifeq ($(TARGET_BUILD),1)
163 include $(INCLUDE_DIR)/kernel-build.mk
164 BuildTarget?=$(BuildKernel)