How to compile your own software package in OpenWrt?
To compile your own software package, you can follow these steps:
- Firstly, make sure that you have the OpenWrt compilation environment installed. If not, please follow the installation guide provided on the official OpenWrt website.
- 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.
- Execute the following command to update the software package list:
./scripts/feeds update mypackages
- Execute the following command to install the software package:
./scripts/feeds install -a -p mypackages
- bundle
cd package
mkdir mypackage
- Copy your software package source code to a newly created subdirectory.
- 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.
- 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.
- 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.
- trash can
- binary file
- 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.