#!/bin/sh
###
#      \file  configure
#      \brief configure file

#      Copyright (c) 2004 Higepon
#      All rights reserved.
#      License=MIT/X License

#      \author  HigePon and nanashi
#      \version $Revision: 1.1 $
#      \date   create:2003/10/07 update:$Date: 2005/07/17 13:01:46 $
###
# gcc is 3.x or 2.x
isOldVersion=`gcc --version|egrep '2\.9.*'`
isMinGW32=`uname|egrep MINGW32`
export OSTYPE="$(uname | cut -d _ -f 1 | tr [:upper:] [:lower:])"

# check MINGWPREFIX
if test -z $1 ; then
   MINGWPREFIX=${MINGWPREFIX:-"/usr/local/mingw32/bin/i386-mingw32-"}
elif test `echo $1 | grep -- --mingw-prefix= ` != "" ; then
   MINGWPREFIX=`echo $1 | sed -e "s/--mingw-prefix=//g"`
fi

echo -n "OSTYPE: "
# cygwin
if test "$OSTYPE" = "cygwin" ; then
   cp 7zip/Compress/LZMA_Alone/Makefile.posix 7zip/Compress/LZMA_Alone/Makefile
   echo "cygwin"
# MinGW (MSys)
elif test $isMinGW32; then
   cp 7zip/Compress/LZMA_Alone/Makefile.mingw32 7zip/Compress/LZMA_Alone/Makefile
   echo "MinGW32"
# MinGW (Unix)
elif test -x `printf "%s%s" $MINGWPREFIX "g++"` ; then
   cp  7zip/Compress/LZMA_Alone/Makefile.posix 7zip/Compress/LZMA_Alone/Makefile
   echo "MinGW32 (Unix)"
else
   echo $OSTYPE
   echo ""
   echo "Sorry, currently your platform is not supported."
   echo "If you can support your platform, please contact with Mona PJ."
   echo "http://mona.sourceforge.jp/"
   exit 1
fi

cp Makefile.in Makefile

echo ""
echo "[How to build]"
echo "1. make"
echo "2. make install"
