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