# Description: GTK+ email client and news reader
# URL: http://sylpheed.sraoss.jp/en/
# Maintainer: Juergen Daubert, juergen dot daubert at t-online dot de
# Arch Maintainer: CRUX-ARM System Team, devel at crux-arm dot nu
# Depends on: gtk openssl

name=sylpheed
version=3.0.3
release=1
source=(http://sylpheed.sraoss.jp/sylpheed/v3.0/$name-$version.tar.bz2 \
        $name-$version-cross_compile.patch)

build () {
  cd $name-$version

  patch -p1 -i $SRC/$name-$version-cross_compile.patch

  export OPENSSL_LIBS="-lssl -lcrypto -ldl"
  export OPENSSL_CFLAGS=""

  export GLIB_LIBS="-pthread -lgobject-2.0 -lgmodule-2.0 -lgthread-2.0 -lrt -lglib-2.0"
  export GLIB_CFLAGS="-pthread -I$CLFS/usr/include/glib-2.0 -I$CLFS/usr/lib/glib-2.0/include"

  export GTK_LIBS="$GLIB_LIBS -pthread -lgtk-x11-2.0 -lgdk-x11-2.0 -latk-1.0 -lgio-2.0 -lpangoft2-1.0 -lgdk_pixbuf-2.0 -lpangocairo-1.0 -lcairo -lpango-1.0 -lfreetype -lfontconfig"
  export GTK_CFLAGS="-I$CLFS/usr/include -pthread -I$CLFS/usr/include/gtk-2.0 -I$CLFS/usr/lib/gtk-2.0/include -I$CLFS/usr/include/atk-1.0 -I$CLFS/usr/include/cairo -I$CLFS/usr/include/pango-1.0 -I$CLFS/usr/include/pixman-1 -I$CLFS/usr/include/freetype2 -I$CLFS/usr/include/libpng12"

  # here 'includedir' is used in the compilation stage for headers
  ./configure --build=$CHOST \
              --host=$CTARGET \
              --prefix=/usr \
              --includedir=$CLFS/usr/include \
              --disable-gtktest \
              --disable-glibtest

  # libtool relink change to avoid hosts libs
  sed "s|add_dir=\"\-L\$libdir\"|add_dir=\"\-L\$CLFS\$dir\"|g" -i libtool
  make
  # and here 'includedir' is used in the installation stage
  make DESTDIR=$PKG includedir=/usr/include install

  sed -ri '/\[.+\]=/d' sylpheed.desktop
  install -d $PKG/usr/share/{applications,pixmaps}
  install -m 0644 sylpheed.desktop $PKG/usr/share/applications
  install -m 0644 sylpheed.png $PKG/usr/share/pixmaps

  rm -r $PKG/usr/share/{locale,sylpheed}
}