How to compile your own software package in OpenWrt?

To compile your own software package, you can follow these steps:

  1. Firstly, make sure that you have the OpenWrt compilation environment installed. If not, please follow the installation guide provided on the official OpenWrt website.
  2. In the source code directory of OpenWrt, locate the file feeds.conf.default and add the following content to the end of the file (skip this step if it already exists):
src-git mypackages https://github.com/your-username/your-repo.git

The your-username/your-repo.git is the git URL for your software package code repository.

  1. Execute the following command to update the software package list:
./scripts/feeds update mypackages
  1. Execute the following command to install the software package:
./scripts/feeds install -a -p mypackages
  1. bundle
cd package
mkdir mypackage
  1. Copy your software package source code to a newly created subdirectory.
  2. Create a file named Makefile in the newly created subdirectory and add the following content inside:
include $(TOPDIR)/rules.mk

PKG_NAME:=mypackage
PKG_VERSION:=1.0
PKG_RELEASE:=1

PKG_SOURCE_PROTO:=git
PKG_SOURCE_URL:=https://github.com/your-username/your-repo.git
PKG_SOURCE_VERSION:=master

include $(INCLUDE_DIR)/package.mk

define Package/mypackage
  SECTION:=utils
  CATEGORY:=Utilities
  TITLE:=My Package
  DEPENDS:=+libopenssl +libcurl
endef

define Package/mypackage/description
  This is my custom package.
endef

define Build/Prepare
endef

define Build/Compile
endef

define Package/mypackage/install
  $(INSTALL_DIR) $(1)/usr/bin
  $(INSTALL_BIN) $(PKG_BUILD_DIR)/mybinary $(1)/usr/bin/
endef

$(eval $(call BuildPackage,mypackage))

Replace the values of variables such as PKG_NAME, PKG_VERSION, PKG_RELEASE, PKG_SOURCE_URL, and DEPENDS to fit your package.

  1. Return to the OpenWrt source code directory and run the following command to configure the compilation options.
make menuconfig

Locate your package in the menu, select it, and then save and exit.

  1. Run the following command to start compiling OpenWrt and your package:
make -j8

The option -j8 indicates the number of concurrent compiling threads; you can adjust it according to your system configuration.

  1. trash can
  2. binary file
  3. development directory

The above are the basic steps for compiling your own software package using OpenWrt. You can further customize and adjust it according to your needs.

bannerAds