#!/bin/sh
# Configure script for biew project
#
#set -x
# Declare useful functions

# Prefer these macros to full length text !
# These macros only return an error code - NO display is done
log(){
    echo "$@" >>"$TMPLOG"
}

log_file(){
    log BEGIN $1
    cat -n $1 >>"$TMPLOG"
    log END $1
}

echolog(){
    log "$@"
    echo "$@"
}

check_cmd(){
    log "$@"
    "$@" >>"$TMPLOG" 2>&1
}

set_all(){
    value=$1
    shift
    for var in $*; do
        eval $var=$value
    done
}

enable(){
    set_all yes $*
}

disable(){
    set_all no $*
}

enabled(){
    eval test "x\$$1" = "xyes"
}

disabled(){
    eval test "x\$$1" = "xno"
}

cc_check() {
  log_file "$TMPC"
  ( check_cmd $_cc $_cdefsys $_cdefos $_extraincdir $_extralibdir --verbose "$TMPC" -o "$TMPO" "$@" ) >> "$TMPLOG" 2>&1
  TMP="$?"
  echo >> "$TMPLOG"
  echo "ldd $TMPO" >> "$TMPLOG"
  ( ldd "$TMPO" ) >> "$TMPLOG" 2>&1
  echo >> "$TMPLOG"
  return "$TMP"
}

check_cpp(){
    log check_cpp "$@"
    cat >$TMPC
    log_file $TMPC
    check_cmd $_cc $CFLAGS $_extraincdir "$@" -E -o $TMPO $TMPC
}

check_header(){
    log check_header "$@"
    header=$1
    shift
    var=`echo $header | sed 's/[^A-Za-z0-9_]/_/g'`
    disable $var
    check_cpp "$@" <<EOF && enable $var
#include <$header>
int x;
EOF
}

check_cc(){
    log check_cc "$@"
    cat >$TMPC
    log_file $TMPC
    check_cmd $_cc $CFLAGS $_cdefsys $_extraincdir "$@" -c -o $TMPO $TMPC
}

# Display error message, flushes tempfile, exit
die () {
  echo
  echo "Error: $@" >&2
  echo >&2
  rm -f "$TMPO" "$TMPC" "$TMPS" "$TMPCPP"
  echo "Check "$TMPLOG" if you do not understand why it failed."
  exit 1
}

# Use this before starting a check
echocheck() {
  echo "============ Checking for $@ ============" >> "$TMPLOG"
  echo ${_echo_n} "Checking for $@ ... ${_echo_c}"
}

# Use this to echo the results of a check
echores() {
  echo "Result is: $@" >> "$TMPLOG"
  echo "##########################################" >> "$TMPLOG"
  echo "" >> "$TMPLOG"
  echo "$@"
}
#############################################################################

x86() {
case "$host_arch" in
   i*86|x86|x86pc|k5|k6|k6-2|k6-3|pentium*|athlon*) return 0;;
   *) return 1;;
esac
}

x86_64() {
case "$host_arch" in
   x86_64|amd64) return 0;;
   *) return 1;;
esac
}

ppc() {
case "$host_arch" in
      ppc) return 0 ;;
      *) return 1 ;;
esac
}

alpha() {
case "$host_arch" in
      alpha) return 0 ;;
      *) return 1 ;;
esac
}

mips() {
case "$host_arch" in
      mips) return 0 ;;
      *) return 1 ;;
esac
}

sparc() {
case "$host_arch" in
      sparc*) return 0 ;;
      *) return 1 ;;
esac
}

arm() {
case "$host_arch" in
      arm*) return 0 ;;
      *) return 1 ;;
esac
}

# Check how echo works in this /bin/sh
case `echo -n` in
  -n)	_echo_n=	_echo_c='\c'	;;	# SysV echo
  *)	_echo_n='-n '	_echo_c=	;;	# BSD echo
esac


# 1st: print out help

for parm in "$@" ; do
  if test "$parm" = "--help" || test "$parm" = "-help" || test "$parm" = "-h" ; then
    cat << EOF

Usage: $0 [OPTIONS]...

Configuration:
  -h, --help             display this help and exit

Installation directories:
  --prefix=DIR           use this prefix for installing biew [/usr/local]
  --datadir=DIR          use this prefix for installing machine independent
                         data files (syntaxes, skins) [PREFIX/share/biew]
  --libdir=DIR           use this prefix for installing machine dependent
                         libraries and plugins (for future) [PREFIX/lib/biew]

Base features:
  --cc=COMPILER          use this C compiler to build biew [gcc]
  --ld=LINKER            use this LD linker to link biew [ld]
  --ar=AR                use this AR to build biewlib    [ar]
  --ranlib=RANLIB        use RANLIB to build indexes on builib [ranlib]
  --rm=RM                use RM program to cleanup files [rm]
  --ln=LN                use LN program to make soft link [ln]
  --cd=CD                use CD program to change directory [cd]
  --cp=CP                use CP program to copy files [cp]
  --target-system=SYSTEM target system (linux, freebsd, win32, etc)  [auto,unix]
  --target-arch=ARCH     target architecture (i386, alpha, etc)   [auto,generic]
  --enable-debug[=1-3]   compile debugging information into biew [disable]
  --enable-profile       compile profiling information into biew [disable]
  --enable-gcov          compile gnu coverage information into biew [disable]

Optional features:
  --enable-slang         disable S-Lang programming library [vt100]
  --enable-curses        disable "curses" terminal control library [vt100]
  --disable-iconv        disable iconv library [autodetect]

Use these options if autodetection fails:
  --with-extraincdir=DIR   extra headers (curses.h ...) in DIR
  --with-extralibdir=DIR   extra library files (libncurses.so, ...) in DIR
  --with-x11incdir=DIR     X headers in DIR
  --with-x11libdir=DIR     X library files in DIR

Environment variables:
  CFLAGS    C compiler flags
  LDFLAGS   linker flags, e.g. -L<lib dir> if you have libraries in a
            nonstandard directory <lib dir>
  LIBS      specifies additional libs (like: export LIBS=-lacml_mv)
  DESTDIR   specifies base of installation
EOF

  exit 0
  fi
done # for parm in ...

# 2nd: checking for options
_cc=gcc
_ld=gcc
_ar="ar -rcu"
_ranlib=ranlib
_rm="rm -f"
_ln=sln
_cd=cd
_cp=cp
_libext=a
_libprefix=lib
test "$CC" && _cc="$CC"
_prefix="/usr/local"
_datadir=
_libdir=
_target_system=auto
_target_arch=auto
_x11incdir=
_x11libdir=
_profile=
_gcov=
_debug=
_osldef=
_oslibs=
disable _curses
disable _slang
enable  _iconv
for ac_option do
  case "$ac_option" in
  --prefix=*)
    _prefix=`echo $ac_option | cut -d '=' -f 2`
    ;;
  --datadir=*)
    _datadir=`echo $ac_option | cut -d '=' -f 2`
    ;;
  --libdir=*)
    _libdir=`echo $ac_option | cut -d '=' -f 2`
    ;;
  --cc=*)
    _cc=`echo $ac_option | cut -d '=' -f 2`
    ;;
  --ld=*)
    _ld=`echo $ac_option | cut -d '=' -f 2`
    ;;
  --as=*)
    _as=`echo $ac_option | cut -d '=' -f 2`
    ;;
  --cd=*)
    _cd=`echo $ac_option | cut -d '=' -f 2`
    ;;
  --cp=*)
    _cp=`echo $ac_option | cut -d '=' -f 2`
    ;;
  --enable-profile)
    _profile='-pg'
    ;;
  --enable-gcov)
    _gcov='-fprofile-arcs -ftest-coverage'
    _oslibs="-lgcov"
    ;;
  --enable-debug)
    _debug='-g'
    ;;
  --enable-debug=*)
    _debug=`echo $_echo_n '-g'$_echo_c; echo $ac_option | cut -d '=' -f 2`
    ;;
  --ar=*)
    _ar=`echo $ac_option | cut -d '=' -f 2`
    ;;
  --ranlib=*)
    _ranlib=`echo $ac_option | cut -d '=' -f 2`
    ;;
  --rm=*)
    _rm=`echo $ac_option | cut -d '=' -f 2`
    ;;
  --ln=*)
    _ln=`echo $ac_option | cut -d '=' -f 2`
    ;;
  --target-system=*)
    _target_system=`echo $ac_option | cut -d '=' -f 2`
    ;;
  --target-arch=*)
    _target_arch=`echo $ac_option | cut -d '=' -f 2`
    ;;
  --with-extraincdir=*)
    _extraincdir="$_extraincdir -I`echo $ac_option | cut -d '=' -f 2`"
    ;;
  --with-extralibdir=*)
    _extralibdir="$_extralibdir -L`echo $ac_option | cut -d '=' -f 2`"
    ;;
  --with-x11incdir=*)
    _x11incdir=-I`echo $ac_option | cut -d '=' -f 2`
    ;;
  --with-x11libdir=*)
    _x11libdir=-L`echo $ac_option | cut -d '=' -f 2`
    ;;
  --disable-curses)
    disable _curses
    ;;
  --enable-curses)
    enable _curses
    ;;
  --disable-slang)
    disable _slang
    ;;
  --enable-slang)
    enable _slang
    ;;
  --disable-iconv)
    disable _iconv
    ;;
  --enable-iconv)
    enable _iconv
    ;;
  esac
done
test -z "$_datadir" && _datadir=$_prefix"/share/biew"
test -z "$_libdir" && _libdir=$_prefix"/lib/biew"

for I in "$TMPDIR" "$TEMPDIR" "/tmp" ; do
  test "$I" && break
done

TMPLOG="config.log"
$_rm -f "$TMPLOG"
TMPC="$I/biew-conf-$RANDOM-$$.c"
TMPCPP="$I/biew-conf-$RANDOM-$$.cpp"
TMPO="$I/biew-conf-$RANDOM-$$.o"
TMPS="$I/biew-conf-$RANDOM-$$.S"
TMPE="$I/biew-conf-$RANDOM-$$.exe"
_tee="tee -a $TMPLOG"

echocheck "architecture"
if test "$_target_arch" = auto ; then
  if test -z "$host_arch" ; then
  host_arch=`( uname -p ) 2>&1`
  log "uname -p :" "$host_arch"
  case "$host_arch" in
   i*86|x86|x86pc|k5|k6|k6-2|k6-3|pentium*|athlon*)
     ;;
   x86_64|amd64)
     ;;
   sparc|ppc|alpha|arm|mips)
     ;;

   *) # uname -p on Linux returns 'unknown' for the processor type,
      # OpenBSD returns 'Intel Pentium/MMX ("Genuine Intel" 586-class)'

      # Maybe uname -m (machine hardware name) returns something we
      # recognize.
      host_arch=`( uname -m ) 2>&1`
      log "uname -m :" "$host_arch"
      case "$host_arch" in
      i*86|x86|x86pc|k5|k6|k6-2|k6-3|pentium*|athlon*)
         ;;
      x86_64|amd64)
         ;;
      ppc)
         ;;
      alpha)
         ;;
      sparc*)
         ;;
      arm*)
         ;;
      *)
         ;;
    esac
    ;;
  esac
  fi
else
  host_arch=$_target_arch
fi
echores "$host_arch"

echocheck "build"
build_arch=generic
x86     && build_arch=ia32
x86_64  && build_arch=x86_64
ppc     && build_arch=ppc
alpha   && build_arch=alpha
sparc   && build_arch=sparc
mips    && build_arch=mips
arm     && build_arch=arm

echores "$build_arch"

_bitness=32
x86_64  && _bitness=64

echocheck "target OS"
if test "$_target_system" = auto ; then
  if test -z "$system_name" ; then
    # OS name
    system_name=`uname -s`
    log "uname -s :" "$system_name"
    case "$system_name" in
	*[Ll]inux*)
	    _target_system=linux
	    ;;
	*QNX*)
	    echo `uname -v` | grep ^42
	    if test $? -eq 0
	    then
	        _target_system=qnx
	        build_arch=ia32
	        _install=cp
	    else
	        _target_system=qnxnto
	        _install=cp
	    fi
	    ;;
	*[cC][yY][gG][wW][iI][nN]*)
	    _target_system=win32
	    ;;
	*MINGW32*)
	    _target_system=win32
	    ;;
	*[eE][mM][xX]*)
	    _target_system=os2
	    ;;
	*msdosdjgpp*)
	    _target_system=dos
	    build_arch=ia32
	    _tee=
	    ;;
#	|FreeBSD|NetBSD|BSD/OS|OpenBSD|SunOS|BeOS)
#	*)
#	    _target_system=unix
#	    ;;
    esac
  else
    _target_system=auto
  fi
fi

if test "$_target_system" = auto ; then
  if test -z "$system_name" ; then
    # OS name
    system_name=`/bin/sh --version 2>&1 | sed -n 's/^.*\([(]\)./\1/p'`
    log "/bin/sh --version:" "$system_name"
    case "$system_name" in
	*linux*)
            _target_system=linux
            ;;
	*[cC][yY][gG][wW][iI][nN]*)
	    _target_system=win32
	    ;;
	*[eE][mM][xX]*)
	    _target_system=os2
	    ;;
	*msdosdjgpp*)
	    _target_system=dos
            build_arch=ia32
	    _tee=
            ;;
#	|FreeBSD|NetBSD|BSD/OS|OpenBSD|SunOS|BeOS)
	*)
	    _target_system=unix
	    ;;
    esac
  else
    _target_system=unix
  fi
fi
echores "$_target_system"


echo "Detected host..."$system_name

_cdefos="-DDATADIR='\"$_datadir\"'"

cc_name=`$_cc -v 2>&1 | tail -n 1 | cut -d ' ' -f 1`
cc_version=`$_cc -dumpversion`

echocheck "C compiler name"
echores $cc_name
case $cc_name in
    gcc)
    ;;
    *)
      die "Unknown compiler name $cc_name. Project required GCC"
    ;;
esac

echocheck "C compiler version"
echores $cc_version
case $cc_version in
  [0-2]|[0-2].[0-9]|[0-2].[0-9].[0-9])
    die "Please upgrade your gcc upto gcc-3.0 at least"
    ;;
esac
# Printout architecture
_cdefsys=
case "$build_arch" in
  ia32)
# TODO: enable >386 optimizations here
  _cdefsys="-m32 -D__MACHINE__=ia32 -D__CPU_NAME__='\"ia32\"' -D__CPU__=386 -D__DEFAULT_DISASM=0 -DCAN_COMPILE_X86_GAS=1"
  _osldef="-m32 $_osldef"
  case $cc_version in
    3.[0-9]|3.[0-9].[0-9]|4.[0-9].[0-9])
      _cdefsys="-D__ENABLE_FASTCALL=1 $_cdefsys"
      ;;
  esac
    ;;

  x86_64)
# TODO: enable >386 optimizations here
  _cdefsys="-m64 -D__MACHINE__=x86_64 -D__CPU_NAME__='\"x86_64\"' -D__CPU__=K8 -D__DEFAULT_DISASM=0 -DCAN_COMPILE_X86_GAS=1"
  _osldef="-m64 $_osldef"
  case $cc_version in
    3.[0-9]|3.[0-9].[0-9]|4.[0-9].[0-9])
      _cdefsys="-D__ENABLE_FASTCALL=1 $_cdefsys"
      ;;
  esac
    ;;

  *)
  _cdefsys="-D__MACHINE__=generic -D__CPU_NAME__='\"generic\"' -D__DEFAULT_DISASM=0"
    echo "It seems noone has ported biew to your OS or CPU type yet."
    echo "using $build_arch architecture"
    ;;
esac

if test -z "$_x11incdir" ; then
echocheck "X11 headers"
  for I in /usr/include /usr/X11R6/include /usr/X11/include /usr/openwin/include ; do
    if test -d "$I/X11" ; then
      _x11incdir="-I$I"
      echores "yes (using $I)"
      break
    fi
  done
fi
if test -z "$_x11incdir" ; then
    echores "x11inc not found"
fi

if test -z "$_x11libdir" ; then
echocheck "X11 libs"
  for I in /usr/X11R6/lib /usr/X11/lib /usr/lib32 /usr/openwin/lib ; do
    if test -d "$I" ; then
      _x11libdir="-L$I"
      echores "yes (using $I)"
      break;
    fi
  done
fi
if test -z "$_x11libdir" ; then
    echores "x11lib not found"
fi

test -z "$_debug" && _osldef="-s $_osldef" || _cdefos="-finline-limit-5 $_cdefos"
if test "$_profile" -o "$_debug" -o "$_gcov"; then
  _cdefos="-W -Wall -O2 -fno-builtin $_debug $_profile $_gcov $_cdefos"
  _osldef="$_debug $_profile $_osldef"
elif test -z "$CFLAGS" ; then
    _cdefos="-DNDEBUG=1 -O2 -ffast-math -fomit-frame-pointer $_cdefos"
    x86 && _cdefos="-mmmx -msse $_cdefos"
else
    _cdefos="-DNDEBUG=1 $CFLAGS $_cdefos"
fi
test -n "$LDFLAGS" && _osldef="$LDFLAGS $_osldef"
test -n "$LIBS" && _osldef="$LIBS $_osldef"

if test "$_target_system" = dos ; then
# disable cc_check call for DJGPP due bugs in bash
_cdefos="-D__HAVE_PRAGMA_PACK__=1 $_cdefos"
else
echocheck "pragma pack"
cat > $TMPC << EOF
#pragma pack(1)
int main(void){return 0;}
EOF
disable _ppack
cc_check && enable _ppack
enabled _ppack && _cdefos="-D__HAVE_PRAGMA_PACK__=1 $_cdefos" || die "Please upgrade your compiler"
echores "$_ppack"
fi

#Printout operating system
case "$_target_system" in
    dos)
	_cdefos="-D__MSDOS__ -D__OS_NAME__='\"DOS$_bitness\"' -D__OS__=\"dos\" -Udos $_cdefos"
	_osldef="--force-exe-suffix $_osldef"
	;;
    os2)
	_cdefos="-D__OS2__ -D__OS_NAME__='\"OS/2-$_bitness\"' -Zomf -D__OS__=\"os2\" -Uos2 $_cdefos"
# here I want to have static link of glibc instead emx.dll
	_osldef="-Zexe -Zsmall-conv -Zsys -Zomf -Zstack 1024 $_osldef"
	_ar="emxomfar -p32 rc"
	_ranlib=echo
	_libext=lib
	_libprefix=
	;;
    win32)
# I named this as win32 because of exists Win386 by Watcom.
# here I link crtdll.dll instead cygwin1.dll (it's safe)
	_cdefos="-D__WIN32__ -D__OS_NAME__='\"Win$_bitness\"' -mno-cygwin -D__OS__=\"win32\" -Uwin32 $_cdefos"
	_osldef="-mno-cygwin --force-exe-suffix $_osldef"
	_oslibs="-lwinmm $_oslibs"
	;;
    beos)
	_cdefos="-D__BEOS__ -D__UNIX__ -D__OS_NAME__='\"BeOS$_bitness\"' -D__OS__=\"beos\" -Ubeos -D_VT100_ -DHAVE_TERMINAL_OUT=1 -DDATADIR='\"/boot/home/config/lib\"' -D__DISABLE_MMF -D__DISABLE_ASM -D__DISABLE_SIGIO -DPREFIX=\"$_prefix\" $_cdefos"
	;;
    qnx)
	_cdefos="-D__QNX4__ -D__UNIX__ -D__OS_NAME__='\"QNX4-$_bitness\"' -D__OS__=\"qnx\" -U__QNX__ -D_VT100_ -DHAVE_TERMINAL_OUT=1 -D__DISABLE_MMF -DPREFIX=\"$_prefix\" $_cdefos"
	_oslibs="-ltermlib -lunix -lphoton3r.lib $_oslibs"

	;;
    qnxnto)
	_cdefos="-D__QNX6__ -D__UNIX__ -D__OS_NAME__='\"QNX6-$_bitness\"' -D__OS__=\"qnxnto\" -U__QNX__ -U__NTO__ -D_VT100_ -DHAVE_TERMINAL_OUT=1 -D__DISABLE_MMF -DPREFIX=\"$_prefix\" $_cdefos"
	_oslibs="-lncurses $_oslibs"
	;;
    linux)
	_cdefos="-D__LINUX__ -D__UNIX__ -D__OS_NAME__='\"Linux$_bitness\"' -D__OS__=\"linux\" -Ulinux -D_VT100_ -DHAVE_TERMINAL_OUT=1 -DPREFIX=\"$_prefix\" $_cdefos"
echocheck "gpm.h"
	check_header gpm.h
	enabled gpm_h && _cdefos="-DHAVE_MOUSE $_cdefos" && _oslibs="-lgpm $_oslibs"
echores "$gpm_h"
	;;
    unix)
	_cdefos="-D__UNIX__ -D__OS__=\"unix\" -Uunix -DHAVE_TERMINAL_OUT=1 $_cdefos"
echocheck "gpm.h"
	check_header gpm.h
	enabled gpm_h && _cdefos="-DHAVE_MOUSE $_cdefos" && _oslibs="-lgpm $_oslibs"
echores "$gpm_h"
	if enabled _slang; then
echocheck "slang.h"
	check_header slang.h
	enabled slang_h && _cdefos="-D_SLANG_ -D__OS_NAME__='\"Unix/Slang\"' $_cdefos"
	enabled slang_h && _oslibs="-lslang $_oslibs" || disable _slang
echores "$slang_h"
	fi
	if enabled _curses -a disabled _slang; then
echocheck "curses.h"
	cat > $TMPC << EOF
	#include <curses.h>
	int main(void) {return 0;}
EOF
	_curseslib=
	disable _curses
	cc_check -lcurses && _curseslib="-lcurses"
	if test -z "$_curseslib" ; then
	    cc_check -lncurses && _curseslib="-lncurses"
	fi
	if test -n "$_curseslib" ; then
	    enable _curses
	    _cdefos="-D_CURSES_ -D__OS_NAME__='\"Unix/Curses\"' $_cdefos"
	    _oslibs="$_curseslib $_oslibs"
	fi
echores "$_curses"
	fi
	disabled _curses -a disabled _slang && _cdefos="-D_VT100_ -D__OS_NAME__='\"Unix/VT100\"' $_cdefos"
	disabled _curses -a disabled _slang && echo "Defaulting to VT100"
	;;
    *)
	;;
esac


echocheck "checking for popen"
cat > $TMPC << EOF
#include <stdio.h>
int main(void){(void)popen; return 0;}
EOF
disable _popen
cc_check && enable _popen
enabled _popen && _cdefos="-DHAVE_POPEN=1 $_cdefos"
echores "$_popen"

echocheck "checking for pclose"
cat > $TMPC << EOF
#include <stdio.h>
int main(void){(void)pclose; return 0;}
EOF
disable _pclose
cc_check && enable _pclose
enabled _pclose && _cdefos="-DHAVE_PCLOSE=1 $_cdefos"
echores "$_pclose"

echocheck "checking for sys/resource.h"
check_header sys/resource.h
enabled sys_resource_h && _cdefos="-DHAVE_SYS_RESOURCE=1 $_cdefos"
echores "$sys_resource_h"

if test -z "$_x11libdir" ; then
 _cdefos="$_cdefos"
else
  if test -z "$_x11incdir" ; then
   _cdefos="$_cdefos"
  else
    _cdefos="-DHAVE_X11 $_cdefos"
  fi
fi

if enabled _iconv; then
disable _iconv
echocheck "iconv"
cat > $TMPC << EOF
#include <iconv.h>
int main(void) { iconv_open(0,0); return 0; }
EOF
cc_check && enable _iconv
if disabled _iconv; then
cc_check -liconv && enable _iconv
enabled _iconv && _oslibs="-liconv $_oslibs"
fi
enabled _iconv && _cdefos="-DHAVE_ICONV $_cdefos"
echores "$_iconv"
fi

# Checking for INSTALL
if test -z $_install
then
    _install="install"
    $_install --version 1>/dev/null 2>/dev/null || _install=""
fi

#Force including of our .h files before standard
_cdefos="-I. $_cdefos"
#############################################################################
echo "Creating config.mak"
cat > config.mak << EOF
# -------- Generated by configure -----------

CC=$_cc
LD=$_ld
AR=$_ar
RANLIB=$_ranlib
RM=$_rm
LN=$_ln
CD=$_cd
CP=$_cp
INSTALL=$_install
LIBEXT=$_libext
LIBPREFIX=$_libprefix
PREFIX=$_prefix
DATADIR=$_datadir
LIBDIR=$_libdir
DESTDIR=$DESTDIR
HOST=$_target_system
MACHINE=$build_arch
CDEFOS=$_cdefos $_extraincdir $_x11incdir
OSLDEF=$_osldef
OS_LIBS=$_extralibdir $_x11libdir $_oslibs
CDEFSYS=$_cdefsys
EOF

#last: printout configure
cat << EOF | $_tee

Config files successfully generated by ./configure !

  Install prefix: $_prefix
  Data directory: $_datadir
  Lib directory: $_libdir
  Compiler: $_cc
  Linker: $_ld
  Librarian: $_ar
  Ranlib: $_ranlib
  Remover: $_rm
  TARGETS
    system: $_target_system
    arch: $build_arch

EOF

$_rm -f "$TMPO" "$TMPC" "$TMPS" "$TMPCPP" "$TMPE"

