summaryrefslogtreecommitdiffstats
path: root/rules/xchain-kernel.make
blob: 311eed6569c0147c61239aa6790d8817130fd2e2 (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
# -*-makefile-*-
# $Id: xchain-kernel.make,v 1.10 2003/09/16 22:13:59 mkl Exp $
#
# (c) 2002 by Pengutronix e.K., Hildesheim, Germany
# See CREDITS for details about who has contributed to this project.
#
# For further information about the PTXDIST project and license conditions
# see the README file.
#

#
# There are two "groups" of targets here: that ones starting with xchain- are
# only used for the cross chain. The "normal" targets are used for building the
# runtime kernel.
#

ifdef BUILD_CROSSCHAIN
XCHAIN += xchain-kernel
endif


XCHAIN_KERNEL_BUILDDIR	= $(BUILDDIR)/xchain-kernel

# ----------------------------------------------------------------------------
# Get
# ----------------------------------------------------------------------------

xchain-kernel_get: $(STATEDIR)/xchain-kernel.get

$(STATEDIR)/xchain-kernel.get: $(kernel_get_deps)
	@$(call targetinfo, xchain-kernel.get)
	touch $@

# ----------------------------------------------------------------------------
# Extract
# ----------------------------------------------------------------------------

xchain-kernel_extract: $(STATEDIR)/xchain-kernel.extract

xchain_kernel_extract_deps =  $(kernel_get_deps)
ifdef PTXCONF_KERNEL_MTD
xchain_kernel_extract_deps += $(STATEDIR)/mtd.extract
endif

$(STATEDIR)/xchain-kernel.extract:  $(xchain_kernel_extract_deps)
	@$(call targetinfo, xchain-kernel.extract)
	@$(call clean, $(BUILDDIR)/xchain-kernel)
	@$(call extract, $(KERNEL_SOURCE), $(BUILDDIR)/xchain-kernel/tmp)
#	#
#	# kernels before 2.4.19 extract to "linux" instead of "linux-version"
#	# 
        ifeq (y,$(PTXCONF_KERNEL_2_4_18))
	cd $(BUILDDIR)/xchain-kernel/tmp && mv linux $(KERNEL)
        endif
#	#
#	# ARM patch 
#	#
        ifeq (y,$(PTXCONF_ARCH_ARM))
	cd $(BUILDDIR)/xchain-kernel/tmp/$(KERNEL) && 			\
		$(KERNEL_RMKPATCH_EXTRACT) $(KERNEL_RMKPATCH_SOURCE) |  \
		patch -p1
        endif
#	# 
#	# XSCALE patch
#	#
        ifeq (y, $(PTXCONF_KERNEL_XSCALE))
	cd $(BUILDDIR)/xchain-kernel/tmp/$(KERNEL) && 			\
		$(KERNEL_PXAPATCH_EXTRACT) $(KERNEL_PXAPATCH_SOURCE) |  \
		patch -p1
        endif
#	#
#	# MTD patch
#	#
        ifeq (y, $(PTXCONF_KERNEL_MTD))
	cd $(BUILDDIR)/xchain-kernel/tmp/$(KERNEL) &&						\
		$(KERNEL_MTDPATCH_EXTRACT) $(KERNEL_MTDPATCH_SOURCE) |	\
		patch -p1
        endif
#	#
#	# XSCALE_PTX patch
#	# 
        ifeq (y, $(PTXCONF_KERNEL_XSCALE_PTX))
	cd $(BUILDDIR)/xchain-kernel/tmp/$(KERNEL) && 			\
		$(KERNEL_PTXPATCH_EXTRACT) $(KERNEL_PTXPATCH_SOURCE) |	\
		patch -p1
        endif
#	#
# 	# patch for mmu-less architectures
#	#
        ifdef PTXCONF_ARCH_NOMMU
	cd $(BUILDDIR)/xchain-kernel/tmp/$(KERNEL) && \
		$(KERNEL_UCLINUXPATCH_EXTRACT) $(KERNEL_UCLINUXPATCH_SOURCE) | \
		patch -p1 || true
        endif
#	# fake headers
	make -C $(BUILDDIR)/xchain-kernel/tmp/$(KERNEL) include/linux/version.h
	touch $(BUILDDIR)/xchain-kernel/tmp/$(KERNEL)/include/linux/autoconf.h
#	# we are only interested in include/ here 
	cp -a $(BUILDDIR)/xchain-kernel/tmp/$(KERNEL)/include $(BUILDDIR)/xchain-kernel/
	rm -fr $(BUILDDIR)/xchain-kernel/tmp
	touch $@

# ----------------------------------------------------------------------------
# Prepare
# ----------------------------------------------------------------------------

xchain-kernel_prepare: $(STATEDIR)/xchain-kernel.prepare

$(STATEDIR)/xchain-kernel.prepare: $(STATEDIR)/xchain-kernel.extract
	@$(call targetinfo, xchain-kernel.prepare)

	rm -rf `find $(XCHAIN_KERNEL_BUILDDIR)/include -name "asm*" -type d |grep -v asm-$(PTXCONF_ARCH)`
	cd $(BUILDDIR)/xchain-kernel/include && ln -s asm-$(PTXCONF_ARCH) asm

ifdef PTXCONF_ARCH_ARM
	cd $(BUILDDIR)/xchain-kernel/include/asm && ln -s proc-$(PTXCONF_ARM_PROC) proc
	cd $(BUILDDIR)/xchain-kernel/include/asm && ln -s arch-$(PTXCONF_ARM_ARCH) arch
endif

ifdef PTXCONF_ARCH_ARM_NOMMU
	cd $(BUILDDIR)/xchain-kernel/include/asm && ln -s proc-$(PTXCONF_ARM_PROC) proc
	cd $(BUILDDIR)/xchain-kernel/include/asm && ln -s arch-$(PTXCONF_ARM_ARCH) arch
endif
	touch $@


# ----------------------------------------------------------------------------
# Compile
# ----------------------------------------------------------------------------

xchain-kernel_compile: $(STATEDIR)/xchain-kernel.compile

$(STATEDIR)/xchain-kernel.compile:
	@$(call targetinfo, xchain-kernel.compile)
	touch $@

# ----------------------------------------------------------------------------
# Install
# ----------------------------------------------------------------------------

$(STATEDIR)/xchain-kernel.install: $(STATEDIR)/xchain-kernel.prepare
	@$(call targetinfo, xchain-kernel.install)
	install -d $(PTXCONF_PREFIX)/$(PTXCONF_GNU_TARGET)
	cp -a $(BUILDDIR)/xchain-kernel/include $(PTXCONF_PREFIX)/$(PTXCONF_GNU_TARGET)/
	touch $@

# ----------------------------------------------------------------------------
# Target-Install
# ----------------------------------------------------------------------------

xchain-kernel_targetinstall: $(STATEDIR)/xchain-kernel.targetinstall

$(STATEDIR)/xchain-kernel.targetinstall:
	@$(call targetinfo, xchain-kernel.targetinstall)
	touch $@

# ----------------------------------------------------------------------------
# Clean
# ----------------------------------------------------------------------------

xchain-kernel_clean: 
	rm -fr $(STATEDIR)/xchain-kernel.*
	rm -fr $(XCHAIN_KERNEL_BUILDDIR)

# vim: syntax=make