Root/include/target.mk

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

Archive Download this file



interactive