source: trunk/make/linux/kernel.mk @ 6289

Letzte Änderung dieser Datei seit 6289 war 6289, erstellt von er13 vor 8 Jahren

toolchain:

  • revise the way kernel headers are installed (use headers_install target where possible); fixes uClibc build problems with 2.6.28 kernel (7320)
  • based on oliver's patch provided in #842
  • refs #842
Dateigröße: 9.2 KB
Zeile 
1comma:=,
2space:=$(empty) $(empty)
3AVM_SOURCE:=$(strip $(subst ",, $(subst $(space),\ ,$(FREETZ_DL_KERNEL_SOURCE))))
4
5AVM_UNPACK__INT_.gz:=z
6AVM_UNPACK__INT_.bz2:=j
7
8KERNEL_SUBVERSION:=iln6
9KERNEL_BOARD_REF:=$(KERNEL_REF)
10KERNEL_MAKE_DIR:=$(MAKE_DIR)/linux
11KERNEL_BUILD_DIR:=$(KERNEL_DIR)
12KERNEL_BUILD_ROOT_DIR:=$(KERNEL_BUILD_DIR)/linux-$(KERNEL_VERSION)
13
14KERNEL_IMAGE:=vmlinux.eva_pad
15KERNEL_TARGET_BINARY:=kernel-$(KERNEL_LAYOUT)-$(KERNEL_REF)-$(AVM_VERSION).bin
16KERNEL_CONFIG_FILE:=$(KERNEL_MAKE_DIR)/Config.$(KERNEL_LAYOUT)-$(KERNEL_REF).$(AVM_VERSION)
17
18$(DL_FW_DIR)/$(AVM_SOURCE): | $(DL_FW_DIR)
19    @$(call _ECHO, downloading...)
20    $(DL_TOOL) $(DL_FW_DIR) .config $(FREETZ_DL_KERNEL_SOURCE) $(FREETZ_DL_KERNEL_SITE) $(FREETZ_DL_KERNEL_SOURCE_MD5) $(SILENT)
21
22# Make sure that a perfectly clean build is performed whenever Freetz package
23# options have changed. The safest way to achieve this is by starting over
24# with the source directory.
25$(KERNEL_DIR)/.unpacked: $(DL_FW_DIR)/$(AVM_SOURCE) | gcc-kernel
26    $(RM) -r $(KERNEL_DIR)
27    mkdir -p $(KERNEL_BUILD_DIR)
28    @$(call _ECHO,checking structure... )
29    @KERNEL_SOURCE_CONTENT=` \
30        tar \
31            -t$(AVM_UNPACK__INT_$(suffix $(strip $(FREETZ_DL_KERNEL_SOURCE)))) \
32            -f $(DL_FW_DIR)/$(FREETZ_DL_KERNEL_SOURCE)| \
33        grep -m 1 -e '^.*\/\(GPL-\(release_\|\)kernel\.tar\.gz\|linux-2\.6\...\..\/\)$$'`; \
34    if [ -z "$${KERNEL_SOURCE_CONTENT}" ]; then \
35        $(call ERROR,1,KERNEL_SOURCE_CONTENT is empty) \
36    else \
37        $(call _ECHO, unpacking... ) \
38        if [ ! -z $$(echo "$$KERNEL_SOURCE_CONTENT"|grep -e '.*\/GPL-\(release_\|\)kernel\.tar\.gz') ]; then \
39            tar -O $(VERBOSE) \
40                -x$(AVM_UNPACK__INT_$(suffix $(strip $(FREETZ_DL_KERNEL_SOURCE)))) \
41                -f $(DL_FW_DIR)/$(FREETZ_DL_KERNEL_SOURCE) \
42                --wildcards "*/$${KERNEL_SOURCE_CONTENT##*/}" | \
43            tar -C $(KERNEL_BUILD_DIR) $(VERBOSE) \
44                -xz \
45                --transform="s|^.*\(linux-2\.6\...\..\/\)|\1|g" --show-transformed; \
46        else \
47            tar -C $(KERNEL_BUILD_DIR) $(VERBOSE) \
48                -x$(AVM_UNPACK__INT_$(suffix $(strip $(FREETZ_DL_KERNEL_SOURCE)))) \
49                -f $(DL_FW_DIR)/$(FREETZ_DL_KERNEL_SOURCE) \
50                --transform="s|^.*\(linux-2\.6\...\..\/\)|\1|g" --show-transformed \
51                "$$KERNEL_SOURCE_CONTENT"; \
52        fi \
53    fi
54    @if [ ! -d $(KERNEL_BUILD_ROOT_DIR) ]; then \
55        $(call ERROR,1,KERNEL_BUILD_ROOT_DIR has wrong structure) \
56    fi
57    @$(call _ECHO, preparing... )
58    @set -e; for i in $(KERNEL_MAKE_DIR)/patches/$(KERNEL_VERSION)/*.patch; do \
59        $(PATCH_TOOL) $(KERNEL_BUILD_DIR) $$i; \
60    done
61    #Version specific patches
62    @set -e; shopt -s nullglob; for i in $(KERNEL_MAKE_DIR)/patches/$(KERNEL_VERSION)/$(AVM_VERSION)/*.patch; do \
63        $(PATCH_TOOL) $(KERNEL_BUILD_DIR) $$i; \
64    done
65    @for i in $(KERNEL_LINKING_FILES); do \
66        if [ -e $(KERNEL_BUILD_ROOT_DIR)/$$i -a \
67        ! -e $(KERNEL_BUILD_ROOT_DIR)/include/linux/$${i##*\/linux_} ]; then \
68            $(call MESSAGE, Linking  $(KERNEL_BUILD_ROOT_DIR)/include/linux/$${i##*\/linux_}); \
69            ln -sf ../../$$i $(KERNEL_BUILD_ROOT_DIR)/include/linux/$${i##*\/linux_}; \
70        fi \
71    done
72    @for i in avm_net_trace.h avm_net_trace_ioctl.h; do \
73        if [ -e $(KERNEL_BUILD_ROOT_DIR)/drivers/char/avm_net_trace/$$i -a \
74            ! -e $(KERNEL_BUILD_ROOT_DIR)/include/linux/$$i ]; then \
75                $(call MESSAGE, Linking  $(KERNEL_BUILD_ROOT_DIR)/include/linux/$$i); \
76                ln -sf ../../drivers/char/avm_net_trace/$$i \
77                    $(KERNEL_BUILD_ROOT_DIR)/include/linux/$$i; \
78        fi \
79    done
80    @for i in $$(find $(KERNEL_BUILD_ROOT_DIR) -name Makefile.26 -printf '%h\n'); do \
81        if [ ! -e $$i/Makefile ] ; then \
82            $(call MESSAGE, Linking  $$i/Makefile); \
83            ln -sf Makefile.26 $$i/Makefile; \
84        fi \
85    done
86    @for i in $$(find $(KERNEL_BUILD_ROOT_DIR) -name Makefile -exec \
87        awk '/(obj|subdir)-.*=/{ \
88        while (match ($$0,/\\/)) {sub(/\\/," "); getline l;$$0=$$0""l} \
89        gsub(/(#.*|.*=)/,""); \
90        if (! match ($$0,/,/)) { \
91            dirname=substr(FILENAME,1,length(FILENAME)-8); \
92            for (i=1;i<=NF;i++) { \
93                if (match ($$i,/\.o$$|\$$/)) { \
94                    $$i=""; \
95                } else if (substr($$i,length($$i))!="/") { \
96                    $$i=$$i"/"; \
97                } \
98                if ($$i!="") { \
99                    if (system("test -e "dirname""$$i"Makefile")) { \
100                        print dirname""$$i"Makefile"; \
101                    } \
102                } \
103            } \
104        } \
105    }' {} '+'|sort -u); do \
106        $(call MESSAGE, Creating $$i); \
107        mkdir -p $$(dirname "$$i"); \
108        [ -h $$i ] && $(RM) $$i; \
109        touch $$i; \
110    done
111    @for i in $$(find $(KERNEL_BUILD_ROOT_DIR) -name Kconfig -exec grep -hs "source.*Kconfig" {} '+'| \
112        sed -e 's/\(.*\)#.*/\1/g;s/.*source //g;s/"//g'|sort -u); do \
113        if [ ! -e $(KERNEL_BUILD_ROOT_DIR)/$$i ]; then \
114            $(call MESSAGE, Creating $(KERNEL_BUILD_ROOT_DIR)/$$i); \
115            mkdir -p $(KERNEL_BUILD_ROOT_DIR)/$${i%\/*}; \
116            [ -h $(KERNEL_BUILD_ROOT_DIR)/$$i ] && \
117                $(RM) $(KERNEL_BUILD_ROOT_DIR)/$$i; \
118            touch $(KERNEL_BUILD_ROOT_DIR)/$$i; \
119        fi \
120    done
121    ln -s linux-$(KERNEL_VERSION) $(KERNEL_DIR)/linux
122    touch $@
123
124$(KERNEL_DIR)/.configured: $(KERNEL_DIR)/.unpacked $(KERNEL_CONFIG_FILE)
125    $(call _ECHO, configuring... )
126    cp $(KERNEL_CONFIG_FILE) $(KERNEL_BUILD_ROOT_DIR)/.config
127    $(SUBMAKE) -C $(KERNEL_BUILD_ROOT_DIR) \
128        CROSS_COMPILE="$(KERNEL_CROSS)" \
129        KERNEL_MAKE_PATH="$(KERNEL_MAKE_PATH):$(PATH)" \
130        ARCH="$(KERNEL_ARCH)" \
131        KERNEL_LAYOUT="$(KERNEL_BOARD_REF)" \
132        oldconfig
133    touch $@
134
135$(KERNEL_DIR)/.prepared: $(KERNEL_DIR)/.configured
136    $(SUBMAKE) -C $(KERNEL_BUILD_ROOT_DIR) \
137        CROSS_COMPILE="$(KERNEL_CROSS)" \
138        KERNEL_MAKE_PATH="$(KERNEL_MAKE_PATH):$(PATH)" \
139        ARCH="$(KERNEL_ARCH)" \
140        KERNEL_LAYOUT="$(KERNEL_BOARD_REF)" \
141        prepare
142    touch $@
143
144$(KERNEL_DIR)/.headers_installed: $(KERNEL_DIR)/.prepared
145ifeq ($(strip $(FREETZ_KERNEL_VERSION_2_6_13_1)),y)
146    $(call COPY_KERNEL_HEADERS,$(KERNEL_BUILD_ROOT_DIR),$(KERNEL_HEADERS_DEVEL_DIR),{asm$(comma)asm-generic$(comma)linux})
147else
148    $(SUBMAKE) -C $(KERNEL_BUILD_ROOT_DIR) \
149        CROSS_COMPILE="$(KERNEL_CROSS)" \
150        ARCH=$(KERNEL_ARCH) \
151        INSTALL_HDR_PATH=$(KERNEL_HEADERS_DEVEL_DIR) \
152        headers_install
153    find "$(KERNEL_HEADERS_DEVEL_DIR)" \( -name "..install.cmd" -o -name ".install" \) -exec rm -f \{\} \+
154endif
155    touch $@
156
157# Install the kernel headers to the toolchain dir if necessary
158ifeq ($(strip $(FREETZ_BUILD_TOOLCHAIN)),y)
159$(KERNEL_DIR)/.depend_done: $(KERNEL_DIR)/.headers_installed
160else
161$(KERNEL_DIR)/.depend_done: $(KERNEL_DIR)/.prepared
162endif
163    touch $@
164
165$(KERNEL_BUILD_ROOT_DIR)/$(KERNEL_IMAGE): $(KERNEL_DIR)/.depend_done $(TOOLS_DIR)/lzma $(TOOLS_DIR)/lzma2eva
166    $(call _ECHO, kernel image... )
167    $(SUBMAKE) -C $(KERNEL_BUILD_ROOT_DIR) \
168        CROSS_COMPILE="$(KERNEL_CROSS)" \
169        ARCH=$(KERNEL_ARCH) \
170        $(KERNEL_IMAGE)
171    touch -c $@
172
173kernel-force:
174    $(SUBMAKE) -C $(KERNEL_BUILD_ROOT_DIR) \
175        CROSS_COMPILE="$(KERNEL_CROSS)" \
176        ARCH=$(KERNEL_ARCH) \
177        $(KERNEL_IMAGE)
178
179$(KERNEL_TARGET_DIR)/$(KERNEL_TARGET_BINARY): $(KERNEL_BUILD_ROOT_DIR)/$(KERNEL_IMAGE)
180    cp $(KERNEL_BUILD_ROOT_DIR)/$(KERNEL_IMAGE) $(KERNEL_TARGET_DIR)/$(KERNEL_TARGET_BINARY)
181    cp $(KERNEL_BUILD_ROOT_DIR)/System.map $(KERNEL_TARGET_DIR)/System-$(KERNEL_LAYOUT)-$(KERNEL_REF)-$(AVM_VERSION).map
182    echo "$(KERNEL_SUBVERSION)" > $(KERNEL_TARGET_DIR)/.version-$(KERNEL_LAYOUT)-$(KERNEL_REF)-$(AVM_VERSION)
183    touch -c $@
184
185$(KERNEL_DIR)/.modules-$(KERNEL_LAYOUT): $(KERNEL_BUILD_ROOT_DIR)/$(KERNEL_IMAGE)
186    @$(call _ECHO, modules... )
187    $(SUBMAKE) -C $(KERNEL_BUILD_ROOT_DIR) \
188        CROSS_COMPILE="$(KERNEL_CROSS)" \
189        KERNEL_MAKE_PATH="$(KERNEL_MAKE_PATH):$(PATH)" \
190        KERNEL_LAYOUT="$(KERNEL_BOARD_REF)" \
191        ARCH=$(KERNEL_ARCH) \
192        INSTALL_MOD_PATH="$(FREETZ_BASE_DIR)/$(KERNEL_DIR)" \
193        modules
194    $(SUBMAKE) -C $(KERNEL_BUILD_ROOT_DIR) \
195        CROSS_COMPILE="$(KERNEL_CROSS)" \
196        KERNEL_MAKE_PATH="$(KERNEL_MAKE_PATH):$(PATH)" \
197        KERNEL_LAYOUT="$(KERNEL_BOARD_REF)" \
198        ARCH=$(KERNEL_ARCH) \
199        INSTALL_MOD_PATH="$(FREETZ_BASE_DIR)/$(KERNEL_DIR)" \
200        modules_install
201    touch $@
202
203$(KERNEL_MODULES_DIR)/.modules-$(KERNEL_LAYOUT): $(KERNEL_DIR)/.modules-$(KERNEL_LAYOUT)
204    $(RM) -r $(KERNEL_MODULES_DIR)/lib
205    mkdir -p $(KERNEL_MODULES_DIR)
206    KERNEL_MODULES_SOURCE_DIR=$(KERNEL_DIR)/lib/modules/*/kernel; \
207    tar -cf - -C $$KERNEL_MODULES_SOURCE_DIR \
208        . | tar -xf - -C $(KERNEL_MODULES_DIR)
209    touch $@
210
211kernel-precompiled: pkg-echo-start $(KERNEL_TARGET_DIR)/$(KERNEL_TARGET_BINARY) $(KERNEL_MODULES_DIR)/.modules-$(KERNEL_LAYOUT) pkg-echo-done
212
213kernel-configured: $(KERNEL_DIR)/.depend_done
214
215kernel-modules: $(KERNEL_DIR)/.modules-$(KERNEL_LAYOUT)
216
217kernel-menuconfig: $(KERNEL_DIR)/.configured
218    $(SUBMAKE) -C $(KERNEL_BUILD_ROOT_DIR) \
219        CROSS_COMPILE="$(KERNEL_CROSS)" \
220        KERNEL_MAKE_PATH="$(KERNEL_MAKE_PATH):$(PATH)" \
221        ARCH="$(KERNEL_ARCH)" \
222        KERNEL_LAYOUT="$(KERNEL_BOARD_REF)" \
223        menuconfig
224    -cp -f $(KERNEL_BUILD_ROOT_DIR)/.config $(KERNEL_CONFIG_FILE) && \
225    touch $(KERNEL_DIR)/.configured
226
227kernel-oldconfig: $(KERNEL_DIR)/.configured
228    -cp -f $(KERNEL_BUILD_ROOT_DIR)/.config $(KERNEL_CONFIG_FILE) && \
229    touch $(KERNEL_DIR)/.configured
230
231kernel-source: $(KERNEL_DIR)/.unpacked
232
233kernel-clean:
234    $(SUBMAKE) -C $(KERNEL_BUILD_ROOT_DIR) \
235        CROSS_COMPILE="$(KERNEL_CROSS)" \
236        KERNEL_MAKE_PATH="$(KERNEL_MAKE_PATH):$(PATH)" \
237        ARCH="$(KERNEL_ARCH)" \
238        KERNEL_LAYOUT="$(KERNEL_BOARD_REF)" \
239        clean
240
241kernel-dirclean:
242    $(RM) -r $(SOURCE_DIR_ROOT)/kernel
243    $(RM) $(KERNEL_TARGET_DIR)/.version-*
244    $(RM) $(KERNEL_TARGET_DIR)/System*
245    $(RM) $(KERNEL_TARGET_DIR)/kernel-*
246    $(RM) -r $(KERNEL_TARGET_DIR)/modules-*
247
248kernel-distclean: kernel-dirclean
249
250pkg-echo-start:
251    @$(RM) $(ECHO_ITEM_START) $(ECHO_ITEM_BUILD)
252
253pkg-echo-done:
254    @$(call _ECHO_DONE)
255
256.PHONY: kernel-configured kernel-modules kernel-menuconfig kernel-oldconfig
Hinweis: Hilfe zum Repository-Browser finden Sie in TracBrowser.