#!/bin/sh
#
# source: http://ftp.gnome.org/pub/gnome/sources/ORBit2/2.14/ORBit2-2.14.19.tar.bz2
#
# maintainer: (package seek a maintainer)
#

CWD=`pwd`
TMP=/tmp/
PKG=$TMP/package-ORBit2

VERSION=2.14.19
ARCH=i486
BUILD=66.1

SLKCFLAGS="-O2 -march=i486 -mtune=i686"

rm -rf $PKG
mkdir -p $PKG
cd $TMP
rm -rf ORBit2-$VERSION
tar xjvf $CWD/ORBit2-$VERSION.tar.bz2
cd ORBit2-$VERSION
chown -R root:root .
find . \
 \( -perm 777 -o -perm 775 -o -perm 711 -o -perm 555 -o -perm 511 \) \
 -exec chmod 755 {} \; -o \
 \( -perm 666 -o -perm 664 -o -perm 600 -o -perm 444 -o -perm 440 -o -perm 400 \) \
 -exec chmod 644 {} \;
CFLAGS="$SLKCFLAGS" \
./configure \
  --prefix=/usr \
  --disable-static

make
make install DESTDIR=$PKG

find $PKG | xargs file | grep -e "executable" -e "shared object" | grep ELF \
  | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null

mkdir -p $PKG/usr/doc/ORBit2-$VERSION
cp -a \
  AUTHORS COPYING HACKING MAINTAINERS NEWS README \
  $PKG/usr/doc/ORBit2-$VERSION
( cd $PKG/usr/doc/ORBit2-$VERSION ; ln -s /usr/share/gtk-doc/html/ORBit2 html )

mkdir -p $PKG/install
cat <<"EOF" > $PKG/install/slack-desc
# HOW TO EDIT THIS FILE:
# The "handy ruler" below makes it easier to edit a package description.  Line
# up the first '|' above the ':' following the base package name, and the '|' on
# the right side marks the last column you can put a character in.  You must make
# exactly 11 lines for the formatting to be correct.  It's also customary to
# leave one space after the ':'.

      |-----handy-ruler------------------------------------------------------|
ORBit2: ORBit2 - is a high-performance CORBA
ORBit2:
ORBit2: ORBit is a high-performance CORBA (Common Object Request Broker
ORBit2: Architecture) ORB (object request broker).  It allows programs to
ORBit2: send requests and receive replies from other programs, regardless
ORBit2: of the locations of the two programs.  CORBA is an architecture that
ORBit2: enables communication between program objects, regardless of the
ORBit2: programming language they're written in or the operating system they
ORBit2: run on.
ORBit2:
ORBit2:
EOF

mkdir -p $PKG/usr/src/ORBit2-$VERSION
cp $CWD/build-ORBit2.sh $PKG/usr/src/ORBit2-$VERSION/

cd $PKG
makepkg -l y -c n ../ORBit2-$VERSION-$ARCH-$BUILD.txz

cd ..
md5sum ORBit2-$VERSION-$ARCH-$BUILD.txz > ORBit2-$VERSION-$ARCH-$BUILD.md5