# This file is a shell script fragment that supplies the information
# necessary for a configure script to process the program in
# this directory.  For more information, look at ../configure.

configdirs=
srctrigger=../libiberty/getopt1.c
srcname="cross -liberty library"
Makefile_in=../libiberty/Makefile.in

case "$srcdir" in
    ".") ;;
    *) srcdir=${srcdir}/../libiberty ;;
esac

# per-host:
# per-target:

files="../libiberty/alloca-norm.h"
links="alloca-conf.h"

xhost=${target}
xsrcdir=../libiberty/
. ${srcdir}/../libiberty/config.table
if test -n "${frag}" ; then
  target_makefile_frag=../libiberty/config/${frag}
fi

case "$srcdir" in
    ".")
	# Make sure we also make links to all the source files
	source_files=`echo ../libiberty/*.[ch] ../libiberty/functions.def`
	files="${files} ${source_files}"
	source_links=`echo "$source_files" | sed -e 's|../libiberty/||g'`
	links="${links} ${source_links}"
	;;
    *)
	;;
esac

# post-target:

cat > Makefile.tem <<'!EOF!'
CC = `if [ -f ../gcc/gcc ] ; \
        then echo ../gcc/gcc -B../gcc/ ; \
        else echo ${target_alias}-gcc ; fi`
INSTALL_DEST = tooldir
!EOF!

# If we are cross-compiling, assume we are building over newlib
if [ "${host}" != "${target}" ] ; then
  cat > Makefile.tem2 <<'!EOF!'
HOST_OFILES = insque.o random.o strdup.o alloca.o
CONFIG_H = xconfig.h
NEEDED_LIST = xneeded-list

xconfig.h:
	echo "#define NEED_sys_nerr 1" >xconfig.h
	echo "#define NEED_sys_errlist 1" >>xconfig.h
	echo "#define NEED_sys_siglist 1" >>xconfig.h
	echo "#define NEED_psignal 1" >>xconfig.h

xneeded-list: Makefile
	echo $(HOST_OFILES) >xneeded-list
!EOF!
fi
sed -e "/^####/  r Makefile.tem" -e "/^####/  r Makefile.tem2" ${Makefile} > Makefile.tem3
mv Makefile.tem3 ${Makefile}
rm -f Makefile.tem Makefile.tem2

if [ "${srcdir}" = "." ] ; then
  echo "EXTRA_LINKS = ${source_links}" >>Makefile
fi
mv Makefile Makefile.tmp
# Patch 'install' and 'Makefile' rules in Makefile
# (The latter is only needed when "$srcdir" = ".".)
sed <Makefile.tmp -e '/INSTALL_DEST =/s/libdir/tooldir/' \
  -e '/Makefile/s|(srcdir)/Makefile.in|(srcdir)/../libiberty/Makefile.in|' \
  >Makefile
rm -f Makefile.tmp
