[usb]: make musb available for omap as well
[openwrt/svn-archive/archive.git] / include / target.mk
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
8 ifneq ($(__target_inc),1)
9 __target_inc=1
10
11 # default device type
12 DEVICE_TYPE?=router
13
14 # Default packages - the really basic set
15 DEFAULT_PACKAGES:=base-files libc libgcc busybox dropbear mtd uci opkg netifd
16 # For router targets
17 DEFAULT_PACKAGES.router:=dnsmasq iptables ip6tables ppp ppp-mod-pppoe kmod-ipt-nathelper firewall odhcpd odhcp6c
18 DEFAULT_PACKAGES.bootloader:=
19
20 ifneq ($(DUMP),)
21 all: dumpinfo
22 endif
23
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 ifeq ($(SUBTARGETS),)
31 SUBTARGETS:=$(strip $(patsubst $(PLATFORM_DIR)/%/target.mk,%,$(wildcard $(PLATFORM_DIR)/*/target.mk)))
32 endif
33 endif
34
35 TARGETID:=$(BOARD)$(if $(SUBTARGET),/$(SUBTARGET))
36 PLATFORM_SUBDIR:=$(PLATFORM_DIR)$(if $(SUBTARGET),/$(SUBTARGET))
37
38 ifneq ($(TARGET_BUILD),1)
39 ifndef DUMP
40 include $(PLATFORM_DIR)/Makefile
41 ifneq ($(PLATFORM_DIR),$(PLATFORM_SUBDIR))
42 include $(PLATFORM_SUBDIR)/target.mk
43 endif
44 endif
45 else
46 ifneq ($(SUBTARGET),)
47 -include ./$(SUBTARGET)/target.mk
48 endif
49 endif
50
51 # Add device specific packages (here below to allow device type set from subtarget)
52 DEFAULT_PACKAGES += $(DEFAULT_PACKAGES.$(DEVICE_TYPE))
53
54 define Profile/Default
55 NAME:=
56 PACKAGES:=
57 endef
58
59 ifndef Profile
60 define Profile
61 $(eval $(call Profile/Default))
62 $(eval $(call Profile/$(1)))
63 $(eval $(call shexport,Profile/$(1)/Config))
64 $(eval $(call shexport,Profile/$(1)/Description))
65 DUMPINFO += \
66 echo "Target-Profile: $(1)"; \
67 echo "Target-Profile-Name: $(NAME)"; \
68 echo "Target-Profile-Packages: $(PACKAGES)"; \
69 if [ -f ./config/profile-$(1) ]; then \
70 echo "Target-Profile-Kconfig: yes"; \
71 fi; \
72 echo "Target-Profile-Config: "; \
73 $(SH_FUNC) getvar "$(call shvar,Profile/$(1)/Config)"; \
74 echo "@@"; \
75 echo "Target-Profile-Description:"; \
76 $(SH_FUNC) getvar "$(call shvar,Profile/$(1)/Description)"; \
77 echo "@@"; \
78 echo;
79 ifeq ($(CONFIG_TARGET_$(call target_conf,$(BOARD)_$(if $(SUBTARGET),$(SUBTARGET)_))$(1)),y)
80 PROFILE=$(1)
81 endif
82 endef
83 endif
84
85 ifneq ($(PLATFORM_DIR),$(PLATFORM_SUBDIR))
86 define IncludeProfiles
87 -include $(sort $(wildcard $(PLATFORM_DIR)/profiles/*.mk))
88 -include $(sort $(wildcard $(PLATFORM_SUBDIR)/profiles/*.mk))
89 endef
90 else
91 define IncludeProfiles
92 -include $(sort $(wildcard $(PLATFORM_DIR)/profiles/*.mk))
93 endef
94 endif
95
96 ifeq ($(TARGET_BUILD),1)
97 $(eval $(call IncludeProfiles))
98 else
99 ifeq ($(DUMP),)
100 $(eval $(call IncludeProfiles))
101 endif
102 endif
103
104 $(eval $(call shexport,Target/Description))
105
106 ifneq ($(TARGET_BUILD)$(if $(DUMP),,1),)
107 include $(INCLUDE_DIR)/kernel-version.mk
108 endif
109
110 GENERIC_PLATFORM_DIR := $(TOPDIR)/target/linux/generic
111 GENERIC_PATCH_DIR := $(GENERIC_PLATFORM_DIR)/patches$(if $(wildcard $(GENERIC_PLATFORM_DIR)/patches-$(KERNEL_PATCHVER)),-$(KERNEL_PATCHVER))
112 GENERIC_FILES_DIR := $(foreach dir,$(wildcard $(GENERIC_PLATFORM_DIR)/files $(GENERIC_PLATFORM_DIR)/files-$(KERNEL_PATCHVER)),"$(dir)")
113
114 __config_name_list = $(1)/config-$(KERNEL_PATCHVER) $(1)/config-default
115 __config_list = $(firstword $(wildcard $(call __config_name_list,$(1))))
116 find_kernel_config=$(if $(__config_list),$(__config_list),$(lastword $(__config_name_list)))
117
118 GENERIC_LINUX_CONFIG = $(call find_kernel_config,$(GENERIC_PLATFORM_DIR))
119 LINUX_TARGET_CONFIG = $(call find_kernel_config,$(PLATFORM_DIR))
120 ifneq ($(PLATFORM_DIR),$(PLATFORM_SUBDIR))
121 LINUX_SUBTARGET_CONFIG = $(call find_kernel_config,$(PLATFORM_SUBDIR))
122 endif
123
124 # config file list used for compiling
125 LINUX_KCONFIG_LIST = $(wildcard $(GENERIC_LINUX_CONFIG) $(LINUX_TARGET_CONFIG) $(LINUX_SUBTARGET_CONFIG) $(TOPDIR)/env/kernel-config)
126
127 # default config list for reconfiguring
128 # defaults to subtarget if subtarget exists and target does not
129 # defaults to target otherwise
130 USE_SUBTARGET_CONFIG = $(if $(wildcard $(LINUX_TARGET_CONFIG)),,$(if $(LINUX_SUBTARGET_CONFIG),1))
131
132 LINUX_RECONFIG_LIST = $(wildcard $(GENERIC_LINUX_CONFIG) $(LINUX_TARGET_CONFIG) $(if $(USE_SUBTARGET_CONFIG),$(LINUX_SUBTARGET_CONFIG)))
133 LINUX_RECONFIG_TARGET = $(if $(USE_SUBTARGET_CONFIG),$(LINUX_SUBTARGET_CONFIG),$(LINUX_TARGET_CONFIG))
134
135 # select the config file to be changed by kernel_menuconfig/kernel_oldconfig
136 ifeq ($(CONFIG_TARGET),platform)
137 LINUX_RECONFIG_LIST = $(wildcard $(GENERIC_LINUX_CONFIG) $(LINUX_TARGET_CONFIG))
138 LINUX_RECONFIG_TARGET = $(LINUX_TARGET_CONFIG)
139 endif
140 ifeq ($(CONFIG_TARGET),subtarget)
141 LINUX_RECONFIG_LIST = $(wildcard $(GENERIC_LINUX_CONFIG) $(LINUX_TARGET_CONFIG) $(LINUX_SUBTARGET_CONFIG))
142 LINUX_RECONFIG_TARGET = $(LINUX_SUBTARGET_CONFIG)
143 endif
144 ifeq ($(CONFIG_TARGET),subtarget_platform)
145 LINUX_RECONFIG_LIST = $(wildcard $(GENERIC_LINUX_CONFIG) $(LINUX_SUBTARGET_CONFIG) $(LINUX_TARGET_CONFIG))
146 LINUX_RECONFIG_TARGET = $(LINUX_TARGET_CONFIG)
147 endif
148 ifeq ($(CONFIG_TARGET),env)
149 LINUX_RECONFIG_LIST = $(LINUX_KCONFIG_LIST)
150 LINUX_RECONFIG_TARGET = $(TOPDIR)/env/kernel-config
151 endif
152
153 __linux_confcmd = $(SCRIPT_DIR)/kconfig.pl $(2) $(patsubst %,+,$(wordlist 2,9999,$(1))) $(1)
154
155 LINUX_CONF_CMD = $(call __linux_confcmd,$(LINUX_KCONFIG_LIST),)
156 LINUX_RECONF_CMD = $(call __linux_confcmd,$(LINUX_RECONFIG_LIST),)
157 LINUX_RECONF_DIFF = $(call __linux_confcmd,$(filter-out $(LINUX_RECONFIG_TARGET),$(LINUX_RECONFIG_LIST)),'>')
158
159 ifeq ($(DUMP),1)
160 BuildTarget=$(BuildTargets/DumpCurrent)
161
162 ifneq ($(BOARD),)
163 TMP_CONFIG:=$(TMP_DIR)/.kconfig-$(call target_conf,$(TARGETID))
164 $(TMP_CONFIG): $(LINUX_KCONFIG_LIST)
165 $(LINUX_CONF_CMD) > $@ || rm -f $@
166 -include $(TMP_CONFIG)
167 .SILENT: $(TMP_CONFIG)
168 .PRECIOUS: $(TMP_CONFIG)
169
170 ifneq ($(CONFIG_OF),)
171 FEATURES += dt
172 endif
173 ifneq ($(CONFIG_GENERIC_GPIO)$(CONFIG_GPIOLIB),)
174 FEATURES += gpio
175 endif
176 ifneq ($(CONFIG_PCI),)
177 FEATURES += pci
178 endif
179 ifneq ($(CONFIG_PCIEPORTBUS),)
180 FEATURES += pcie
181 endif
182 ifneq ($(CONFIG_USB)$(CONFIG_USB_SUPPORT),)
183 ifneq ($(CONFIG_USB_ARCH_HAS_HCD)$(CONFIG_USB_EHCI_HCD),)
184 FEATURES += usb
185 endif
186 endif
187 ifneq ($(CONFIG_PCMCIA)$(CONFIG_PCCARD),)
188 FEATURES += pcmcia
189 endif
190 ifneq ($(CONFIG_VGA_CONSOLE)$(CONFIG_FB),)
191 FEATURES += display
192 endif
193 ifneq ($(CONFIG_RTC_CLASS),)
194 FEATURES += rtc
195 endif
196 FEATURES += $(foreach v,v4 v5 v6 v7,$(if $(findstring -march=arm$(v),$(CFLAGS)),arm_$(v)))
197
198 # remove duplicates
199 FEATURES:=$(sort $(FEATURES))
200 endif
201 CPU_CFLAGS = -Os -pipe
202 ifneq ($(findstring mips,$(ARCH)),)
203 ifneq ($(findstring mips64,$(ARCH)),)
204 CPU_TYPE ?= mips64
205 else
206 CPU_TYPE ?= mips32
207 endif
208 CPU_CFLAGS += -mno-branch-likely
209 CPU_CFLAGS_mips32 = -mips32 -mtune=mips32
210 CPU_CFLAGS_mips32r2 = -mips32r2 -mtune=mips32r2
211 CPU_CFLAGS_mips64 = -mips64 -mtune=mips64 -mabi=64
212 CPU_CFLAGS_24kec = -mips32r2 -mtune=24kec
213 CPU_CFLAGS_34kc = -mips32r2 -mtune=34kc
214 CPU_CFLAGS_dsp = -mdsp
215 CPU_CFLAGS_dsp2 = -mdspr2
216 endif
217 ifeq ($(ARCH),i386)
218 CPU_TYPE ?= i486
219 CPU_CFLAGS_i486 = -march=i486
220 CPU_CFLAGS_geode = -march=geode -mmmx -m3dnow
221 endif
222 ifneq ($(findstring arm,$(ARCH)),)
223 CPU_TYPE ?= xscale
224 CPU_CFLAGS_arm920t = -march=armv4t -mtune=arm920t
225 CPU_CFLAGS_arm926ej-s = -march=armv5te -mtune=arm926ej-s
226 CPU_CFLAGS_arm1136j-s = -march=armv6 -mtune=arm1136j-s
227 CPU_CFLAGS_arm1176jzf-s = -march=armv6 -mtune=arm1176jzf-s
228 CPU_CFLAGS_cortex-a7 = -march=armv7-a -mtune=cortex-a7
229 CPU_CFLAGS_cortex-a8 = -march=armv7-a -mtune=cortex-a8
230 CPU_CFLAGS_cortex-a9 = -march=armv7-a -mtune=cortex-a9
231 CPU_CFLAGS_fa526 = -march=armv4 -mtune=fa526
232 CPU_CFLAGS_mpcore = -march=armv6k -mtune=mpcore
233 CPU_CFLAGS_xscale = -march=armv5te -mtune=xscale
234 ifneq ($(CONFIG_SOFT_FLOAT),)
235 CPU_CFLAGS_vfp = -mfpu=vfp
236 CPU_CFLAGS_vfpv3 = -mfpu=vfpv3-d16
237 endif
238 endif
239 ifeq ($(ARCH),powerpc)
240 CPU_CFLAGS_603e:=-mcpu=603e
241 CPU_CFLAGS_8540:=-mcpu=8540
242 CPU_CFLAGS_405:=-mcpu=405
243 CPU_CFLAGS_440:=-mcpu=440
244 endif
245 ifeq ($(ARCH),sparc)
246 CPU_TYPE = sparc
247 CPU_CFLAGS_ultrasparc = -mcpu=ultrasparc
248 endif
249 DEFAULT_CFLAGS=$(strip $(CPU_CFLAGS) $(CPU_CFLAGS_$(CPU_TYPE)) $(CPU_CFLAGS_$(CPU_SUBTYPE)))
250 endif
251
252 define BuildTargets/DumpCurrent
253 .PHONY: dumpinfo
254 dumpinfo:
255 @echo 'Target: $(TARGETID)'; \
256 echo 'Target-Board: $(BOARD)'; \
257 echo 'Target-Name: $(BOARDNAME)$(if $(SUBTARGETS),$(if $(SUBTARGET),))'; \
258 echo 'Target-Path: $(subst $(TOPDIR)/,,$(PWD))'; \
259 echo 'Target-Arch: $(ARCH)'; \
260 echo 'Target-Arch-Packages: $(if $(ARCH_PACKAGES),$(ARCH_PACKAGES),$(BOARD))'; \
261 echo 'Target-Features: $(FEATURES)'; \
262 echo 'Target-Depends: $(DEPENDS)'; \
263 echo 'Target-Optimization: $(if $(CFLAGS),$(CFLAGS),$(DEFAULT_CFLAGS))'; \
264 echo 'CPU-Type: $(CPU_TYPE)$(if $(CPU_SUBTYPE),+$(CPU_SUBTYPE))'; \
265 echo 'Linux-Version: $(LINUX_VERSION)'; \
266 echo 'Linux-Release: $(LINUX_RELEASE)'; \
267 echo 'Linux-Kernel-Arch: $(LINUX_KARCH)'; \
268 $(if $(SUBTARGET),,$(if $(DEFAULT_SUBTARGET), echo 'Default-Subtarget: $(DEFAULT_SUBTARGET)'; ))
269 echo 'Target-Description:'; \
270 $(SH_FUNC) getvar $(call shvar,Target/Description); \
271 echo '@@'; \
272 echo 'Default-Packages: $(DEFAULT_PACKAGES)'; \
273 $(DUMPINFO)
274 $(if $(SUBTARGET),,@$(foreach SUBTARGET,$(SUBTARGETS),$(SUBMAKE) -s DUMP=1 SUBTARGET=$(SUBTARGET); ))
275 endef
276
277 include $(INCLUDE_DIR)/kernel.mk
278 ifeq ($(TARGET_BUILD),1)
279 include $(INCLUDE_DIR)/kernel-build.mk
280 BuildTarget?=$(BuildKernel)
281 endif
282
283 endif #__target_inc