From 60eb97a42fe0cf8ebad55a6213e2399b4201e3ec Mon Sep 17 00:00:00 2001 From: Ulf Samuelsson Date: Fri, 24 Aug 2007 05:36:46 +0000 Subject: [PATCH] This patch allows each project to have a private linux build. Split build of kernel headers and kernel image into two source trees. Kernel headers are built in $(TOOL_BUILD_DIR) Kernel build is in $(PROJECT_BUILD_DIR) Make sure that kernel patches are applied to the kernel tree in $(PROJECT_BUILD_DIR) Add board specific patches, if available. --- target/linux/Makefile.in | 71 ++++++++++++++----- .../kernel-headers-new.makefile | 10 +-- toolchain/kernel-headers/kernel-headers.mk | 1 + 3 files changed, 58 insertions(+), 24 deletions(-) diff --git a/target/linux/Makefile.in b/target/linux/Makefile.in index e83bfd53ce..948dd3ea26 100644 --- a/target/linux/Makefile.in +++ b/target/linux/Makefile.in @@ -6,48 +6,53 @@ ifneq ($(filter $(TARGETS),linux26),) +ifeq ($(DOWNLOAD_LINUX26_VERSION),) +# User did not define linux version, try using headers ifeq ($(LINUX_HEADERS_VERSION),) -# Version of Linux to download and then apply patches to -# XXX: andersee, i do not understand why we need this (BF) -DOWNLOAD_LINUX26_VERSION=2.6.19.2 +# We did not have headers (this is for real???) +# Version of linuc before patches +DOWNLOAD_LINUX26_VERSION=2.6.22.1 # Version of Linux after applying any patches -LINUX26_VERSION=2.6.19.2 +LINUX26_VERSION=2.6.22.1 else +# OK, we have headers, use them... DOWNLOAD_LINUX26_VERSION=$(LINUX_HEADERS_VERSION) LINUX26_VERSION=$(LINUX_HEADERS_VERSION) endif +endif LINUX26_SOURCE=linux-$(DOWNLOAD_LINUX26_VERSION).tar.bz2 LINUX26_BZCAT:=$(BZCAT) LINUX26_SITE=http://ftp.kernel.org/pub/linux/kernel/v2.6 -#LINUX26_FORMAT=vmlinux -#LINUX26_BINLOC=$(LINUX26_FORMAT) +ifeq ($(BOARD_PATH),) +BOARD_PATH:=$(strip $(subst ",,$(BR2_BOARD_PATH))) +#")) +endif # Linux kernel configuration file # Has to be set by the target/device # If it is not set by the target/device, then pick the one from .config -# LINUX26_KCONFIG=$(BR2_BOARD_PATH)/linux26.config ifndef LINUX26_KCONFIG ifneq ($(strip $(subst ",,$(BR2_PACKAGE_LINUX_KCONFIG))),) LINUX26_KCONFIG=$(strip $(subst ",,$(BR2_PACKAGE_LINUX_KCONFIG))) #")) #")) +else +# LINUX26_KCONFIG=$(BOARD_PATH)/linux26.config endif endif + ifndef LINUX26_FORMAT ifneq ($(strip $(subst ",,$(BR2_PACKAGE_LINUX_FORMAT))),) LINUX26_FORMAT=$(strip $(subst ",,$(BR2_PACKAGE_LINUX_FORMAT))) #")) #")) +else +LINUX26_FORMAT=zImage endif endif -# Has to be set by the target/device -# LINUX26_FORMAT=bzImage -ifndef LINUX26_FORMAT -LINUX26_FORMAT=zImage -endif # Has to be set by the target/device ifndef LINUX26_BINLOC # default: @@ -60,15 +65,20 @@ LINUX26_KERNEL=$(BINARIES_DIR)/linux-kernel-$(LINUX26_VERSION)-$(KERNEL_ARCH) endif # Version of Linux AFTER patches -LINUX26_DIR=$(BUILD_DIR)/linux-$(LINUX26_VERSION) +LINUX26_DIR=$(PROJECT_BUILD_DIR)/linux-$(LINUX26_VERSION) # for packages that need it -LINUX_VERSION:=$(LINUX_VERSION) +LINUX_VERSION:=$(LINUX26_VERSION) LINUX_DIR=$(LINUX26_DIR) LINUX_KERNEL=$(LINUX26_KERNEL) # kernel patches -LINUX26_PATCH_DIR=$(BR2_BOARD_PATH)/kernel-patches/ +ifeq ($(strip $(LINUX26_PATCH_DIR)),) +ifneq ($(BOARD_PATH),) +LINUX26_PATCH_DIR:=$(BOARD_PATH)/kernel-patches/ +#")) +endif +endif __LINUX26_NO_PIC=-fPIC -fpic -DPIC LINUX26_MAKE_FLAGS = HOSTCC="$(HOSTCC)" HOSTCFLAGS=$(HOSTCFLAGS) \ ARCH=$(KERNEL_ARCH) \ @@ -88,20 +98,43 @@ $(LINUX26_KCONFIG): ifneq ($(strip $(LINUX26_VERSION)),$(strip $(LINUX_HEADERS_VERSION))) $(DL_DIR)/$(LINUX26_SOURCE): $(WGET) -P $(DL_DIR) $(LINUX26_SITE)/$(LINUX26_SOURCE) +endif # ($(LINUX26_VERSION),$(LINUX_HEADERS_VERSION)) $(LINUX26_DIR)/.unpacked: $(DL_DIR)/$(LINUX26_SOURCE) rm -rf $(LINUX26_DIR) - $(LINUX26_BZCAT) $(DL_DIR)/$(LINUX26_SOURCE) | tar -C $(BUILD_DIR) $(TAR_OPTIONS) - + @echo "*** Unpacking kernel source" + $(LINUX26_BZCAT) $(DL_DIR)/$(LINUX26_SOURCE) | tar -C $(PROJECT_BUILD_DIR) $(TAR_OPTIONS) - ifneq ($(DOWNLOAD_LINUX26_VERSION),$(LINUX26_VERSION)) # Rename the dir from the downloaded version to the AFTER patch version - mv -f $(BUILD_DIR)/linux-$(DOWNLOAD_LINUX26_VERSION) $(LINUX26_DIR) + mv -f $(PROJECT_BUILD_DIR)/linux-$(DOWNLOAD_LINUX26_VERSION) $(LINUX26_DIR) endif touch $@ $(LINUX26_DIR)/.patched: $(LINUX26_DIR)/.unpacked - toolchain/patch-kernel.sh $(LINUX26_DIR) $(LINUX26_PATCH_DIR) \*.patch + toolchain/patch-kernel.sh $(LINUX26_DIR) toolchain/kernel-headers \ + linux-$(LINUX26_VERSION)-\*.patch{,.gz,.bz2} +ifeq ($(BR2_KERNEL_HEADERS_IPMI),y) + toolchain/patch-kernel.sh $(LINUX26_DIR) toolchain/kernel-headers/ipmi \ + linux-$(LINUX26_VERSION)-\*.patch{,.gz,.bz2} +endif +ifeq ($(BR2_KERNEL_HEADERS_LZMA),y) + toolchain/patch-kernel.sh $(LINUX26_DIR) toolchain/kernel-headers/lzma \ + linux-$(LINUX26_VERSION)-\*.patch{,.gz,.bz2} +endif +ifeq ($(BR2_KERNEL_HEADERS_PATCH_DIR),y) + toolchain/patch-kernel.sh $(LINUX26_DIR) $(KERNEL_HEADERS_PATCH_DIR) \ + linux-$(LINUX26_VERSION)-\*.patch{,.gz,.bz2} +endif +ifeq ($(BR2_PACKAGE_OPENSWAN),y) + toolchain/patch-kernel.sh $(LINUX_HEADERS_UNPACK_DIR) package/openswan \ + linux-$(LINUX26_VERSION)-\*.patch{,.gz,.bz2} +endif +ifneq ($(LINUX26_PATCH_DIR),) + if [ -d $(LINUX26_PATCH_DIR) ] ; then \ + toolchain/patch-kernel.sh $(LINUX26_DIR) $(LINUX26_PATCH_DIR) linux-$(LINUX26_VERSION)\*.patch ; \ + fi +endif touch $@ -endif # ($(LINUX26_VERSION),$(LINUX_HEADERS_VERSION)) $(LINUX26_DIR)/.configured: $(LINUX26_DIR)/.patched $(LINUX26_KCONFIG) cp -dpf $(LINUX26_KCONFIG) $(LINUX26_DIR)/.config diff --git a/toolchain/kernel-headers/kernel-headers-new.makefile b/toolchain/kernel-headers/kernel-headers-new.makefile index 6d3bb75731..67c1114f03 100644 --- a/toolchain/kernel-headers/kernel-headers-new.makefile +++ b/toolchain/kernel-headers/kernel-headers-new.makefile @@ -13,7 +13,7 @@ LINUX_HEADERS_VERSION:=$(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION) LINUX_HEADERS_SITE:=http://www.kernel.org/pub/linux/kernel/v2.6/ LINUX_HEADERS_SOURCE:=linux-$(LINUX_HEADERS_VERSION).tar.bz2 LINUX_HEADERS_CAT:=$(BZCAT) -LINUX_HEADERS_UNPACK_DIR:=$(BUILD_DIR)/linux-$(LINUX_HEADERS_VERSION) +LINUX_HEADERS_UNPACK_DIR:=$(TOOL_BUILD_DIR)/linux-$(LINUX_HEADERS_VERSION) LINUX_HEADERS_DIR:=$(TOOL_BUILD_DIR)/linux LINUX_HEADERS_IS_KERNEL=y endif @@ -28,7 +28,7 @@ LINUX_HEADERS_VERSION:=$(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION) LINUX_HEADERS_SITE:=http://www.kernel.org/pub/linux/kernel/v2.6/ LINUX_HEADERS_SOURCE:=linux-$(LINUX_HEADERS_VERSION).tar.bz2 LINUX_HEADERS_CAT:=$(BZCAT) -LINUX_HEADERS_UNPACK_DIR:=$(BUILD_DIR)/linux-$(LINUX_HEADERS_VERSION) +LINUX_HEADERS_UNPACK_DIR:=$(TOOL_BUILD_DIR)/linux-$(LINUX_HEADERS_VERSION) LINUX_HEADERS_DIR:=$(TOOL_BUILD_DIR)/linux LINUX_HEADERS_IS_KERNEL=y endif @@ -43,7 +43,7 @@ LINUX_HEADERS_VERSION:=$(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION) LINUX_HEADERS_SITE:=http://www.kernel.org/pub/linux/kernel/v2.6/ LINUX_HEADERS_SOURCE:=linux-$(LINUX_HEADERS_VERSION).tar.bz2 LINUX_HEADERS_CAT:=$(BZCAT) -LINUX_HEADERS_UNPACK_DIR:=$(BUILD_DIR)/linux-$(LINUX_HEADERS_VERSION) +LINUX_HEADERS_UNPACK_DIR:=$(TOOL_BUILD_DIR)/linux-$(LINUX_HEADERS_VERSION) LINUX_HEADERS_DIR:=$(TOOL_BUILD_DIR)/linux LINUX_HEADERS_IS_KERNEL=y endif @@ -56,8 +56,8 @@ KERNEL_HEADERS_PATCH_DIR:=toolchain/kernel-headers/empty $(LINUX_HEADERS_UNPACK_DIR)/.unpacked: $(DL_DIR)/$(LINUX_HEADERS_SOURCE) @echo "*** Using kernel-headers generated from kernel source" rm -rf $(LINUX_HEADERS_DIR) - [ -d $(BUILD_DIR) ] || $(INSTALL) -d $(BUILD_DIR) - $(LINUX_HEADERS_CAT) $(DL_DIR)/$(LINUX_HEADERS_SOURCE) | tar -C $(BUILD_DIR) $(TAR_OPTIONS) - + [ -d $(TOOL_BUILD_DIR) ] || $(INSTALL) -d $(TOOL_BUILD_DIR) + $(LINUX_HEADERS_CAT) $(DL_DIR)/$(LINUX_HEADERS_SOURCE) | tar -C $(TOOL_BUILD_DIR) $(TAR_OPTIONS) - touch $@ $(LINUX_HEADERS_UNPACK_DIR)/.patched: $(LINUX_HEADERS_UNPACK_DIR)/.unpacked diff --git a/toolchain/kernel-headers/kernel-headers.mk b/toolchain/kernel-headers/kernel-headers.mk index 92eaf15586..b4e0c38ac1 100644 --- a/toolchain/kernel-headers/kernel-headers.mk +++ b/toolchain/kernel-headers/kernel-headers.mk @@ -37,5 +37,6 @@ kernel-headers-clean: clean kernel-headers-dirclean: rm -rf $(LINUX_HEADERS_DIR) + rm -rf $(LINUX_HEADERS_UNPACK_DIR) .PHONY: kernel-headers -- 2.30.2