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