Difference between revisions of "Compile Software for the Humax"
Line 23: | Line 23: | ||
--disable-nls | --disable-nls | ||
</pre> | </pre> | ||
+ | |||
+ | == Test == | ||
+ | |||
+ | <syntaxhighlight lang='bash'> | ||
+ | #!/bin/sh | ||
+ | |||
+ | tar="gtar --owner=root --group=root" | ||
+ | ar="/opt/GNUbinutils/bin/ar" | ||
+ | |||
+ | pkg=${1:?"No package specified"} | ||
+ | dst=${2:-"base"} | ||
+ | force=0 | ||
+ | [ "$3" = "-f" ] && force=1 | ||
+ | |||
+ | srcdir="src/$pkg" | ||
+ | dstdir="`pwd`/pkg/$dst" | ||
+ | |||
+ | [ ! -d "$srcdir" ] && echo "$srcdir does not exist here." && exit 1 | ||
+ | [ ! -d "$dstdir" ] && echo "$dstdir does not exist here." && exit 1 | ||
+ | |||
+ | param() | ||
+ | { | ||
+ | grep "^$1:" $srcdir/CONTROL/control | cut -d: -f2 | sed 's/^ *//' | ||
+ | } | ||
+ | |||
+ | version=`param Version` | ||
+ | arch=`param Architecture` | ||
+ | |||
+ | pkgfile="$dstdir/${pkg}_${version}_${arch}.opk" | ||
+ | |||
+ | if [ -f "$pkgfile" ]; then | ||
+ | echo "$pkgfile already exists." | ||
+ | [ $force -eq 0 ] && exit 1 | ||
+ | fi | ||
+ | |||
+ | tmpdir=pkg/OPKG_BUILD.$$ | ||
+ | [ -d "$tmpdir" ] && echo "Temporary directory already exists." && exit 1 | ||
+ | mkdir $tmpdir | ||
+ | |||
+ | (cd $srcdir && $tar -czf - * --exclude=CONTROL) > $tmpdir/data.tar.gz | ||
+ | (cd $srcdir/CONTROL && $tar -czf - *) > $tmpdir/control.tar.gz | ||
+ | echo "2.0" > $tmpdir/debian-binary | ||
+ | |||
+ | (cd $tmpdir && $ar -crf $pkgfile debian-binary data.tar.gz control.tar.gz) | ||
+ | rm -rf $tmpdir | ||
+ | |||
+ | echo "Packaged contents of $srcdir into $pkgfile" | ||
+ | |||
+ | </syntaxhighlight> |
Revision as of 11:03, 18 August 2011
Contents
Compiling on-box
It is possible to compile some software directly on the Humax itself, however due to the limited amount of CPU horsepower available, this is only recommended for fairly small packages.
First you need to install the gcc and gawk packages. gcc is the compiler itself and automatically pulls in dependant packages, gawk is needed to properly support packages which use GNU autoconf, which most do.
humax# opkg install gcc gawk
After this, close your telnet session and create a new one to properly set up the environment, and you are ready to compile your first piece of software on the Humax.
Cross compiling on an external host
Recommended configure parameters
CFLAGS="-D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64" \ ./configure \ --prefix=/mod \ --host=mipsel-linux \ --target=mipsel-linux \ --disable-nls
Test
<syntaxhighlight lang='bash'>
- !/bin/sh
tar="gtar --owner=root --group=root" ar="/opt/GNUbinutils/bin/ar"
pkg=${1:?"No package specified"} dst=${2:-"base"} force=0 [ "$3" = "-f" ] && force=1
srcdir="src/$pkg" dstdir="`pwd`/pkg/$dst"
[ ! -d "$srcdir" ] && echo "$srcdir does not exist here." && exit 1 [ ! -d "$dstdir" ] && echo "$dstdir does not exist here." && exit 1
param() {
grep "^$1:" $srcdir/CONTROL/control | cut -d: -f2 | sed 's/^ *//'
}
version=`param Version` arch=`param Architecture`
pkgfile="$dstdir/${pkg}_${version}_${arch}.opk"
if [ -f "$pkgfile" ]; then
echo "$pkgfile already exists." [ $force -eq 0 ] && exit 1
fi
tmpdir=pkg/OPKG_BUILD.$$ [ -d "$tmpdir" ] && echo "Temporary directory already exists." && exit 1 mkdir $tmpdir
(cd $srcdir && $tar -czf - * --exclude=CONTROL) > $tmpdir/data.tar.gz (cd $srcdir/CONTROL && $tar -czf - *) > $tmpdir/control.tar.gz echo "2.0" > $tmpdir/debian-binary
(cd $tmpdir && $ar -crf $pkgfile debian-binary data.tar.gz control.tar.gz) rm -rf $tmpdir
echo "Packaged contents of $srcdir into $pkgfile"
</syntaxhighlight>