1
0

kernel.mk 2.9 KB

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