creating openwrt-packages for kamikaze

24 Oct

NOTE: this article is still under construction

a detailed description of setting up the openwrt development environment can be found on the openwrt-wiki: buildroot

as an example, we will create a hello-world-program in standard C and build a package for ipkg that will be provided online in a ready-to-use repository

0: prerequisites

on the host where we setup the buildchain, we need some devel-packages. this list is not quite complete as i didn’t check from a bare system… you definitely need the following stuff, the system will notify you of other packages that are missing…
subversion make flex bison

make help from trunk tells us we need at least those packages:
gcc binutils patch bzip2 flex bison make gettext pkg-config unzip libz-dev libc

on a current ubuntu installation you also need the following packages:
g++ libncurses-dev gawk autoconf

1.1: get the sources

select the right svn-branch for your requirements… usually trunk is fine, but if you want to build kernel-modules for your running kamikaze-installation you’ll need the stable release:

option 1: check out the current svn-trunk:
svn co https://svn.openwrt.org/openwrt/trunk

option 2: check out the stable kamikaze-release:
svn co https://svn.openwrt.org/openwrt/tags/kamikaze_7.09/

1.2: get additional packages

run the following command inside the trunk or kamikaze directory to check out additional source-packages and create the corresponding symlinks:
make package/symlinks

2: create configuration

make menuconfig

3: compile

make

4.1: hello world sources

this is the example code we will use to build a binary (ipkg) package:

#include <stdio.h>
int main()
{
	printf("hello world\n");
}

4.2: the simple version: manual makefile

ATTENTION: make sure the indenting below is done with tabs, not with spaces! this can be achieved by piping it through expand

# build helloworld executable when user executes "make"
helloworld: helloworld.o
        $(CC) $(LDFLAGS) helloworld.o -o helloworld 
helloworld.o:
        helloworld.c $(CC) $(CFLAGS) -c helloworld.c 
# remove object files and executable when user executes "make clean"
clean:
        rm *.o helloworld 

TODO

NOTES: useful commands

compile a specific package:
make package/feeds/packages/<PACKAGENAME>-compile

(re)generate package index:
make package/index