#!/bin/bash

package=serf
#version=-1.3.1
version=-1.3.9

progname=$0

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

prefix=$GEXTSVN_INSTALLED

#export CFLAGS="-fPIC -I$prefix/include $CFLAGS"
#export CXXFLAGS="-fPIC -I$prefix/include $CXXFLAGS"
#export CPPFLAGS="-fPIC -I$prefix/include $CPPFLAGS"
#export LDFLAGS="-L$prefix/lib $LDFLAGS"

# Even though gcc and g++ are added to PATH, if they're not in /usr/bin scons.py doesn't find them.
# Gemini explains: "SCons intentionally does not inherit your shell's full environment variables
# like PATH in the interest of producing reproducible builds. When SCons initializes an Environment
# object, it uses a minimal set of environment variables, which can lead to it not finding tools
# like gcc if they are in a non-standard directory.
# The quickest and cleanest solution for a one-off build is to tell SCons the exact path to your
# gcc and g++ (C and C++ compilers) executables using SCons's command-line variables.
# Run your SCons command like this: scons CC=/path/to/your/gcc CXX=/path/to/your/g++"
# We only need to do this for make, as make install doesn't use the compiler (it just copies
# over the compiled files into the destination denoted by prefix).

cc=`which gcc`
cxx=`which g++`

opt_run_untar $force_untar $auto_untar $package $version
if [ -d $package$version ] && [ ! -f $package$version/scons.py ] ; then
  /bin/cp scons-local-2.3.0.tar.gz $package$version/. \
  && (cd $package$version ; tar xvzf scons-local-2.3.0.tar.gz )
fi

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

#opt_run_make $compile   $package $version
if [ $compile = 1 ] ; then
  (cd $package$version ; ./scons.py CC=$cc CXX=$cxx APR=$prefix APU=$prefix OPENSSL=$prefix PREFIX=$prefix)
fi

#opt_run_make $install   $package $version "install"
if [ $compile = 1 ] ; then
  (cd $package$version ; ./scons.py install)
fi

#opt_run_make $clean     $package $version "clean"
if [ $compile = 1 ] ; then
  (cd $package$version ; ./scons.py -c)
fi


opt_run_make $distclean $package $version "distclean"

opt_run_tarclean $tarclean $package $version




