Disable rt2500 for big-endian targets, we will update to a mac80211 version (#1886)
[librecmc/librecmc.git] / include / kernel-build.mk
1
2 # Copyright (C) 2006-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 KERNEL_BUILD:=1
8
9 include $(INCLUDE_DIR)/kernel-version.mk
10 include $(INCLUDE_DIR)/host.mk
11 include $(INCLUDE_DIR)/kernel.mk
12 include $(INCLUDE_DIR)/prereq.mk
13
14 LINUX_CONFIG ?= ./config/default
15
16 -include $(TOPDIR)/target/linux/generic-$(KERNEL)/config-template
17 -include $(LINUX_CONFIG)
18
19 ifneq ($(CONFIG_ATM),)
20   FEATURES += atm
21 endif
22 ifneq ($(CONFIG_PCI),)
23   FEATURES += pci
24 endif
25 ifneq ($(CONFIG_USB),)
26   FEATURES += usb
27 endif
28 ifneq ($(CONFIG_PCMCIA)$(CONFIG_PCCARD),)
29   FEATURES += pcmcia
30 endif
31 ifneq ($(CONFIG_VIDEO_DEV),)
32   FEATURES += video
33 endif
34
35 # remove duplicates
36 FEATURES:=$(sort $(FEATURES))
37
38 ifeq ($(DUMP),1)
39   all: dumpinfo
40 else
41   all: compile
42 endif
43
44 ifneq (,$(findstring uml,$(BOARD)))
45   LINUX_KARCH:=um
46 else
47   LINUX_KARCH:=$(shell echo $(ARCH) | sed -e 's/i[3-9]86/i386/' \
48         -e 's/mipsel/mips/' \
49         -e 's/mipseb/mips/' \
50         -e 's/powerpc/ppc/' \
51         -e 's/sh[234]/sh/' \
52         -e 's/armeb/arm/' \
53   )
54 endif
55
56 STAMP_PREPARED:=$(LINUX_DIR)/.prepared
57 STAMP_CONFIGURED:=$(LINUX_DIR)/.configured
58 include $(INCLUDE_DIR)/quilt.mk
59 include $(INCLUDE_DIR)/kernel-defaults.mk
60
61 define Kernel/Prepare
62         $(call Kernel/Prepare/Default)
63 endef
64
65 define Kernel/Configure
66         $(call Kernel/Configure/Default)
67 endef
68
69 define Kernel/CompileModules
70         $(call Kernel/CompileModules/Default)
71 endef
72
73 define Kernel/CompileImage
74         $(call Kernel/CompileImage/Default)
75 endef
76
77 define Kernel/Clean
78         $(call Kernel/Clean/Default)
79 endef
80
81 define BuildKernel
82   ifneq ($(LINUX_SITE),)
83     $(DL_DIR)/$(LINUX_SOURCE):
84                 -mkdir -p $(DL_DIR)
85                 $(SCRIPT_DIR)/download.pl $(DL_DIR) $(LINUX_SOURCE) $(LINUX_KERNEL_MD5SUM) $(LINUX_SITE)
86   endif
87
88   $(STAMP_PREPARED): $(DL_DIR)/$(LINUX_SOURCE)
89         -rm -rf $(KERNEL_BUILD_DIR)
90         -mkdir -p $(KERNEL_BUILD_DIR)
91         $(call Kernel/Prepare)
92         touch $$@
93
94   $(STAMP_CONFIGURED): $(LINUX_DIR)/.prepared $(LINUX_CONFIG)
95         $(call Kernel/Configure)
96         touch $$@
97
98   $(LINUX_DIR)/.modules: $(LINUX_DIR)/.configured $(LINUX_DIR)/.config FORCE
99         $(call Kernel/CompileModules)
100         touch $$@
101
102   $(LINUX_DIR)/.image: $(LINUX_DIR)/.configured FORCE
103         $(call Kernel/CompileImage)
104         touch $$@
105         
106   mostlyclean: FORCE
107         $(call Kernel/Clean)
108
109   ifeq ($(DUMP),1)
110     dumpinfo:
111                 @echo 'Target: $(BOARD)-$(KERNEL)'
112                 @echo 'Target-Name: $(BOARDNAME) [$(KERNEL)]'
113                 @echo 'Target-Path: $(subst $(TOPDIR)/,,$(PWD))'
114                 @echo 'Target-Arch: $(ARCH)'
115                 @echo 'Target-Features: $(FEATURES)'
116                 @echo 'Linux-Version: $(LINUX_VERSION)'
117                 @echo 'Linux-Release: $(LINUX_RELEASE)'
118                 @echo 'Linux-Kernel-Arch: $(LINUX_KARCH)'
119                 @echo 'Target-Description:'
120                 @getvar $(call shvar,Target/Description)
121                 @echo '@@'
122                 @echo 'Default-Packages: $(DEFAULT_PACKAGES)'
123     ifneq ($(DUMPINFO),)
124                 @$(DUMPINFO)
125     endif
126   endif
127
128   define BuildKernel
129   endef
130 endef
131
132 define Profile/Default
133   NAME:=
134   PACKAGES:=
135 endef
136
137 confname=$(subst .,_,$(subst -,_,$(1)))
138 define Profile
139   $(eval $(call Profile/Default))
140   $(eval $(call Profile/$(1)))
141   $(eval $(call shexport,Profile/$(1)/Config))
142   $(eval $(call shexport,Profile/$(1)/Description))
143   DUMPINFO += \
144         echo "Target-Profile: $(1)"; \
145         echo "Target-Profile-Name: $(NAME)"; \
146         echo "Target-Profile-Packages: $(PACKAGES)"; \
147         if [ -f ./config/profile-$(1) ]; then \
148                 echo "Target-Profile-Kconfig: yes"; \
149         fi; \
150         echo "Target-Profile-Config: "; \
151         getvar "$(call shvar,Profile/$(1)/Config)"; \
152         echo "@@"; \
153         echo "Target-Profile-Description:"; \
154         getvar "$(call shvar,Profile/$(1)/Description)"; \
155         echo "@@"; \
156         echo;
157   ifeq ($(CONFIG_LINUX_$(call confname,$(KERNEL)_$(1))),y)
158     PROFILE=$(1)
159   endif
160 endef
161
162 $(eval $(call shexport,Target/Description))
163
164 download: $(DL_DIR)/$(LINUX_SOURCE)
165 prepare: $(LINUX_DIR)/.configured
166 compile: $(LINUX_DIR)/.modules
167 menuconfig: $(LINUX_DIR)/.prepared FORCE
168         $(call Kernel/Configure)
169         $(SCRIPT_DIR)/config.pl '+' $(GENERIC_PLATFORM_DIR)/config-template $(LINUX_CONFIG) > $(LINUX_DIR)/.config
170         $(MAKE) -C $(LINUX_DIR) $(KERNEL_MAKEOPTS) menuconfig
171         $(SCRIPT_DIR)/config.pl '>' $(GENERIC_PLATFORM_DIR)/config-template $(LINUX_DIR)/.config > $(LINUX_CONFIG)
172
173 install: $(LINUX_DIR)/.image
174
175 clean: FORCE
176         rm -f $(STAMP_DIR)/.linux-compile
177         rm -rf $(KERNEL_BUILD_DIR)
178
179 rebuild: FORCE
180         @$(MAKE) mostlyclean
181         @if [ -f $(LINUX_KERNEL) ]; then \
182                 $(MAKE) clean; \
183         fi
184         @$(MAKE) compile
185
186