1 # Lots of reusable functions. This file is sourced, not run.
3 # libraries are configured with --prefix=/usr to run on
4 # the final system but they are then installed with
5 # make DESTDIR="..." install or similar to temporary
6 # staging directory where other libs can be cross compiled
9 # This doesn't work because libtool will hardwire paths
10 # to /usr/lib in it's *.la files and this leds the cross
11 # compiler to link against libraries from the host system
12 # which of course doesn't work.
14 # We therefore prefix every path in the *.la files with our
15 # temporary staging dir.
17 # This was mostly taken from OpenWRT's autotools.mk
19 function libtool_fixup_libdir
() {
20 cd "$STAGING_DIR/usr/lib"
21 find .
-name $1\
*.la
-o -name lib
$1\
*.la
-o -path .
/$1/\
*.la |
xargs \
22 sed -i "s,\(^libdir='\| \|-L\|^dependency_libs='\)/usr/lib,\1$STAGING_DIR/usr/lib,g"
26 # In theory this should be controllable with the $PKG_CONFIG_SYSROOT_DIR
27 # environment variable but this feature was introduced in pkg-config 0.23
28 # and Debian unstable still ships with 0.22 so we hardwire the paths.
30 function pkgconfig_fixup_prefix
() {
31 find "$STAGING_DIR/usr/lib/pkgconfig" -name $1\
*.pc |
xargs \
32 sed -i "s,^prefix=.*$,prefix=$STAGING_DIR/usr,g"
35 function install_shared_library
() {
36 cp -P $STAGING_DIR/usr
/lib
/lib
$1*.so
* $ROOT_DIR/usr
/lib || dienow
37 if [ -d "$STAGING_DIR/usr/lib/$1" ]
39 cd $STAGING_DIR/usr
/lib
40 find $1 -name '*.so' |
xargs tar -cf - |
tar -xf - -C $ROOT_DIR/usr
/lib
45 function create_rootfs_tarball
()
47 echo -n creating rootfs.
tar.gz
48 { tar -C "$ROOT_DIR" -czvf rootfs.
tar.gz . || dienow
52 # Try to download a given revision from a svn repository
54 function download_svn
()
57 # In a first step get a tarball filename for the requested revison
59 [ -z "$SVN_REV" ] && SVN_REV
="HEAD"
61 PACKAGE
=`echo "$URL" | sed 's .*/ '`
62 DIRNAME
=$PACKAGE-r$SVN_REV
63 FILENAME
=$PACKAGE-r$SVN_REV.
tar.bz2
65 # Update timestamp so cleanup_oldfiles doesn't delete it
66 touch -c "$SRCDIR/$FILENAME" 2>/dev
/null
68 # Return success if we have a valid copy of the file
69 try_checksum
&& return 0
71 echo Checking out
$PACKAGE revision
$SVN_REV from svn repository
72 # Checkout files from source repository if no revison was
73 # requested find out which revison current HEAD is and
74 # package everything into a tarball.
75 svn co
--non-interactive -r$SVN_REV "$URL" "$SRCDIR/$PACKAGE" | dotprogress ||
return 1
77 if [ "x$SVN_REV" = "xHEAD" ]; then
78 cd "$SRCDIR/$PACKAGE" &&
79 DIRNAME
="$PACKAGE-r$(svn info | grep Revision: | sed 's/Revision: //')" &&
83 mv "$SRCDIR/$PACKAGE" "$SRCDIR/$DIRNAME" &&
84 find "$SRCDIR/$DIRNAME" -name .svn |
xargs rm -rf &&
85 tar -C "$SRCDIR" -cjf "$SRCDIR/$DIRNAME.tar.bz2" "$DIRNAME" &&
86 rm -rf "$SRCDIR/$DIRNAME" && return 0
91 # Note that this sources the file, rather than calling it as a separate
92 # process. That way it can set environment variables if it wants to.
94 function build_package
()
96 [ ! -f "$SOURCES"/sections
/"$1".sh
] && echo "Unknown package: $1" && exit 1
97 .
"$SOURCES"/sections
/"$1".sh