#!/bin/bash

package=4store
#version=-v1.1.5
version=-git-june2013

progname=$0

source ../cascade-make/lib/cascade-lib.bash GEXT_AFREPO ../.. $*

prefix=$GEXT_AFREPO_INSTALLED


opt_run_untar $force_untar $auto_untar $package $version

# Doing "-lreadline -lncurses" OK
# But the otherway around "-lncurses -lreadline" (on CentOS) leads to linking errors, 
#   requiring '-ltermcap' to be explicitly listed
# => Only one Makefile.in has it the wrong way around => patch that one

if [ "x$1" = "xtarclean" ] ; then
  /bin/rm -f .PATCH-DONE.$package
elif [ ! -f .PATCH-DONE.$package ] ; then

  echo "*******"
  echo "* Applying $package patch"
  echo "*******"

  cd "$package$version" && patch -p0 < ../patches/$package.patch && cd ..

  if [ $? = 0 ] ; then
    echo "Patch applied" > .PATCH-DONE.$package
  fi

fi


#opt_run_configure $force_config $auto_config $package $version $prefix \

ac_cv_func_malloc_0_nonnull=yes \
RAPTOR_CFLAGS=-I$GEXT_AFREPO_INSTALLED/include/raptor2 RAPTOR_LIBS="$GEXT_AFREPO_INSTALLED/lib/libraptor2.so" \
RASQAL_CFLAGS=-I$GEXT_AFREPO_INSTALLED/include/rasqal RASQAL_LIBS="$GEXT_AFREPO_INSTALLED/lib/librasqal.so" \
  opt_run_configure $force_config $auto_config $package $version $prefix \
     --with-storage-path=$prefix/var/lib/4store --with-config-path=$prefix/etc/4store.conf


opt_run_make $compile $package $version
#opt_run_make $install $package $version "install" DESTDIR=$prefix
opt_run_make $install $package $version "install"
opt_run_make $clean $package $version "clean"
opt_run_make $distclean $package $version "distclean"

opt_run_tarclean $tarclean $package $version

