5d55ac9f708fb29cb8c8767c46d68e9880dc7e15
[openwrt.git] / openwrt / package / linux / linux.mk
1 #############################################################
2 # $Id$
3 #
4 # Linux kernel target for the OpenWRT project
5 #
6 # patches are sorted by numbers
7 # 000 patch between linux-2.4.29 and linux-mips-cvs
8 # 0xx linksys patches
9 # 1xx OpenWRT patches (diag,compressed,..)
10 # 2xx fixes for 2.4.29 integration (wl driver)
11 # 3xx kernel feature patches (squashfs,jffs2 compression,..)
12 # 4xx patches needed to integrate feature patches
13 #
14 #############################################################
15
16 LINUX_FORMAT=zImage
17 LINUX_KARCH:=$(shell echo $(ARCH) | sed -e 's/i[3-9]86/i386/' \
18 -e 's/mipsel/mips/' \
19 -e 's/powerpc/ppc/' \
20 -e 's/sh[234]/sh/' \
21 )
22
23 LINUX_BINARY_DRIVER_SITE=http://openwrt.openbsd-geek.de
24 LINUX_SOURCE=linux-$(LINUX_VERSION).tar.bz2
25 LINUX_KCONFIG=./linux.config
26 LINUX_PATCHES=./kernel-patches
27 LINUX_KERNEL_SOURCE=./kernel-source
28 LINUX_BINLOC=arch/$(LINUX_KARCH)/brcm-boards/bcm947xx/compressed/piggy
29 # Used by pcmcia-cs and others
30 LINUX_SOURCE_DIR=$(LINUX_DIR)-$(LINUX_VERSION)
31
32 # binary driver extracted from linksys firmware GPL sourcetree WRT54GS_3_37_2_1109_US
33 LINUX_BINARY_WL_DRIVER=kernel-binary-wl-0.1.tar.gz
34 LINUX_BINARY_WL_MD5SUM=1b57ba129ad80c7f1702d0be1422cfba
35 LINUX_BINARY_ET_DRIVER=kernel-binary-et-0.2.tar.gz
36 LINUX_BINARY_ET_MD5SUM=d657f929bceee926bc28821d753d945c
37
38 TARGET_MODULES_DIR=$(TARGET_DIR)/lib/modules/$(LINUX_VERSION)
39
40 $(DL_DIR)/$(LINUX_BINARY_WL_DRIVER):
41 $(SCRIPT_DIR)/download.pl $(DL_DIR) $(LINUX_BINARY_WL_DRIVER) $(LINUX_BINARY_WL_MD5SUM) $(LINUX_BINARY_DRIVER_SITE)
42
43 $(DL_DIR)/$(LINUX_BINARY_ET_DRIVER):
44 $(SCRIPT_DIR)/download.pl $(DL_DIR) $(LINUX_BINARY_ET_DRIVER) $(LINUX_BINARY_ET_MD5SUM) $(LINUX_BINARY_DRIVER_SITE)
45
46 $(LINUX_DIR)/.unpacked: $(DL_DIR)/$(LINUX_SOURCE) $(DL_DIR)/$(LINUX_BINARY_WL_DRIVER) $(DL_DIR)/$(LINUX_BINARY_ET_DRIVER)
47 -mkdir -p $(BUILD_DIR)
48 bzcat $(DL_DIR)/$(LINUX_SOURCE) | tar -C $(BUILD_DIR) $(TAR_OPTIONS) -
49 ln -sf $(LINUX_DIR)-$(LINUX_VERSION) $(LINUX_DIR)
50 # extract wlan and lan binary only driver
51 zcat $(DL_DIR)/$(LINUX_BINARY_WL_DRIVER) | tar -C $(BUILD_DIR) $(TAR_OPTIONS) -
52 zcat $(DL_DIR)/$(LINUX_BINARY_ET_DRIVER) | tar -C $(BUILD_DIR) $(TAR_OPTIONS) -
53 touch $(LINUX_DIR)/.unpacked
54
55 $(LINUX_DIR)/.patched: $(LINUX_DIR)/.unpacked
56 $(PATCH) $(LINUX_DIR) $(LINUX_PATCHES)
57 # copy kernel source which is maintained in openwrt via cvs
58 cp -a $(LINUX_KERNEL_SOURCE)/* $(LINUX_DIR)
59 # copy binary drivers
60 cp -a $(BUILD_DIR)/wl/*.o $(LINUX_DIR)/drivers/net/wl
61 cp -a $(BUILD_DIR)/et/*.o $(LINUX_DIR)/drivers/net/et
62 touch $(LINUX_DIR)/.patched
63
64 $(LINUX_DIR)/.configured: $(LINUX_DIR)/.patched
65 -cp $(LINUX_KCONFIG) $(LINUX_DIR)/.config
66 $(SED) "s,^CROSS_COMPILE.*,CROSS_COMPILE=$(KERNEL_CROSS),g;" \
67 $(LINUX_DIR)/Makefile \
68 $(LINUX_DIR)/arch/mips/Makefile
69 $(SED) "s,\-mcpu=,\-mtune=,g;" $(LINUX_DIR)/arch/mips/Makefile
70 $(MAKE) -C $(LINUX_DIR) ARCH=$(LINUX_KARCH) oldconfig include/linux/version.h
71 touch $(LINUX_DIR)/.configured
72
73 $(LINUX_DIR)/.depend_done: $(LINUX_DIR)/.configured
74 $(MAKE) -C $(LINUX_DIR) ARCH=$(LINUX_KARCH) dep
75 touch $(LINUX_DIR)/.depend_done
76
77 $(LINUX_DIR)/$(LINUX_BINLOC): $(LINUX_DIR)/.depend_done
78 $(MAKE) -C $(LINUX_DIR) ARCH=$(LINUX_KARCH) PATH=$(TARGET_PATH) $(LINUX_FORMAT)
79
80 $(LINUX_KERNEL): $(LINUX_DIR)/$(LINUX_BINLOC)
81 cp -fa $(LINUX_DIR)/$(LINUX_BINLOC) $(LINUX_KERNEL)
82 touch -c $(LINUX_KERNEL)
83
84 $(LINUX_DIR)/.modules_done: $(LINUX_KERNEL)
85 rm -rf $(BUILD_DIR)/modules
86 $(MAKE) -C $(LINUX_DIR) ARCH=$(LINUX_KARCH) PATH=$(TARGET_PATH) modules
87 $(MAKE) -C $(LINUX_DIR) DEPMOD=true INSTALL_MOD_PATH=$(BUILD_DIR)/modules modules_install
88 touch $(LINUX_DIR)/.modules_done
89
90 $(STAGING_DIR)/include/linux/version.h: $(LINUX_DIR)/.configured
91 mkdir -p $(STAGING_DIR)/include
92 tar -ch -C $(LINUX_DIR)/include -f - linux | tar -xf - -C $(STAGING_DIR)/include/
93 tar -ch -C $(LINUX_DIR)/include -f - asm | tar -xf - -C $(STAGING_DIR)/include/
94
95 $(TARGET_MODULES_DIR):
96 -mkdir -p $(TARGET_MODULES_DIR)
97 cp $(LINUX_DIR)/drivers/net/wl/wl.o $(TARGET_MODULES_DIR)
98 cp $(LINUX_DIR)/drivers/net/et/et.o $(TARGET_MODULES_DIR)
99 cp $(LINUX_DIR)/drivers/net/diag/diag.o $(TARGET_MODULES_DIR)
100
101 linux: $(LINUX_DIR)/.modules_done $(TARGET_MODULES_DIR)
102
103 linux-source: $(DL_DIR)/$(LINUX_SOURCE)
104
105 # This has been renamed so we do _NOT_ by default run this on 'make clean'
106 linuxclean: clean
107 rm -f $(LINUX_KERNEL)
108 -$(MAKE) -C $(LINUX_DIR) clean
109
110 linux-dirclean:
111 rm -f $(BUILD_DIR)/openwrt-kmodules.tar.bz2
112 rm -rf $(LINUX_DIR)-$(LINUX_VERSION)
113 rm -rf $(LINUX_DIR)
114 rm -rf $(BUILD_DIR)/modules
115 rm -rf $(BUILD_DIR)/wl
116 rm -rf $(BUILD_DIR)/et
117
This page took 0.044159 seconds and 3 git commands to generate.