Initial revision
[openwrt/svn-archive/archive.git] / openwrt / package / linux / linux.mk
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 # sources/kernel-patches/001-my-special-stuff.bz2
10 # sources/kernel-patches/003-gcc-Os.bz2
11 # sources/kernel-patches/004_no-warnings.bz2
12 # sources/kernel-patches/030-lowlatency-mini.bz2
13 # sources/kernel-patches/031-lowlatency-fixes-5.bz2
14 # sources/kernel-patches/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 #############################################################
22 ifneq ($(filter $(TARGETS),linux),)
23
24 # Version of Linux to download and then apply patches to
25 DOWNLOAD_LINUX_VERSION=2.4.27
26 # Version of Linux AFTER patches
27 LINUX_VERSION=2.4.28-pre4-erik
28
29 LINUX_FORMAT=vmlinux
30 #LINUX_FORMAT=images/zImage.prep
31 LINUX_KARCH:=$(shell echo $(ARCH) | sed -e 's/i[3-9]86/i386/' \
32 -e 's/mipsel/mips/' \
33 -e 's/powerpc/ppc/' \
34 -e 's/sh[234]/sh/' \
35 )
36 LINUX_BINLOC=arch/$(LINUX_KARCH)/boot/$(LINUX_FORMAT)
37
38 LINUX_DIR=$(BUILD_DIR)/linux-$(LINUX_VERSION)
39 LINUX_SOURCE=linux-$(DOWNLOAD_LINUX_VERSION).tar.bz2
40 LINUX_SITE=http://www.kernel.org/pub/linux/kernel/v2.4
41 LINUX_KCONFIG=package/linux/linux.config
42 LINUX_KERNEL=$(BUILD_DIR)/buildroot-kernel
43 # Used by pcmcia-cs and others
44 LINUX_SOURCE_DIR=$(LINUX_DIR)
45
46
47 $(DL_DIR)/$(LINUX_SOURCE):
48 -mkdir -p $(DL_DIR)
49 $(WGET) -P $(DL_DIR) $(LINUX_SITE)/$(LINUX_SOURCE)
50
51 $(LINUX_DIR)/.unpacked: $(DL_DIR)/$(LINUX_SOURCE)
52 -mkdir -p $(TOOL_BUILD_DIR)
53 -(cd $(TOOL_BUILD_DIR); ln -sf $(LINUX_DIR) linux)
54 bzcat $(DL_DIR)/$(LINUX_SOURCE) | tar -C $(BUILD_DIR) $(TAR_OPTIONS) -
55 ifneq ($(DOWNLOAD_LINUX_VERSION),$(LINUX_VERSION))
56 # Rename the dir from the downloaded version to the AFTER patch version
57 mv -f $(BUILD_DIR)/linux-$(DOWNLOAD_LINUX_VERSION) $(BUILD_DIR)/linux-$(LINUX_VERSION)
58 endif
59 mkdir -p package/linux/kernel-patches
60 toolchain/patch-kernel.sh $(LINUX_DIR) package/linux/kernel-patches
61 touch $(LINUX_DIR)/.unpacked
62
63 $(LINUX_KCONFIG):
64 @if [ ! -f "$(LINUX_KCONFIG)" ] ; then \
65 echo ""; \
66 echo "You should create a .config for your kernel"; \
67 echo "and install it as $(LINUX_KCONFIG)"; \
68 echo ""; \
69 sleep 5; \
70 fi;
71
72 $(LINUX_DIR)/.configured $(BUILD_DIR)/linux/.configured: $(LINUX_DIR)/.unpacked $(LINUX_KCONFIG)
73 $(SED) "s,^CROSS_COMPILE.*,CROSS_COMPILE=$(KERNEL_CROSS),g;" $(LINUX_DIR)/Makefile
74 -cp $(LINUX_KCONFIG) $(LINUX_DIR)/.config
75 $(MAKE) -C $(LINUX_DIR) ARCH=$(LINUX_KARCH) oldconfig include/linux/version.h
76 touch $(LINUX_DIR)/.configured
77
78 $(LINUX_DIR)/.depend_done: $(LINUX_DIR)/.configured
79 $(MAKE) -C $(LINUX_DIR) ARCH=$(LINUX_KARCH) dep
80 touch $(LINUX_DIR)/.depend_done
81
82 $(LINUX_DIR)/$(LINUX_BINLOC): $(LINUX_DIR)/.depend_done
83 $(MAKE) -C $(LINUX_DIR) ARCH=$(LINUX_KARCH) PATH=$(TARGET_PATH) $(LINUX_FORMAT)
84 $(MAKE) -C $(LINUX_DIR) ARCH=$(LINUX_KARCH) PATH=$(TARGET_PATH) modules
85
86 $(LINUX_KERNEL): $(LINUX_DIR)/$(LINUX_BINLOC)
87 cp -fa $(LINUX_DIR)/$(LINUX_BINLOC) $(LINUX_KERNEL)
88 touch -c $(LINUX_KERNEL)
89
90 $(TARGET_DIR)/lib/modules/$(LINUX_VERSION)/modules.dep: $(LINUX_KERNEL)
91 rm -rf $(TARGET_DIR)/lib/modules
92 rm -f $(TARGET_DIR)/sbin/cardmgr
93 $(MAKE) -C $(LINUX_DIR) INSTALL_MOD_PATH=$(TARGET_DIR) modules_install
94 (cd $(TARGET_DIR)/lib/modules; ln -s $(LINUX_VERSION)/kernel/drivers .)
95
96 $(STAGING_DIR)/include/linux/version.h: $(LINUX_DIR)/.configured
97 mkdir -p $(STAGING_DIR)/include
98 tar -ch -C $(LINUX_DIR)/include -f - linux | tar -xf - -C $(STAGING_DIR)/include/
99 tar -ch -C $(LINUX_DIR)/include -f - asm | tar -xf - -C $(STAGING_DIR)/include/
100
101 linux: $(STAGING_DIR)/include/linux/version.h $(TARGET_DIR)/lib/modules/$(LINUX_VERSION)/modules.dep
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 -rf $(LINUX_DIR)
112
113 linux-headers: $(LINUX_DIR)/.configured
114
115 endif