#!/bin/sh
#
# Copyright 2009 Tiago Salvador Souza
# Available under the terms of the GNU GPL.
#
# Ported from http://slackbuilds.org/repository/12.2/libraries/lablgtk/
# By: Ferenc Deak <ferenc dot deak at gmail dot com>

NAME="unison"
VERSION="2.32.52"
REVISION="1"

PKG_SOURCEURL='http://www.seas.upenn.edu/~bcpierce/${NAME}/download/releases/${NAME}-${VERSION}/${NAME}-${VERSION}.tar.gz'

. $DLG_ROOT/config
. $DLG_ROOT/SCRIPTS/dropline-functions.sh

DLG_PKGER="salv"

PKG_DISABLESMP='evil!'

#Use gtk2 or text (all lower case)
FLAVOR=${FLAVOR:-gtk2}

# This packages requires ocaml to be build, but it won't fail if it ain't available,
# so we will have to make it fail ourselves
spew 3 "Checking if the ocaml package is available."
which ocaml > /dev/null 2>&1
OCAML_INSTALLED=$?

if [ $OCAML_INSTALLED -ne 0 ]; then
	die "ocaml not found. Unison build requires the ocaml package to be installed."
fi

cflags
cxxflags
prepare
analyzesource
make UISTYLE=$FLAVOR DEBUGGING=false THREADS=true NATIVE=true
spewdo "mkdir -p $PKG_STAGEROOT/usr/bin"
spewdp "install -D -m 755 $PKG_WORKROOT/${NAME}-${VERSION}/unison $PKG_STAGEROOT/usr/bin"

# Adding an icon and a .desktop file
spewdo "mkdir -p $PKG_STAGEROOT/usr/share/applications"
spewdo "mkdir -p $PKG_STAGEROOT/usr/share/pixmaps"
spewdo "install -D -m0644 $DLG_SRCDIR/$NAME/unison.desktop $PKG_STAGEROOT/usr/share/applications"
spewdo "install -D -m0644 $DLG_SRCDIR/$NAME/unison.png $PKG_STAGEROOT/usr/share/pixmaps"

tidydocumentation
analyzebinaries
finalizepackage
packagize
cleanup
