#!/bin/sh
#############################
## Build script for: gnucash
## Creator: Jay Scott Raymond
## Adapted from examples from linuxpackages.net
## Date: 19 Sept 2005
## Builds package: Yes
## Source location: http://www.gnucash.org/
## Downloads source: No
## Build script version: v1
## Requirements: 
##
## Notes: 
##

## Include the slackware-pkg conf file
if [ -a /etc/slack-package.conf ]; then
. /etc/slack-package.conf
  else
  echo "Sorry you need to have the slack-package.conf file to run these"
  echo "please install the slackbuilds package from LinuxPackages.net"
  exit
fi

# Set initial variables:
NAME=goffice
VERSION=0.6.2
BUILD=1${MYIN}


## Location to download the sources
#SRC_LOC=""

PKG=$TMP/package-$NAME

## Lets Grab the Source if needed
#if [ -a $CWD/$NAME-$VERSION.tar.gz ]; then
#  echo "Source present not downloading"
#  else
#  $WGET $SRC_LOC || true
#fi

if [ ! -d $PKG ]; then
  mkdir -p $PKG # place for the package to be built
fi

unpack() {
    if [ ! -d $TMP ]; then
	mkdir -p $TMP # location to build the source
    fi
    cd $TMP
    rm -rf $NAME-$VERSION
# choose one
    tar xjvf $CWD/$NAME-$VERSION.tar.bz2
#tar xzvf $CWD/$NAME-$VERSION.tar.gz
    cd $NAME-$VERSION
#patch -p0 < $CWD/test2.patch || exit 1
    fix_source
}

configure() {
    cd $TMP/$NAME-$VERSION
#./autogen.sh
    ./configure --prefix=/usr \
        --sysconfdir=/etc \
    	--infodir=/usr/info \
        --localstatedir=/var \
    	--build=$ARCH-slackware-linux
}

compile() {
    cd $TMP/$NAME-$VERSION
    make || exit 2
}

install() {
    cd $TMP/$NAME-$VERSION
    make DESTDIR=$PKG install || exit 3
}

# use this for packages that don't respect DESTDIR or need additional fixup
construct() {
echo -e "no construct step"
}

prepare() {
    create_docs $PKG $NAME-$VERSION
    ( cd $PKG/usr/doc/$NAME-$VERSION
	mv docs/reference/html .
	rm -rf docs
	)

## Some package cleanup
( cd $PKG
strip_bin
strip_lib
strip_static
gzip_man $PKG
gzip_info $PKG
bin_perms $PKG
sbin_perms $PKG
)
}

description() {
mkdir -p $PKG/install 
        cat > $PKG/install/slack-desc << END 
        |-----handy-ruler------------------------------------------------------|
goffice: GOffice (GNOME Document Objects and Widgets)
goffice:
goffice: goffice is a library of document-centric objects and utilities which
goffice: provides a standard set of GTK widgets and objects for use in many 
goffice: GNOME office applications, like Gnumeric.
goffice:
goffice:
goffice:
goffice:
goffice:
goffice:
END
}

doinst() {
mkdir -p $PKG/install 
        cat > $PKG/install/doinst.sh << END 

END
}

cpslackbuild() {
mkdir -p $PKG/usr/src/slackbuilds/$NAME
cp $CWD/$NAME.SlackBuild $PKG/usr/src/slackbuilds/$NAME
}

build() {
# Build the package:
cd $PKG
makepkg -l y -c n /$PKG_DIR/$NAME-$VERSION-$ARCH-$BUILD.tgz
echo "Your $NAME package is complete, make sure you open it up before installing it."
echo "It is located in $PKG_DIR thanks for your support The Linuxpackages.net Folks"
}

unpack
configure
compile
install
construct
prepare
description
doinst
cpslackbuild
build
