ntp: add hotplug class for ntp-events
[openwrt/openwrt.git] / include / kernel.mk
index 6185237765472355349e4b1b0a7bf5163cff6dca..01fb4dbd8107fa62097d133f4c755acc37bba958 100644 (file)
@@ -66,7 +66,7 @@ ifneq (,$(findstring uml,$(BOARD)))
   LINUX_KARCH=um
 else
   ifeq (,$(LINUX_KARCH))
-    LINUX_KARCH=$(strip $(subst i386,x86,$(subst armeb,arm,$(subst mipsel,mips,$(subst mips64,mips,$(subst mips64el,mips,$(subst sh2,sh,$(subst sh3,sh,$(subst sh4,sh,$(ARCH))))))))))
+    LINUX_KARCH=$(strip $(subst i386,x86,$(subst armeb,arm,$(subst mipsel,mips,$(subst mips64,mips,$(subst mips64el,mips,$(subst sh2,sh,$(subst sh3,sh,$(subst sh4,sh,$(subst aarch64,arm64,$(subst aarch64_be,arm64,$(ARCH))))))))))))
   endif
 endif
 
@@ -79,16 +79,30 @@ endef
 define ModuleAutoLoad
        $(SH_FUNC) \
        export modules=; \
+       probe_module() { \
+               mods="$$$$$$$$1"; \
+               boot="$$$$$$$$2"; \
+               shift 2; \
+               for mod in $$$$$$$$mods; do \
+                       mkdir -p $(2)/etc/modules.d; \
+                       echo "$$$$$$$$mod" >> $(2)/etc/modules.d/$(1); \
+               done; \
+               if [ -e $(2)/etc/modules.d/$(1) ]; then \
+                       if [ "$$$$$$$$boot" = "1" ]; then \
+                               mkdir -p $(2)/etc/modules-boot.d; \
+                               ln -s ../modules.d/$(1) $(2)/etc/modules-boot.d/; \
+                       fi; \
+                       modules="$$$$$$$${modules:+$$$$$$$$modules}"; \
+               fi; \
+       }; \
        add_module() { \
                priority="$$$$$$$$1"; \
                mods="$$$$$$$$2"; \
                boot="$$$$$$$$3"; \
                shift 3; \
                for mod in $$$$$$$$mods; do \
-                       if [ -e $(2)/$(MODULES_SUBDIR)/$$$$$$$$mod.ko ]; then \
-                               mkdir -p $(2)/etc/modules.d; \
-                               echo "$$$$$$$$mod" >> $(2)/etc/modules.d/$$$$$$$$priority-$(1); \
-                       fi; \
+                       mkdir -p $(2)/etc/modules.d; \
+                       echo "$$$$$$$$mod" >> $(2)/etc/modules.d/$$$$$$$$priority-$(1); \
                done; \
                if [ -e $(2)/etc/modules.d/$$$$$$$$priority-$(1) ]; then \
                        if [ "$$$$$$$$boot" = "1" ]; then \
@@ -104,8 +118,8 @@ define ModuleAutoLoad
                mkdir -p $(2)/CONTROL; \
                echo "#!/bin/sh" > $(2)/CONTROL/postinst; \
                echo "[ -z \"\$$$$$$$$IPKG_INSTROOT\" ] || exit 0" >> $(2)/CONTROL/postinst; \
-               echo ". /etc/functions.sh" >> $(2)/CONTROL/postinst; \
-               echo "load_modules $$$$$$$$modules" >> $(2)/CONTROL/postinst; \
+               echo ". /lib/functions.sh" >> $(2)/CONTROL/postinst; \
+               echo "insert_modules $$$$$$$$modules" >> $(2)/CONTROL/postinst; \
                chmod 0755 $(2)/CONTROL/postinst; \
        fi
 endef
@@ -163,11 +177,11 @@ $(call KernelPackage/$(1)/config)
                                if grep -q "$$$$$$$${mod##$(LINUX_DIR)/}" "$(LINUX_DIR)/modules.builtin"; then \
                                        echo "NOTICE: module '$$$$$$$$mod' is built-in."; \
                                else \
-                                       echo "ERROR: module '$$$$$$$$mod' is missing."; \
+                                       echo "ERROR: module '$$$$$$$$mod' is missing." >&2; \
                                        exit 1; \
                                fi; \
                        else \
-                               echo "WARNING: module '$$$$$$$$mod' missing and modules.builtin not available, assuming built-in."; \
+                               echo "WARNING: module '$$$$$$$$mod' missing and modules.builtin not available, assuming built-in." >&2; \
                        fi; \
                  done;
                  $(call ModuleAutoLoad,$(1),$$(1),$(AUTOLOAD))
@@ -176,9 +190,13 @@ $(call KernelPackage/$(1)/config)
     endif
   $(if $(CONFIG_PACKAGE_kmod-$(1)),
     else
-      compile: kmod-$(1)-unavailable
-      kmod-$(1)-unavailable:
-               @echo "WARNING: kmod-$(1) is not available in the kernel config"
+      compile: $(1)-disabled
+      $(1)-disabled:
+               @echo "WARNING: kmod-$(1) is not available in the kernel config - generating empty package" >&2
+
+      define Package/kmod-$(1)/install
+               true
+      endef
   )
   endif
   $$(eval $$(call BuildPackage,kmod-$(1)))
@@ -190,6 +208,10 @@ define AutoLoad
   add_module "$(1)" "$(2)" "$(3)";
 endef
 
+define AutoProbe
+  probe_module "$(1)" "$(2)";
+endef
+
 version_field=$(if $(word $(1),$(2)),$(word $(1),$(2)),0)
 kernel_version_merge=$$(( ($(call version_field,1,$(1)) << 24) + ($(call version_field,2,$(1)) << 16) + ($(call version_field,3,$(1)) << 8) + $(call version_field,4,$(1)) ))