Support building regular kernels
This commit is contained in:
parent
be4cf785bd
commit
98b6fb27b3
6
Makefile
6
Makefile
|
@ -61,6 +61,11 @@ ifeq ($(USE_UCLIBC_TOOLCHAIN),true)
|
|||
TARGETS=uclibc_toolchain
|
||||
endif
|
||||
|
||||
# Do you want user mode Linux, or are you building a
|
||||
# real kernel that will run on its own?
|
||||
TARGETS+=linux
|
||||
#TARGETS+=user-mode-linux
|
||||
|
||||
# The default minimal set
|
||||
TARGETS+=user-mode-linux busybox tinylogin
|
||||
|
||||
|
@ -87,7 +92,6 @@ TARGETS+=ext2root
|
|||
#############################################################
|
||||
BASE_DIR:=${shell pwd}
|
||||
HOSTCC:=gcc
|
||||
LINUX_KERNEL=$(BASE_DIR)/UMlinux
|
||||
SOURCE_DIR:=$(BASE_DIR)/sources
|
||||
DL_DIR:=$(SOURCE_DIR)/dl
|
||||
PATCH_DIR=$(SOURCE_DIR)/patches
|
||||
|
|
88
make/linux.mk
Normal file
88
make/linux.mk
Normal file
|
@ -0,0 +1,88 @@
|
|||
#############################################################
|
||||
#
|
||||
# Linux kernel targets
|
||||
#
|
||||
# Note: If you have any patched to apply, create the directory
|
||||
# sources/kernel-patches and put your patches in there and number
|
||||
# them in the order you wish to apply them... i.e.
|
||||
#
|
||||
# sources/kernel-patches/001-my-special-stuff.bz2
|
||||
# sources/kernel-patches/003-gcc-Os.bz2
|
||||
# sources/kernel-patches/004_no-warnings.bz2
|
||||
# sources/kernel-patches/030-lowlatency-mini.bz2
|
||||
# sources/kernel-patches/031-lowlatency-fixes-5.bz2
|
||||
# sources/kernel-patches/099-shutup.bz2
|
||||
#
|
||||
# these patched will all be applied by the patch-kernel.sh
|
||||
# script (which will also abort the build if it finds rejects)
|
||||
# -Erik
|
||||
#
|
||||
#############################################################
|
||||
ifneq ($(filter $(TARGETS),linux),)
|
||||
|
||||
LINUX_KERNEL=$(BUILD_DIR)/buildroot-kernel
|
||||
LINUX_DIR=$(BUILD_DIR)/linux-2.4.20
|
||||
LINUX_SOURCE=linux-2.4.20.tar.bz2
|
||||
LINUX_SITE=http://ftp.us.kernel.org/pub/linux/kernel/v2.4
|
||||
LINUX_KCONFIG=$(SOURCE_DIR)/linux.config
|
||||
LINUX_VERSION=$(shell grep -s UTS_RELEASE $(LINUX_DIR)/include/linux/version.h || echo '\#define UTS_RELEASE \"2.4.20\"' | cut -f 2 -d \" )
|
||||
|
||||
$(DL_DIR)/$(LINUX_SOURCE):
|
||||
$(WGET) -P $(DL_DIR) $(LINUX_SITE)/$(LINUX_SOURCE)
|
||||
|
||||
$(LINUX_DIR)/.dist: $(DL_DIR)/$(LINUX_SOURCE)
|
||||
rm -rf $(LINUX_DIR)
|
||||
bzcat $(DL_DIR)/$(LINUX_SOURCE) | tar -C $(BUILD_DIR) -xvf -
|
||||
$(SOURCE_DIR)/patch-kernel.sh $(LINUX_DIR) $(SOURCE_DIR)/kernel-patches \
|
||||
touch $(LINUX_DIR)/.dist
|
||||
|
||||
$(LINUX_DIR)/.configured: $(LINUX_DIR)/.dist $(LINUX_KCONFIG)
|
||||
perl -i -p -e "s,^CROSS_COMPILE.*,\
|
||||
CROSS_COMPILE=$(STAGING_DIR)/bin/$(ARCH)-uclibc-,g;" \
|
||||
$(LINUX_DIR)/Makefile
|
||||
cp $(LINUX_KCONFIG) $(LINUX_DIR)/.config
|
||||
make -C $(LINUX_DIR) oldconfig include/linux/version.h
|
||||
touch $(LINUX_DIR)/.configured
|
||||
|
||||
$(LINUX_DIR)/.depend_done: $(LINUX_DIR)/.configured
|
||||
make -C $(LINUX_DIR) dep
|
||||
touch $(LINUX_DIR)/.depend_done
|
||||
|
||||
$(LINUX_DIR)/arch/$(ARCH)/boot/bzImage: $(LINUX_DIR)/.depend_done
|
||||
make -C $(LINUX_DIR) bzImage
|
||||
make -C $(LINUX_DIR) modules
|
||||
|
||||
$(LINUX_KERNEL): $(LINUX_DIR)/arch/$(ARCH)/boot/bzImage
|
||||
cp -fa $(LINUX_DIR)/arch/$(ARCH)/boot/bzImage $(LINUX_KERNEL)
|
||||
|
||||
$(TARGET_DIR)/lib/modules/$(LINUX_VERSION)/modules.dep: $(LINUX_KERNEL)
|
||||
rm -rf $(TARGET_DIR)/lib/modules
|
||||
rm -f $(TARGET_DIR)/sbin/cardmgr
|
||||
make -C $(LINUX_DIR) INSTALL_MOD_PATH=$(TARGET_DIR) modules_install
|
||||
(cd $(TARGET_DIR)/lib/modules; ln -s $(LINUX_VERSION)/kernel/drivers .)
|
||||
|
||||
$(STAGING_DIR)/include/linux/version.h: $(LINUX_DIR)/include/linux/version.h
|
||||
mkdir -p $(STAGING_DIR)/include
|
||||
tar -ch -C $(LINUX_DIR)/include -f - linux | tar -xf - -C $(STAGING_DIR)/include/
|
||||
tar -ch -C $(LINUX_DIR)/include -f - asm | tar -xf - -C $(STAGING_DIR)/include/
|
||||
|
||||
linux: $(STAGING_DIR)/include/linux/version.h $(TARGET_DIR)/lib/modules/$(LINUX_VERSION)/modules.dep
|
||||
|
||||
# Rename this so it is cleaned by default on a make clean
|
||||
linuxclean: clean
|
||||
rm -f $(LINUX_KERNEL)
|
||||
-make -C $(LINUX_DIR) clean
|
||||
|
||||
linux-dirclean:
|
||||
rm -rf $(LINUX_DIR)
|
||||
|
||||
#############################################################
|
||||
#
|
||||
# Setup the kernel headers, but don't compile anything for the target yet,
|
||||
# since we still need to build a cross-compiler to do that little task for
|
||||
# us... Try to work around this little chicken-and-egg problem..
|
||||
#
|
||||
#############################################################
|
||||
linux_headers: $(LINUX_DIR)/.configured
|
||||
|
||||
endif
|
|
@ -3,6 +3,9 @@
|
|||
# Linux kernel targets
|
||||
#
|
||||
#############################################################
|
||||
ifneq ($(filter $(TARGETS),user-mode-linux),)
|
||||
|
||||
LINUX_KERNEL=$(BASE_DIR)/UMlinux
|
||||
UMLINUX_DIR=$(BUILD_DIR)/linux-2.4.19
|
||||
LINUX_DIR=$(UMLINUX_DIR)
|
||||
UMLINUX_SOURCE=linux-2.4.19.tar.bz2
|
||||
|
@ -65,3 +68,4 @@ user-mode-linux-dirclean:
|
|||
#############################################################
|
||||
linux_headers: $(UMLINUX_DIR)/.configured
|
||||
|
||||
endif
|
||||
|
|
47
sources/patch-kernel.sh
Executable file
47
sources/patch-kernel.sh
Executable file
|
@ -0,0 +1,47 @@
|
|||
#! /bin/sh
|
||||
|
||||
# Set directories from arguments, or use defaults.
|
||||
targetdir=${1-.}
|
||||
patchdir=${2-../kernel-patches}
|
||||
|
||||
if [ ! -d "${targetdir}" ] ; then
|
||||
echo "Aborting. '${targetdir}' is not a directory."
|
||||
exit 1
|
||||
fi
|
||||
if [ ! -d "${patchdir}" ] ; then
|
||||
echo "Aborting. '${patchdir}' is not a directory."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
for i in ${patchdir}/* ; do
|
||||
case "$i" in
|
||||
*.gz)
|
||||
type="gzip"; uncomp="gunzip -dc"; ;;
|
||||
*.bz)
|
||||
type="bzip"; uncomp="bunzip -dc"; ;;
|
||||
*.bz2)
|
||||
type="bzip2"; uncomp="bunzip2 -dc"; ;;
|
||||
*.zip)
|
||||
type="zip"; uncomp="unzip -d"; ;;
|
||||
*.Z)
|
||||
type="compress"; uncomp="uncompress -c"; ;;
|
||||
*)
|
||||
type="plaintext"; uncomp="cat"; ;;
|
||||
esac
|
||||
echo ""
|
||||
echo "Applying ${i} using ${type}: "
|
||||
${uncomp} ${i} | patch -p1 -E -d ${targetdir}
|
||||
if [ $? != 0 ] ; then
|
||||
echo "Patch failed! Please fix $i!"
|
||||
exit 1
|
||||
fi
|
||||
done
|
||||
|
||||
# Check for rejects...
|
||||
if [ "`find $targetdir/ '(' -name '*.rej' -o -name '.*.rej' ')' -print`" ] ; then
|
||||
echo "Aborting. Reject files found."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Remove backup files
|
||||
find $targetdir/ '(' -name '*.orig' -o -name '.*.orig' ')' -exec rm -f {} \;
|
Loading…
Reference in a new issue