source: floppyfw/makefiles/linux.mk @ 122

Revision 122, 6.7 KB checked in by root, 8 years ago (diff)

Adding madwifi.

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# Version of Linux to download and then apply patches to
29DOWNLOAD_LINUX_VERSION=2.4.33.3
30# Version of Linux AFTER patches
31LINUX_VERSION=$(DOWNLOAD_LINUX_VERSION)-floppyfw-$(FLOPPYFW_VERSION)
32
33LINUX_FORMAT=bzImage
34LINUX_BINLOC=arch/$(ARCH)/boot/$(LINUX_FORMAT)
35
36LINUX_DIR=$(BUILD_DIR)/linux-$(LINUX_VERSION)
37LINUX_SOURCE=linux-$(DOWNLOAD_LINUX_VERSION).tar.bz2
38LINUX_SITE=ftp://ftp.kernel.org/pub/linux/kernel/v2.4
39LINUX_KCONFIG=$(CONFIG_DIR)/config-kernel
40LINUX_KERNEL=$(LINUX_DIR)/vmlinuz
41# Used by pcmcia-cs and others
42LINUX_SOURCE_DIR=$(LINUX_DIR)
43
44UPX=upx-1.11
45#LINUX_CC_OPTS="-Os -pipe"
46# LINUX_CC_OPTS="-Os -mregparm=3 -falign-functions=2 -falign-jumps=2 -falign-labels=2 -falign-loops=2"
47#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"
48
49$(DL_DIR)/$(LINUX_SOURCE):
50         $(WGET) -P $(DL_DIR) $(LINUX_SITE)/$(LINUX_SOURCE)
51
52$(LINUX_DIR)/.unpacked: $(DL_DIR)/$(LINUX_SOURCE) 
53        -$(RM) -r $(MODULES_DIR)/lib
54        -$(RM) $(MODULES_DIR)/.stripped
55        -$(RM) -r $(LINUX_DIR)
56        bzcat $(DL_DIR)/$(LINUX_SOURCE) | tar $(TAR_VERBOSE) \
57                -C $(BUILD_DIR) -xf -
58ifneq ($(DOWNLOAD_LINUX_VERSION),$(LINUX_VERSION))
59        # Rename the dir from the downloaded version to the AFTER patch version
60        mv -f $(BUILD_DIR)/linux-$(DOWNLOAD_LINUX_VERSION) $(LINUX_DIR)
61        touch $(LINUX_DIR)/.unpacked
62endif
63
64$(LINUX_DIR)/.patched: $(LINUX_DIR)/.unpacked
65        mkdir -p $(PATCH_DIR)/kernel
66        # Patching the kernel.
67        $(PATCH_DIR)/patch-kernel.sh $(LINUX_DIR) $(PATCH_DIR)/kernel 0*
68        echo "Patched the kernel with $(PATCH_DIR)/kernel patches"
69
70        # Patching the kernel with iptables-pom-stuff:
71ifeq ($(filter $(TARGETS),patch-o-matic), patch-o-matic)
72        (cd $(PATCH_O_MATIC_DIR); \
73                KERNEL_DIR=$(LINUX_DIR) \
74                IPTABLES_DIR=$(IPTABLES_BUILD_DIR) \
75                ./runme --batch $(POM_PATCHES) \
76                 );
77endif
78ifeq ($(filter $(TARGETS),hostap), hostap)
79        (cd $(LINUX_DIR); \
80        cat $(HOSTAP_DRIVER_KERNEL_PATCH) | patch -p1 ; \
81        cp $(HOSTAP_DRIVER_DIR)/driver/modules/hostap*.[ch] \
82        drivers/net/wireless/. );
83endif
84
85        # Postpatching the kernel after iptables-pom-stuff because of the
86        # troublesome CONFIG_IP_NF_MATCH_OWNER option.
87        $(PATCH_DIR)/patch-kernel.sh $(LINUX_DIR) \
88                $(PATCH_DIR)/kernel-after-pom 0*
89
90        # From a lwn article: need gcc 3.4/3.5,
91        # It segfaults with it..
92        #  -funit-at-a-time  -mregparm=3
93        # From a patch by Eric Anderson: (But these don't reduce size, weird)
94        #  -falign-functions=2 -falign-jumps=2 -falign-labels=2 -falign-loops=2
95        # From: http://www.ussg.iu.edu/hypermail/linux/kernel/0501.2/0856.html
96        #  -mpreferred-stack-boundary=2 -malign-loops=0 -malign-jumps=0 -malign-functions=0
97        #  But: -malign-loops is obsolete, use -falign-loops
98        #  -malign-jumps is obsolete, use -falign-jumps
99        #  -malign-functions is obsolete, use -falign-functions
100        #  And they don't make a smaller kernel than pure -Os anyway.
101        $(SED) 's/\-O2/-Os -pipe/;' $(LINUX_DIR)/Makefile
102        -(cd $(BUILD_DIR); ln -sf $(LINUX_DIR) linux)
103        touch $(LINUX_DIR)/.patched
104
105$(LINUX_KCONFIG):
106        @if [ ! -f "$(LINUX_KCONFIG)" ] ; then \
107                echo ""; \
108                echo "You should create a .config for your kernel"; \
109                echo "and install it as $(LINUX_KCONFIG)"; \
110                echo ""; \
111                sleep 5; \
112        fi;
113
114
115$(LINUX_DIR)/.configured:  $(LINUX_DIR)/.patched  $(LINUX_KCONFIG)
116        -cp $(LINUX_KCONFIG) $(LINUX_DIR)/.config
117ifeq ($(strip $(EMULATE_FPU)),true)
118        $(SED) "s/^.*CONFIG_MATH_EMULATION.*/CONFIG_MATH_EMULATION=y/;" \
119                $(LINUX_DIR)/.config
120else
121        $(SED) "s/^.*CONFIG_MATH_EMULATION.*/CONFIG_MATH_EMULATION=n/;" \
122                $(LINUX_DIR)/.config
123endif
124ifeq ($(filter $(TARGETS),madwifi), madwifi)
125        $(SED) "s/^.*CONFIG_CRYPTO.*/CONFIG_CRYPTO=y/;" \
126                $(LINUX_DIR)/.config
127endif
128        $(SED) 's/^EXTRAVERSION\s=\s(.*)/EXTRAVERSION = $$1-floppyfw-$(FLOPPYFW_VERSION)/;' \
129                $(LINUX_DIR)/Makefile
130        $(MAKE) -C $(LINUX_DIR) oldconfig include/linux/version.h
131        touch $(LINUX_DIR)/.configured
132
133linux-source-configured: $(LINUX_DIR)/.configured
134
135$(LINUX_DIR)/.depend_done: $(LINUX_DIR)/.configured
136        $(MAKE) -C $(LINUX_DIR) dep
137        touch $(LINUX_DIR)/.depend_done
138
139$(LINUX_DIR)/$(LINUX_BINLOC): $(LINUX_DIR)/.depend_done
140        $(MAKE) CC="$(TARGET_CC)" -C $(LINUX_DIR) $(LINUX_FORMAT)
141        $(MAKE) CC="$(TARGET_CC)" -C $(LINUX_DIR) modules
142
143$(MODULES_DIR)/lib/modules/$(LINUX_VERSION)/modules.dep: $(LINUX_DIR)/.depend_done
144        $(RM) -r $(MODULES_DIR)/lib/modules
145        $(MAKE) -C $(LINUX_DIR) INSTALL_MOD_PATH=$(MODULES_DIR) modules_install
146        (cd $(MODULES_BASE_DIR) ; cat $(MODULES_DIR)/lib/modules/$(LINUX_VERSION)/modules.dep | $(BASE_DIR)/perl/capsfix.pl > $(TMP_DIR)/moddep)
147        #mv $(MODULES_DIR)/lib/modules/$(LINUX_VERSION)/modules.dep \
148        #       $(MODULES_DIR)/lib/modules/$(LINUX_VERSION)/modules.dep.precaps
149        mv $(TMP_DIR)/moddep $(MODULES_DIR)/lib/modules/$(LINUX_VERSION)/modules.dep
150        (cd $(MODULES_DIR)/lib/modules; ln -s $(LINUX_VERSION)/kernel/drivers .)
151        # $(DEPMOD)
152
153$(LINUX_KERNEL): $(LINUX_DIR)/$(LINUX_BINLOC)
154        cp -fa $(LINUX_DIR)/$(LINUX_BINLOC) $(LINUX_KERNEL)
155        # cp -fa $(LINUX_DIR)/$(LINUX_BINLOC) $(LINUX_KERNEL).upx
156        # $(UPX) -9 $(LINUX_KERNEL).upx
157        touch -c $(LINUX_KERNEL)
158
159
160linux:  patch-o-matic hostap-driver-source $(IPTABLES_BUILD_DIR)/.configured $(LINUX_KERNEL) $(MODULES_DIR)/lib/modules/$(LINUX_VERSION)/modules.dep
161
162linux-depmod: linux
163        # Modutils-version
164        #/sbin/depmod -aen -F $(LINUX_DIR)/System.map -b $(MODULES_DIR)/lib/modules/$(LINUX_VERSION) > $(MODULES_DIR)/lib/modules/$(LINUX_VERSION)/modules.dep
165        #/sbin/depmod -aen -F $(LINUX_DIR)/System.map -b $(MODULES_DIR)/lib/modules/$(LINUX_VERSION)
166        # busybox perl.
167        [ -d $(MODULES_DIR)/lib/modules/$(LINUX_VERSION) ] && \
168        $(BUSYBOX_DIR)/examples/depmod.pl -n \
169                -b $(MODULES_DIR)/lib/modules/$(LINUX_VERSION)/ \
170                -k $(LINUX_DIR)/vmlinux \
171                > $(MODULES_DIR)/lib/modules/$(LINUX_VERSION)/modules.dep
172
173linux-source: $(DL_DIR)/$(LINUX_SOURCE)
174
175# This has been renamed so we do _NOT_ by default run this on 'make clean'
176linuxclean: clean
177        $(RM) $(LINUX_KERNEL)
178        -$(MAKE) -C $(LINUX_DIR) clean
179
180linux-dirclean:
181        $(RM) -r $(LINUX_DIR)
Note: See TracBrowser for help on using the repository browser.