asus not netgear
[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.xx and linux-mips-cvs
8 # 0xx linksys patches
9 # 1xx OpenWRT patches (diag,compressed,..)
10 # 2xx fixes for wl driver integration
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 # proprietary driver extracted from linksys firmware GPL sourcetree WRT54GS_3_37_2_1109_US
33 LINUX_BINARY_WL_DRIVER=kernel-binary-wl-0.2.tar.gz
34 LINUX_BINARY_WL_MD5SUM=ab2a6d39ccb550e494bbeccf1b0e228f
35 LINUX_ET_DRIVER=kernel-source-et-0.6.tar.gz
36 LINUX_ET_MD5SUM=b7883403d3c1ce7b73c362db621c6f00
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_ET_DRIVER):
44 $(SCRIPT_DIR)/download.pl $(DL_DIR) $(LINUX_ET_DRIVER) $(LINUX_ET_MD5SUM) $(LINUX_BINARY_DRIVER_SITE)
45
46 $(LINUX_DIR)/.unpacked: $(DL_DIR)/$(LINUX_SOURCE) $(DL_DIR)/$(LINUX_BINARY_WL_DRIVER) $(DL_DIR)/$(LINUX_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 zcat $(DL_DIR)/$(LINUX_BINARY_WL_DRIVER) | tar -C $(BUILD_DIR) $(TAR_OPTIONS) -
51 zcat $(DL_DIR)/$(LINUX_ET_DRIVER) | tar -C $(BUILD_DIR) $(TAR_OPTIONS) -
52 touch $(LINUX_DIR)/.unpacked
53
54 $(LINUX_DIR)/.patched: $(LINUX_DIR)/.unpacked
55 # copy kernel source which is maintained in openwrt via cvs
56 cp -a $(LINUX_KERNEL_SOURCE)/* $(LINUX_DIR)
57 # copy binary wlan driver
58 cp -a $(BUILD_DIR)/wl/*.o $(LINUX_DIR)/drivers/net/wl
59 # copy proprietary et source
60 cp -a $(BUILD_DIR)/et/* $(LINUX_DIR)/drivers/net/et
61 cp -a $(BUILD_DIR)/et/*.h $(LINUX_DIR)/include/
62 $(PATCH) $(LINUX_DIR) $(LINUX_PATCHES)
63 $(SED) 's/@expr length/@-expr length/' $(LINUX_DIR)/Makefile
64 touch $(LINUX_DIR)/.patched
65
66 $(LINUX_DIR)/.configured: $(LINUX_DIR)/.patched
67 -cp $(LINUX_KCONFIG) $(LINUX_DIR)/.config
68 $(SED) "s,^CROSS_COMPILE.*,CROSS_COMPILE=$(KERNEL_CROSS),g;" \
69 $(LINUX_DIR)/Makefile \
70 $(LINUX_DIR)/arch/mips/Makefile
71 $(SED) "s,\-mcpu=,\-mtune=,g;" $(LINUX_DIR)/arch/mips/Makefile
72 $(MAKE) -C $(LINUX_DIR) ARCH=$(LINUX_KARCH) oldconfig include/linux/version.h
73 touch $(LINUX_DIR)/.configured
74
75 $(LINUX_DIR)/.depend_done: $(LINUX_DIR)/.configured
76 $(MAKE) -C $(LINUX_DIR) ARCH=$(LINUX_KARCH) dep
77 touch $(LINUX_DIR)/.depend_done
78
79 $(LINUX_DIR)/$(LINUX_BINLOC): $(LINUX_DIR)/.depend_done
80 $(MAKE) -C $(LINUX_DIR) ARCH=$(LINUX_KARCH) PATH=$(TARGET_PATH) CFLAGS_KERNEL="-fno-delayed-branch " $(LINUX_FORMAT)
81
82 $(LINUX_KERNEL): $(LINUX_DIR)/$(LINUX_BINLOC)
83 cp -fa $< $@
84 touch -c $(LINUX_KERNEL)
85
86 $(LINUX_IMAGE): $(LINUX_KERNEL)
87 cat $^ | $(BUILD_DIR)/lzma/lzma e -si -so -eos > $@ || (rm -f $@ && false)
88
89 $(LINUX_DIR)/.modules_done: $(LINUX_KERNEL) $(LINUX_IMAGE)
90 rm -rf $(BUILD_DIR)/modules
91 $(MAKE) -C $(LINUX_DIR) ARCH=$(LINUX_KARCH) PATH=$(TARGET_PATH) CFLAGS_KERNEL="-fno-delayed-branch " modules
92 $(MAKE) -C $(LINUX_DIR) DEPMOD=true INSTALL_MOD_PATH=$(BUILD_DIR)/modules modules_install
93 touch $(LINUX_DIR)/.modules_done
94
95 $(STAGING_DIR)/include/linux/version.h: $(LINUX_DIR)/.configured
96 mkdir -p $(STAGING_DIR)/include
97 tar -ch -C $(LINUX_DIR)/include -f - linux | tar -xf - -C $(STAGING_DIR)/include/
98 tar -ch -C $(LINUX_DIR)/include -f - asm | tar -xf - -C $(STAGING_DIR)/include/
99
100 $(TARGET_MODULES_DIR):
101 -mkdir -p $(TARGET_MODULES_DIR)
102
103 linux: $(LINUX_DIR)/.modules_done $(TARGET_MODULES_DIR)
104
105 linux-source: $(DL_DIR)/$(LINUX_SOURCE)
106
107 # This has been renamed so we do _NOT_ by default run this on 'make clean'
108 linuxclean: clean
109 rm -f $(LINUX_KERNEL) $(LINUX_IMAGE)
110 -$(MAKE) -C $(LINUX_DIR) clean
111
112 linux-dirclean:
113 rm -f $(BUILD_DIR)/openwrt-kmodules.tar.bz2
114 rm -rf $(LINUX_DIR)-$(LINUX_VERSION)
115 rm -rf $(LINUX_DIR)
116 rm -rf $(BUILD_DIR)/modules
117 rm -rf $(BUILD_DIR)/wl
118 rm -rf $(BUILD_DIR)/et
119
This page took 0.03957 seconds and 5 git commands to generate.