source: trunk/include/target.mk

Last change on this file was 49285, checked in by blogic, 7 months ago

ubox: turn logd into a separate package

Currently system log is always included as a part of ubox.
Add logd as a seperate package and add it to default packages list.

Signed-off-by: Andrej Vlasic <andrej.vlasic@…>

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