2006-06-27 02:35:46 +02: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 01:04:46 +02:00
|
|
|
include $(INCLUDE_DIR)/host.mk
|
2006-06-23 02:49:42 +02:00
|
|
|
-include $(INCLUDE_DIR)/modules-$(KERNEL).mk
|
2006-06-21 04:16:37 +02:00
|
|
|
|
|
|
|
LINUX_SOURCE:=linux-$(LINUX_VERSION).tar.bz2
|
2006-02-09 23:21:44 +01: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 20:43:00 +01:00
|
|
|
http://www.kernel.org/pub/linux/kernel/v$(KERNEL) \
|
|
|
|
http://www.de.kernel.org/pub/linux/kernel/v$(KERNEL)
|
|
|
|
|
2006-06-21 04:16:37 +02:00
|
|
|
KERNEL_IDIR:=$(KERNEL_BUILD_DIR)/kernel-ipkg
|
|
|
|
KERNEL_IPKG:=$(KERNEL_BUILD_DIR)/kernel_$(LINUX_VERSION)-$(BOARD)-$(LINUX_RELEASE)_$(ARCH).ipk
|
2006-06-25 18:59:19 +02:00
|
|
|
TARGETS += $(KERNEL_IPKG)
|
2006-06-21 04:16:37 +02:00
|
|
|
INSTALL_TARGETS += $(KERNEL_IPKG)
|
2006-01-10 20:43:00 +01:00
|
|
|
|
2006-10-18 15:16:44 +02: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 15:41:00 +02: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 15:16:44 +02:00
|
|
|
)
|
|
|
|
endif
|
|
|
|
|
|
|
|
KERNELNAME=
|
|
|
|
ifneq (,$(findstring x86,$(BOARD)))
|
|
|
|
KERNELNAME="bzImage"
|
|
|
|
endif
|
|
|
|
ifneq (,$(findstring ppc,$(BOARD)))
|
|
|
|
KERNELNAME="uImage"
|
|
|
|
endif
|
2006-10-10 15:41:00 +02:00
|
|
|
|
|
|
|
|
2006-01-10 20:43:00 +01:00
|
|
|
$(TARGETS): $(PACKAGE_DIR)
|
|
|
|
|
|
|
|
$(PACKAGE_DIR):
|
2006-06-01 02:47:29 +02:00
|
|
|
mkdir -p $@
|
|
|
|
|
2006-01-10 20:43:00 +01:00
|
|
|
$(DL_DIR)/$(LINUX_SOURCE):
|
|
|
|
-mkdir -p $(DL_DIR)
|
2006-05-10 22:32:22 +02:00
|
|
|
$(SCRIPT_DIR)/download.pl $(DL_DIR) $(LINUX_SOURCE) $(LINUX_KERNEL_MD5SUM) $(LINUX_SITE)
|
2006-01-10 20:43:00 +01:00
|
|
|
|
|
|
|
$(LINUX_DIR)/.unpacked: $(DL_DIR)/$(LINUX_SOURCE)
|
2006-06-21 04:16:37 +02:00
|
|
|
-mkdir -p $(KERNEL_BUILD_DIR)
|
2006-10-14 16:51:48 +02:00
|
|
|
bzcat $(DL_DIR)/$(LINUX_SOURCE) | tar -C $(KERNEL_BUILD_DIR) $(TAR_OPTIONS)
|
2006-01-10 20:43:00 +01: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 13:16:46 +02: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 20:43:00 +01:00
|
|
|
touch $@
|
|
|
|
|
|
|
|
$(LINUX_DIR)/.depend_done: $(LINUX_DIR)/.configured
|
2006-05-10 22:32:22 +02:00
|
|
|
$(MAKE) -C $(LINUX_DIR) CROSS_COMPILE="$(KERNEL_CROSS)" ARCH=$(LINUX_KARCH) dep
|
2006-01-10 20:43:00 +01:00
|
|
|
touch $@
|
|
|
|
|
|
|
|
$(LINUX_DIR)/vmlinux: $(LINUX_DIR)/.depend_done
|
|
|
|
else
|
|
|
|
$(LINUX_DIR)/.configured: $(LINUX_DIR)/.patched
|
2006-08-10 13:16:46 +02:00
|
|
|
$(MAKE) -C $(LINUX_DIR) CROSS_COMPILE="$(KERNEL_CROSS)" CC="$(KERNEL_CC)" ARCH=$(LINUX_KARCH) oldconfig prepare scripts
|
2006-01-10 20:43:00 +01:00
|
|
|
touch $@
|
|
|
|
endif
|
|
|
|
|
2006-06-08 01:59:04 +02: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 01:52:27 +02:00
|
|
|
$(LINUX_DIR)/vmlinux: $(LINUX_DIR)/.linux-compile pkg-install ramdisk-config
|
2006-10-18 21:00:05 +02:00
|
|
|
$(MAKE) -j$(CONFIG_JLEVEL) -C $(LINUX_DIR) CROSS_COMPILE="$(KERNEL_CROSS)" CC="$(KERNEL_CC)" ARCH=$(LINUX_KARCH) $(KERNELNAME)
|
2006-01-10 20:43:00 +01:00
|
|
|
|
|
|
|
$(LINUX_KERNEL): $(LINUX_DIR)/vmlinux
|
2006-08-04 13:59:52 +02:00
|
|
|
$(KERNEL_CROSS)objcopy -O binary -R .reginfo -R .note -R .comment -R .mdebug -S $< $@
|
2006-01-10 20:43:00 +01:00
|
|
|
touch -c $(LINUX_KERNEL)
|
|
|
|
|
2006-01-14 00:15:16 +01:00
|
|
|
$(LINUX_DIR)/.modules_done:
|
2006-06-21 04:16:37 +02:00
|
|
|
rm -rf $(KERNEL_BUILD_DIR)/modules
|
2006-10-18 21:00:05 +02:00
|
|
|
$(MAKE) -j$(CONFIG_JLEVEL) -C "$(LINUX_DIR)" CROSS_COMPILE="$(KERNEL_CROSS)" CC="$(KERNEL_CC)" ARCH=$(LINUX_KARCH) modules
|
2006-08-18 03:18:24 +02:00
|
|
|
$(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 20:43:00 +01:00
|
|
|
touch $(LINUX_DIR)/.modules_done
|
|
|
|
|
2006-06-25 18:59:19 +02:00
|
|
|
modules: $(LINUX_DIR)/.modules_done
|
|
|
|
packages: $(TARGETS)
|
|
|
|
|
2006-07-21 01:52:27 +02:00
|
|
|
$(LINUX_DIR)/.linux-compile:
|
2006-08-05 02:55:41 +02:00
|
|
|
@rm -f $(BUILD_DIR)/linux
|
2006-07-21 01:52:27 +02:00
|
|
|
ln -sf $(KERNEL_BUILD_DIR)/linux-$(LINUX_VERSION) $(BUILD_DIR)/linux
|
2006-06-25 18:59:19 +02:00
|
|
|
@$(MAKE) modules
|
2006-01-10 20:43:00 +01: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 04:16:37 +02:00
|
|
|
$(IPKG_BUILD) $(KERNEL_IDIR) $(KERNEL_BUILD_DIR)
|
2006-01-10 20:43:00 +01:00
|
|
|
|
2006-08-16 02:35:30 +02: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 15:41:00 +02:00
|
|
|
echo "CONFIG_LINUX_KARCH:=$(LINUX_KARCH)" >> $@
|
2006-05-31 14:33:06 +02:00
|
|
|
|
2006-06-01 01:29:05 +02:00
|
|
|
pkg-install: FORCE
|
2006-06-28 19:30:39 +02:00
|
|
|
@for pkg in $(INSTALL_TARGETS); do \
|
|
|
|
$(IPKG) install $$pkg || echo; \
|
|
|
|
done
|
2006-05-31 22:29:11 +02:00
|
|
|
|
2006-07-21 19:00:14 +02:00
|
|
|
download: $(DL_DIR)/$(LINUX_SOURCE)
|
2006-06-24 00:10:43 +02:00
|
|
|
prepare: $(LINUX_DIR)/.configured
|
2006-07-21 01:52:27 +02:00
|
|
|
@mkdir -p $(LINUX_DIR) $(PACKAGE_DIR)
|
2006-01-10 20:43:00 +01:00
|
|
|
|
2006-07-21 01:52:27 +02:00
|
|
|
compile: prepare $(LINUX_DIR)/.linux-compile
|
2006-08-27 15:22:42 +02:00
|
|
|
@$(MAKE) packages
|
2006-01-14 00:15:16 +01:00
|
|
|
|
2006-05-31 14:38:39 +02:00
|
|
|
install: compile $(LINUX_KERNEL)
|
2006-01-10 20:43:00 +01:00
|
|
|
|
2006-06-01 01:29:05 +02:00
|
|
|
mostlyclean: FORCE
|
2006-07-21 01:52:27 +02:00
|
|
|
rm -f $(LINUX_DIR)/.linux-compile
|
2006-06-21 04:16:37 +02: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 00:15:16 +01:00
|
|
|
rm -f $(LINUX_KERNEL)
|
2006-01-10 20:43:00 +01:00
|
|
|
|
2006-06-01 01:29:05 +02:00
|
|
|
rebuild: FORCE
|
2006-01-10 20:43:00 +01:00
|
|
|
-$(MAKE) mostlyclean
|
2006-05-30 21:38:38 +02:00
|
|
|
if [ -f $(LINUX_KERNEL) ]; then \
|
|
|
|
$(MAKE) clean; \
|
|
|
|
fi
|
|
|
|
$(MAKE) compile $(MAKE_TRACE)
|
2006-01-10 20:43:00 +01:00
|
|
|
|
2006-06-01 01:29:05 +02:00
|
|
|
clean: FORCE
|
2006-01-10 20:43:00 +01:00
|
|
|
rm -f $(STAMP_DIR)/.linux-compile
|
2006-06-21 04:16:37 +02:00
|
|
|
rm -rf $(KERNEL_BUILD_DIR)
|
2006-01-10 20:43:00 +01:00
|
|
|
rm -f $(TARGETS)
|
2006-06-26 03:55:47 +02:00
|
|
|
|