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