+ echo '***' \(At least ${srctrigger} is missing.\) 1>&2
+ exit 1
+ fi
+
+ # Set up the list of links to be made.
+ # ${links} is the list of link names, and ${files} is the list of names to link to.
+
+ # Make the links.
+ while [ -n "${files}" ] ; do
+ # set file to car of files, files to cdr of files
+ set ${files}; file=$1; shift; files=$*
+ set ${links}; link=$1; shift; links=$*
+
+ if [ ! -r ${srcdir}/${file} ] ; then
+ echo '***' "${progname}: cannot create a link \"${link}\"," 1>&2
+ echo '***' "since the file \"${file}\" does not exist." 1>&2
+ exit 1
+ fi
+
+ ${remove} -f ${link}
+ rm -f config.status
+ # Make a symlink if possible, otherwise try a hard link
+ ${symbolic_link} ${srcdir}/${file} ${link} 2>/dev/null || ${hard_link} ${srcdir}/${file} ${link}
+
+ if [ ! -r ${link} ] ; then
+ echo '***' "${progname}: unable to link \"${link}\" to \"${srcdir}/${file}\"." 1>&2
+ exit 1
+ fi
+
+ if [ -n "${verbose}" ] ; then
+ echo "Linked \"${link}\" to \"${srcdir}/${file}\"."
+ fi
+ done
+
+ # Create a .gdbinit file which runs the one in srcdir
+ # and tells GDB to look there for source files.
+
+ case ${srcdir} in
+ .)
+ ;;
+ *)
+ echo "dir ." > .gdbinit
+ echo "dir ${srcdir}" >> .gdbinit
+ echo "source ${srcdir}/.gdbinit" >> .gdbinit
+ ;;
+ esac
+
+ # Install a makefile, and make it set VPATH
+ # if necessary so that the sources are found.
+ # Also change its value of srcdir.
+
+ # FIXME-someday: This business of always writing to .tem and mv back
+ # is so that I don't screw things up while developing. Once this
+ # template is stable, these should be optimized. xoxorich.
+
+ # Define macro CROSS_COMPILE in compilation if this is a cross-compiler.
+ if [ "${host}" != "${target}" ] ; then
+ echo "CROSS=-DCROSS_COMPILE" > ${Makefile}
+ echo "ALL=start.encap" >> ${Makefile}
+ else
+ echo "ALL=all.internal" > ${Makefile}
+ fi
+
+ # set target, host, VPATH
+ echo "host_alias = ${host_alias}" >> ${Makefile}
+ echo "host_cpu = ${host_cpu}" >> ${Makefile}
+ echo "host_vendor = ${host_vendor}" >> ${Makefile}
+ echo "host_os = ${host_os}" >> ${Makefile}
+
+ echo "target_alias = ${target_alias}" >> ${Makefile}
+ echo "target_cpu = ${target_cpu}" >> ${Makefile}
+ echo "target_vendor = ${target_vendor}" >> ${Makefile}
+ echo "target_os = ${target_os}" >> ${Makefile}
+
+ if [ -n "${subdirs}" ] ; then
+ echo "subdir = /${hostsubdir}/${targetsubdir}" >> ${Makefile}
+ else
+ echo "subdir =" >> ${Makefile}
+ fi
+
+ # echo "workdir = `pwd`" >> ${Makefile}
+ echo "VPATH = ${srcdir}" >> ${Makefile}
+
+ # add "Makefile.in" (or whatever it's called)
+ cat ${srcdir}/${Makefile_in} >> ${Makefile}
+
+ # Conditionalize the makefile for this host.
+ if [ -f ${srcdir}/${host_makefile_frag} ] ; then
+ (echo "host_makefile_frag = ${srcdir}/${host_makefile_frag}" ;
+ sed -e "/^####/ r ${srcdir}/${host_makefile_frag}" ${Makefile}) > Makefile.tem
+ mv Makefile.tem ${Makefile}
+ fi
+
+ # Conditionalize the makefile for this target.
+ if [ -f ${srcdir}/${target_makefile_frag} ] ; then
+ (echo "target_makefile_frag = ${srcdir}/${target_makefile_frag}" ;
+ sed -e "/^####/ r ${srcdir}/${target_makefile_frag}" ${Makefile}) > Makefile.tem
+ mv Makefile.tem ${Makefile}
+ fi
+
+ # set srcdir
+ sed "s@^srcdir = \.@srcdir = ${srcdir}@" ${Makefile} > Makefile.tem
+ mv Makefile.tem ${Makefile}
+
+ # set destdir
+ if [ -n "${destdir}" ] ; then
+ sed "s:^destdir =.*$:destdir = ${destdir}:" ${Makefile} > Makefile.tem
+ mv Makefile.tem ${Makefile}
+ fi
+
+ # reset SUBDIRS
+ sed "s:^SUBDIRS =.*$:SUBDIRS = ${configdirs}:" ${Makefile} > Makefile.tem
+ mv Makefile.tem ${Makefile}
+
+ # reset NONSUBDIRS
+ sed "s:^NONSUBDIRS =.*$:NONSUBDIRS = ${noconfigdirs}:" ${Makefile} > Makefile.tem
+ mv Makefile.tem ${Makefile}
+
+ using=
+ if [ -f ${srcdir}/${host_makefile_frag} ] ; then
+ using=" using \"${host_makefile_frag}\""
+ fi
+
+ # remove any form feeds.
+ sed -e "s/\f//" ${Makefile} > Makefile.tem
+ mv Makefile.tem ${Makefile}
+
+ if [ -f ${srcdir}/${target_makefile_frag} ] ; then
+ if [ -z "${using}" ] ; then
+ andusing=" using \"${target_makefile_frag}\""
+ else
+ andusing="${using} and \"${target_makefile_frag}\""
+ fi
+ else
+ andusing=${using}
+ fi
+
+ if [ -n "${verbose}" -o -z "${recurring}" ] ; then
+ echo "Created \"${Makefile}\"" in `pwd`${andusing}.
+ fi
+
+#### configure.in post-target parts come in here.
+
+## end of post-target part.
+
+ # describe the chosen configuration in config.status.
+ # Make that file a shellscript which will reestablish
+ # the same configuration. Used in Makefiles to rebuild
+ # Makefiles.
+
+ echo "#!/bin/sh
+# ${srcname} was configured as follows:
+${srcdir}/configure" ${arguments} `if [ -z "${norecursion}" ] ; then echo +norecursion ; else true ; fi` > config.status
+ chmod a+x config.status
+
+ originaldir=`pwd`
+ cd ${srcdir}
+ fi
+
+ # If there are subdirectories, then recurse.
+ if [ -z "${norecursion}" -a -n "${configdirs}" ] ; then
+ for configdir in ${configdirs} ; do
+ if [ -n "${verbose}" ] ; then
+ echo Configuring ${configdir}...
+ fi
+
+ if [ -d ${configdir} ] ; then
+ (cd ${configdir} ;
+ ./configure +recurring ${host_alias} +target=${target_alias} \
+ ${verbose} ${subdirs} ${removing} +destdir=${destdir}) \
+ | sed 's/^/ /'
+ else
+ if [ -n "${verbose}" ] ; then
+ echo Warning: directory \"${configdir}\" is missing.
+ fi
+ fi
+ done
+ fi
+ done # for each target
+
+ # Now build a Makefile for this host.
+ if [ -n "${subdirs}" -a ! -n "${removing}" ] ; then
+ cd ${hostsubdir}
+ cat > GNUmakefile << E!O!F
+# Makefile generated by configure for host ${host_alias}.
+
+ALL := $(shell ls -d Target-*)
+
+%:
+ $(foreach subdir,$(ALL),$(MAKE) -C $(subdir) \$@ &&) true
+
+all:
+E!O!F
+ cd ..
+ fi
+done # for each host