source: trunk/include/target.mk @ 26269

Last change on this file since 26269 was 26269, checked in by jow, 5 years ago

[include] target.mk: don't enable coreutils by default, it does not even exist anymore... fixes the Image Builder

  • Property svn:eol-style set to native
File size: 6.6 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 hotplug2
16# For router targets
17DEFAULT_PACKAGES.router:=dnsmasq iptables ppp ppp-mod-pppoe kmod-ipt-nathelper firewall
18DEFAULT_PACKAGES.bootloader:=
19
20# Add device specific packages
21DEFAULT_PACKAGES += $(DEFAULT_PACKAGES.$(DEVICE_TYPE))
22
23ifneq ($(DUMP),)
24  all: dumpinfo
25endif
26
27target_conf=$(subst .,_,$(subst -,_,$(subst /,_,$(1))))
28ifeq ($(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))))
31else
32  PLATFORM_DIR:=${CURDIR}
33endif
34
35TARGETID:=$(BOARD)$(if $(SUBTARGET),/$(SUBTARGET))
36PLATFORM_SUBDIR:=$(PLATFORM_DIR)$(if $(SUBTARGET),/$(SUBTARGET))
37
38ifneq ($(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
45else
46  ifneq ($(SUBTARGET),)
47    -include ./$(SUBTARGET)/target.mk
48  endif
49endif
50
51define Profile/Default
52  NAME:=
53  PACKAGES:=
54endef
55
56ifndef Profile
57define Profile
58  $(eval $(call Profile/Default))
59  $(eval $(call Profile/$(1)))
60  $(eval $(call shexport,Profile/$(1)/Config))
61  $(eval $(call shexport,Profile/$(1)/Description))
62  DUMPINFO += \
63        echo "Target-Profile: $(1)"; \
64        echo "Target-Profile-Name: $(NAME)"; \
65        echo "Target-Profile-Packages: $(PACKAGES)"; \
66        if [ -f ./config/profile-$(1) ]; then \
67                echo "Target-Profile-Kconfig: yes"; \
68        fi; \
69        echo "Target-Profile-Config: "; \
70        $(SH_FUNC) getvar "$(call shvar,Profile/$(1)/Config)"; \
71        echo "@@"; \
72        echo "Target-Profile-Description:"; \
73        $(SH_FUNC) getvar "$(call shvar,Profile/$(1)/Description)"; \
74        echo "@@"; \
75        echo;
76  ifeq ($(CONFIG_TARGET_$(call target_conf,$(BOARD)_$(if $(SUBTARGET),$(SUBTARGET)_)$(1))),y)
77    PROFILE=$(1)
78  endif
79endef
80endif
81
82ifneq ($(PLATFORM_DIR),$(PLATFORM_SUBDIR))
83  define IncludeProfiles
84    -include $(PLATFORM_DIR)/profiles/*.mk
85    -include $(PLATFORM_SUBDIR)/profiles/*.mk
86  endef
87else
88  define IncludeProfiles
89    -include $(PLATFORM_DIR)/profiles/*.mk
90  endef
91endif
92
93ifeq ($(TARGET_BUILD),1)
94  $(eval $(call IncludeProfiles))
95else
96  ifeq ($(DUMP),)
97    $(eval $(call IncludeProfiles))
98  endif
99endif
100
101$(eval $(call shexport,Target/Description))
102
103ifneq ($(TARGET_BUILD)$(if $(DUMP),,1),)
104  include $(INCLUDE_DIR)/kernel-version.mk
105endif
106
107GENERIC_PLATFORM_DIR := $(TOPDIR)/target/linux/generic
108GENERIC_PATCH_DIR := $(GENERIC_PLATFORM_DIR)/patches$(if $(wildcard $(GENERIC_PLATFORM_DIR)/patches-$(KERNEL_PATCHVER)),-$(KERNEL_PATCHVER))
109GENERIC_FILES_DIR := $(foreach dir,$(wildcard $(GENERIC_PLATFORM_DIR)/files $(GENERIC_PLATFORM_DIR)/files-$(KERNEL_PATCHVER)),"$(dir)")
110
111GENERIC_LINUX_CONFIG?=$(firstword $(wildcard $(GENERIC_PLATFORM_DIR)/config-$(KERNEL_PATCHVER) $(GENERIC_PLATFORM_DIR)/config-default))
112LINUX_CONFIG?=$(firstword $(wildcard $(foreach subdir,$(PLATFORM_DIR) $(PLATFORM_SUBDIR),$(subdir)/config-$(KERNEL_PATCHVER) $(subdir)/config-default)) $(PLATFORM_DIR)/config-$(KERNEL_PATCHVER))
113LINUX_SUBCONFIG?=$(if $(SHARED_LINUX_CONFIG),,$(firstword $(wildcard $(PLATFORM_SUBDIR)/config-$(KERNEL_PATCHVER) $(PLATFORM_SUBDIR)/config-default)))
114ifeq ($(LINUX_CONFIG),$(LINUX_SUBCONFIG))
115  LINUX_SUBCONFIG:=
116endif
117LINUX_CONFCMD=$(if $(LINUX_CONFIG), \
118        $(if $(GENERIC_LINUX_CONFIG),,$(error The generic kernel config for your kernel version is missing)) \
119        $(if $(LINUX_CONFIG),,$(error The target kernel config for your kernel version is missing)) \
120        $(SCRIPT_DIR)/kconfig.pl \
121                + $(GENERIC_LINUX_CONFIG) \
122                $(if $(LINUX_SUBCONFIG),+ $(LINUX_CONFIG) $(LINUX_SUBCONFIG),$(LINUX_CONFIG)), \
123        true)
124
125ifeq ($(DUMP),1)
126  BuildTarget=$(BuildTargets/DumpCurrent)
127
128  ifneq ($(BOARD),)
129    TMP_CONFIG:=$(TMP_DIR)/.kconfig-$(call target_conf,$(TARGETID))
130    $(TMP_CONFIG): $(GENERIC_LINUX_CONFIG) $(LINUX_CONFIG) $(LINUX_SUBCONFIG)
131                $(LINUX_CONFCMD) > $@ || rm -f $@
132    -include $(TMP_CONFIG)
133    .SILENT: $(TMP_CONFIG)
134    .PRECIOUS: $(TMP_CONFIG)
135
136    ifneq ($(CONFIG_GENERIC_GPIO),)
137      FEATURES += gpio
138    endif
139    ifneq ($(CONFIG_PCI),)
140      FEATURES += pci
141    endif
142    ifneq ($(CONFIG_PCIEPORTBUS),)
143      FEATURES += pcie
144    endif
145    ifneq ($(CONFIG_USB)$(CONFIG_USB_SUPPORT),)
146      ifneq ($(CONFIG_USB_ARCH_HAS_HCD)$(CONFIG_USB_EHCI_HCD),)
147        FEATURES += usb
148      endif
149    endif
150    ifneq ($(CONFIG_PCMCIA)$(CONFIG_PCCARD),)
151      FEATURES += pcmcia
152    endif
153    ifneq ($(CONFIG_VGA_CONSOLE)$(CONFIG_FB),)
154      FEATURES += display
155    endif
156
157    # remove duplicates
158    FEATURES:=$(sort $(FEATURES))
159  endif
160  DEFAULT_CFLAGS_i386=-O2 -pipe -march=i486 -funit-at-a-time
161  DEFAULT_CFLAGS_x86_64=-O2 -pipe -march=athlon64 -funit-at-a-time
162  DEFAULT_CFLAGS_m68k=-Os -pipe -mcfv4e -funit-at-a-time
163  DEFAULT_CFLAGS_mips=-Os -pipe -mips32 -mtune=mips32 -funit-at-a-time
164  DEFAULT_CFLAGS_mipsel=$(DEFAULT_CFLAGS_mips)
165  DEFAULT_CFLAGS_mips64=-Os -pipe -mips64 -mtune=mips64 -mabi=64 -funit-at-a-time
166  DEFAULT_CFLAGS_mips64el=$(DEFAULT_CFLAGS_mips64)
167  DEFAULT_CFLAGS_sparc=-Os -pipe -mcpu=ultrasparc -funit-at-a-time
168  DEFAULT_CFLAGS_arm=-Os -pipe -march=armv5te -mtune=xscale -funit-at-a-time
169  DEFAULT_CFLAGS_armeb=$(DEFAULT_CFLAGS_arm)
170  DEFAULT_CFLAGS=$(if $(DEFAULT_CFLAGS_$(ARCH)),$(DEFAULT_CFLAGS_$(ARCH)),-Os -pipe -funit-at-a-time)
171endif
172
173define BuildTargets/DumpCurrent
174  .PHONY: dumpinfo
175  dumpinfo:
176        @echo 'Target: $(TARGETID)'; \
177         echo 'Target-Board: $(BOARD)'; \
178         echo 'Target-Kernel: $(KERNEL)'; \
179         echo 'Target-Name: $(BOARDNAME)$(if $(SUBTARGETS),$(if $(SUBTARGET),))'; \
180         echo 'Target-Path: $(subst $(TOPDIR)/,,$(PWD))'; \
181         echo 'Target-Arch: $(ARCH)'; \
182         echo 'Target-Arch-Packages: $(if $(ARCH_PACKAGES),$(ARCH_PACKAGES),$(BOARD))'; \
183         echo 'Target-Features: $(FEATURES)'; \
184         echo 'Target-Depends: $(DEPENDS)'; \
185         echo 'Target-Optimization: $(if $(CFLAGS),$(CFLAGS),$(DEFAULT_CFLAGS))'; \
186         echo 'Linux-Version: $(LINUX_VERSION)'; \
187         echo 'Linux-Release: $(LINUX_RELEASE)'; \
188         echo 'Linux-Kernel-Arch: $(LINUX_KARCH)'; \
189         echo 'Target-Description:'; \
190         $(SH_FUNC) getvar $(call shvar,Target/Description); \
191         echo '@@'; \
192         echo 'Default-Packages: $(DEFAULT_PACKAGES)'; \
193         $(DUMPINFO)
194        $(if $(SUBTARGET),,@$(foreach SUBTARGET,$(SUBTARGETS),$(SUBMAKE) -s DUMP=1 SUBTARGET=$(SUBTARGET); ))
195endef
196
197include $(INCLUDE_DIR)/kernel.mk
198ifeq ($(TARGET_BUILD),1)
199  include $(INCLUDE_DIR)/kernel-build.mk
200  BuildTarget?=$(BuildKernel)
201endif
202
203endif #__target_inc
Note: See TracBrowser for help on using the repository browser.