fixes script that mounts usd storage when it gets attached
[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 libgcc uclibc busybox dropbear mtd uci opkg
16 # For router targets
17 DEFAULT_PACKAGES.router:=dnsmasq iptables ppp ppp-mod-pppoe kmod-ipt-nathelper bridge firewall
18
19 # Additional packages for Linux 2.6
20 ifneq ($(KERNEL),2.4)
21 DEFAULT_PACKAGES += udevtrigger hotplug2
22 endif
23
24 # Add device specific packages
25 DEFAULT_PACKAGES += $(DEFAULT_PACKAGES.$(DEVICE_TYPE))
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 include $(PLATFORM_DIR)/Makefile
44 ifneq ($(PLATFORM_DIR),$(PLATFORM_SUBDIR))
45 include $(PLATFORM_SUBDIR)/target.mk
46 endif
47 else
48 ifneq ($(SUBTARGET),)
49 -include ./$(SUBTARGET)/target.mk
50 endif
51 endif
52
53 define Profile/Default
54 NAME:=
55 PACKAGES:=
56 endef
57
58 ifndef Profile
59 define Profile
60 $(eval $(call Profile/Default))
61 $(eval $(call Profile/$(1)))
62 $(eval $(call shexport,Profile/$(1)/Config))
63 $(eval $(call shexport,Profile/$(1)/Description))
64 DUMPINFO += \
65 echo "Target-Profile: $(1)"; \
66 echo "Target-Profile-Name: $(NAME)"; \
67 echo "Target-Profile-Packages: $(PACKAGES)"; \
68 if [ -f ./config/profile-$(1) ]; then \
69 echo "Target-Profile-Kconfig: yes"; \
70 fi; \
71 echo "Target-Profile-Config: "; \
72 getvar "$(call shvar,Profile/$(1)/Config)"; \
73 echo "@@"; \
74 echo "Target-Profile-Description:"; \
75 getvar "$(call shvar,Profile/$(1)/Description)"; \
76 echo "@@"; \
77 echo;
78 ifeq ($(CONFIG_TARGET_$(call target_conf,$(BOARD)_$(if $(SUBTARGET),$(SUBTARGET)_)$(1))),y)
79 PROFILE=$(1)
80 endif
81 endef
82 endif
83
84 ifneq ($(PLATFORM_DIR),$(PLATFORM_SUBDIR))
85 define IncludeProfiles
86 -include $(PLATFORM_DIR)/profiles/*.mk
87 -include $(PLATFORM_SUBDIR)/profiles/*.mk
88 endef
89 else
90 define IncludeProfiles
91 -include $(PLATFORM_DIR)/profiles/*.mk
92 endef
93 endif
94
95 ifeq ($(TARGET_BUILD),1)
96 $(eval $(call IncludeProfiles))
97 else
98 ifeq ($(DUMP),)
99 $(eval $(call IncludeProfiles))
100 endif
101 endif
102
103 $(eval $(call shexport,Target/Description))
104
105 include $(INCLUDE_DIR)/kernel-version.mk
106
107 GENERIC_PLATFORM_DIR := $(TOPDIR)/target/linux/generic-$(KERNEL)
108 GENERIC_PATCH_DIR := $(GENERIC_PLATFORM_DIR)/patches$(shell [ -d "$(GENERIC_PLATFORM_DIR)/patches-$(KERNEL_PATCHVER)" ] && printf -- "-$(KERNEL_PATCHVER)" || true )
109 GENERIC_FILES_DIR := $(GENERIC_PLATFORM_DIR)/files$(shell [ -d "$(GENERIC_PLATFORM_DIR)/files-$(KERNEL_PATCHVER)" ] && printf -- "-$(KERNEL_PATCHVER)" || true )
110
111 GENERIC_LINUX_CONFIG?=$(firstword $(wildcard $(GENERIC_PLATFORM_DIR)/config-$(KERNEL_PATCHVER) $(GENERIC_PLATFORM_DIR)/config-default))
112 LINUX_CONFIG?=$(firstword $(wildcard $(foreach subdir,$(PLATFORM_DIR) $(PLATFORM_SUBDIR),$(subdir)/config-$(KERNEL_PATCHVER) $(subdir)/config-default)) $(PLATFORM_DIR)/config-$(KERNEL_PATCHVER))
113 LINUX_SUBCONFIG?=$(firstword $(wildcard $(PLATFORM_SUBDIR)/config-$(KERNEL_PATCHVER) $(PLATFORM_SUBDIR)/config-default))
114 ifeq ($(LINUX_CONFIG),$(LINUX_SUBCONFIG))
115 LINUX_SUBCONFIG:=
116 endif
117 LINUX_CONFCMD=$(if $(LINUX_CONFIG),$(SCRIPT_DIR)/kconfig.pl + $(GENERIC_LINUX_CONFIG) $(if $(LINUX_SUBCONFIG),+ $(LINUX_CONFIG) $(LINUX_SUBCONFIG),$(LINUX_CONFIG)),true)
118
119 ifeq ($(DUMP),1)
120 BuildTarget=$(BuildTargets/DumpCurrent)
121
122 ifneq ($(BOARD),)
123 TMP_CONFIG:=$(TMP_DIR)/.kconfig-$(call target_conf,$(TARGETID))
124 $(TMP_CONFIG): $(GENERIC_LINUX_CONFIG) $(LINUX_CONFIG) $(LINUX_SUBCONFIG)
125 $(LINUX_CONFCMD) > $@ || rm -f $@
126 -include $(TMP_CONFIG)
127 .SILENT: $(TMP_CONFIG)
128 .PRECIOUS: $(TMP_CONFIG)
129
130 ifneq ($(CONFIG_GENERIC_GPIO),)
131 FEATURES += gpio
132 endif
133 ifneq ($(CONFIG_PCI),)
134 FEATURES += pci
135 endif
136 ifneq ($(CONFIG_USB),)
137 FEATURES += usb
138 endif
139 ifneq ($(CONFIG_PCMCIA)$(CONFIG_PCCARD),)
140 FEATURES += pcmcia
141 endif
142 ifneq ($(CONFIG_VGA_CONSOLE)$(CONFIG_FB),)
143 FEATURES += display
144 endif
145
146 # remove duplicates
147 FEATURES:=$(sort $(FEATURES))
148 endif
149 endif
150
151 define BuildTargets/DumpCurrent
152 .PHONY: dumpinfo
153 dumpinfo:
154 @echo 'Target: $(TARGETID)'; \
155 echo 'Target-Board: $(BOARD)'; \
156 echo 'Target-Kernel: $(KERNEL)'; \
157 echo 'Target-Name: $(BOARDNAME)$(if $(SUBTARGET),, [$(KERNEL)])'; \
158 echo 'Target-Path: $(subst $(TOPDIR)/,,$(PWD))'; \
159 echo 'Target-Arch: $(ARCH)'; \
160 echo 'Target-Features: $(FEATURES)'; \
161 echo 'Target-Depends: $(DEPENDS)'; \
162 echo 'Linux-Version: $(LINUX_VERSION)'; \
163 echo 'Linux-Release: $(LINUX_RELEASE)'; \
164 echo 'Linux-Kernel-Arch: $(LINUX_KARCH)'; \
165 echo 'Target-Description:'; \
166 getvar $(call shvar,Target/Description); \
167 echo '@@'; \
168 echo 'Default-Packages: $(DEFAULT_PACKAGES)'; \
169 $(DUMPINFO)
170 $(if $(SUBTARGET),,@$(foreach SUBTARGET,$(SUBTARGETS),$(SUBMAKE) -s DUMP=1 SUBTARGET=$(SUBTARGET); ))
171 endef
172
173 include $(INCLUDE_DIR)/kernel.mk
174 ifeq ($(TARGET_BUILD),1)
175 include $(INCLUDE_DIR)/kernel-build.mk
176 BuildTarget?=$(BuildKernel)
177 endif
178
179 endif #__target_inc
This page took 0.069145 seconds and 5 git commands to generate.