+if ! check_cmd type mktemp; then
+ # simple replacement for missing mktemp
+ # NOT SAFE FOR GENERAL USE
+ mktemp(){
+ echo "${2%XXX*}.${HOSTNAME}.${UID}.$$"
+ }
+fi
+
+tmpfile(){
+ tmp=$(mktemp -u "${TMPDIR}/ffconf.XXXXXXXX")$2 &&
+ (set -C; exec > $tmp) 2>/dev/null ||
+ die "Unable to create temoporary file in $TMPDIR."
+ append TMPFILES $tmp
+ eval $1=$tmp
+}
+
+trap 'rm -f -- $TMPFILES' EXIT
+trap exit HUP INT TERM
+
+tmpfile TMPC .c
+tmpfile TMPE $EXESUF
+tmpfile TMPH .h
+tmpfile TMPO .o
+tmpfile TMPS .S
+tmpfile TMPSH .sh
+
+unset -f mktemp
+
+# make sure we can execute files in $TMPDIR
+cat > $TMPSH 2>> $logfile <<EOF
+#! /bin/sh
+EOF
+chmod +x $TMPSH >> $logfile 2>&1
+if ! $TMPSH >> $logfile 2>&1; then
+ cat <<EOF
+Unable to create and execute files in $TMPDIR. Set the TMPDIR environment
+variable to another directory and make sure that it is not mounted noexec.
+EOF
+ die "Sanity test failed."
+fi
+
+if $cc --version 2>/dev/null | grep -qi gcc; then
+ cc_type=gcc
+elif $cc --version 2>/dev/null | grep -q Intel; then
+ cc_type=icc
+elif $cc -v 2>&1 | grep -q xlc; then
+ cc_type=xlc
+elif $cc -V 2>/dev/null | grep -q Compaq; then
+ cc_type=ccc
+ DEPEND_CMD='$(CC) $(CFLAGS) -M $< | sed -e "/^\#.*/d" -e "s,^[[:space:]]*$(*F)\\.o,$(@D)/$(*F).o,"'
+ debuglevel=3
+ add_ldflags -Wl,-z,now # calls to libots crash without this
+elif $cc --vsn 2>/dev/null | grep -q RVCT; then
+ test -d "$sysroot" || die "No valid sysroot specified."
+ cc_type=armcc
+ armcc_conf="$PWD/armcc.conf"
+ $cc --arm_linux_configure \
+ --arm_linux_config_file="$armcc_conf" \
+ --configure_sysroot="$sysroot" \
+ --configure_cpp_headers="$sysinclude" >>$logfile 2>&1 ||
+ die "Error creating armcc configuration file."
+ cc="$cc --arm_linux_config_file=$armcc_conf --translate_gcc"
+ as_default="${cross_prefix}gcc"
+fi
+
+test -n "$cc_type" && enable $cc_type || echolog "Unknown C compiler $cc"
+
+set_default as
+
+if test -n "$sysroot"; then
+ case "$cc_type" in
+ gcc)
+ add_cflags --sysroot="$sysroot"
+ add_ldflags --sysroot="$sysroot"
+ ;;
+ esac
+fi
+
+# compiler sanity check
+check_exec <<EOF
+int main(void){ return 0; }
+EOF
+if test "$?" != 0; then
+ echo "$cc is unable to create an executable file."
+ if test -z "$cross_prefix" && ! enabled cross_compile ; then
+ echo "If $cc is a cross-compiler, use the --enable-cross-compile option."
+ echo "Only do this if you know what cross compiling means."
+ fi
+ die "C compiler test failed."
+fi