kernel.mk 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. # This file is part of the OpenADK project. OpenADK is copyrighted
  2. # material, please see the LICENCE file in the top-level directory.
  3. include $(ADK_TOPDIR)/mk/kernel-ver.mk
  4. LINUX_KMOD_SUFFIX=ko
  5. MODULES_SUBDIR := lib/modules/$(KERNEL_MOD_VERSION)
  6. LINUX_BUILD_DIR := $(BUILD_DIR)/linux-$(ADK_TARGET_ARCH)
  7. KMOD_BUILD_DIR := $(LINUX_BUILD_DIR)/linux-modules
  8. MODULES_DIR := $(LINUX_BUILD_DIR)/modules/$(MODULES_SUBDIR)
  9. TARGET_MODULES_DIR := $(LINUX_TARGET_DIR)/$(MODULES_SUBDIR)
  10. INSTALL_TARGETS:= $(KERNEL_PKG)
  11. NOINSTALL_TARGETS:=
  12. TARGETS:=
  13. ifneq ($(ADK_RUNTIME_DEV_UDEV),y)
  14. # KMOD_template (not used for udev which autoloads modules)
  15. #
  16. # Adds a target for creating a package containing
  17. # the specified (kernel-provided) modules.
  18. # Parameters:
  19. # 1: the config symbol name (without leading 'ADK_KERNEL_')
  20. # this _must_ be equal to the kernel config symbol name
  21. # 2: the name for the package, should be unique
  22. # 3: actual modules to add; absolute path inside $(MODULES_DIR)
  23. # OMIT THE KERNEL-SPECIFIC EXTENSION!
  24. # 4: order of module loading at system startup; the modules in $(3) are (in their order)
  25. # added to this file, if $(6) is non-empty
  26. # 5: the kmod packages this package depends on
  27. #
  28. define KMOD_template
  29. IDEPENDK_$(1):=kernel ($(KERNEL_VERSION)) $(foreach pkg,$(5),", $(pkg)")
  30. PKG_$(1) := $(PACKAGE_DIR)/kmod-$(2)_$(KERNEL_VERSION)-$(KERNEL_RELEASE)_$(ADK_TARGET_CPU_ARCH).$(PKG_SUFFIX)
  31. I_$(1) := $(KMOD_BUILD_DIR)/ipkg/$(2)
  32. ifeq ($${ADK_TARGET_KERNEL_CUSTOMISING},y)
  33. ifeq ($$(ADK_KERNEL_$(1)),m)
  34. TARGETS+=$$(PKG_$(1))
  35. INSTALL_TARGETS+=$$(PKG_$(1))
  36. endif
  37. endif
  38. $$(PKG_$(1)):
  39. rm -rf $$(I_$(1))
  40. @mkdir -p $$(I_$(1))
  41. echo "Package: kmod-$(2)" > $(LINUX_BUILD_DIR)/kmod-control/kmod-$(2).control
  42. echo "Priority: optional" >> $(LINUX_BUILD_DIR)/kmod-control/kmod-$(2).control
  43. echo "Section: sys" >> $(LINUX_BUILD_DIR)/kmod-control/kmod-$(2).control
  44. echo "Description: kernel module $(2)" >> $(LINUX_BUILD_DIR)/kmod-control/kmod-$(2).control
  45. ${BASH} ${SCRIPT_DIR}/make-ipkg-dir.sh $$(I_$(1)) \
  46. $(LINUX_BUILD_DIR)/kmod-control/kmod-$(2).control \
  47. $(KERNEL_VERSION)-$(KERNEL_RELEASE) $(ADK_TARGET_CPU_ARCH)
  48. echo "Depends: $$(IDEPENDK_$(1))" >> $$(I_$(1))/CONTROL/control
  49. ifneq ($(strip $(3)),)
  50. mkdir -p $$(I_$(1))/lib/modules/$(KERNEL_MOD_VERSION)
  51. $(CP) $(foreach mod,$(3),$(mod).$(LINUX_KMOD_SUFFIX)) $$(I_$(1))/lib/modules/$(KERNEL_MOD_VERSION)
  52. ifneq ($(4),)
  53. mkdir -p $$(I_$(1))/etc/modules.d
  54. for module in $(notdir $(3)); do \
  55. echo $$$$module >> $$(I_$(1))/etc/modules.d/$(4)-$(2); \
  56. done
  57. echo "#!/bin/sh" >> $$(I_$(1))/CONTROL/postinst
  58. echo "if [ -z \"\$$$${IPKG_INSTROOT}\" ]; then" >> $$(I_$(1))/CONTROL/postinst
  59. echo ". /etc/functions.sh" >> $$(I_$(1))/CONTROL/postinst
  60. echo "load_modules /etc/modules.d/$(4)-$(2)" >> $$(I_$(1))/CONTROL/postinst
  61. echo "fi" >> $$(I_$(1))/CONTROL/postinst
  62. chmod 0755 $$(I_$(1))/CONTROL/postinst
  63. endif
  64. endif
  65. $${RSTRIP} $${I_$(1)} $(MAKE_TRACE)
  66. $(PKG_BUILD) $$(I_$(1)) $(PACKAGE_DIR) $(MAKE_TRACE)
  67. endef
  68. endif
  69. include $(BUILD_DIR)/.kernelconfig