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