ar71xx: add kernel support for the EnGenius EAP300 v2 board
[openwrt/openwrt.git] / include / kernel.mk
index b637de5918339ba52c8544487f33c4fcb92d92ed..ae2dcc3fd98206871751e002cb25c412a02ff501 100644 (file)
@@ -79,6 +79,24 @@ endef
 define ModuleAutoLoad
        $(SH_FUNC) \
        export modules=; \
+       probe_module() { \
+               mods="$$$$$$$$1"; \
+               boot="$$$$$$$$2"; \
+               shift 2; \
+               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/$(1); \
+                       fi; \
+               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"; \
@@ -105,7 +123,7 @@ define ModuleAutoLoad
                echo "#!/bin/sh" > $(2)/CONTROL/postinst; \
                echo "[ -z \"\$$$$$$$$IPKG_INSTROOT\" ] || exit 0" >> $(2)/CONTROL/postinst; \
                echo ". /lib/functions.sh" >> $(2)/CONTROL/postinst; \
-               echo "load_modules $$$$$$$$modules" >> $(2)/CONTROL/postinst; \
+               echo "insert_modules $$$$$$$$modules" >> $(2)/CONTROL/postinst; \
                chmod 0755 $(2)/CONTROL/postinst; \
        fi
 endef
@@ -176,9 +194,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" >&2
+      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 +212,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)) ))