Introduction

 _______                     ________        __
|       |.-----.-----.-----.|  |  |  |.----.|  |_
|   -   ||  _  |  -__|     ||  |  |  ||   _||   _|
|_______||   __|_____|__|__||________||__|  |____|
         |__| W I R E L E S S   F R E E D O M

Some basic stuff you maybe want to know about OpenWrt package development

Building OpenWrt

Linux Development Environment

I had no trouble building OpenWrt using the following Linux distributions.

  • Gentoo (very nice because i love it)
  • Debian (seems to be the best choice because many tools are available and stable)

I had trouble building OpenWrt using the following distributions.

  • Fedora (I had much trouble to get it running and some patches where needed. I don't use Fedora for OpenWrt development anymore; It is a pain!

Getting the source code

This command is checking out the base system trunk and toolchain to the current directory:

svn co https://svn.openwrt.org/openwrt/trunk/ .

Creating packages

Example Makefile

This is not complete yet; I will try to keep records of relevant sections and settings.

You need to know that there are many small differences in each software available. It is mostly not possible to use the same Makefile parameters for multiple pieces of software. Therefore you really need to take a look at other Makefiles to learn what is possible. In most cases there is a simple way to fix every build problems but when not you simply could aplly patches to the original code to make it work.

# Copyright (C) 2008 OpenWrt.org
#
# This is free software, licensed under the GNU General Public License v2.
#

include $(TOPDIR)/rules.mk

PKG_NAME:=foo
PKG_VERSION:=1.0.2
PKG_RELEASE:=1

PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
PKG_SOURCE_URL:=http://hanez.org/foo
PKG_MD5SUM:=9e7589e90519bc6ac2f4656ea6869439

# Sart make install at build time
PKG_INSTALL:=1

TARGET_LDFLAGS+= \
        -Wl,-rpath-link=$(STAGING_DIR)/usr/lib \
        -Wl,-rpath-link=$(STAGING_DIR)/usr/lib/libiconv/lib \
        -Wl,-rpath-link=$(STAGING_DIR)/usr/lib/libintl/lib

include $(INCLUDE_DIR)/package.mk

define Package/foo
  TITLE:=The Foo Manager
  SECTION:=app
  CATEGORY:=Xorg
  DEPENDS:=+glib2
  URL:=http://hanez.org/foo/
endef

define Package/foo/description
  Foo software for making foo...
endef

define Build/Compile
        $(MAKE) -C $(PKG_BUILD_DIR) DESTDIR="$(PKG_INSTALL_DIR)" install
endef

$(eval $(call BuildPackage,foo))

Adding patches

TODO!

Adding default files to packages

TODO! files like /etc/config/foo.etc ...

Mark packages broken

Just add the @BROKEN flag to the DEPENDS section and your packages will not be selectable in menuconfig.

define Package/pidgin-x-session
  TITLE:=pidgin X session support
  SECTION:=xorg-wm
  SUBMENU:=app
  CATEGORY:=Xorg
  DEPENDS:=pidgin +libX11 @BROKEN
endef

Package repositories

Add your own local repository

Go to the root of your OpenWrt source directory.

hanez@phantom ~ % cd /home/hanez/openwrt/new
hanez@phantom new % cp feeds.conf.default feeds.conf

Edit feeds.conf with your favorite $EDITOR. Add a line like the following to add a local filesystem based repository with the name "hanez":

src-link hanez /home/hanez/openwrt/packages

My file looks like this:

src-svn packages https://svn.openwrt.org/openwrt/packages
src-svn xwrt http://x-wrt.googlecode.com/svn/trunk/package
src-svn luci http://dev.leipzig.freifunk.net/svn/ff-luci/trunk/contrib/package
src-link hanez /home/hanez/openwrt/packages

After that you need to update the OpenWrt repository cache. You need to use the following command for updating the the feed named "hanez":

hanez@phantom new % scripts/feeds update hanez
Updating feed 'hanez' from '/home/hanez/openwrt/packages' ...
Create index file './feeds/hanez.index' 
Collecting package info: done

Now you need to install the packages:

hanez@phantom new % scripts/feeds install -p hanez
++ mkdir -p /home/hanez/openwrt/new/staging_dir/toolchain-arm_gcc4.1.2
++ cd /home/hanez/openwrt/new/staging_dir/toolchain-arm_gcc4.1.2
++ mkdir -p bin lib include stamp

Building packages

Show output at build time

You need to add the parameter V=99 if you want full output of the configure and make process while building a package or the toolchain.

make V=99

Compile a single package

If you want to compile a single package you need the following command. Make shure to select the package in menuconfig before. If it is not selected you need to add DEVELOPER=1 to compile it. Replace $PACKENAME with the name of your software package.

make package/$PACKAGENAME/{clean,compile,install} V=99

Links