[sibyte]: upgrade to 2.6.37.4
[openwrt.git] / 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
8 ifneq ($(__target_inc),1)
9 __target_inc=1
10
11 # default device type
12 DEVICE_TYPE?=router
13
14 # Default packages - the really basic set
15 DEFAULT_PACKAGES:=base-files libc libgcc busybox dropbear mtd uci opkg hotplug2
16 # For router targets
17 DEFAULT_PACKAGES.router:=dnsmasq iptables ppp ppp-mod-pppoe kmod-ipt-nathelper firewall
18 DEFAULT_PACKAGES.bootloader:=
19
20 # Add device specific packages
21 DEFAULT_PACKAGES += $(DEFAULT_PACKAGES.$(DEVICE_TYPE))
22
23 # Add metapackages for menu groups that a) don't build or install anything, and b) prevent other packages from
24 # appearing in the package list if they are not selected
25 DEFAULT_PACKAGES += coreutils
26
27 ifneq ($(DUMP),)
28 all: dumpinfo
29 endif
30
31 target_conf=$(subst .,_,$(subst -,_,$(subst /,_,$(1))))
32 ifeq ($(DUMP),)
33 PLATFORM_DIR:=$(TOPDIR)/target/linux/$(BOARD)
34 SUBTARGET:=$(strip $(foreach subdir,$(patsubst $(PLATFORM_DIR)/%/target.mk,%,$(wildcard $(PLATFORM_DIR)/*/target.mk)),$(if $(CONFIG_TARGET_$(call target_conf,$(BOARD)_$(subdir))),$(subdir))))
35 else
36 PLATFORM_DIR:=${CURDIR}
37 endif
38
39 TARGETID:=$(BOARD)$(if $(SUBTARGET),/$(SUBTARGET))
40 PLATFORM_SUBDIR:=$(PLATFORM_DIR)$(if $(SUBTARGET),/$(SUBTARGET))
41
42 ifneq ($(TARGET_BUILD),1)
43 ifndef DUMP
44 include $(PLATFORM_DIR)/Makefile
45 ifneq ($(PLATFORM_DIR),$(PLATFORM_SUBDIR))
46 include $(PLATFORM_SUBDIR)/target.mk
47 endif
48 endif
49 else
50 ifneq ($(SUBTARGET),)
51 -include ./$(SUBTARGET)/target.mk
52 endif
53 endif
54
55 define Profile/Default
56 NAME:=
57 PACKAGES:=
58 endef
59
60 ifndef Profile
61 define Profile
62 $(eval $(call Profile/Default))
63 $(eval $(call Profile/$(1)))
64 $(eval $(call shexport,Profile/$(1)/Config))
65 $(eval $(call shexport,Profile/$(1)/Description))
66 DUMPINFO += \
67 echo "Target-Profile: $(1)"; \
68 echo "Target-Profile-Name: $(NAME)"; \
69 echo "Target-Profile-Packages: $(PACKAGES)"; \
70 if [ -f ./config/profile-$(1) ]; then \
71 echo "Target-Profile-Kconfig: yes"; \
72 fi; \
73 echo "Target-Profile-Config: "; \
74 $(SH_FUNC) getvar "$(call shvar,Profile/$(1)/Config)"; \
75 echo "@@"; \
76 echo "Target-Profile-Description:"; \
77 $(SH_FUNC) getvar "$(call shvar,Profile/$(1)/Description)"; \
78 echo "@@"; \
79 echo;
80 ifeq ($(CONFIG_TARGET_$(call target_conf,$(BOARD)_$(if $(SUBTARGET),$(SUBTARGET)_)$(1))),y)
81 PROFILE=$(1)
82 endif
83 endef
84 endif
85
86 ifneq ($(PLATFORM_DIR),$(PLATFORM_SUBDIR))
87 define IncludeProfiles
88 -include $(PLATFORM_DIR)/profiles/*.mk
89 -include $(PLATFORM_SUBDIR)/profiles/*.mk
90 endef
91 else
92 define IncludeProfiles
93 -include $(PLATFORM_DIR)/profiles/*.mk
94 endef
95 endif
96
97 ifeq ($(TARGET_BUILD),1)
98 $(eval $(call IncludeProfiles))
99 else
100 ifeq ($(DUMP),)
101 $(eval $(call IncludeProfiles))
102 endif
103 endif
104
105 $(eval $(call shexport,Target/Description))
106
107 ifneq ($(TARGET_BUILD)$(if $(DUMP),,1),)
108 include $(INCLUDE_DIR)/kernel-version.mk
109 endif
110
111 GENERIC_PLATFORM_DIR := $(TOPDIR)/target/linux/generic
112 GENERIC_PATCH_DIR := $(GENERIC_PLATFORM_DIR)/patches$(if $(wildcard $(GENERIC_PLATFORM_DIR)/patches-$(KERNEL_PATCHVER)),-$(KERNEL_PATCHVER))
113 GENERIC_FILES_DIR := $(foreach dir,$(wildcard $(GENERIC_PLATFORM_DIR)/files $(GENERIC_PLATFORM_DIR)/files-$(KERNEL_PATCHVER)),"$(dir)")
114
115 GENERIC_LINUX_CONFIG?=$(firstword $(wildcard $(GENERIC_PLATFORM_DIR)/config-$(KERNEL_PATCHVER) $(GENERIC_PLATFORM_DIR)/config-default))
116 LINUX_CONFIG?=$(firstword $(wildcard $(foreach subdir,$(PLATFORM_DIR) $(PLATFORM_SUBDIR),$(subdir)/config-$(KERNEL_PATCHVER) $(subdir)/config-default)) $(PLATFORM_DIR)/config-$(KERNEL_PATCHVER))
117 LINUX_SUBCONFIG?=$(if $(SHARED_LINUX_CONFIG),,$(firstword $(wildcard $(PLATFORM_SUBDIR)/config-$(KERNEL_PATCHVER) $(PLATFORM_SUBDIR)/config-default)))
118 ifeq ($(LINUX_CONFIG),$(LINUX_SUBCONFIG))
119 LINUX_SUBCONFIG:=
120 endif
121 LINUX_CONFCMD=$(if $(LINUX_CONFIG), \
122 $(if $(GENERIC_LINUX_CONFIG),,$(error The generic kernel config for your kernel version is missing)) \
123 $(if $(LINUX_CONFIG),,$(error The target kernel config for your kernel version is missing)) \
124 $(SCRIPT_DIR)/kconfig.pl \
125 + $(GENERIC_LINUX_CONFIG) \
126 $(if $(LINUX_SUBCONFIG),+ $(LINUX_CONFIG) $(LINUX_SUBCONFIG),$(LINUX_CONFIG)), \
127 true)
128
129 ifeq ($(DUMP),1)
130 BuildTarget=$(BuildTargets/DumpCurrent)
131
132 ifneq ($(BOARD),)
133 TMP_CONFIG:=$(TMP_DIR)/.kconfig-$(call target_conf,$(TARGETID))
134 $(TMP_CONFIG): $(GENERIC_LINUX_CONFIG) $(LINUX_CONFIG) $(LINUX_SUBCONFIG)
135 $(LINUX_CONFCMD) > $@ || rm -f $@
136 -include $(TMP_CONFIG)
137 .SILENT: $(TMP_CONFIG)
138 .PRECIOUS: $(TMP_CONFIG)
139
140 ifneq ($(CONFIG_GENERIC_GPIO),)
141 FEATURES += gpio
142 endif
143 ifneq ($(CONFIG_PCI),)
144 FEATURES += pci
145 endif
146 ifneq ($(CONFIG_PCIEPORTBUS),)
147 FEATURES += pcie
148 endif
149 ifneq ($(CONFIG_USB)$(CONFIG_USB_SUPPORT),)
150 ifneq ($(CONFIG_USB_ARCH_HAS_HCD)$(CONFIG_USB_EHCI_HCD),)
151 FEATURES += usb
152 endif
153 endif
154 ifneq ($(CONFIG_PCMCIA)$(CONFIG_PCCARD),)
155 FEATURES += pcmcia
156 endif
157 ifneq ($(CONFIG_VGA_CONSOLE)$(CONFIG_FB),)
158 FEATURES += display
159 endif
160
161 # remove duplicates
162 FEATURES:=$(sort $(FEATURES))
163 endif
164 DEFAULT_CFLAGS_i386=-O2 -pipe -march=i486 -funit-at-a-time
165 DEFAULT_CFLAGS_x86_64=-O2 -pipe -march=athlon64 -funit-at-a-time
166 DEFAULT_CFLAGS_m68k=-Os -pipe -mcfv4e -funit-at-a-time
167 DEFAULT_CFLAGS_mips=-Os -pipe -mips32 -mtune=mips32 -funit-at-a-time
168 DEFAULT_CFLAGS_mipsel=$(DEFAULT_CFLAGS_mips)
169 DEFAULT_CFLAGS_mips64=-Os -pipe -mips64 -mtune=mips64 -mabi=64 -funit-at-a-time
170 DEFAULT_CFLAGS_mips64el=$(DEFAULT_CFLAGS_mips64)
171 DEFAULT_CFLAGS_sparc=-Os -pipe -mcpu=ultrasparc -funit-at-a-time
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)
175 endif
176
177 define 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 $(SH_FUNC) 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); ))
199 endef
200
201 include $(INCLUDE_DIR)/kernel.mk
202 ifeq ($(TARGET_BUILD),1)
203 include $(INCLUDE_DIR)/kernel-build.mk
204 BuildTarget?=$(BuildKernel)
205 endif
206
207 endif #__target_inc
This page took 0.047784 seconds and 5 git commands to generate.