#!/bin/sh

# ==========================================================================
# - USER CONFIGURATION -----------------------------------------------------

PREFIX=c:/chicken-iup

FFCALL_SITE=http://www.haible.de/bruno/gnu
FFCALL_DEFAULT_VERSION=cvs

#CHICKEN_SITE=http://code.call-cc.org/releases/4.9.0/chicken-4.9.0.1.tar.gz
CHICKEN_SITE=http://code.call-cc.org/releases
CHICKEN_DEFAULT_VERSION="4.9.0"
CHICKEN_DEFAULT_PATCHLEVEL=".1"

IUP_SITE=http://sourceforge.net/projects
IUP_PLATFORM="Win32_dllw4"
IM_DEFAULT_VERSION="3.9"
CD_DEFAULT_VERSION="5.8.1"
IUP_DEFAULT_VERSION="3.13"


# ==========================================================================
# - AUTOMATIC CONFIGURATION ------------------------------------------------

STARTDIR=`pwd`


# ==========================================================================
# - BUILD FFCALL -----------------------------------------------------------

# if [ "x$FFCALL_VERSION" = "x" ]; then
#     FFCALL_VERSION=${FFCALL_DEFAULT_VERSION}
# fi
# if [ "$FFCALL_VERSION" = "cvs" ]; then
#     cvs -z3 -d:pserver:anonymous@cvs.savannah.gnu.org:/sources/libffcall co ffcall
#     FFCALL_DIR=ffcall
# else
#     wget ${FFCALL_SITE}/ffcall-${FFCALL_VERSION}.tar.gz
#     tar zxvf ffcall-${FFCALL_VERSION}.tar.gz
#     FFCALL_DIR=ffcall-${FFCALL_VERSION}
# fi
# 
# cd ${FFCALL_DIR}
# ./configure --prefix=${PREFIX}
# make
# make install
# make clean
# 
# cd ${STARTDIR}


# ==========================================================================
# - BUILD CHICKEN ----------------------------------------------------------

# if [ "x$CHICKEN_VERSION" = "x" ]; then
#     CHICKEN_VERSION=${CHICKEN_DEFAULT_VERSION}
#     CHICKEN_PATCHLEVEL=${CHICKEN_DEFAULT_PATCHLEVEL}
# fi
# CHICKEN_PKGNAME=chicken-${CHICKEN_VERSION}${CHICKEN_PATCHLEVEL}
# 
# wget ${CHICKEN_SITE}/${CHICKEN_VERSION}/${CHICKEN_PKGNAME}.tar.gz
# md5_ok=`md5sum -c ${CHICKEN_PKGNAME}.md5 2>&1 |grep OK`
# if [ "x$md5_ok" = "x" ]; then
#     echo "ERROR: Bad checksum for ${CHICKEN_PKGNAME}"
#     exit 1
# fi
# 
# tar zxvf ${CHICKEN_PKGNAME}.tar.gz
# cd ${CHICKEN_PKGNAME}
# 
# patch -p0 < ../0001-Disable-getc_unlocked.patch
# 
# make PLATFORM=mingw-msys PREFIX=${PREFIX}
# make PLATFORM=mingw-msys PREFIX=${PREFIX} install
# make PLATFORM=mingw-msys clean
# 
# cd ${STARTDIR}


# ==========================================================================
# - INSTALL IUP & RELATED BINARIES -----------------------------------------

if [ "x$IM_VERSION" = "x" ]; then
    IM_VERSION=${IM_DEFAULT_VERSION}
fi
if [ "x$CD_VERSION" = "x" ]; then
    CD_VERSION=${CD_DEFAULT_VERSION}
fi
if [ "x$IUP_VERSION" = "x" ]; then
    IUP_VERSION=${IUP_DEFAULT_VERSION}
fi

IM_LONGNAME="imtoolkit"
CD_LONGNAME="canvasdraw"

wget ${IUP_SITE}/${IM_LONGNAME}/files/${IM_VERSION}/Windows%20Libraries/Dynamic/im-${IM_VERSION}_${IUP_PLATFORM}_lib.zip
wget ${IUP_SITE}/${CD_LONGNAME}/files/${CD_VERSION}/Windows%20Libraries/Dynamic/cd-${CD_VERSION}_${IUP_PLATFORM}_lib.zip
wget ${IUP_SITE}/iup/files/${IUP_VERSION}/Windows%20Libraries/Dynamic/iup-${IUP_VERSION}_${IUP_PLATFORM}_lib.zip



# ==========================================================================
# --------------------------------------------------------------------------
# ==========================================================================
# --------------------------------------------------------------------------
# ==========================================================================
# --------------------------------------------------------------------------
