kernel.mk 2.8 KB

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