#!/bin/sh -x
# Only make Makefile if it does not exist.
if [ -e Makefile ]; then
  exit 0
fi

TOPDIR=`cd ../../..; pwd`

# SU="eval sudo"
AR=mips-ar
CC=mips-gcc
# CP="${SU} ${TOPDIR}/brecis/holes/gzipelf/gzipelf.sh"
RANLIB=mips-ranlib

CFLAGS="-Os"

LDFLAGS="-Wl,--no-undefined -Wl,--warn-once -Wl,--warn-common -Wl,--warn-constructors -Wl,--warn-multiple-gp"

# LIBS="-lc -lgcc"

INSTALL="${CP}"
INSTALL_PROGRAM="${INSTALL}"
INSTALL_DATA="${INSTALL}"
INSTALL_SCRIPT="${INSTALL}"

export AR
export CC
export CFLAGS
export CPPFLAGS
export LDFLAGS
export LIBS
export RANLIB
export INSTALL
export INSTALL_PROGRAM
export INSTALL_DATA
export INSTALL_SCRIPT

ac_cv_func_setreuid=yes \
ac_cv_func_feof_unlocked=yes \
ac_cv_func_fgets_unlocked=yes \
ac_cv_func_getegid=yes \
ac_cv_func_geteuid=yes \
ac_cv_func_getgid=yes \
ac_cv_func_getuid=yes \
ac_cv_func_tsearch=yes \
lt_cv_sys_global_symbol_pipe=no \
\
ac_cv_func_getcwd=no \
ac_cv_func_dup2=yes \
ac_cv_func_ulimit=yes \
\
am_cv_lib_error_at_line=yes \
ac_cv_func_pathconf=yes \
ac_cv_func_strerror_r_works=yes \
ac_cv_search_nanosleep=no \
jm_cv_func_nanosleep_works=yes \
ac_cv_func_memcmp_working=yes \
jm_cv_func_working_getgroups=yes \
ac_cv_func_ftruncate=yes \
ac_cv_func_memcmp=yes \
ac_cv_func_rmdir=yes \
ac_cv_func_strndup=yes \
ac_cv_func_strnlen=yes \
ac_cv_func_getpass=yes \
ac_cv_func_memrchr=yes \
ac_cv_func_mkstemp=yes \
ac_cv_func_fchdir=yes \
ac_cv_func_fdatasync=yes \
ac_cv_func_fseeko=yes \
ac_cv_func_hasmntopt=yes \
ac_cv_func_mkfifo=yes \
ac_cv_func_realpath=yes \
am_cv_func_working_getline=yes \
ac_cv_func_getmntent=yes \
\
ac_cv_func_fnmatch_works=yes \
ac_cv_func_vprintf=yes \
su_cv_sys_c_line_in_termios=yes \
su_cv_func_ut_host_in_utmp=yes \
su_cv_func_ut_host_in_utmpx=yes \
ac_cv_func_mmap_fixed_mapped=yes \
ac_cv_func_uname=yes \
ac_cv_func_chroot=yes \
ac_cv_func_gethostid=yes \
ac_cv_func_alarm=yes \
ac_cv_func_working_mktime=yes \
jm_cv_func_memcmp_working=yes \
jm_cv_struct_dirent_d_type=yes \
ac_cv_func_strerror=yes \
ac_cv_func_strerror_r=yes \
ac_cv_func_bzero=yes \
ac_cv_func_bcopy=yes \
ac_cv_func_isascii=yes \
ac_cv_func_lchown=yes \
jm_cv_func_working_chown=yes \
ac_cv_func_localtime_r=yes \
jm_cv_func_working_realloc=yes \
jm_cv_func_working_malloc=yes \
jm_cv_func_working_readdir=yes \
ac_cv_func_strtoumax=yes \
ac_cv_func_strtoull=yes \
jm_cv_func_working_re_compile_pattern=yes \
ac_cv_func_strcasecmp=yes \
ac_cv_func_strncasecmp=yes \
ac_cv_func_dup2=yes \
ac_cv_func_memchr=yes \
ac_cv_func_memmove=yes \
ac_cv_func_getpagesize=yes \
ac_cv_func_getline=yes \
ac_cv_func_getdelim=yes \
ac_cv_func_gethostbyname=yes \
ac_cv_func_gethostbyaddr=yes \
ac_cv_func_inet_ntoa=yes \
ac_cv_func_endgrent=yes \
ac_cv_func_endpwent=yes \
ac_cv_func_ftime=yes \
ac_cv_func_getcwd=yes \
ac_cv_func_gettimeofday=yes \
ac_cv_func_memcpy=yes \
ac_cv_func_mempcpy=yes \
ac_cv_func_sethostname=yes \
ac_cv_func_strchr=yes \
ac_cv_func_strrchr=yes \
ac_cv_func_sysinfo=yes \
ac_cv_func_tzset=yes \
ac_cv_func_initgroups=yes \
ac_cv_func_syslog=yes \
ac_cv_func_gethostname=yes \
ac_cv_func_getusershell=yes \
ac_cv_func_memset=yes \
ac_cv_func_stime=yes \
ac_cv_func_strcspn=yes \
ac_cv_func_stpcpy=yes \
ac_cv_func_strstr=yes \
ac_cv_func_strtol=yes \
ac_cv_func_strtoul=yes \
ac_cv_func_strpbrk=yes \
ac_cv_func_getgroups=yes \
utils_cv_func_setpriority=yes \
utils_cv_func_nice=yes \
ac_cv_func_utmpname=yes \
am_cv_func_strtod=yes \
ac_cv_func_munmap=yes \
ac_cv_func_putenv=yes \
jm_cv_func_svid_putenv=yes \
ac_cv_func_setenv=yes \
ac_cv_func_strdup=yes \
\
ac_cv_prog_RANLIB=mips-ranlib \
ac_cv_func_setvbuf_reversed=no \
ac_cv_search_crypt="-lcrypt -lc" \
./configure \
	--prefix="${TOPDIR}/uC-src" \
	--host=mips-linux-elf \
	--target=mips-linux-elf \
	--includedir=${TOPDIR}/uclibc/include \
	--libdir=${TOPDIR}/uclibc/lib/ \
	--without-included-regex \
	--disable-assert \
	--disable-nls \
	--with-included-gettext

