X-Git-Url: http://git.openwrt.org/?a=blobdiff_plain;f=include%2Fkernel.mk;h=565a96c6a90dbd9da0f7d96d5dceb127b57e6aa2;hb=473eedd8669280d7aeee98e37b8f8ac935b214aa;hp=2b87aeba337550597564da4336ef2f1e0d9dc03f;hpb=349e7b635ea819ad34a571bc0adcce9b205df4e9;p=openwrt%2Fstaging%2Fflorian.git diff --git a/include/kernel.mk b/include/kernel.mk index 2b87aeba33..565a96c6a9 100644 --- a/include/kernel.mk +++ b/include/kernel.mk @@ -5,8 +5,21 @@ # See /LICENSE for more information. # +ifneq ($(filter check,$(MAKECMDGOALS)),) +CHECK:=1 +DUMP:=1 +endif + +ifneq ($(SOURCE_DATE_EPOCH),) + ifndef DUMP + KBUILD_BUILD_TIMESTAMP:=$(shell perl -e 'print scalar gmtime($(SOURCE_DATE_EPOCH))') + endif +endif + ifeq ($(__target_inc),) - include $(INCLUDE_DIR)/target.mk + ifndef CHECK + include $(INCLUDE_DIR)/target.mk + endif endif ifeq ($(DUMP),1) @@ -30,8 +43,8 @@ else endif ifeq ($(TARGET_BUILD),1) - PATCH_DIR ?= ./patches$(if $(wildcard ./patches-$(KERNEL_PATCHVER)),-$(KERNEL_PATCHVER)) - FILES_DIR ?= $(foreach dir,$(wildcard ./files ./files-$(KERNEL_PATCHVER)),"$(dir)") + PATCH_DIR ?= $(CURDIR)/patches$(if $(wildcard ./patches-$(KERNEL_PATCHVER)),-$(KERNEL_PATCHVER)) + FILES_DIR ?= $(foreach dir,$(wildcard $(CURDIR)/files $(CURDIR)/files-$(KERNEL_PATCHVER)),"$(dir)") endif KERNEL_BUILD_DIR ?= $(BUILD_DIR)/linux-$(BOARD)$(if $(SUBTARGET),_$(SUBTARGET)) LINUX_DIR ?= $(KERNEL_BUILD_DIR)/linux-$(LINUX_VERSION) @@ -44,17 +57,19 @@ else LINUX_UNAME_VERSION:=$(LINUX_UNAME_VERSION)-$(strip $(lastword $(subst -, ,$(LINUX_VERSION)))) endif - MODULES_SUBDIR:=lib/modules/$(LINUX_UNAME_VERSION) - TARGET_MODULES_DIR := $(LINUX_TARGET_DIR)/$(MODULES_SUBDIR) - LINUX_KERNEL:=$(KERNEL_BUILD_DIR)/vmlinux LINUX_SOURCE:=linux-$(LINUX_VERSION).tar.xz TESTING:=$(if $(findstring -rc,$(LINUX_VERSION)),/testing,) ifeq ($(call qstrip,$(CONFIG_EXTERNAL_KERNEL_TREE))$(call qstrip,$(CONFIG_KERNEL_GIT_CLONE_URI)),) LINUX_SITE:=@KERNEL/linux/kernel/v$(word 1,$(subst ., ,$(KERNEL_BASE))).x$(TESTING) + else + LINUX_UNAME_VERSION:=$(strip $(shell cat $(LINUX_DIR)/include/config/kernel.release)) endif + MODULES_SUBDIR:=lib/modules/$(LINUX_UNAME_VERSION) + TARGET_MODULES_DIR:=$(LINUX_TARGET_DIR)/$(MODULES_SUBDIR) + ifneq ($(TARGET_BUILD),1) PKG_BUILD_DIR ?= $(KERNEL_BUILD_DIR)/$(PKG_NAME)$(if $(PKG_VERSION),-$(PKG_VERSION)) endif @@ -78,6 +93,34 @@ else LINUX_KARCH := $(ARCH) endif +KERNEL_MAKE = $(MAKE) $(KERNEL_MAKEOPTS) + +KERNEL_MAKE_FLAGS := \ + HOSTCFLAGS="$(HOST_CFLAGS) -Wall -Wmissing-prototypes -Wstrict-prototypes" \ + CROSS_COMPILE="$(KERNEL_CROSS)" \ + ARCH="$(LINUX_KARCH)" \ + KBUILD_HAVE_NLS=no \ + KBUILD_BUILD_USER="$(call qstrip,$(CONFIG_KERNEL_BUILD_USER))" \ + KBUILD_BUILD_HOST="$(call qstrip,$(CONFIG_KERNEL_BUILD_DOMAIN))" \ + KBUILD_BUILD_TIMESTAMP="$(KBUILD_BUILD_TIMESTAMP)" \ + KBUILD_BUILD_VERSION="0" \ + HOST_LOADLIBES="-L$(STAGING_DIR_HOST)/lib" \ + CONFIG_SHELL="$(BASH)" \ + $(if $(findstring c,$(OPENWRT_VERBOSE)),V=1,V='') \ + $(if $(PKG_BUILD_ID),LDFLAGS_MODULE=--build-id=0x$(PKG_BUILD_ID)) \ + cmd_syscalls= + +ifeq ($(call qstrip,$(CONFIG_EXTERNAL_KERNEL_TREE))$(call qstrip,$(CONFIG_KERNEL_GIT_CLONE_URI)),) + KERNEL_MAKE_FLAGS += \ + KERNELRELEASE=$(LINUX_VERSION) +endif + +KERNEL_MAKEOPTS := -C $(LINUX_DIR) $(KERNEL_MAKE_FLAGS) + +ifdef CONFIG_USE_SPARSE + KERNEL_MAKEOPTS += C=1 CHECK=$(STAGING_DIR_HOST)/bin/sparse +endif + define KernelPackage/Defaults FILES:= AUTOLOAD:= @@ -88,15 +131,21 @@ define ModuleAutoLoad $(SH_FUNC) \ export modules=; \ probe_module() { \ - mods="$$$$$$$$1"; \ - boot="$$$$$$$$2"; \ - shift 2; \ - for mod in $(sort $$$$$$$$mods); do \ + local mods="$$$$$$$$1"; \ + params="$$$$$$$$3"; \ + local boot="$$$$$$$$2"; \ + local mod; \ + shift 3; \ + for mod in $$$$$$$$mods; do \ mkdir -p $(2)/etc/modules.d; \ - echo "$$$$$$$$mod" >> $(2)/etc/modules.d/$(1); \ + if [ -n "$$$$$$$$params" ]; then \ + echo "$$$$$$$$mod $$$$$$$$params" >> $(2)/etc/modules.d/$(1); \ + else \ + echo "$$$$$$$$mod" >> $(2)/etc/modules.d/$(1); \ + fi; \ done; \ if [ -e $(2)/etc/modules.d/$(1) ]; then \ - if [ "$$$$$$$$boot" = "1" ]; then \ + if [ "$$$$$$$$boot" = "1" -a ! -e $(2)/etc/modules-boot.d/$(1) ]; then \ mkdir -p $(2)/etc/modules-boot.d; \ ln -s ../modules.d/$(1) $(2)/etc/modules-boot.d/; \ fi; \ @@ -104,16 +153,22 @@ define ModuleAutoLoad fi; \ }; \ add_module() { \ - priority="$$$$$$$$1"; \ - mods="$$$$$$$$2"; \ - boot="$$$$$$$$3"; \ - shift 3; \ - for mod in $(sort $$$$$$$$mods); do \ + local priority="$$$$$$$$1"; \ + local mods="$$$$$$$$2"; \ + local boot="$$$$$$$$3"; \ + params="$$$$$$$$4"; \ + local mod; \ + shift 4; \ + for mod in $$$$$$$$mods; do \ mkdir -p $(2)/etc/modules.d; \ - echo "$$$$$$$$mod" >> $(2)/etc/modules.d/$$$$$$$$priority-$(1); \ + if [ -n "$$$$$$$$params" ]; then \ + echo "$$$$$$$$mod $$$$$$$$params" >> $(2)/etc/modules.d/$$$$$$$$priority-$(1); \ + else \ + echo "$$$$$$$$mod" >> $(2)/etc/modules.d/$$$$$$$$priority-$(1); \ + fi; \ done; \ if [ -e $(2)/etc/modules.d/$$$$$$$$priority-$(1) ]; then \ - if [ "$$$$$$$$boot" = "1" ]; then \ + if [ "$$$$$$$$boot" = "1" -a ! -e $(2)/etc/modules-boot.d/$$$$$$$$priority-$(1) ]; then \ mkdir -p $(2)/etc/modules-boot.d; \ ln -s ../modules.d/$$$$$$$$priority-$(1) $(2)/etc/modules-boot.d/; \ fi; \ @@ -122,6 +177,7 @@ define ModuleAutoLoad }; \ $(3) \ if [ -n "$$$$$$$$modules" ]; then \ + modules="$$$$$$$$(echo "$$$$$$$$modules" | tr ' ' '\n' | sort | uniq | paste -s -d' ' -)"; \ mkdir -p $(2)/etc/modules.d; \ mkdir -p $(2)/CONTROL; \ echo "#!/bin/sh" > $(2)/CONTROL/postinst-pkg; \ @@ -148,6 +204,7 @@ define KernelPackage $(eval $(call KernelPackage/Defaults)) $(eval $(call KernelPackage/$(1))) $(eval $(call KernelPackage/$(1)/$(BOARD))) + $(eval $(call KernelPackage/$(1)/$(BOARD)/$(if $(SUBTARGET),$(SUBTARGET),generic))) define Package/kmod-$(1) TITLE:=$(TITLE) @@ -159,6 +216,7 @@ define KernelPackage PKGFLAGS:=$(PKGFLAGS) $(call KernelPackage/$(1)) $(call KernelPackage/$(1)/$(BOARD)) + $(call KernelPackage/$(1)/$(BOARD)/$(if $(SUBTARGET),$(SUBTARGET),generic)) endef ifdef KernelPackage/$(1)/conffiles @@ -215,14 +273,14 @@ $(call KernelPackage/$(1)/config) $$(IPKG_kmod-$(1)): $$(wildcard $$(FILES)) endef -version_filter=$(if $(findstring @,$(1)),$(shell $(SCRIPT_DIR)/metadata.pl version_filter $(KERNEL_PATCHVER) $(1)),$(1)) +version_filter=$(if $(findstring @,$(1)),$(shell $(SCRIPT_DIR)/package-metadata.pl version_filter $(KERNEL_PATCHVER) $(1)),$(1)) define AutoLoad - add_module "$(1)" "$(call version_filter,$(2))" "$(3)"; + add_module "$(1)" "$(call version_filter,$(2))" "$(3)" "$(4)"; endef define AutoProbe - probe_module "$(call version_filter,$(1))" "$(2)"; + probe_module "$(call version_filter,$(1))" "$(2)" "$(3)"; endef version_field=$(if $(word $(1),$(2)),$(word $(1),$(2)),0)