fix quilt update breakage for kernel related packages
[openwrt/staging/wigyori.git] / include / target.mk
1 #
2 # Copyright (C) 2007 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 ($(DUMP),)
9 all: dumpinfo
10 endif
11
12 ifneq ($(__target_inc),1)
13 __target_inc=1
14
15 target_conf=$(subst .,_,$(subst -,_,$(subst /,_,$(1))))
16 ifeq ($(DUMP),)
17 PLATFORM_DIR:=$(TOPDIR)/target/linux/$(BOARD)
18 SUBTARGET:=$(strip $(foreach subdir,$(patsubst $(PLATFORM_DIR)/%/target.mk,%,$(wildcard $(PLATFORM_DIR)/*/target.mk)),$(if $(CONFIG_TARGET_$(call target_conf,$(BOARD)_$(subdir))),$(subdir))))
19 else
20 PLATFORM_DIR:=${CURDIR}
21 endif
22
23 TARGETID:=$(BOARD)$(if $(SUBTARGET),/$(SUBTARGET))
24 PLATFORM_SUBDIR:=$(PLATFORM_DIR)$(if $(SUBTARGET),/$(SUBTARGET))
25
26 define Target
27 KERNEL_TARGETS+=$(1)
28 ifeq ($(DUMP),1)
29 ifeq ($(SUBTARGET),)
30 BuildTarget=$$(BuildTargets/DumpAll)
31 endif
32 endif
33 endef
34
35 ifneq ($(TARGET_BUILD),1)
36 include $(PLATFORM_DIR)/Makefile
37 ifneq ($(PLATFORM_DIR),$(PLATFORM_SUBDIR))
38 include $(PLATFORM_SUBDIR)/target.mk
39 endif
40 else
41 ifneq ($(SUBTARGET),)
42 -include ./$(SUBTARGET)/target.mk
43 endif
44 endif
45
46 define Profile/Default
47 NAME:=
48 PACKAGES:=
49 endef
50
51 define Profile
52 $(eval $(call Profile/Default))
53 $(eval $(call Profile/$(1)))
54 $(eval $(call shexport,Profile/$(1)/Config))
55 $(eval $(call shexport,Profile/$(1)/Description))
56 DUMPINFO += \
57 echo "Target-Profile: $(1)"; \
58 echo "Target-Profile-Name: $(NAME)"; \
59 echo "Target-Profile-Packages: $(PACKAGES)"; \
60 if [ -f ./config/profile-$(1) ]; then \
61 echo "Target-Profile-Kconfig: yes"; \
62 fi; \
63 echo "Target-Profile-Config: "; \
64 getvar "$(call shvar,Profile/$(1)/Config)"; \
65 echo "@@"; \
66 echo "Target-Profile-Description:"; \
67 getvar "$(call shvar,Profile/$(1)/Description)"; \
68 echo "@@"; \
69 echo;
70 ifeq ($(CONFIG_TARGET_$(call target_conf,$(BOARD)_$(if $(SUBTARGET),$(SUBTARGET)_)$(1))),y)
71 PROFILE=$(1)
72 endif
73 endef
74
75 ifneq ($(PLATFORM_DIR),$(PLATFORM_SUBDIR))
76 define IncludeProfiles
77 -include $(PLATFORM_DIR)/profiles/*.mk
78 -include $(PLATFORM_SUBDIR)/profiles/*.mk
79 endef
80 else
81 define IncludeProfiles
82 -include $(PLATFORM_DIR)/profiles/*.mk
83 endef
84 endif
85
86 ifeq ($(TARGET_BUILD),1)
87 $(eval $(call IncludeProfiles))
88 else
89 ifeq ($(DUMP),)
90 $(eval $(call IncludeProfiles))
91 endif
92 endif
93
94 $(eval $(call shexport,Target/Description))
95
96 include $(INCLUDE_DIR)/kernel-version.mk
97
98 GENERIC_PLATFORM_DIR := $(TOPDIR)/target/linux/generic-$(KERNEL)
99 GENERIC_PATCH_DIR := $(GENERIC_PLATFORM_DIR)/patches$(shell [ -d "$(GENERIC_PLATFORM_DIR)/patches-$(KERNEL_PATCHVER)" ] && printf -- "-$(KERNEL_PATCHVER)" || true )
100
101 GENERIC_LINUX_CONFIG?=$(firstword $(wildcard $(GENERIC_PLATFORM_DIR)/config-$(KERNEL_PATCHVER) $(GENERIC_PLATFORM_DIR)/config-default))
102 LINUX_CONFIG?=$(firstword $(wildcard $(foreach subdir,$(PLATFORM_DIR) $(PLATFORM_SUBDIR),$(subdir)/config-$(KERNEL_PATCHVER) $(subdir)/config-default)))
103 LINUX_SUBCONFIG?=$(firstword $(wildcard $(PLATFORM_SUBDIR)/config-$(KERNEL_PATCHVER) $(PLATFORM_SUBDIR)/config-default))
104 ifeq ($(LINUX_CONFIG),$(LINUX_SUBCONFIG))
105 LINUX_SUBCONFIG:=
106 endif
107 LINUX_CONFCMD=$(if $(LINUX_CONFIG),$(SCRIPT_DIR)/kconfig.pl + $(GENERIC_LINUX_CONFIG) $(if $(LINUX_SUBCONFIG),+ $(LINUX_CONFIG) $(LINUX_SUBCONFIG),$(LINUX_CONFIG)),true)
108
109 ifeq ($(DUMP),1)
110 BuildTarget=$(BuildTargets/DumpCurrent)
111
112 ifneq ($(BOARD),)
113 TMP_CONFIG:=$(TMP_DIR)/.kconfig-$(call target_conf,$(TARGETID))
114 $(TMP_CONFIG): $(GENERIC_LINUX_CONFIG) $(LINUX_CONFIG) $(LINUX_SUBCONFIG)
115 $(LINUX_CONFCMD) > $@ || rm -f $@
116 -include $(TMP_CONFIG)
117 .SILENT: $(TMP_CONFIG)
118 .PRECIOUS: $(TMP_CONFIG)
119
120 ifneq ($(CONFIG_PCI),)
121 FEATURES += pci
122 endif
123 ifneq ($(CONFIG_USB),)
124 FEATURES += usb
125 endif
126 ifneq ($(CONFIG_PCMCIA)$(CONFIG_PCCARD),)
127 FEATURES += pcmcia
128 endif
129
130 # remove duplicates
131 FEATURES:=$(sort $(FEATURES))
132 endif
133 endif
134
135 define BuildTargets/DumpAll
136 dumpinfo:
137 @$(foreach SUBTARGET,$(KERNEL_TARGETS),$(SUBMAKE) -s DUMP=1 SUBTARGET=$(SUBTARGET); )
138 endef
139
140 define BuildTargets/DumpCurrent
141
142 dumpinfo:
143 @echo 'Target: $(TARGETID)'; \
144 echo 'Target-Board: $(BOARD)'; \
145 echo 'Target-Kernel: $(KERNEL)'; \
146 echo 'Target-Name: $(BOARDNAME) [$(KERNEL)]'; \
147 echo 'Target-Path: $(subst $(TOPDIR)/,,$(PWD))'; \
148 echo 'Target-Arch: $(ARCH)'; \
149 echo 'Target-Features: $(FEATURES)'; \
150 echo 'Target-Depends: $(DEPENDS)'; \
151 echo 'Linux-Version: $(LINUX_VERSION)'; \
152 echo 'Linux-Release: $(LINUX_RELEASE)'; \
153 echo 'Linux-Kernel-Arch: $(LINUX_KARCH)'; \
154 echo 'Target-Description:'; \
155 getvar $(call shvar,Target/Description); \
156 echo '@@'; \
157 echo 'Default-Packages: $(DEFAULT_PACKAGES)'; \
158 $(DUMPINFO)
159 endef
160
161 include $(INCLUDE_DIR)/kernel.mk
162 ifeq ($(TARGET_BUILD),1)
163 include $(INCLUDE_DIR)/kernel-build.mk
164 BuildTarget?=$(BuildKernel)
165 endif
166
167 endif #__target_inc