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))
26 ifneq ($(TARGET_BUILD),1)
27 include $(PLATFORM_DIR)/Makefile
28 ifneq ($(PLATFORM_DIR),$(PLATFORM_SUBDIR))
29 include $(PLATFORM_SUBDIR)/target.mk
33 -include ./$(SUBTARGET)/target.mk
37 define Profile/Default
43 $(eval $(call Profile/Default))
44 $(eval $(call Profile/$(1)))
45 $(eval $(call shexport,Profile/$(1)/Config))
46 $(eval $(call shexport,Profile/$(1)/Description))
48 echo "Target-Profile: $(1)"; \
49 echo "Target-Profile-Name: $(NAME)"; \
50 echo "Target-Profile-Packages: $(PACKAGES)"; \
51 if [ -f ./config/profile-$(1) ]; then \
52 echo "Target-Profile-Kconfig: yes"; \
54 echo "Target-Profile-Config: "; \
55 getvar "$(call shvar,Profile/$(1)/Config)"; \
57 echo "Target-Profile-Description:"; \
58 getvar "$(call shvar,Profile/$(1)/Description)"; \
61 ifeq ($(CONFIG_TARGET_$(call target_conf,$(BOARD)_$(if $(SUBTARGET),$(SUBTARGET)_)$(1))),y)
66 ifneq ($(PLATFORM_DIR),$(PLATFORM_SUBDIR))
67 define IncludeProfiles
68 -include $(PLATFORM_DIR)/profiles/*.mk
69 -include $(PLATFORM_SUBDIR)/profiles/*.mk
72 define IncludeProfiles
73 -include $(PLATFORM_DIR)/profiles/*.mk
77 ifeq ($(TARGET_BUILD),1)
78 $(eval $(call IncludeProfiles))
81 $(eval $(call IncludeProfiles))
85 $(eval $(call shexport,Target/Description))
87 include $(INCLUDE_DIR)/kernel-version.mk
89 GENERIC_PLATFORM_DIR := $(TOPDIR)/target/linux/generic-$(KERNEL)
90 GENERIC_PATCH_DIR := $(GENERIC_PLATFORM_DIR)/patches$(shell [ -d "$(GENERIC_PLATFORM_DIR)/patches-$(KERNEL_PATCHVER)" ] && printf -- "-$(KERNEL_PATCHVER)" || true )
92 GENERIC_LINUX_CONFIG?=$(firstword $(wildcard $(GENERIC_PLATFORM_DIR)/config-$(KERNEL_PATCHVER) $(GENERIC_PLATFORM_DIR)/config-default))
93 LINUX_CONFIG?=$(firstword $(wildcard $(foreach subdir,$(PLATFORM_DIR) $(PLATFORM_SUBDIR),$(subdir)/config-$(KERNEL_PATCHVER) $(subdir)/config-default)))
94 LINUX_SUBCONFIG?=$(firstword $(wildcard $(PLATFORM_SUBDIR)/config-$(KERNEL_PATCHVER) $(PLATFORM_SUBDIR)/config-default))
95 ifeq ($(LINUX_CONFIG),$(LINUX_SUBCONFIG))
98 LINUX_CONFCMD=$(if $(LINUX_CONFIG),$(SCRIPT_DIR)/kconfig.pl + $(GENERIC_LINUX_CONFIG) $(if $(LINUX_SUBCONFIG),+ $(LINUX_CONFIG) $(LINUX_SUBCONFIG),$(LINUX_CONFIG)),true)
101 BuildTarget=$(BuildTargets/DumpCurrent)
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)
111 ifneq ($(CONFIG_PCI),)
114 ifneq ($(CONFIG_USB),)
117 ifneq ($(CONFIG_PCMCIA)$(CONFIG_PCCARD),)
122 FEATURES:=$(sort $(FEATURES))
126 define BuildTargets/DumpCurrent
129 @echo 'Target: $(TARGETID)'; \
130 echo 'Target-Board: $(BOARD)'; \
131 echo 'Target-Kernel: $(KERNEL)'; \
132 echo 'Target-Name: $(BOARDNAME)$(if $(SUBTARGET),, [$(KERNEL)])'; \
133 echo 'Target-Path: $(subst $(TOPDIR)/,,$(PWD))'; \
134 echo 'Target-Arch: $(ARCH)'; \
135 echo 'Target-Features: $(FEATURES)'; \
136 echo 'Target-Depends: $(DEPENDS)'; \
137 echo 'Linux-Version: $(LINUX_VERSION)'; \
138 echo 'Linux-Release: $(LINUX_RELEASE)'; \
139 echo 'Linux-Kernel-Arch: $(LINUX_KARCH)'; \
140 echo 'Target-Description:'; \
141 getvar $(call shvar,Target/Description); \
143 echo 'Default-Packages: $(DEFAULT_PACKAGES)'; \
145 $(if $(SUBTARGET),,@$(foreach SUBTARGET,$(SUBTARGETS),$(SUBMAKE) -s DUMP=1 SUBTARGET=$(SUBTARGET); ))
148 include $(INCLUDE_DIR)/kernel.mk
149 ifeq ($(TARGET_BUILD),1)
150 include $(INCLUDE_DIR)/kernel-build.mk
151 BuildTarget?=$(BuildKernel)