title: How do I write the makefile for a kernel module in OpenWrt to load the module automatically
body: <p>I'm writing a simple kernel module for Openwrt. I have working code that loads and does what it needs to do. What I am missing is how to get the code into the build process of Openwrt. I have a Makefile as below:</p>
  
  <pre><code># Copyright (C) 2006-2012 OpenWrt.org
  #
  # This is free software, licensed under the GNU General Public License v2.
  # See /LICENSE for more information.
  
  include $(TOPDIR)/rules.mk
  include $(INCLUDE_DIR)/kernel.mk
  
  # name
  PKG_NAME:=HelloWorld
  # version of what we are downloading
  PKG_VERSION:=1.0
  # version of this makefile
  PKG_RELEASE:=0
  
  PKG_BUILD_DIR:=$(KERNEL_BUILD_DIR)/$(PKG_NAME)
  PKG_CHECK_FORMAT_SECURITY:=0
  
  include $(INCLUDE_DIR)/package.mk
  
  define KernelPackage/$(PKG_NAME)
      SUBMENU:=Other modules
      TITLE:=helloworld lkm
      FILES:= $(PKG_BUILD_DIR)/hello.ko
  endef
  
  define KernelPackage/$(PKG_NAME)/description
      A sample kernel module.
  endef
  
  define Build/Prepare
      mkdir -p $(PKG_BUILD_DIR)
      $(CP) ./src/* $(PKG_BUILD_DIR)/
  endef
  
  MAKE_OPTS:= \
      ARCH="$(LINUX_KARCH)" \
      CROSS_COMPILE="$(TARGET_CROSS)" \
      SUBDIRS="$(PKG_BUILD_DIR)"
  
  define Build/Compile
      $(MAKE) -C "$(LINUX_DIR)" \
          $(MAKE_OPTS) \
          modules
  endef
  
  $(eval $(call KernelPackage,$(PKG_NAME)))
  </code></pre>
  
  <p>I'm trying to follow the instructions here: <a href="https://wiki.openwrt.org/doc/devel/packages#creating_packages_for_kernel_modules" rel="nofollow noreferrer">https://wiki.openwrt.org/doc/devel/packages#creating_packages_for_kernel_modules</a></p>
  
  <p>Right now, I can see the module in the make menuconfig and select it. However when I run the build in QEMU I don't see the module. I can actually copy the *.ko module over and load it and that works. I just want the module to load automatically. How can I do that?</p>