omcproxy: silence fw3 warnings
[openwrt/openwrt.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-ipv6only 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 PRIORITY:=
63 PACKAGES:=
64 endef
65
66 ifndef Profile
67 define Profile
68 $(eval $(call ProfileDefault))
69 $(eval $(call Profile/$(1)))
70 dumpinfo : $(call shexport,Profile/$(1)/Description)
71 DUMPINFO += \
72 echo "Target-Profile: $(1)"; \
73 $(if $(PRIORITY), echo "Target-Profile-Priority: $(PRIORITY)"; ) \
74 echo "Target-Profile-Name: $(NAME)"; \
75 echo "Target-Profile-Packages: $(PACKAGES) $(call extra_packages,$(DEFAULT_PACKAGES) $(PACKAGES))"; \
76 echo "Target-Profile-Description:"; \
77 echo "$$$$$$$$$(call shvar,Profile/$(1)/Description)"; \
78 echo "@@"; \
79 echo;
80 endef
81 endif
82
83 ifneq ($(PLATFORM_DIR),$(PLATFORM_SUBDIR))
84 define IncludeProfiles
85 -include $(sort $(wildcard $(PLATFORM_DIR)/profiles/*.mk))
86 -include $(sort $(wildcard $(PLATFORM_SUBDIR)/profiles/*.mk))
87 endef
88 else
89 define IncludeProfiles
90 -include $(sort $(wildcard $(PLATFORM_DIR)/profiles/*.mk))
91 endef
92 endif
93
94 PROFILE?=$(call qstrip,$(CONFIG_TARGET_PROFILE))
95
96 ifeq ($(TARGET_BUILD),1)
97 ifneq ($(DUMP),)
98 $(eval $(call IncludeProfiles))
99 endif
100 endif
101
102 ifneq ($(TARGET_BUILD)$(if $(DUMP),,1),)
103 include $(INCLUDE_DIR)/kernel-version.mk
104 endif
105
106 GENERIC_PLATFORM_DIR := $(TOPDIR)/target/linux/generic
107 GENERIC_BACKPORT_DIR := $(GENERIC_PLATFORM_DIR)/backport$(if $(wildcard $(GENERIC_PLATFORM_DIR)/backport-$(KERNEL_PATCHVER)),-$(KERNEL_PATCHVER))
108 GENERIC_PATCH_DIR := $(GENERIC_PLATFORM_DIR)/pending$(if $(wildcard $(GENERIC_PLATFORM_DIR)/pending-$(KERNEL_PATCHVER)),-$(KERNEL_PATCHVER))
109 GENERIC_HACK_DIR := $(GENERIC_PLATFORM_DIR)/hack$(if $(wildcard $(GENERIC_PLATFORM_DIR)/hack-$(KERNEL_PATCHVER)),-$(KERNEL_PATCHVER))
110 GENERIC_FILES_DIR := $(foreach dir,$(wildcard $(GENERIC_PLATFORM_DIR)/files $(GENERIC_PLATFORM_DIR)/files-$(KERNEL_PATCHVER)),"$(dir)")
111
112 __config_name_list = $(1)/config-$(KERNEL_PATCHVER) $(1)/config-default
113 __config_list = $(firstword $(wildcard $(call __config_name_list,$(1))))
114 find_kernel_config=$(if $(__config_list),$(__config_list),$(lastword $(__config_name_list)))
115
116 GENERIC_LINUX_CONFIG = $(call find_kernel_config,$(GENERIC_PLATFORM_DIR))
117 LINUX_TARGET_CONFIG = $(call find_kernel_config,$(PLATFORM_DIR))
118 ifneq ($(PLATFORM_DIR),$(PLATFORM_SUBDIR))
119 LINUX_SUBTARGET_CONFIG = $(call find_kernel_config,$(PLATFORM_SUBDIR))
120 endif
121
122 # config file list used for compiling
123 LINUX_KCONFIG_LIST = $(wildcard $(GENERIC_LINUX_CONFIG) $(LINUX_TARGET_CONFIG) $(LINUX_SUBTARGET_CONFIG) $(TOPDIR)/env/kernel-config)
124
125 # default config list for reconfiguring
126 # defaults to subtarget if subtarget exists and target does not
127 # defaults to target otherwise
128 USE_SUBTARGET_CONFIG = $(if $(wildcard $(LINUX_TARGET_CONFIG)),,$(if $(LINUX_SUBTARGET_CONFIG),1))
129
130 LINUX_RECONFIG_LIST = $(wildcard $(GENERIC_LINUX_CONFIG) $(LINUX_TARGET_CONFIG) $(if $(USE_SUBTARGET_CONFIG),$(LINUX_SUBTARGET_CONFIG)))
131 LINUX_RECONFIG_TARGET = $(if $(USE_SUBTARGET_CONFIG),$(LINUX_SUBTARGET_CONFIG),$(LINUX_TARGET_CONFIG))
132
133 # select the config file to be changed by kernel_menuconfig/kernel_oldconfig
134 ifeq ($(CONFIG_TARGET),platform)
135 LINUX_RECONFIG_LIST = $(wildcard $(GENERIC_LINUX_CONFIG) $(LINUX_TARGET_CONFIG))
136 LINUX_RECONFIG_TARGET = $(LINUX_TARGET_CONFIG)
137 endif
138 ifeq ($(CONFIG_TARGET),subtarget)
139 LINUX_RECONFIG_LIST = $(wildcard $(GENERIC_LINUX_CONFIG) $(LINUX_TARGET_CONFIG) $(LINUX_SUBTARGET_CONFIG))
140 LINUX_RECONFIG_TARGET = $(LINUX_SUBTARGET_CONFIG)
141 endif
142 ifeq ($(CONFIG_TARGET),subtarget_platform)
143 LINUX_RECONFIG_LIST = $(wildcard $(GENERIC_LINUX_CONFIG) $(LINUX_SUBTARGET_CONFIG) $(LINUX_TARGET_CONFIG))
144 LINUX_RECONFIG_TARGET = $(LINUX_TARGET_CONFIG)
145 endif
146 ifeq ($(CONFIG_TARGET),env)
147 LINUX_RECONFIG_LIST = $(LINUX_KCONFIG_LIST)
148 LINUX_RECONFIG_TARGET = $(TOPDIR)/env/kernel-config
149 endif
150
151 __linux_confcmd = $(SCRIPT_DIR)/kconfig.pl $(2) $(patsubst %,+,$(wordlist 2,9999,$(1))) $(1)
152
153 LINUX_CONF_CMD = $(call __linux_confcmd,$(LINUX_KCONFIG_LIST),)
154 LINUX_RECONF_CMD = $(call __linux_confcmd,$(LINUX_RECONFIG_LIST),)
155 LINUX_RECONF_DIFF = $(call __linux_confcmd,$(filter-out $(LINUX_RECONFIG_TARGET),$(LINUX_RECONFIG_LIST)),'>')
156
157 ifeq ($(DUMP),1)
158 BuildTarget=$(BuildTargets/DumpCurrent)
159
160 CPU_CFLAGS = -Os -pipe
161 ifneq ($(findstring mips,$(ARCH)),)
162 ifneq ($(findstring mips64,$(ARCH)),)
163 CPU_TYPE ?= mips64
164 else
165 CPU_TYPE ?= mips32
166 endif
167 CPU_CFLAGS += -mno-branch-likely
168 CPU_CFLAGS_mips32 = -mips32 -mtune=mips32
169 CPU_CFLAGS_mips64 = -mips64 -mtune=mips64 -mabi=64
170 CPU_CFLAGS_24kc = -mips32r2 -mtune=24kc
171 CPU_CFLAGS_74kc = -mips32r2 -mtune=74kc
172 CPU_CFLAGS_octeon = -march=octeon -mabi=64
173 endif
174 ifeq ($(ARCH),i386)
175 CPU_TYPE ?= pentium
176 CPU_CFLAGS_pentium = -march=pentium-mmx
177 CPU_CFLAGS_pentium4 = -march=pentium4
178 endif
179 ifneq ($(findstring arm,$(ARCH)),)
180 CPU_TYPE ?= xscale
181 CPU_CFLAGS_arm920t = -mcpu=arm920t
182 CPU_CFLAGS_arm926ej-s = -mcpu=arm926ej-s
183 CPU_CFLAGS_arm1136j-s = -mcpu=arm1136j-s
184 CPU_CFLAGS_arm1176jzf-s = -mcpu=arm1176jzf-s
185 CPU_CFLAGS_cortex-a5 = -mcpu=cortex-a5
186 CPU_CFLAGS_cortex-a7 = -mcpu=cortex-a7
187 CPU_CFLAGS_cortex-a8 = -mcpu=cortex-a8
188 CPU_CFLAGS_cortex-a9 = -mcpu=cortex-a9
189 CPU_CFLAGS_cortex-a15 = -mcpu=cortex-a15
190 CPU_CFLAGS_cortex-a53 = -mcpu=cortex-a53
191 CPU_CFLAGS_fa526 = -mcpu=fa526
192 CPU_CFLAGS_mpcore = -mcpu=mpcore
193 CPU_CFLAGS_xscale = -mcpu=xscale
194 ifeq ($(CONFIG_SOFT_FLOAT),)
195 CPU_CFLAGS_neon = -mfpu=neon
196 CPU_CFLAGS_vfp = -mfpu=vfp
197 CPU_CFLAGS_vfpv3 = -mfpu=vfpv3-d16
198 CPU_CFLAGS_neon-vfpv4 = -mfpu=neon-vfpv4
199 endif
200 endif
201 ifeq ($(ARCH),powerpc)
202 CPU_CFLAGS_603e:=-mcpu=603e
203 CPU_CFLAGS_8540:=-mcpu=8540
204 CPU_CFLAGS_405:=-mcpu=405
205 CPU_CFLAGS_440:=-mcpu=440
206 CPU_CFLAGS_464fp:=-mcpu=464fp
207 endif
208 ifeq ($(ARCH),powerpc64)
209 CPU_TYPE ?= powerpc64
210 CPU_CFLAGS_powerpc64:=-mcpu=powerpc64
211 endif
212 ifeq ($(ARCH),sparc)
213 CPU_TYPE = sparc
214 CPU_CFLAGS_ultrasparc = -mcpu=ultrasparc
215 endif
216 ifeq ($(ARCH),aarch64)
217 CPU_TYPE ?= generic
218 CPU_CFLAGS_generic = -mcpu=generic
219 CPU_CFLAGS_cortex-a53 = -mcpu=cortex-a53
220 endif
221 ifeq ($(ARCH),arc)
222 CPU_TYPE ?= arc700
223 CPU_CFLAGS += -matomic
224 CPU_CFLAGS_arc700 = -mcpu=arc700
225 CPU_CFLAGS_archs = -mcpu=archs
226 endif
227 ifneq ($(CPU_TYPE),)
228 ifndef CPU_CFLAGS_$(CPU_TYPE)
229 $(warning CPU_TYPE "$(CPU_TYPE)" doesn't correspond to a known type)
230 endif
231 endif
232 DEFAULT_CFLAGS=$(strip $(CPU_CFLAGS) $(CPU_CFLAGS_$(CPU_TYPE)) $(CPU_CFLAGS_$(CPU_SUBTYPE)))
233
234 ifneq ($(BOARD),)
235 TMP_CONFIG:=$(TMP_DIR)/.kconfig-$(call target_conf,$(TARGETID))
236 $(TMP_CONFIG): $(LINUX_KCONFIG_LIST)
237 $(LINUX_CONF_CMD) > $@ || rm -f $@
238 -include $(TMP_CONFIG)
239 .SILENT: $(TMP_CONFIG)
240 .PRECIOUS: $(TMP_CONFIG)
241
242 ifneq ($(CONFIG_OF),)
243 FEATURES += dt
244 endif
245 ifneq ($(CONFIG_GENERIC_GPIO)$(CONFIG_GPIOLIB),)
246 FEATURES += gpio
247 endif
248 ifneq ($(CONFIG_PCI),)
249 FEATURES += pci
250 endif
251 ifneq ($(CONFIG_PCIEPORTBUS),)
252 FEATURES += pcie
253 endif
254 ifneq ($(CONFIG_USB)$(CONFIG_USB_SUPPORT),)
255 ifneq ($(CONFIG_USB_ARCH_HAS_HCD)$(CONFIG_USB_EHCI_HCD),)
256 FEATURES += usb
257 endif
258 endif
259 ifneq ($(CONFIG_PCMCIA)$(CONFIG_PCCARD),)
260 FEATURES += pcmcia
261 endif
262 ifneq ($(CONFIG_VGA_CONSOLE)$(CONFIG_FB),)
263 FEATURES += display
264 endif
265 ifneq ($(CONFIG_RTC_CLASS),)
266 FEATURES += rtc
267 endif
268 ifneq ($(CONFIG_VIRTIO),)
269 FEATURES += virtio
270 endif
271 ifneq ($(CONFIG_CPU_MIPS32_R2),)
272 ifneq ($(CPU_SUBTYPE),nomips16)
273 FEATURES += mips16
274 endif
275 endif
276 FEATURES += $(foreach v,6 7,$(if $(CONFIG_CPU_V$(v)),arm_v$(v)))
277
278 # remove duplicates
279 FEATURES:=$(sort $(FEATURES))
280 endif
281 endif
282
283 CUR_SUBTARGET:=$(SUBTARGET)
284 ifeq ($(SUBTARGETS),)
285 CUR_SUBTARGET := default
286 endif
287
288 define BuildTargets/DumpCurrent
289 .PHONY: dumpinfo
290 dumpinfo : export DESCRIPTION=$$(Target/Description)
291 dumpinfo:
292 @echo 'Target: $(TARGETID)'; \
293 echo 'Target-Board: $(BOARD)'; \
294 echo 'Target-Name: $(BOARDNAME)$(if $(SUBTARGETS),$(if $(SUBTARGET),))'; \
295 echo 'Target-Arch: $(ARCH)'; \
296 echo 'Target-Arch-Packages: $(if $(ARCH_PACKAGES),$(ARCH_PACKAGES),$(ARCH)$(if $(CPU_TYPE),_$(CPU_TYPE))$(if $(CPU_SUBTYPE),_$(CPU_SUBTYPE)))'; \
297 echo 'Target-Features: $(FEATURES)'; \
298 echo 'Target-Depends: $(DEPENDS)'; \
299 echo 'Target-Optimization: $(if $(CFLAGS),$(CFLAGS),$(DEFAULT_CFLAGS))'; \
300 echo 'CPU-Type: $(CPU_TYPE)$(if $(CPU_SUBTYPE),+$(CPU_SUBTYPE))'; \
301 echo 'Linux-Version: $(LINUX_VERSION)'; \
302 echo 'Linux-Release: $(LINUX_RELEASE)'; \
303 echo 'Linux-Kernel-Arch: $(LINUX_KARCH)'; \
304 $(if $(SUBTARGET),,$(if $(DEFAULT_SUBTARGET), echo 'Default-Subtarget: $(DEFAULT_SUBTARGET)'; )) \
305 echo 'Target-Description:'; \
306 echo "$$$$DESCRIPTION"; \
307 echo '@@'; \
308 echo 'Default-Packages: $(DEFAULT_PACKAGES) $(call extra_packages,$(DEFAULT_PACKAGES))'; \
309 $(DUMPINFO)
310 $(if $(CUR_SUBTARGET),$(SUBMAKE) -r --no-print-directory -C image -s DUMP=1 SUBTARGET=$(CUR_SUBTARGET))
311 $(if $(SUBTARGET),,@$(foreach SUBTARGET,$(SUBTARGETS),$(SUBMAKE) -s DUMP=1 SUBTARGET=$(SUBTARGET); ))
312 endef
313
314 include $(INCLUDE_DIR)/kernel.mk
315 ifeq ($(TARGET_BUILD),1)
316 include $(INCLUDE_DIR)/kernel-build.mk
317 BuildTarget?=$(BuildKernel)
318 endif
319
320 endif #__target_inc