summaryrefslogtreecommitdiff
path: root/target/linux-experimental/Makefile.in
blob: bfad7c5b4ff22ce3de641a0182e941fbe173f83e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
#############################################################
#
# Linux kernel 2.6 target
#
#############################################################
ifneq ($(filter $(TARGETS),linux26),)


ifeq ($(LINUX_HEADERS_VERSION),)
# Version of Linux to download and then apply patches to
# XXX: andersee, i do not understand why we need this (BF)
DOWNLOAD_LINUX26_VERSION:=$(strip $(subst ",, $(BR2_DOWNLOAD_LINUX26_VERSION)))
# "))
LINUX26_VERSION:=$(strip $(subst ",, $(BR2_LINUX26_VERSION)))
# "))
LINUX26_RC_PATCH:=$(strip $(subst ",, $(BR2_LINUX26_RC_PATCH)))
# "))
LINUX_BSP_PATCH:=$(strip $(subst ",, $(BR2_LINUX_BSP_ATMEL_PATCH)))
# " ))
MKIMAGE:=$(BUILD_DIR)/mkimage

ifeq ($(DOWNLOAD_LINUX26_VERSION),)
DOWNLOAD_LINUX26_VERSION=2.6.19.2
endif
# Version of Linux after applying any patches
LINUX26_VERSION=$(DOWNLOAD_LINUX26_VERSION)


else # ---------------------------------------------------

# Define DOWNLOAD_LINUX26_VERSION unless defined
ifeq ($(strip $(BR2_DOWNLOAD_LINUX26_VERSION)),)
DOWNLOAD_LINUX26_VERSION=$(LINUX_HEADERS_VERSION)
else
DOWNLOAD_LINUX26_VERSION:=$(strip $(subst ",, $(BR2_DOWNLOAD_LINUX26_VERSION)))
# "))
endif


# Define LINUX26_VERSION unless defined
ifeq ($(strip $(BR2_LINUX26_VERSION)),)
LINUX26_VERSION=$(LINUX_HEADERS_VERSION)
else
LINUX26_VERSION:=$(strip $(subst ",, $(BR2_LINUX26_VERSION)))
# "))
endif

endif # ---------------------------------------------------

# Handle case when we want to build using an "rc" patch
# Example: to build 2.6.21-rc1 you need to:
# * Download linux-2.6.20
# * Apply patch-2.6.21-rc1

LINUX26_SOURCE:=linux-$(DOWNLOAD_LINUX26_VERSION).tar.bz2
LINUX26_SITE=http://ftp.kernel.org/pub/linux/kernel/v2.6
LINUX26_BZCAT:=$(BZCAT)

# Linux kernel binary
LINUX26_FORMAT:=$(strip $(subst ",, $(BR2_LINUX26_FORMAT)))
# " ))

# Linux kernel configuration file
ifeq ($(strip $(LINUX26_KCONFIG)),)
LINUX26_KCONFIG=$(BR2_BOARD_PATH)/linux26.config
endif

# File name for the Linux kernel binary
ifeq ($(strip $(LINUX26_KERNEL)),)
#LINUX26_KERNEL=linux-kernel-$(LINUX26_VERSION)-$(KERNEL_ARCH)
LINUX26_KERNEL:=$(BOARD_NAME)-linux-$(LINUX26_VERSION)-$(DATE).gz
endif

ifeq ($(strip $(LINUX26_BINLOC)),)
LINUX26_BINLOC=$(LINUX26_FORMAT)
endif

# Put binary in root file system
ifeq ($(strip $(BR2_LINUX_IN_ROOTFS)),y)
ifeq ($(strip $(LINUX26_TARGET)),)
LINUX26_TARGET:=$(TARGET_DIR)/boot/$(LINUX26_BINLOC)
endif
else
LINUX26_TARGET:=$(BINARIES_DIR)/$(LINUX26_KERNEL)
endif
endif

ifeq ($(strip $(LINUX26_BUILD_DIR)),)
LINUX26_BUILD_DIR=$(PROJECT_BUILD_DIR)
endif

ifeq ($(strip $(BR2_LINUX26_DEFCONFIG)),y)
LINUX26_DEFCONFIG=$(BOARD_NAME)_defconfig
endif

# Version of Linux AFTER patches
LINUX26_DIR=$(LINUX26_BUILD_DIR)/linux-$(LINUX26_VERSION)

# for packages that need it
LINUX_VERSION=$(LINUX26_VERSION)
LINUX_DIR=$(LINUX26_DIR)
LINUX_KERNEL=$(LINUX26_KERNEL)

# kernel patches
ifeq ($(strip $(subst ",, $(LINUX26_PATCH_DIR))),)
# ")))
LINUX26_PATCH_DIR:=$(BR2_BOARD_PATH)/kernel-patches/
endif
PATCH_DIR=$(strip $(subst ",, $(LINUX26_PATCH_DIR)))
# " ))

LINUX26_MAKE_FLAGS = $(TARGET_CONFIGURE_OPTS) ARCH=$(KERNEL_ARCH) \
	PATH=$(TARGET_PATH) INSTALL_MOD_PATH=$(TARGET_DIR) \
	CROSS_COMPILE=$(KERNEL_CROSS)

$(LINUX26_KCONFIG):
	@if [ ! -f "$(LINUX26_KCONFIG)" ] ; then \
		echo ""; \
		echo "You should create a .config for your kernel"; \
		echo "and install it as $(LINUX26_KCONFIG)"; \
		echo ""; \
		sleep 5; \
	fi

# Check if we have a release candidate.
# This makes life complex
# To build linux-2.6.21-rc2 you need to:
# * Download linux.2.6.20.tar.bz2
# * Download patch-2.6.21-rc2.bz2
# I:E you have to download the *previous* major version

ifneq ($(LINUX26_RC_PATCH),)
# We have a "release candidate"
LINUX26_RC_PATCH_SOURCE:=$(PROJECT_BUILD_DIR)/linux-patch/$(LINUX26_RC_PATCH)

# Create rule to download the patch
$(LINUX26_RC_PATCH_SOURCE):
	mkdir -p $(PROJECT_BUILD_DIR)/linux-patch/
	$(WGET) -P $(PROJECT_BUILD_DIR)/linux-patch $(LINUX26_SITE)/$(LINUX26_RC_PATCH)
# $(LINUX26_BZCAT) $(PROJECT_BUILD_DIR)/linux-patch/$(LINUX26_RC_PATCH).bz2
else
# We have a vanilla style linux kernel
LINUX26_RC_PATCH_SOURCE:=
endif

ifneq ($(strip $(LINUX_HEADERS_SOURCE)),$(strip $(LINUX26_SOURCE)))
$(DL_DIR)/$(LINUX26_SOURCE):
	 $(WGET) -P $(DL_DIR) $(LINUX26_SITE)/$(LINUX26_SOURCE)
endif

$(LINUX26_DIR)/.unpacked: $(DL_DIR)/$(LINUX26_SOURCE) $(LINUX26_RC_PATCH_SOURCE)
	rm -rf $(LINUX26_DIR)
	$(LINUX26_BZCAT) $(DL_DIR)/$(LINUX26_SOURCE) | tar -C $(LINUX26_BUILD_DIR) $(TAR_OPTIONS) -
ifneq ($(DOWNLOAD_LINUX26_VERSION),$(LINUX26_VERSION))
	# Rename the dir from the downloaded version to the AFTER patch version
	mv -f $(LINUX26_BUILD_DIR)/linux-$(DOWNLOAD_LINUX26_VERSION) $(LINUX26_DIR)
endif
ifneq ($(LINUX26_RC_PATCH),)
	-(cd $(LINUX26_DIR); $(LINUX26_BZCAT) $(LINUX26_RC_PATCH_SOURCE) | patch -p1)
endif
	-(cd $(TOOL_BUILD_DIR); ln -snf $(LINUX26_DIR) linux)
	rm -f $(LINUX26_DIR)/.kernelrelease
	echo $(LINUX26_VERSION) > $(LINUX26_DIR)/.kernelrelease
	touch $@

$(LINUX26_DIR)/.patched: $(LINUX26_DIR)/.unpacked
	echo $(PATCH_DIR)
	toolchain/patch-kernel.sh $(LINUX26_DIR) $(LINUX26_PATCH_DIR)
	touch $@

$(LINUX26_DIR)/.configured: $(LINUX26_DIR)/.patched $(LINUX26_KCONFIG)
	-ls -l $(LINUX26_DIR)/.patched
	-ls -l $(LINUX26_KCONFIG)
	-ls -l $(LINUX26_DIR)/.configured
	-ls -l $(LINUX26_DIR)/.unpacked
	-ls -l $(DL_DIR)/$(LINUX26_SOURCE)
	-ls -l $(LINUX26_RC_PATCH_SOURCE)
ifeq ($(strip $(BR2_LINUX26_DEFCONFIG)),y)
	make ARCH=$(ARCH) -C $(LINUX26_DIR) $(BOARD_NAME)_defconfig
else
	cp -df --preserve=mode,ownership $(LINUX26_KCONFIG) $(LINUX26_DIR)/.config
endif
ifeq ($(strip $(BR2_LINUX_CUSTOMIZE)),y)
	make -C $(LINUX26_DIR) xconfig
endif
	$(SED) '/CONFIG_AEABI/d' $(LINUX26_DIR)/.config
ifeq ($(BR2_EABI),y)
	echo "CONFIG_AEABI=y" >> $(LINUX26_DIR)/.config
	$(SED) '/CONFIG_OABI_COMPAT/d' $(LINUX26_DIR)/.config
	echo "# CONFIG_OABI_COMPAT is not set" >> $(LINUX26_DIR)/.config
else
	echo "# CONFIG_AEABI is not set" >> $(LINUX26_DIR)/.config
endif
	$(MAKE) $(LINUX26_MAKE_FLAGS) -C $(LINUX26_DIR) oldconfig include/linux/version.h
	touch $@

$(LINUX26_DIR)/.depend_done: $(LINUX26_DIR)/.configured
	$(MAKE) $(LINUX26_MAKE_FLAGS) -C $(LINUX26_DIR) prepare
	touch $@

$(LINUX26_DIR)/arch/$(ARCH)/boot/$(LINUX26_FORMAT): $(LINUX26_DIR)/vmlinux
	$(MAKE) $(LINUX26_MAKE_FLAGS) -C $(LINUX26_DIR) $(LINUX26_FORMAT)
	$(MAKE) $(LINUX26_MAKE_FLAGS) -C $(LINUX26_DIR) modules
	touch -c $@

$(LINUX26_DIR)/vmlinux: $(LINUX26_DIR)/.depend_done $(STAGING_DIR)/include/linux/version.h
	$(MAKE) $(LINUX26_MAKE_FLAGS) -C $(LINUX26_DIR) vmlinux
	$(MAKE) $(LINUX26_MAKE_FLAGS) -C $(LINUX26_DIR) modules
	touch -c $@



#-----------------------------------------------------------------------------------
# Rule can be enabled by setting
# LINUX26_TARGET:= $(TARGET_DIR)/boot/$(LINUX26_BINLOC)
#
$(TARGET_DIR)/boot/$(LINUX26_FORMAT): $(LINUX26_DIR)/$(LINUX26_FORMAT)
	[ -d $(TARGET_DIR)/boot/ ] || mkdir $(TARGET_DIR)/boot
	cp -a $(LINUX26_DIR)/$(LINUX26_FORMAT) $(LINUX26_DIR)/System.map $(TARGET_DIR)/boot/$(LINUX26_FORMAT)
	touch -c $@

#-----------------------------------------------------------------------------------
# Rule can be enabled by setting
# LINUX26_TARGET:= $(BINARIES_DIR)/$(LINUX26_KERNEL)
# LINUX26_FORMAT:= vmlinux

$(BINARIES_DIR)/$(LINUX26_KERNEL): $(LINUX26_DIR)/uImage
	cp -dpf $(LINUX26_DIR)/uImage $(BINARIES_DIR)/$(LINUX26_KERNEL)
	cp -dpf $(LINUX26_DIR)/uImage /tftpboot/$(LINUX26_KERNEL)
	mkdir -p $(TARGET_DIR)/boot/
	cp -dpf $(LINUX26_DIR)/.config $(TARGET_DIR)/boot/$(BOARD_NAME)-linux-$(LINUX26_VERSION).config
	cp -dpf .config $(TARGET_DIR)/boot/$(BOARD_NAME)-buildroot.config
	cp -dpf $(BUSYBOX_DIR)/.config $(TARGET_DIR)/boot/busybox.config

$(PROJECT_BUILD_DIR)/linux.bin: $(LINUX26_DIR)/vmlinux
	${KERNEL_CROSS}objcopy -O binary -S $(LINUX26_DIR)/vmlinux $(PROJECT_BUILD_DIR)/linux.bin

$(LINUX26_DIR)/uImage: $(LINUX26_DIR)/arch/$(ARCH)/boot/uImage
	cp -dpf $(LINUX26_DIR)/arch/$(ARCH)/boot/uImage $(LINUX26_DIR)/uImage


$(PROJECT_BUILD_DIR)/xxxx: $(PROJECT_BUILD_DIR)/linux.bin $(MKIMAGE)
	gzip -v9 -c $(PROJECT_BUILD_DIR)/linux.bin > $(PROJECT_BUILD_DIR)/linux.bin.gz
	$(MKIMAGE) -A $(ARCH) \
				-O linux \
				-C gzip \
				-a 0x20008000 \
				-e 0x20008000 \
				-d $(PROJECT_BUILD_DIR)/linux.bin.gz \
				$(LINUX26_DIR)/uImage
	rm -f $(PROJECT_BUILD_DIR)/linux.bin.gz
#-----------------------------------------------------------------------------------

$(TARGET_DIR)/lib/modules/$(LINUX26_VERSION)/modules.dep: $(LINUX26_TARGET) $(TARGET_DIR)/sbin/modprobe $(LINUX26_DIR)/vmlinux
	rm -rf $(TARGET_DIR)/lib/modules/$(LINUX26_VERSION)
	rm -f $(TARGET_DIR)/sbin/cardmgr
	$(MAKE) $(LINUX26_MAKE_FLAGS) -C $(LINUX26_DIR) \
		DEPMOD=$(STAGING_DIR)/bin/$(GNU_TARGET_NAME)-depmod26 \
		INSTALL_MOD_PATH=$(TARGET_DIR) modules_install
	(cd $(TARGET_DIR)/lib/modules; \
	  rm -f drivers; \
	  ln -s $(LINUX26_VERSION)/kernel/drivers .)
	chmod a+x target/depmod.pl
	target/depmod.pl \
		-b $(TARGET_DIR)/lib/modules/$(DOWNLOAD_LINUX26_VERSION) \
		-k $(LINUX26_DIR)/vmlinux \
		-F $(LINUX26_DIR)/System.map \
		> $(TARGET_DIR)/lib/modules/$(shell cat $(LINUX26_DIR)/include/config/kernel.release 2> /dev/null)/modules.dep
	rm -f $(TARGET_DIR)/lib/modules/$(LINUX26_VERSION)/build
	touch -c $@

$(STAGING_DIR)/include/linux/version.h: $(LINUX26_DIR)/.configured
	mkdir -p $(STAGING_DIR)/include
	tar -ch -C $(LINUX26_DIR)/include -f - linux | tar -xf - -C $(STAGING_DIR)/include/
	tar -ch -C $(LINUX26_DIR)/include -f - asm | tar -xf - -C $(STAGING_DIR)/include/

linux26-menuconfig: $(LINUX26_DIR)/.patched host-sed
	[ -f $(LINUX26_DIR)/.config ] || cp $(LINUX26_KCONFIG) $(LINUX26_DIR)/.config
	$(MAKE) $(LINUX26_MAKE_FLAGS) -C $(LINUX26_DIR) menuconfig
	-[ -f $(LINUX26_DIR)/.config ] && touch $(LINUX26_DIR)/.configured

linux26: cross-depmod26 $(TARGET_DIR)/lib/modules/$(LINUX26_VERSION)/modules.dep $(LINUX26_TARGET)

linux26-source: $(DL_DIR)/$(LINUX26_SOURCE)

# This has been renamed so we do _NOT_ by default run this on 'make clean'
linux26clean:
	rm -f $(LINUX26_TARGET)
	rm -f $(PROJECT_BUILD_DIR)/linux.bin
	rm -f $(LINUX26_DIR)/uImage
	-$(MAKE) PATH=$(TARGET_PATH) -C $(LINUX26_DIR) clean

linux26-dirclean:
	rm -f $(LINUX26_TARGET)
	rm -f $(PROJECT_BUILD_DIR)/linux.bin
	rm -rf $(LINUX26_DIR)

linux-update:
	cp -dpf $(LINUX26_DIR)/.config $(LINUX26_KCONFIG)

linux-test:
	@echo "LINUX_HEADERS_VERSION" $(LINUX_HEADERS_VERSION)
	@echo "BR2_PACKAGE_LINUX" $(BR2_PACKAGE_LINUX)
	@echo "BR2_CUSTOM_DOWNLOAD_LINUX26_VERSION" $(BR2_CUSTOM_DOWNLOAD_LINUX26_VERSION)
	@echo "BR2_CUSTOM_LINUX26_VERSION" $(BR2_CUSTOM_LINUX26_VERSION)
	@echo "BR2_CUSTOM_LINUX26_RC_PATCH" $(BR2_CUSTOM_LINUX26_RC_PATCH)
	@echo "BR2_LINUX_BSP_PATCH" $(BR2_LINUX_BSP_PATCH)
	@echo "BR2_DOWNLOAD_LINUX26_VERSION" $(BR2_DOWNLOAD_LINUX26_VERSION)
	@echo "BR2_LINUX26_VERSION" $(BR2_LINUX26_VERSION)
	@echo "LINUX26_VERSION" $(LINUX26_VERSION)
	@echo "BR2_LINUX26_RC_PATCH" $(BR2_LINUX26_RC_PATCH)
	@echo "BR2_PACKAGE_LINUX26_KCONFIG" $(BR2_PACKAGE_LINUX_KCONFIG)
	@echo "LINUX26_KCONFIG" $(LINUX26_KCONFIG)
	@echo "BR2_LINUX_BIN_CUSTOM" $(BR2_LINUX_BIN_CUSTOM)
	@echo "BR2_PACKAGE_LINUX_FORMAT" $(BR2_PACKAGE_LINUX_FORMAT)
	@echo "BR2_LINUX_IN_ROOTFS" $(BR2_LINUX_IN_ROOTFS)
	@echo "BR2_LINUX_2_6_22_1" $(BR2_LINUX_2_6_22_1)