source: floppyfw/package/linux/linux.mk @ 218

Revision 218, 7.1 KB checked in by root, 10 years ago (diff)

Way too much for one commit (as usual) but this is the 2.6 preparation and also fixes on the make system.

Line 
1#############################################################
2#
3# Linux kernel targets
4#
5# Note:  If you have any patches to apply, create the directory
6# sources/kernel-patches and put your patches in there and number
7# them in the order you wish to apply them...  i.e.
8#
9#   patches/kernel/001-my-special-stuff.bz2
10#   patches/kernel/003-gcc-Os.bz2
11#   patches/kernel/004_no-warnings.bz2
12#   patches/kernel/030-lowlatency-mini.bz2
13#   patches/kernel/031-lowlatency-fixes-5.bz2
14#   patches/kernel/099-shutup.bz2
15#   etc...
16#
17# these patches will all be applied by the patch-kernel.sh
18# script (which will also abort the build if it finds rejects)
19#  -Erik
20#
21# It will also do patch-o-matic patches, dependant on the patch-o-matic
22# TARGET and the POM_PATCHES list in the main Makefile.
23#
24# -Thomas.
25#
26#############################################################
27
28# Encapsulate:
29ifeq ($(strip $(BR2_PACKAGE_LINUX_24)),y)
30
31
32# Version of Linux to download and then apply patches to
33DOWNLOAD_LINUX_VERSION=2.4.34
34# Version of Linux AFTER patches
35LINUX_VERSION=$(DOWNLOAD_LINUX_VERSION)-floppyfw-$(FLOPPYFW_VERSION)
36
37LINUX_FORMAT=bzImage
38LINUX_BINLOC=arch/$(ARCH)/boot/$(LINUX_FORMAT)
39
40LINUX_DIR=$(BUILD_DIR)/linux-$(LINUX_VERSION)
41LINUX_SOURCE=linux-$(DOWNLOAD_LINUX_VERSION).tar.bz2
42LINUX_SITE=ftp://ftp.kernel.org/pub/linux/kernel/v2.4
43LINUX_KERNEL=$(LINUX_DIR)/vmlinuz
44# Used by pcmcia-cs and others
45LINUX_SOURCE_DIR=$(LINUX_DIR)
46LINUX_MODULES_DEP=$(MODULES_DIR)/lib/modules/$(LINUX_VERSION)/modules.dep
47
48# LINUX_CC_OPTS="-Os -pipe"
49# LINUX_CC_OPTS="-Os -mregparm=3 -falign-functions=2 -falign-jumps=2 -falign-labels=2 -falign-loops=2"
50# LINUX_CC_OPTS="-Os -funit-at-a-time  -mregparm=3 -Wall -Wstrict-prototypes -Wno-trigraphs -fno-strict-aliasing -fno-common -fomit-frame-pointer -pipe -mpreferred-stack-boundary=2 -march=i386 -nostdinc -iwithprefix"
51
52LINUX_KCONFIG_24:=$(strip $(subst ",, $(LINUX_KCONFIG_24)))
53#"
54
55DEPMOD=scripts/depmod.pl
56DEPMOD_CMD= [ -d $(MODULES_DIR)/lib/modules/$(LINUX_VERSION) ] && \
57        $(DEPMOD) -n \
58        -b $(MODULES_DIR)/lib/modules/$(LINUX_VERSION)/ \
59        -F $(LINUX_DIR)/System.map \
60        > $(LINUX_MODULES_DEP)
61
62$(DL_DIR)/$(LINUX_SOURCE):
63         $(WGET) -P $(DL_DIR) $(LINUX_SITE)/$(LINUX_SOURCE)
64
65$(LINUX_DIR)/.unpacked: \
66                busybox-source patch-o-matic-source hostap-driver-source \
67                $(IPTABLES_BUILD_DIR)/.configured $(DL_DIR)/$(LINUX_SOURCE)
68        ARGH!
69        # Just to make sure it's gone.
70        -$(RM) -r $(MODULES_DIR)/lib
71        -$(RM) $(MODULES_DIR)/.stripped
72        -$(RM) -r $(LINUX_DIR)
73        bzcat $(DL_DIR)/$(LINUX_SOURCE) | tar $(TAR_VERBOSE) \
74                -C $(BUILD_DIR) -xf -
75# I shall not need this!
76ifneq ($(DOWNLOAD_LINUX_VERSION),$(LINUX_VERSION))
77        # Rename the dir from the downloaded version to the AFTER patch version
78        mv -f $(BUILD_DIR)/linux-$(DOWNLOAD_LINUX_VERSION) $(LINUX_DIR)
79        touch $(LINUX_DIR)/.unpacked
80endif
81
82$(LINUX_DIR)/.patched: $(LINUX_DIR)/.unpacked
83        mkdir -p $(PATCH_DIR)/kernel
84        # Patching the kernel.
85        $(SCRIPTS_DIR)/patch-kernel.sh $(LINUX_DIR) $(PATCH_DIR)/kernel 0*
86        echo "Patched the kernel with $(PATCH_DIR)/kernel patches"
87
88        # Patching the kernel with iptables-pom-stuff:
89ifeq ($(BR2_PACKAGE_POM),y)
90        (cd $(PATCH_O_MATIC_DIR); \
91                KERNEL_DIR=$(LINUX_DIR) \
92                IPTABLES_DIR=$(IPTABLES_BUILD_DIR) \
93                ./runme --batch $(POM_PATCHES) \
94                 );
95endif
96ifeq ($(BR2_PACKAGE_HOSTAP),y)
97        (cd $(LINUX_DIR); \
98        cat $(HOSTAP_DRIVER_KERNEL_PATCH) | patch -p1 ; \
99        cp $(HOSTAP_DRIVER_DIR)/driver/modules/hostap*.[ch] \
100        drivers/net/wireless/. );
101endif
102
103        # Postpatching the kernel after iptables-pom-stuff because of the
104        # troublesome CONFIG_IP_NF_MATCH_OWNER option.
105        $(SCRIPTS_DIR)/patch-kernel.sh $(LINUX_DIR) \
106                $(PATCH_DIR)/kernel-after-pom 0*
107
108        # From a lwn article: need gcc 3.4/3.5,
109        # It segfaults with it..
110        #  -funit-at-a-time  -mregparm=3
111        # From a patch by Eric Anderson: (But these don't reduce size, weird)
112        #  -falign-functions=2 -falign-jumps=2 -falign-labels=2 -falign-loops=2
113        # From: http://www.ussg.iu.edu/hypermail/linux/kernel/0501.2/0856.html
114        #  -mpreferred-stack-boundary=2 -malign-loops=0 -malign-jumps=0 -malign-functions=0
115        #  But: -malign-loops is obsolete, use -falign-loops
116        #  -malign-jumps is obsolete, use -falign-jumps
117        #  -malign-functions is obsolete, use -falign-functions
118        #  And they don't make a smaller kernel than pure -Os anyway.
119        $(SED) 's/\-O2/-Os -pipe/;' $(LINUX_DIR)/Makefile
120        -(cd $(BUILD_DIR); ln -sf $(LINUX_DIR) linux)
121        touch $(LINUX_DIR)/.patched
122
123$(CONFIG_DIR)/$(LINUX_KCONFIG_24):
124        @if [ ! -f "$(CONFIG_DIR)/$(LINUX_KCONFIG_24)" ] ; then \
125                echo ""; \
126                echo "You should create a .config for your kernel"; \
127                echo "and install it as $(CONFIG_DIR)/$(LINUX_KCONFIG_24)"; \
128                echo ""; \
129                sleep 5; \
130        fi;
131
132$(LINUX_DIR)/.configured:  $(LINUX_DIR)/.patched  $(CONFIG_DIR)/$(LINUX_KCONFIG_24)
133        -cp $(CONFIG_DIR)/$(LINUX_KCONFIG_24) $(LINUX_DIR)/.config
134ifeq ($(strip $(EMULATE_FPU)),y)
135        $(SED) "s/^.*CONFIG_MATH_EMULATION.*/CONFIG_MATH_EMULATION=y/;" \
136                $(LINUX_DIR)/.config
137else
138        $(SED) "s/^.*CONFIG_MATH_EMULATION.*/CONFIG_MATH_EMULATION=n/;" \
139                $(LINUX_DIR)/.config
140endif
141# Don't need this right now.
142#ifeq ($(filter $(TARGETS),madwifi), madwifi)
143#       $(SED) "s/^.*CONFIG_CRYPTO.*/CONFIG_CRYPTO=y/;" \
144#               $(LINUX_DIR)/.config
145#endif
146        $(SED) 's/^EXTRAVERSION\s=\s(.*)/EXTRAVERSION = $$1-floppyfw-$(FLOPPYFW_VERSION)/;' \
147                $(LINUX_DIR)/Makefile
148        $(MAKE) -C $(LINUX_DIR) oldconfig include/linux/version.h
149        touch $(LINUX_DIR)/.configured
150
151linux-source-configured: $(LINUX_DIR)/.configured
152        Innom linux-source-configured
153
154$(LINUX_DIR)/.depend_done: $(LINUX_DIR)/.configured
155        $(MAKE) -C $(LINUX_DIR) dep
156        touch $(LINUX_DIR)/.depend_done
157
158$(LINUX_DIR)/$(LINUX_BINLOC): $(LINUX_DIR)/.depend_done
159        $(MAKE) CC="$(TARGET_CC)" -C $(LINUX_DIR) $(LINUX_FORMAT)
160        $(MAKE) CC="$(TARGET_CC)" -C $(LINUX_DIR) modules
161        $(RM) -r $(MODULES_DIR)/lib/modules
162        $(MAKE) -C $(LINUX_DIR) INSTALL_MOD_PATH=$(MODULES_DIR) modules_install
163        (cd $(MODULES_DIR)/lib/modules; ln -s $(LINUX_VERSION)/kernel/drivers .)
164
165$(LINUX_KERNEL): $(LINUX_DIR)/$(LINUX_BINLOC)
166        cp -fa $(LINUX_DIR)/$(LINUX_BINLOC) $(LINUX_KERNEL)
167        # cp -fa $(LINUX_DIR)/$(LINUX_BINLOC) $(LINUX_KERNEL).upx
168        # $(UPX) -9 $(LINUX_KERNEL).upx
169        touch -c $(LINUX_KERNEL)
170
171$(LINUX_MODULES_DEP): $(LINUX_KERNEL)
172        # Modutils-version
173        #/sbin/depmod -aen -F $(LINUX_DIR)/System.map -b $(MODULES_DIR)/lib/modules/$(LINUX_VERSION) > $(LINUX_MODULES_DEP)
174
175        # Back up first.
176        [ -f  $(LINUX_MODULES_DEP) ] && cp $(LINUX_MODULES_DEP) \
177                $(LINUX_MODULES_DEP).org
178
179        # Run depmod.
180        $(DEPMOD_CMD)
181
182        [ -f  $(LINUX_MODULES_DEP) ] && cp $(LINUX_MODULES_DEP) \
183                $(LINUX_MODULES_DEP).precaps
184
185        (cd $(MODULES_DIR) ; \
186                cat $(LINUX_MODULES_DEP) \
187                        | $(SCRIPTS_DIR)/capsfix.pl > $(TMP_DIR)/moddep \
188                );
189
190        mv $(TMP_DIR)/moddep $(LINUX_MODULES_DEP)
191
192linux: busybox-source patch-o-matic-source hostap-driver-source \
193                $(IPTABLES_BUILD_DIR)/.configured \
194                $(LINUX_MODULES_DEP)
195                # $(LINUX_KERNEL)
196
197linux-source: $(DL_DIR)/$(LINUX_SOURCE)
198
199linux-menuconfig: $(LINUX_DIR)/.configured
200        ( cd $(LINUX_DIR) ; \
201                make menuconfig ; \
202                cp .config $(CONFIG_DIR)/$(LINUX_KCONFIG_24) \
203        )
204
205# This has been renamed so we do _NOT_ by default run this on 'make clean'
206linuxclean: clean
207        $(RM) $(LINUX_KERNEL)
208        -$(MAKE) -C $(LINUX_DIR) clean
209
210linux-dirclean:
211        $(RM) -r $(LINUX_DIR)
212
213# End encapsulation
214endif
Note: See TracBrowser for help on using the repository browser.