2 # Copyright (C) 2007-2008 OpenWrt.org
3 # Copyright (C) 2016 LEDE Project
5 # This is free software, licensed under the GNU General Public License v2.
6 # See /LICENSE for more information.
9 ifneq ($(__target_inc
),1)
15 # Default packages - the really basic set
34 DEFAULT_PACKAGES.basic
:=
36 DEFAULT_PACKAGES.nas
:=\
42 DEFAULT_PACKAGES.router
:=\
57 target_conf
=$(subst .
,_
,$(subst -,_
,$(subst /,_
,$(1))))
59 PLATFORM_DIR
:=$(TOPDIR
)/target
/linux
/$(BOARD
)
60 SUBTARGET
:=$(strip $(foreach subdir
,$(patsubst $(PLATFORM_DIR
)/%/target.mk
,%,$(wildcard $(PLATFORM_DIR
)/*/target.mk
)),$(if
$(CONFIG_TARGET_
$(call target_conf
,$(BOARD
)_
$(subdir
))),$(subdir
))))
62 PLATFORM_DIR
:=${CURDIR}
64 SUBTARGETS
:=$(strip $(patsubst $(PLATFORM_DIR
)/%/target.mk
,%,$(wildcard $(PLATFORM_DIR
)/*/target.mk
)))
68 TARGETID
:=$(BOARD
)$(if
$(SUBTARGET
),/$(SUBTARGET
))
69 PLATFORM_SUBDIR
:=$(PLATFORM_DIR
)$(if
$(SUBTARGET
),/$(SUBTARGET
))
71 ifneq ($(TARGET_BUILD
),1)
73 include $(PLATFORM_DIR
)/Makefile
74 ifneq ($(PLATFORM_DIR
),$(PLATFORM_SUBDIR
))
75 include $(PLATFORM_SUBDIR
)/target.mk
80 -include .
/$(SUBTARGET
)/target.mk
84 # Add device specific packages (here below to allow device type set from subtarget)
85 DEFAULT_PACKAGES
+= $(DEFAULT_PACKAGES.
$(DEVICE_TYPE
))
87 filter_packages
= $(filter-out -% $(patsubst -%,%,$(filter -%,$(1))),$(1))
88 extra_packages
= $(if
$(filter wpad-mini wpad-basic wpad-basic-wolfssl wpad nas
,$(1)),iwinfo
)
98 $(eval
$(call ProfileDefault
))
99 $(eval
$(call Profile
/$(1)))
100 dumpinfo
: $(call shexport
,Profile
/$(1)/Description
)
101 PACKAGES
:= $(filter-out -%,$(PACKAGES
))
103 echo
"Target-Profile: $(1)"; \
104 $(if
$(PRIORITY
), echo
"Target-Profile-Priority: $(PRIORITY)"; ) \
105 echo
"Target-Profile-Name: $(NAME)"; \
106 echo
"Target-Profile-Packages: $(PACKAGES) $(call extra_packages,$(DEFAULT_PACKAGES) $(PACKAGES))"; \
107 echo
"Target-Profile-Description:"; \
108 echo
"$$$$$$$$$(call shvar,Profile/$(1)/Description)"; \
114 ifneq ($(PLATFORM_DIR
),$(PLATFORM_SUBDIR
))
115 define IncludeProfiles
116 -include $(sort $(wildcard $(PLATFORM_DIR
)/profiles
/*.mk
))
117 -include $(sort $(wildcard $(PLATFORM_SUBDIR
)/profiles
/*.mk
))
120 define IncludeProfiles
121 -include $(sort $(wildcard $(PLATFORM_DIR
)/profiles
/*.mk
))
125 PROFILE?
=$(call qstrip
,$(CONFIG_TARGET_PROFILE
))
127 ifeq ($(TARGET_BUILD
),1)
129 $(eval
$(call IncludeProfiles
))
133 ifneq ($(TARGET_BUILD
)$(if
$(DUMP
),,1),)
134 include $(INCLUDE_DIR
)/kernel-version.mk
137 GENERIC_PLATFORM_DIR
:= $(TOPDIR
)/target
/linux
/generic
138 GENERIC_BACKPORT_DIR
:= $(GENERIC_PLATFORM_DIR
)/backport
$(if
$(wildcard $(GENERIC_PLATFORM_DIR
)/backport-
$(KERNEL_PATCHVER
)),-$(KERNEL_PATCHVER
))
139 GENERIC_PATCH_DIR
:= $(GENERIC_PLATFORM_DIR
)/pending
$(if
$(wildcard $(GENERIC_PLATFORM_DIR
)/pending-
$(KERNEL_PATCHVER
)),-$(KERNEL_PATCHVER
))
140 GENERIC_HACK_DIR
:= $(GENERIC_PLATFORM_DIR
)/hack
$(if
$(wildcard $(GENERIC_PLATFORM_DIR
)/hack-
$(KERNEL_PATCHVER
)),-$(KERNEL_PATCHVER
))
141 GENERIC_FILES_DIR
:= $(foreach dir,$(wildcard $(GENERIC_PLATFORM_DIR
)/files
$(GENERIC_PLATFORM_DIR
)/files-
$(KERNEL_PATCHVER
)),"$(dir)")
143 __config_name_list
= $(1)/config-
$(KERNEL_PATCHVER
) $(1)/config-default
144 __config_list
= $(firstword $(wildcard $(call __config_name_list
,$(1))))
145 find_kernel_config
=$(if
$(__config_list
),$(__config_list
),$(lastword
$(__config_name_list
)))
147 GENERIC_LINUX_CONFIG
= $(call find_kernel_config
,$(GENERIC_PLATFORM_DIR
))
148 LINUX_TARGET_CONFIG
= $(call find_kernel_config
,$(PLATFORM_DIR
))
149 ifneq ($(PLATFORM_DIR
),$(PLATFORM_SUBDIR
))
150 LINUX_SUBTARGET_CONFIG
= $(call find_kernel_config
,$(PLATFORM_SUBDIR
))
153 # config file list used for compiling
154 LINUX_KCONFIG_LIST
= $(wildcard $(GENERIC_LINUX_CONFIG
) $(LINUX_TARGET_CONFIG
) $(LINUX_SUBTARGET_CONFIG
) $(TOPDIR
)/env
/kernel-config
)
156 # default config list for reconfiguring
157 # defaults to subtarget if subtarget exists and target does not
158 # defaults to target otherwise
159 USE_SUBTARGET_CONFIG
= $(if
$(wildcard $(LINUX_TARGET_CONFIG
)),,$(if
$(LINUX_SUBTARGET_CONFIG
),1))
161 LINUX_RECONFIG_LIST
= $(wildcard $(GENERIC_LINUX_CONFIG
) $(LINUX_TARGET_CONFIG
) $(if
$(USE_SUBTARGET_CONFIG
),$(LINUX_SUBTARGET_CONFIG
)))
162 LINUX_RECONFIG_TARGET
= $(if
$(USE_SUBTARGET_CONFIG
),$(LINUX_SUBTARGET_CONFIG
),$(LINUX_TARGET_CONFIG
))
164 # select the config file to be changed by kernel_menuconfig/kernel_oldconfig
165 ifeq ($(CONFIG_TARGET
),platform
)
166 LINUX_RECONFIG_LIST
= $(wildcard $(GENERIC_LINUX_CONFIG
) $(LINUX_TARGET_CONFIG
))
167 LINUX_RECONFIG_TARGET
= $(LINUX_TARGET_CONFIG
)
169 ifeq ($(CONFIG_TARGET
),subtarget
)
170 LINUX_RECONFIG_LIST
= $(wildcard $(GENERIC_LINUX_CONFIG
) $(LINUX_TARGET_CONFIG
) $(LINUX_SUBTARGET_CONFIG
))
171 LINUX_RECONFIG_TARGET
= $(LINUX_SUBTARGET_CONFIG
)
173 ifeq ($(CONFIG_TARGET
),subtarget_platform
)
174 LINUX_RECONFIG_LIST
= $(wildcard $(GENERIC_LINUX_CONFIG
) $(LINUX_SUBTARGET_CONFIG
) $(LINUX_TARGET_CONFIG
))
175 LINUX_RECONFIG_TARGET
= $(LINUX_TARGET_CONFIG
)
177 ifeq ($(CONFIG_TARGET
),env
)
178 LINUX_RECONFIG_LIST
= $(LINUX_KCONFIG_LIST
)
179 LINUX_RECONFIG_TARGET
= $(TOPDIR
)/env
/kernel-config
182 __linux_confcmd
= $(SCRIPT_DIR
)/kconfig.pl
$(2) $(patsubst %,+,$(wordlist
2,9999,$(1))) $(1)
184 LINUX_CONF_CMD
= $(call __linux_confcmd
,$(LINUX_KCONFIG_LIST
),)
185 LINUX_RECONF_CMD
= $(call __linux_confcmd
,$(LINUX_RECONFIG_LIST
),)
186 LINUX_RECONF_DIFF
= $(call __linux_confcmd
,$(filter-out $(LINUX_RECONFIG_TARGET
),$(LINUX_RECONFIG_LIST
)),'>')
189 BuildTarget
=$(BuildTargets
/DumpCurrent
)
191 CPU_CFLAGS
= -Os
-pipe
192 ifneq ($(findstring mips
,$(ARCH
)),)
193 ifneq ($(findstring mips64
,$(ARCH
)),)
198 CPU_CFLAGS
+= -mno-branch-likely
199 CPU_CFLAGS_mips32
= -mips32
-mtune
=mips32
200 CPU_CFLAGS_mips64
= -mips64
-mtune
=mips64
-mabi
=64
201 CPU_CFLAGS_24kc
= -mips32r2
-mtune
=24kc
202 CPU_CFLAGS_74kc
= -mips32r2
-mtune
=74kc
203 CPU_CFLAGS_octeonplus
= -march
=octeon
+ -mabi
=64
206 CPU_TYPE ?
= pentium-mmx
207 CPU_CFLAGS_pentium-mmx
= -march
=pentium-mmx
208 CPU_CFLAGS_pentium4
= -march
=pentium4
210 ifneq ($(findstring arm
,$(ARCH
)),)
213 ifeq ($(ARCH
),powerpc
)
214 CPU_CFLAGS_603e
:=-mcpu
=603e
215 CPU_CFLAGS_8540
:=-mcpu
=8540
216 CPU_CFLAGS_405
:=-mcpu
=405
217 CPU_CFLAGS_440
:=-mcpu
=440
218 CPU_CFLAGS_464fp
:=-mcpu
=464fp
220 ifeq ($(ARCH
),powerpc64
)
221 CPU_TYPE ?
= powerpc64
222 CPU_CFLAGS_powerpc64
:=-mcpu
=powerpc64
226 CPU_CFLAGS_ultrasparc
= -mcpu
=ultrasparc
228 ifeq ($(ARCH
),aarch64
)
230 CPU_CFLAGS_generic
= -mcpu
=generic
231 CPU_CFLAGS_cortex-a53
= -mcpu
=cortex-a53
235 CPU_CFLAGS
+= -matomic
236 CPU_CFLAGS_arc700
= -mcpu
=arc700
237 CPU_CFLAGS_archs
= -mcpu
=archs
240 ifndef CPU_CFLAGS_
$(CPU_TYPE
)
241 $(warning CPU_TYPE
"$(CPU_TYPE)" doesn
't correspond to a known type)
244 DEFAULT_CFLAGS=$(strip $(CPU_CFLAGS) $(CPU_CFLAGS_$(CPU_TYPE)) $(CPU_CFLAGS_$(CPU_SUBTYPE)))
247 TMP_CONFIG:=$(TMP_DIR)/.kconfig-$(call target_conf,$(TARGETID))
248 $(TMP_CONFIG): $(LINUX_KCONFIG_LIST)
249 $(LINUX_CONF_CMD) > $@ || rm -f $@
250 -include $(TMP_CONFIG)
251 .SILENT: $(TMP_CONFIG)
252 .PRECIOUS: $(TMP_CONFIG)
254 ifdef KERNEL_TESTING_PATCHVER
255 ifneq ($(KERNEL_TESTING_PATCHVER),$(KERNEL_PATCHVER))
256 FEATURES += testing-kernel
259 ifneq ($(CONFIG_OF),)
262 ifneq ($(CONFIG_GENERIC_GPIO)$(CONFIG_GPIOLIB),)
265 ifneq ($(CONFIG_PCI),)
268 ifneq ($(CONFIG_PCIEPORTBUS),)
271 ifneq ($(CONFIG_USB)$(CONFIG_USB_SUPPORT),)
272 ifneq ($(CONFIG_USB_ARCH_HAS_HCD)$(CONFIG_USB_EHCI_HCD),)
276 ifneq ($(CONFIG_PCMCIA)$(CONFIG_PCCARD),)
279 ifneq ($(CONFIG_VGA_CONSOLE)$(CONFIG_FB),)
282 ifneq ($(CONFIG_RTC_CLASS),)
285 ifneq ($(CONFIG_VIRTIO),)
288 ifneq ($(CONFIG_CPU_MIPS32_R2),)
291 FEATURES += $(foreach v,6 7,$(if $(CONFIG_CPU_V$(v)),arm_v$(v)))
294 FEATURES:=$(sort $(FEATURES))
298 CUR_SUBTARGET:=$(SUBTARGET)
299 ifeq ($(SUBTARGETS),)
300 CUR_SUBTARGET := default
303 define BuildTargets/DumpCurrent
305 dumpinfo : export DESCRIPTION=$$(Target/Description)
307 @echo 'Target
: $(TARGETID
)'; \
308 echo 'Target-Board
: $(BOARD
)'; \
309 echo 'Target-Name
: $(BOARDNAME
)$(if
$(SUBTARGETS
),$(if
$(SUBTARGET
),))'; \
310 echo 'Target-Arch
: $(ARCH
)'; \
311 echo 'Target-Arch-Packages
: $(if
$(ARCH_PACKAGES
),$(ARCH_PACKAGES
),$(ARCH
)$(if
$(CPU_TYPE
),_
$(CPU_TYPE
))$(if
$(CPU_SUBTYPE
),_
$(CPU_SUBTYPE
)))'; \
312 echo 'Target-Features
: $(FEATURES
)'; \
313 echo 'Target-Depends
: $(DEPENDS
)'; \
314 echo 'Target-Optimization
: $(if
$(CFLAGS
),$(CFLAGS
),$(DEFAULT_CFLAGS
))'; \
315 echo 'CPU-Type
: $(CPU_TYPE
)$(if
$(CPU_SUBTYPE
),+$(CPU_SUBTYPE
))'; \
316 echo 'Linux-Version
: $(LINUX_VERSION
)'; \
317 $(if $(LINUX_TESTING_VERSION),echo 'Linux-Testing-Version
: $(LINUX_TESTING_VERSION
)';) \
318 echo 'Linux-Release
: $(LINUX_RELEASE
)'; \
319 echo 'Linux-Kernel-Arch
: $(LINUX_KARCH
)'; \
320 $(if $(SUBTARGET),,$(if $(DEFAULT_SUBTARGET), echo 'Default-Subtarget
: $(DEFAULT_SUBTARGET
)'; )) \
321 echo 'Target-Description
:'; \
322 echo "$$$$DESCRIPTION"; \
324 echo 'Default-Packages
: $(DEFAULT_PACKAGES
) $(call extra_packages
,$(DEFAULT_PACKAGES
))'; \
326 $(if $(CUR_SUBTARGET),$(SUBMAKE) -r --no-print-directory -C image -s DUMP=1 SUBTARGET=$(CUR_SUBTARGET))
327 $(if $(SUBTARGET),,@$(foreach SUBTARGET,$(SUBTARGETS),$(SUBMAKE) -s DUMP=1 SUBTARGET=$(SUBTARGET); ))
330 include $(INCLUDE_DIR)/kernel.mk
331 ifeq ($(TARGET_BUILD),1)
332 include $(INCLUDE_DIR)/kernel-build.mk
333 BuildTarget?=$(BuildKernel)