2006-06-27 03:35:46 +03:00
|
|
|
#
|
|
|
|
# Copyright (C) 2006 OpenWrt.org
|
|
|
|
#
|
|
|
|
# This is free software, licensed under the GNU General Public License v2.
|
|
|
|
# See /LICENSE for more information.
|
|
|
|
#
|
2006-10-11 02:04:46 +03:00
|
|
|
include $(INCLUDE_DIR)/host.mk
|
2006-06-23 03:49:42 +03:00
|
|
|
-include $(INCLUDE_DIR)/modules-$(KERNEL).mk
|
2006-06-21 05:16:37 +03:00
|
|
|
|
|
|
|
LINUX_SOURCE:=linux-$(LINUX_VERSION).tar.bz2
|
2006-02-10 00:21:44 +02:00
|
|
|
LINUX_SITE=http://www.us.kernel.org/pub/linux/kernel/v$(KERNEL) \
|
|
|
|
http://www.us.kernel.org/pub/linux/kernel/v$(KERNEL) \
|
2006-01-10 21:43:00 +02:00
|
|
|
http://www.kernel.org/pub/linux/kernel/v$(KERNEL) \
|
|
|
|
http://www.de.kernel.org/pub/linux/kernel/v$(KERNEL)
|
|
|
|
|
2006-06-21 05:16:37 +03:00
|
|
|
KERNEL_IDIR:=$(KERNEL_BUILD_DIR)/kernel-ipkg
|
|
|
|
KERNEL_IPKG:=$(KERNEL_BUILD_DIR)/kernel_$(LINUX_VERSION)-$(BOARD)-$(LINUX_RELEASE)_$(ARCH).ipk
|
2006-06-25 19:59:19 +03:00
|
|
|
TARGETS += $(KERNEL_IPKG)
|
2006-06-21 05:16:37 +03:00
|
|
|
INSTALL_TARGETS += $(KERNEL_IPKG)
|
2006-01-10 21:43:00 +02:00
|
|
|
|
2006-10-18 16:16:44 +03:00
|
|
|
ifneq (,$(findstring uml,$(BOARD)))
|
|
|
|
LINUX_KARCH:=um
|
|
|
|
else
|
|
|
|
LINUX_KARCH:=$(shell echo $(ARCH) | sed -e 's/i[3-9]86/i386/' \
|
2006-10-10 16:41:00 +03:00
|
|
|
-e 's/mipsel/mips/' \
|
|
|
|
-e 's/mipseb/mips/' \
|
|
|
|
-e 's/powerpc/ppc/' \
|
|
|
|
-e 's/sh[234]/sh/' \
|
|
|
|
-e 's/armeb/arm/' \
|
2006-10-18 16:16:44 +03:00
|
|
|
)
|
|
|
|
endif
|
|
|
|
|
|
|
|
KERNELNAME=
|
|
|
|
ifneq (,$(findstring x86,$(BOARD)))
|
|
|
|
KERNELNAME="bzImage"
|
|
|
|
endif
|
|
|
|
ifneq (,$(findstring ppc,$(BOARD)))
|
|
|
|
KERNELNAME="uImage"
|
|
|
|
endif
|
2006-10-10 16:41:00 +03:00
|
|
|
|
|
|
|
|
2006-01-10 21:43:00 +02:00
|
|
|
$(TARGETS): $(PACKAGE_DIR)
|
|
|
|
|
|
|
|
$(PACKAGE_DIR):
|
2006-06-01 03:47:29 +03:00
|
|
|
mkdir -p $@
|
|
|
|
|
2006-01-10 21:43:00 +02:00
|
|
|
$(DL_DIR)/$(LINUX_SOURCE):
|
|
|
|
-mkdir -p $(DL_DIR)
|
2006-05-10 23:32:22 +03:00
|
|
|
$(SCRIPT_DIR)/download.pl $(DL_DIR) $(LINUX_SOURCE) $(LINUX_KERNEL_MD5SUM) $(LINUX_SITE)
|
2006-01-10 21:43:00 +02:00
|
|
|
|
|
|
|
$(LINUX_DIR)/.unpacked: $(DL_DIR)/$(LINUX_SOURCE)
|
2006-06-21 05:16:37 +03:00
|
|
|
-mkdir -p $(KERNEL_BUILD_DIR)
|
2006-10-14 17:51:48 +03:00
|
|
|
bzcat $(DL_DIR)/$(LINUX_SOURCE) | tar -C $(KERNEL_BUILD_DIR) $(TAR_OPTIONS)
|
2006-01-10 21:43:00 +02:00
|
|
|
touch $@
|
|
|
|
|
|
|
|
ifeq ($(KERNEL),2.4)
|
|
|
|
$(LINUX_DIR)/.configured: $(LINUX_DIR)/.patched
|
|
|
|
$(SED) "s,\-mcpu=,\-mtune=,g;" $(LINUX_DIR)/arch/mips/Makefile
|
2006-08-10 14:16:46 +03:00
|
|
|
$(MAKE) -C $(LINUX_DIR) CROSS_COMPILE="$(KERNEL_CROSS)" CC="$(KERNEL_CC)" ARCH=$(LINUX_KARCH) oldconfig include/linux/compile.h include/linux/version.h
|
2006-01-10 21:43:00 +02:00
|
|
|
touch $@
|
|
|
|
|
|
|
|
$(LINUX_DIR)/.depend_done: $(LINUX_DIR)/.configured
|
2006-05-10 23:32:22 +03:00
|
|
|
$(MAKE) -C $(LINUX_DIR) CROSS_COMPILE="$(KERNEL_CROSS)" ARCH=$(LINUX_KARCH) dep
|
2006-01-10 21:43:00 +02:00
|
|
|
touch $@
|
|
|
|
|
|
|
|
$(LINUX_DIR)/vmlinux: $(LINUX_DIR)/.depend_done
|
|
|
|
else
|
|
|
|
$(LINUX_DIR)/.configured: $(LINUX_DIR)/.patched
|
2006-08-10 14:16:46 +03:00
|
|
|
$(MAKE) -C $(LINUX_DIR) CROSS_COMPILE="$(KERNEL_CROSS)" CC="$(KERNEL_CC)" ARCH=$(LINUX_KARCH) oldconfig prepare scripts
|
2006-01-10 21:43:00 +02:00
|
|
|
touch $@
|
|
|
|
endif
|
|
|
|
|
2006-06-08 02:59:04 +03:00
|
|
|
ramdisk-config: $(LINUX_DIR)/.configured FORCE
|
|
|
|
mv $(LINUX_DIR)/.config $(LINUX_DIR)/.config.old
|
|
|
|
grep -v INITRAMFS $(LINUX_DIR)/.config.old > $(LINUX_DIR)/.config
|
|
|
|
ifeq ($(CONFIG_TARGET_ROOTFS_INITRAMFS),y)
|
|
|
|
echo 'CONFIG_INITRAMFS_SOURCE="../../root"' >> $(LINUX_DIR)/.config
|
|
|
|
echo 'CONFIG_INITRAMFS_ROOT_UID=0' >> $(LINUX_DIR)/.config
|
|
|
|
echo 'CONFIG_INITRAMFS_ROOT_GID=0' >> $(LINUX_DIR)/.config
|
|
|
|
mkdir -p $(BUILD_DIR)/root/etc/init.d
|
|
|
|
$(CP) ../generic-2.6/files/init $(BUILD_DIR)/root/
|
|
|
|
else
|
|
|
|
rm -f $(BUILD_DIR)/root/init $(BUILD_DIR)/root/etc/init.d/S00initramfs
|
|
|
|
echo 'CONFIG_INITRAMFS_SOURCE=""' >> $(LINUX_DIR)/.config
|
|
|
|
endif
|
|
|
|
|
2006-07-21 02:52:27 +03:00
|
|
|
$(LINUX_DIR)/vmlinux: $(LINUX_DIR)/.linux-compile pkg-install ramdisk-config
|
2006-08-17 10:20:08 +03:00
|
|
|
$(MAKE) -C $(LINUX_DIR) CROSS_COMPILE="$(KERNEL_CROSS)" CC="$(KERNEL_CC)" ARCH=$(LINUX_KARCH) $(KERNELNAME)
|
2006-01-10 21:43:00 +02:00
|
|
|
|
|
|
|
$(LINUX_KERNEL): $(LINUX_DIR)/vmlinux
|
2006-08-04 14:59:52 +03:00
|
|
|
$(KERNEL_CROSS)objcopy -O binary -R .reginfo -R .note -R .comment -R .mdebug -S $< $@
|
2006-01-10 21:43:00 +02:00
|
|
|
touch -c $(LINUX_KERNEL)
|
|
|
|
|
2006-01-14 01:15:16 +02:00
|
|
|
$(LINUX_DIR)/.modules_done:
|
2006-06-21 05:16:37 +03:00
|
|
|
rm -rf $(KERNEL_BUILD_DIR)/modules
|
2006-08-18 04:18:24 +03:00
|
|
|
$(MAKE) -C "$(LINUX_DIR)" CROSS_COMPILE="$(KERNEL_CROSS)" CC="$(KERNEL_CC)" ARCH=$(LINUX_KARCH) modules
|
|
|
|
$(MAKE) -C "$(LINUX_DIR)" CROSS_COMPILE="$(KERNEL_CROSS)" CC="$(KERNEL_CC)" ARCH=$(LINUX_KARCH) DEPMOD=true INSTALL_MOD_PATH=$(KERNEL_BUILD_DIR)/modules modules_install
|
2006-01-10 21:43:00 +02:00
|
|
|
touch $(LINUX_DIR)/.modules_done
|
|
|
|
|
2006-06-25 19:59:19 +03:00
|
|
|
modules: $(LINUX_DIR)/.modules_done
|
|
|
|
packages: $(TARGETS)
|
|
|
|
|
2006-07-21 02:52:27 +03:00
|
|
|
$(LINUX_DIR)/.linux-compile:
|
2006-08-05 03:55:41 +03:00
|
|
|
@rm -f $(BUILD_DIR)/linux
|
2006-07-21 02:52:27 +03:00
|
|
|
ln -sf $(KERNEL_BUILD_DIR)/linux-$(LINUX_VERSION) $(BUILD_DIR)/linux
|
2006-06-25 19:59:19 +03:00
|
|
|
@$(MAKE) modules
|
2006-01-10 21:43:00 +02:00
|
|
|
touch $@
|
|
|
|
|
|
|
|
$(KERNEL_IPKG):
|
|
|
|
rm -rf $(KERNEL_IDIR)
|
|
|
|
mkdir -p $(KERNEL_IDIR)/etc
|
|
|
|
$(SCRIPT_DIR)/make-ipkg-dir.sh $(KERNEL_IDIR) ../control/kernel.control $(LINUX_VERSION)-$(BOARD)-$(LINUX_RELEASE) $(ARCH)
|
|
|
|
if [ -f ./config/$(BOARD).modules ]; then \
|
|
|
|
cp ./config/$(BOARD).modules $(KERNEL_IDIR)/etc/modules; \
|
|
|
|
fi
|
2006-06-21 05:16:37 +03:00
|
|
|
$(IPKG_BUILD) $(KERNEL_IDIR) $(KERNEL_BUILD_DIR)
|
2006-01-10 21:43:00 +02:00
|
|
|
|
2006-08-16 03:35:30 +03:00
|
|
|
$(TOPDIR)/.kernel.mk: $(TOPDIR)/target/linux/$(BOARD)-$(KERNEL)/Makefile
|
|
|
|
echo "CONFIG_BOARD:=$(BOARD)" > $@
|
|
|
|
echo "CONFIG_KERNEL:=$(KERNEL)" >> $@
|
|
|
|
echo "CONFIG_LINUX_VERSION:=$(LINUX_VERSION)" >> $@
|
|
|
|
echo "CONFIG_LINUX_RELEASE:=$(LINUX_RELEASE)" >> $@
|
2006-10-10 16:41:00 +03:00
|
|
|
echo "CONFIG_LINUX_KARCH:=$(LINUX_KARCH)" >> $@
|
2006-05-31 15:33:06 +03:00
|
|
|
|
2006-06-01 02:29:05 +03:00
|
|
|
pkg-install: FORCE
|
2006-06-28 20:30:39 +03:00
|
|
|
@for pkg in $(INSTALL_TARGETS); do \
|
|
|
|
$(IPKG) install $$pkg || echo; \
|
|
|
|
done
|
2006-05-31 23:29:11 +03:00
|
|
|
|
2006-07-21 20:00:14 +03:00
|
|
|
download: $(DL_DIR)/$(LINUX_SOURCE)
|
2006-06-24 01:10:43 +03:00
|
|
|
prepare: $(LINUX_DIR)/.configured
|
2006-07-21 02:52:27 +03:00
|
|
|
@mkdir -p $(LINUX_DIR) $(PACKAGE_DIR)
|
2006-01-10 21:43:00 +02:00
|
|
|
|
2006-07-21 02:52:27 +03:00
|
|
|
compile: prepare $(LINUX_DIR)/.linux-compile
|
2006-08-27 16:22:42 +03:00
|
|
|
@$(MAKE) packages
|
2006-01-14 01:15:16 +02:00
|
|
|
|
2006-05-31 15:38:39 +03:00
|
|
|
install: compile $(LINUX_KERNEL)
|
2006-01-10 21:43:00 +02:00
|
|
|
|
2006-06-01 02:29:05 +03:00
|
|
|
mostlyclean: FORCE
|
2006-07-21 02:52:27 +03:00
|
|
|
rm -f $(LINUX_DIR)/.linux-compile
|
2006-06-21 05:16:37 +03:00
|
|
|
rm -f $(KERNEL_BUILD_DIR)/linux-$(LINUX_VERSION)/.modules_done
|
|
|
|
rm -f $(KERNEL_BUILD_DIR)/linux-$(LINUX_VERSION)/.drivers-unpacked
|
|
|
|
$(MAKE) -C $(KERNEL_BUILD_DIR)/linux-$(LINUX_VERSION) clean
|
2006-01-14 01:15:16 +02:00
|
|
|
rm -f $(LINUX_KERNEL)
|
2006-01-10 21:43:00 +02:00
|
|
|
|
2006-06-01 02:29:05 +03:00
|
|
|
rebuild: FORCE
|
2006-01-10 21:43:00 +02:00
|
|
|
-$(MAKE) mostlyclean
|
2006-05-30 22:38:38 +03:00
|
|
|
if [ -f $(LINUX_KERNEL) ]; then \
|
|
|
|
$(MAKE) clean; \
|
|
|
|
fi
|
|
|
|
$(MAKE) compile $(MAKE_TRACE)
|
2006-01-10 21:43:00 +02:00
|
|
|
|
2006-06-01 02:29:05 +03:00
|
|
|
clean: FORCE
|
2006-01-10 21:43:00 +02:00
|
|
|
rm -f $(STAMP_DIR)/.linux-compile
|
2006-06-21 05:16:37 +03:00
|
|
|
rm -rf $(KERNEL_BUILD_DIR)
|
2006-01-10 21:43:00 +02:00
|
|
|
rm -f $(TARGETS)
|
2006-06-26 04:55:47 +03:00
|
|
|
|