Search code examples
linuxarmcross-compilingbeagleboneblackopenwrt

How to cross compile a .c file for Openwrt?


I am trying to cross compile a .c file for Openwrt. I downloaded Openwrt and added my file in package directory and created Makefile for it but while compiling it is skipping. I don't know what is wrong

This the Makefile :

*

include $(TOPDIR)/rules.mk
include $(INCLUDE_DIR)/kernel.mk
PKG_NAME:=gav
PKG_VERSION:=1
PKG_RELEASE:=1
include $(INCLUDE_DIR)/package.mk
define Package/gav
  SECTION:=utils
  CATEGORY:=Base system
  TITLE:=gaurav
endef
define Package/gav/description
 This package contains an utility useful to upgrade from other firmware or 
 older OpenWrt releases.
endef
define Build/Prepare
    mkdir -p $(PKG_BUILD_DIR/)
    $(CP) ./src/* $(PKG_BUILD_DIR)/
endef
define Package/gav/install
    $(INSTALL_DIR) $(1)/sbin
    $(INSTALL_BIN) $(PKG_BUILD_DIR)/gav $(1)/sbin/
endef
$(eval $(call Buildpackage,gav))

*


Solution

  • If the toolchain skips your Makefile entirely, most probably you haven't run make menuconfig.

    So generally the steps are:

    1. Place your openWRT Makefile into openwrt/package/name folder
    2. run make menuconfig
    3. in the pop-up dialog choose the package you want to compile by putting either an M or * next to it.
    4. run make package/name/compile
    5. you'll find the .ipk file in openwrt/bin/