This is an old revision of the document!


Create Meson-based packages in OpenWRT

This tutorial provides a step-by-step guide to creating and installing meson-based packages in OpenWRT. We assume that the source code is local, but the process is the same for other cases such as Git, SVN, etc.

The include directory in OpenWrt contains information about the build system for different types of packages. Here, For example, meson.mk in the include directory provides useful insights:

# To build your package using meson:
#
# include $(INCLUDE_DIR)/meson.mk
# MESON_ARGS+=-Dfoo -Dbar=baz
#
# To pass additional environment variables to meson:
#
# MESON_VARS+=FOO=bar
#
.
.
.
#
# same for Build/Compile and Build/Install
#
# Host packages are built in the same fashion, just use these vars instead:
#
# MESON_HOST_ARGS+=-Dfoo -Dbar=baz
# MESON_HOST_VARS+=FOO=bar

To create a Meson package for OpenWRT, we need to perform a few steps. Firstly, we should include $(INCLUDE_DIR)/meson.mk in the Makefile, which will enable us to use Meson build system within the OpenWRT environment. Secondly, we can pass Meson arguments to specify various configuration options by using the MESON_ARGS+=<arg> syntax. This is especially useful when we want to customize build settings, such as choosing a specific compiler or setting optimization flags. Additionally, we can also pass environmental variables to Meson by using MESON_VARS. This allows us to define environment-specific settings or pass additional information to the build system. By following these steps, we can create a robust and flexible Meson package for OpenWRT that meets our specific requirements.

Meson is a build system that is designed to optimize and simplify the process of building software. By creating a Meson package, we can take advantage of this build system to automate the process of building and installing our software package. To begin with, we will be creating a single Meson package. This package will be located in the directory path /media/workspace/packages/mesonsexmpl/.

mkdir /media/workspace/packages/mesonsexmpl/helloworld
cd /media/workspace/packages/mesonsexmpl/helloworld

Next, we will create the required files. These files are main.c source file and meson.build configuration file.

touch main.c  meson.build
This website uses cookies. By using the website, you agree with storing cookies on your computer. Also you acknowledge that you have read and understand our Privacy Policy. If you do not agree leave the website.More information about cookies
  • Last modified: 2023/12/12 14:18
  • by javad.rahimi