Adding a package to Optware ng

alllexx88 edited this page Mar 3, 2016 · 4 revisions

The best way to learn Optware-ng build system is by studying examples. This page doesn't aim to fully describe all possible issues you may encounter, but will try to give you some guidelines for what to begin with.

Refer to Contributing to Optware ng to setup a development environment.

1. Creating a new package Makefile using template

$ make make/<package>.mk

This will create make/<package>.mk, the Makefile that will be used to fetch source, configure, build, stage (if needed) and package your <package> (no pun intended). This template Makefile you created follows the following schema:

  1. Source is fetched using wget
  2. Configure stage uses ./configure script. This template also assumes the use of libtool (see $(PATCH_LIBTOOL) $(@D)/libtool line)
  3. Package is built and installed using make

2. Filling in package info fields

Here we'll describe main fields you have to fill in in the newly created Makefile

2.1. <FOO>_URL=

This points to full URL address of the sourcecode archive


This is the sourcecode version

2.3. <FOO>_SOURCE=

The name that will be used to save the sourcecode archive in the downloads dir

2.4. <FOO>_DIR=

The top-level dir name of the sourcecode tarball

2.5. <FOO>_UNZIP=

  • zcat for gunzipped tarballs
  • bzcat for bzipped tarballs
  • xzcat for .tar.xz archives

If the sourcecode is not a tarball, you have to modify $(<FOO>_BUILD_DIR)/.configured stage accordingly, e.g., see make/


This field is slightly outdated, but you can still list yourself as a maintainer if you want to


Package description


You usually want to leave it to optional


Runtime package dependencies


Runtime suggestions


Runtime conflicts


This should be incremented on every ipk change


Space separated user-editable configuration files

3. Build- and packaging-related places you should look at


This lists the patches in the order in which they should be applied to the sourcecode. template Makefile uses $(PATCH) -d $(BUILD_DIR)/$(<FOO>_DIR) -p0 to apply the pattches. $(PATCH) is patch binary wrapper that replaces all %OPTWARE_TARGET_PREFIX% occurrences with $(TARGET_PREFIX) before passing patches to patch.


Additional compilation and linking flags

3.3. $(<FOO>_BUILD_DIR)/.configured target

This rule unpacks, patches and configures the sourcecode.

3.3.1. $(MAKE) <bar>-stage <baz>-stage

Edit this line to stage the buildtime dependencies before running configure script.

3.3.2. Configure args

Check and set configure switches and/or environment variables here:

	(cd $(@D); \
		./configure \
		--build=$(GNU_HOST_NAME) \
		--host=$(GNU_TARGET_NAME) \
		--target=$(GNU_TARGET_NAME) \
		--prefix=$(TARGET_PREFIX) \
		--disable-nls \
		--disable-static \

3.3.3. $(PATCH_LIBTOOL) $(@D)/libtool

Comment this line out if you package doesn't use libtool

3.4. $(<FOO>_BUILD_DIR)/.built rule

This rule builds the configured package using make

3.5. $(<FOO>_BUILD_DIR)/.staged rule

This rule is used to install the compiled package to staging dir. This is usually useful if you're building a library. You may also want to add a line to delete the staged .la file(s) if the package uses libtool:

	rm -f $(STAGING_LIB_DIR)/<lib>.la

3.6. $(<FOO>_IPK_DIR)/CONTROL/control rule

This creates the control file used to build ipk, based on the info fields you filled in earlier. You don't usually have to edit this

3.7. $(<FOO>_IPK) rule

This creates the ipk file. If install-strip make target isn't supported, or doesn't work properly, change it to install, and then add a line like this one to strip the binaries after you install them:

	$(STRIP_COMMAND) $(<FOO>_IPK_DIR)$(TARGET_PREFIX)/{<binary1>,<binary2>,..}

Also, if package uses libtool:

	find $(<FOO>_IPK_DIR)$(TARGET_PREFIX) -type f -name '*.la' -exec rm -f {} \;

4. Building your package

When you try to build you package for the first time, if using wget, you have to call make with CREATE_CHECKSUM=1 argument, which will create checksums/<packagesource>.sha512:

make <package> CREATE_CHECKSUM=1

Later on, don't forget to push this checksum to your fork before creating a pull request. Also, please test that your package builds and installs with -j10 make switch.

5. Useful examples

Here're some useful examples to look at. The list is to be appended in the future.

5.1. Python packages

  • — pure python library
  • — pure python library that also installs binary/ies. This package also uses a different (older) version to build python25 package
  • — python wrapper around C(++) library. This package also has a host build.

5.2. Perl packages

  • — pure perl module
  • — perl module that links with C(++) library

5.3. Various sourecode fetch schemes

  • — can fetch certain sourcecode revision using subversion
  • — uses git clone --bare and git archive to fetch certain commit based on date
  • — uses git to clone and checkout specific commit based on date, then executes certain package-specific code that can be executed from git worktree only git describe, and finally archives excluding '.git' dir to save space
  • — fetches code using cvs. cvs is almost never used nowadays
  • — fetches code using mercurial host build

5.4 Source configuration schemes

  • — classic autoconf'ed configure script configuration
  • — samba project homebrew waf
  • — using cmake
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Press h to open a hovercard with more details.