4 # Copyright (C) 1988, 1990, 1991 Free Software Foundation, Inc.
6 #This file is part of GNU.
8 # This program is free software; you can redistribute it and/or modify
9 # it under the terms of the GNU General Public License as published by
10 # the Free Software Foundation; either version 2 of the License, or
11 # (at your option) any later version.
13 # This program is distributed in the hope that it will be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 # GNU General Public License for more details.
18 # You should have received a copy of the GNU General Public License
19 # along with this program; if not, write to the Free Software
20 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
24 # Please email any bugs, comments, and/or additions to this file to:
28 # Shell script to create proper links to machine-dependent files in
29 # preparation for compilation.
31 # If configure succeeds, it leaves its status in config.status.
32 # If configure fails after disturbing the status quo,
33 # config.status is removed.
36 # NOTE: This script contains support for a Cygnus experimental feature, called
37 # +subdirs, which is currently, tentatively, de-supported.
39 export PATH || (echo "OOPS, this isn't sh. Desperation time. I will feed myself to sh."; sh $0 $argv; kill $$)
48 #symbolic_link="echo ln -s"
50 # clear some things potentially inherited from environment.
53 Makefile_in=Makefile.in
62 floating_point=default
91 # or maybe grab from gcc/version.c
95 NO_EDIT="This file was generated automatically by configure. Do not edit."
97 ## this is a little touchy and won't always work, but...
99 ## if the argv[0] starts with a slash then it is an absolute name that can be
102 ## otherwise, if argv[0] has no slash in it, we can assume that it is on the
103 ## path. Since PATH might include "." we also add `pwd` to the end of PATH.
105 ## otherwise we prepend `pwd` to $0 and hope that will give us an absolute
111 if (echo $0 | grep '^/' > /dev/null) ; then
113 elif (echo $0 | grep '/' > /dev/null) ; then
117 PATH=$PATH:${PWD} ; export PATH
120 configsubr=`echo ${progname} | sed 's/configure$/config.subr/'`
122 if ${configsubr} none >/dev/null 2>&1 ; then
125 echo '***' cannot find config.subr.
131 # handle things that might have args following as separate words
132 if [ -n "${next_prefix}" ] ; then prefix=${arg} ; prefixoption="-prefix=${prefix}" ; next_prefix=
133 elif [ -n "${next_datadir}" ] ; then datadir=${arg} ; datadiroption="-datadir=${datadir}" ; next_datadir=
134 # elif [ -n "${next_namesubdir}" ] ; then \
135 # namesubdir=${arg} ; namesubdiroption="--namesubdir=${namesubdir}" ; next_namesubdir=
136 # elif [ -n "${next_objdir}" ] ; then objdir=${arg} ; objdiroption="--objdir=${objdir}" ; next_objdir=
137 elif [ -n "${next_version_path}" ] ; then version_path=${arg} ; next_version_path=
138 elif [ -n "${next_site}" ] ; then site=${arg} ; next_site=
139 elif [ -n "${next_srcdir}" ] ; then srcdir=${arg} ; next_srcdir=
140 elif [ -n "${next_target}" ] ; then
142 if [ -z "${targets}" ] ; then
143 newtargets="${targets} ${arg}"
144 targets="${newtargets}"
146 echo '***' Can only configure for one target at a time.
149 elif [ -n "${next_tmpdir}" ] ; then
151 tmpdiroption="--tmpdir=${arg}"
160 -datadir=* | --datadir=* | --datadi=* | --datad=* | --data=* | --dat=* | --da=* | --d=*)
161 datadir=`echo ${arg} | sed 's/^[-a-z]*=//'`
164 -datadir | --datadir | --datadi | --datad | --data | --dat | --da | --d)
173 -host=* | --host=* | --hos=* | --ho=*)
174 # if [ -n "${hosts}" ] ; then
175 # subdirs="--subdirs"
178 if [ -z "${hosts}" ] ; then
179 newhosts="${hosts} `echo ${arg} | sed 's/^[-a-z]*=//'`"
182 echo '***' Can only configure for one host at a time.
186 -languages=* | --languages=* | --language=* | --languag=* \
187 | --langua=* | --langu=* | --lang=* | --lan=* | --la=* \
189 languages="${languages} `echo ${arg} | sed 's/^[-a-z]*=//'`"
191 # -namesubdir | --namesubdir | --namesubdi | --namesubd | --namesub | --namesu | --names | --name | --nam | --na)
192 # next_namesubdir=yes
194 # -namesubdir=* | --namesubdir=* | --namesubdi=* | --namesubd=* | --namesub=* | --namesu=* | --names=* | --name=* | --nam=* | --na=*)
195 # namesubdir=`echo ${arg} | sed 's/^[-a-z]*=//'`
196 # namesubdiroption=${arg}
201 -norecursion | --no*)
204 # -objdir=* | --objdir=* | --objdi=* | --objd=* | --obj=* | --ob=* | --o=*)
205 # objdiroption=${arg}
206 # objdir=`echo ${arg} | sed 's/^[-a-z]*=//'`
208 # -objdir | --objdir | --objdi | --objd | --obj | --ob | --o)
211 -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*)
212 prefix=`echo ${arg} | sed 's/^[-a-z]*=//'`
215 -prefix | --prefix | --prefi | --pref | --pre | --pr | --p)
218 -recurring | --recurring | --recurrin | --recurri | --recurr | --recur | --recu | --rec | --re)
220 arguments=`echo ${arguments} | sed "s:${arg}::"`
225 -site=* | --site=* | --sit=* | --si=*)
226 site=`echo ${arg} | sed 's/^[-a-z]*=//'`
228 -site | --site | --sit | --si)
231 -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*)
232 srcdir=`echo ${arg} | sed 's/^[-a-z]*=//'`
234 -srcdir | --srcdir | --srcdi | --srcd | --src | --sr)
240 -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=*)
241 # if [ -n "${targets}" ] ; then
242 # subdirs="--subdirs"
245 if [ -z "${targets}" ] ; then
246 newtargets="${targets} `echo ${arg} | sed 's/^[-a-z]*=//'`"
247 targets="${newtargets}"
249 echo '***' Can only configure for one target at a time.
253 -target | --target | --targe | --targ | --tar | --ta)
256 -tmpdir=* | --tmpdir=* | --tmpdi=* | --tmpd=* | --tmp=* | --tm=*)
258 TMPDIR=`echo ${arg} | sed 's/^[-a-z]*=//'`
260 -tmpdir | --tmpdir | --tmpdi | --tmpd | --tmp | --tm)
269 echo "Unrecognized option: \"${arg}\"". ;
274 # if [ -n "${hosts}" ] ; then
275 # subdirs="--subdirs"
278 if [ -z "${undefs}" ] ; then
279 newundefs="${undefs} ${arg}"
282 echo '***' Can only configure for one host and one target at a time.
290 if [ -n "${verbose}" ] ; then
294 # process host and target
295 if [ -z "${fatal}" ] ; then
296 # # Complain if an arg is missing
297 # if [ -z "${hosts}" ] ; then
299 # echo "configure: No HOST specified." ;
304 ### This is a bit twisted.
305 ### * if all three are specified, this is an error.
306 ### * if we have neither hosts, nor unadorned args, this is an error.
307 ### * if no hosts are specified, then the unadorned args are hosts, but if
308 ### there were none, this is an error.
309 ### * if no targets are specified, then the unadorned args are targets, but if
310 ### there were no unadorned args, then the hosts are also targets.
312 if [ -n "${hosts}" -a -n "${targets}" -a -n "${undefs}" ] ; then
313 echo '***' Can only configure for one host and one target at a time.
315 elif [ -z "${hosts}" -a -z "${undefs}" ] ; then
316 echo '***' You must tell me for which host you want to configure.
319 if [ -z "${hosts}" ] ; then
323 if [ -z "${targets}" ] ; then
324 if [ -n "${undefs}" ] ; then
333 if [ -n "${fatal}" -o "${hosts}" = "help" ] ; then
334 (echo "Usage: configure HOST" ;
336 echo "Options: [defaults in brackets]" ;
337 echo " -ansi configure w/ANSI library. [no ansi lib]" ;
338 echo " -datadir=MYDIR configure for installation of host dependent files into MYDIR. [\"/usr/local\"]" ;
339 echo " -gas configure the compilers for use with gas. [native as]" ;
340 echo " -help print this message. [normal config]" ;
341 echo " -lang=LANG configure to build LANG. [gcc]" ;
342 echo " -nfp configure the compilers default to soft floating point. [hard float]" ;
343 echo " -norecursion configure this directory only. [recurse]" ;
344 # echo " -objdir=ODIR configure in a parallel tree rooted in ODIR. [rooted in \".\"]" ;
345 echo " -prefix=MYDIR configure for installation of host dependent files into MYDIR. [\"/usr/local\"]" ;
346 echo " -rm remove this configuration. [build a configuration]" ;
347 echo " -site configure with site specific makefile" ;
348 echo " -srcdir=DIR find the sources in DIR. [\".\" or \"..\"]" ;
349 # This is correctly aligned in the output, even though it isn't here.
350 # echo " -subdirs configure in subdirectories. [in source directories]" ;
351 echo " -target=TARGET configure for TARGET. [TARGET = HOST]" ;
352 echo " -tmpdir=TMPDIR create temporary files in TMPDIR. [ TMPDIR = \"/tmp\" ]" ;
354 echo "Where HOST and TARGET are something like \"vax\", \"sun3\", \"encore\", etc." ;
355 # echo "Asking for more than one \"--target\" implies \"--subdirs\". Any other" ;
356 # echo "options given will apply to all targets."
359 if [ -r config.status ] ; then
366 if [ -z "${srcdir}" ] ; then
367 if [ -r configure.in ] ; then
369 elif [ -r ../configure.in ] ; then
372 echo '***' "Can't find configure.in. Try using -srcdir=some_dir"
378 ### break up ${srcdir}/configure.in.
379 if [ -z "`grep '^# per\-host:' ${srcdir}/configure.in`" ] ; then
380 echo '***' ${srcdir}/configure.in has no "per-host:" line. 1>&2
384 if [ -z "`grep '^# per\-target:' ${srcdir}/configure.in`" ] ; then
385 echo '***' ${srcdir}/configure.in has no "per-target:" line. 1>&2
389 if [ -z "${TMPDIR}" ] ; then
390 TMPDIR=/tmp ; export TMPDIR
393 # keep this filename short for &%*%$*# 14 char file names
394 tmpfile=${TMPDIR}/cONf$$
395 trap "rm -f ${tmpfile}.com ${tmpfile}.tgt ${tmpfile}.hst ${tmpfile}.pos" 0
397 # split ${srcdir}/configure.in into common, per-host, per-target,
398 # and post-target parts. Post-target is optional.
399 sed -e '/^# per\-host:/,$d' ${srcdir}/configure.in > ${tmpfile}.com
400 sed -e '1,/^# per\-host:/d' -e '/^# per\-target:/,$d' ${srcdir}/configure.in > ${tmpfile}.hst
401 if grep '^# post-target:' ${srcdir}/configure.in >/dev/null ; then
402 sed -e '1,/^# per\-target:/d' -e '/^# post\-target:/,$d' ${srcdir}/configure.in > ${tmpfile}.tgt
403 sed -e '1,/^# post\-target:/d' ${srcdir}/configure.in > ${tmpfile}.pos
405 sed -e '1,/^# per\-target:/d' ${srcdir}/configure.in > ${tmpfile}.tgt
409 ### do common part of configure.in
413 # some sanity checks on configure.in
414 if [ -z "${srctrigger}" ] ; then
415 echo '***' srctrigger not set in ${PWD}/configure.in.
419 for host in ${hosts} ; do
421 if [ -z "${targets}" -o -n "${defaulttargets}" ] ; then
428 result=`${configsubr} ${host}`
429 host_cpu=`echo $result | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\1/'`
430 host_vendor=`echo $result | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\2/'`
431 host_os=`echo $result | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\3/'`
432 host=${host_cpu}-${host_vendor}-${host_os}
433 host_makefile_frag=config/mh-${host}
434 if [ ! -f ${host_makefile_frag} ]
436 host_makefile_frag=config/mh-${host_alias}
441 for target in ${targets} ; do
443 target_alias=${target}
444 result=`${configsubr} ${target}`
445 target_cpu=`echo $result | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\1/'`
446 target_vendor=`echo $result | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\2/'`
447 target_os=`echo $result | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\3/'`
448 target=${target_cpu}-${target_vendor}-${target_os}
449 target_makefile_frag=config/mt-${target}
450 if [ ! -f ${target_makefile_frag} ]
452 target_makefile_frag=config/mt-${target_alias}
457 if [ "${host_alias}" = "${target_alias}" ] ; then
458 subdirname=H-${host_alias}
460 subdirname=X-${host_alias}-${target_alias}
463 if [ -n "${namesubdir}" ] ; then
464 subdirname=${namesubdir}
467 if [ -n "${removing}" ] ; then
468 # if [ -n "${objdir}" ] ; then
469 # echo '***' --rm not supported for --objdir. Just \"rm -rf ${objdir}\" by hand.
473 # if [ -n "${subdirs}" ] ; then
474 # if [ -d "${subdirname}" ] ; then
475 # rm -rf ${hostsubdir}
477 # echo Warning: no ${PWD}/${hostsubdir} to remove.
480 rm -f ${Makefile} config.status ${links}
483 # if [ -n "${objdir}" ]; then
488 # if [ -n "${subdirs}" ] ; then
489 # # check for existing status before allowing forced subdirs.
490 # if [ -f ${Makefile} ] ; then
491 # echo '***' "${Makefile} already exists in source directory. ${PWD} not configured." 1>&2
495 # # use a subdir common to all targets for this host iff: this is a cross AND
496 # # this tool does not claim to be target dependent AND we have not been asked to name the subdir.
497 # if [ ${host_alias} != ${target_alias} -a -z "${target_dependent}" -a -z "${namesubdiroption}" ]
499 # if [ ! -d H-${host_alias} ] ; then mkdir H-${host_alias} ; fi
501 # if (${symbolic_link} ${subdirname} H-${host_alias} 2> /dev/null) ; then
503 # else # just give up. they lose.
504 # rmdir H-${host_alias}
505 # if [ ! -d ${subdirname} ] ; then mkdir ${subdirname} ; fi
507 # elif [ ! -d ${subdirname} ] ; then
508 # mkdir ${subdirname}
513 # if [ -z "${srcdir}" ] ; then
516 # elif [ "`echo H-*`" != "H-*" -a "`echo X-*`" != "X-*" ] ; then
517 # # if not subdir builds, then make sure none exist.
518 # # We might miss if there are explicitly named subdirs.
519 # echo '***' "Configured subdirs exist. ${PWD} not configured." 1>&2
525 # Find the source files, if location was not specified.
526 if [ -z "${srcdir}" ] ; then
529 if [ ! -r ${srctrigger} ] ; then
534 if [ ! -r ${srcdir}/${srctrigger} ] ; then
535 if [ -z "${srcdirdefaulted}" ] ; then
536 echo '***' "${progname}: Can't find ${srcname} sources in ${PWD}/${srcdir}" 1>&2
538 echo '***' "${progname}: Can't find ${srcname} sources in ${PWD}/. or ${PWD}/.." 1>&2
541 echo '***' \(At least ${srctrigger} is missing.\) 1>&2
545 # Set up the list of links to be made.
546 # ${links} is the list of link names, and ${files} is the list of names to link to.
549 while [ -n "${files}" ] ; do
550 # set file to car of files, files to cdr of files
551 set ${files}; file=$1; shift; files=$*
552 set ${links}; link=$1; shift; links=$*
554 if [ ! -r ${srcdir}/${file} ] ; then
555 echo '***' "${progname}: cannot create a link \"${link}\"," 1>&2
556 echo '***' "since the file \"${file}\" does not exist." 1>&2
562 # Make a symlink if possible, otherwise try a hard link
563 ${symbolic_link} ${srcdir}/${file} ${link} 2>/dev/null || ${hard_link} ${srcdir}/${file} ${link}
565 if [ ! -r ${link} ] ; then
566 echo '***' "${progname}: unable to link \"${link}\" to \"${srcdir}/${file}\"." 1>&2
570 if [ -n "${verbose}" ] ; then
571 echo "Linked \"${link}\" to \"${srcdir}/${file}\"."
575 # Create a .gdbinit file which runs the one in srcdir
576 # and tells GDB to look there for source files.
578 if [ -r ${srcdir}/.gdbinit ] ; then
583 echo "# "${NO_EDIT} > .gdbinit
584 echo "dir ." >> .gdbinit
585 echo "dir ${srcdir}" >> .gdbinit
586 echo "source ${srcdir}/.gdbinit" >> .gdbinit
591 # Install a makefile, and make it set VPATH
592 # if necessary so that the sources are found.
593 # Also change its value of srcdir.
595 # FIXME-someday: This business of always writing to .tem and mv back
596 # is so that I don't screw things up while developing. Once this
597 # template is stable, these should be optimized. xoxorich.
599 # Define macro CROSS_COMPILE in compilation if this is a cross-compiler.
600 if [ "${host}" != "${target}" ] ; then
601 echo "CROSS=-DCROSS_COMPILE" > ${Makefile}
602 echo "ALL=start.encap" >> ${Makefile}
604 echo "ALL=all.internal" > ${Makefile}
607 # set target, host, VPATH
608 echo "host_alias = ${host_alias}" >> ${Makefile}
609 echo "host_cpu = ${host_cpu}" >> ${Makefile}
610 echo "host_vendor = ${host_vendor}" >> ${Makefile}
611 echo "host_os = ${host_os}" >> ${Makefile}
612 echo "version_path = ${version_path}" >> ${Makefile}
613 echo "target_alias = ${target_alias}" >> ${Makefile}
614 echo "target_cpu = ${target_cpu}" >> ${Makefile}
615 echo "target_vendor = ${target_vendor}" >> ${Makefile}
616 echo "target_os = ${target_os}" >> ${Makefile}
618 # if [ -n "${subdirs}" ] ; then
619 # (echo "subdir = /${subdirname}" ;
620 # echo "unsubdir = ..") >> ${Makefile}
623 echo "unsubdir = .") >> ${Makefile}
626 # echo "workdir = ${PWD}" >> ${Makefile}
627 echo "VPATH = ${srcdir}" >> ${Makefile}
629 # add "Makefile.in" (or whatever it's called)
630 cat ${srcdir}/${Makefile_in} >> ${Makefile}
632 # Conditionalize the makefile for this site.
633 if [ -n "${site}" ] ; then
634 site_makefile_frag=config/ms-${site}
636 if [ -f ${srcdir}/${site_makefile_frag} ] ; then
637 (echo "site_makefile_frag = ${srcdir}/${site_makefile_frag}" ;
638 sed -e "/^####/ r ${srcdir}/${site_makefile_frag}" ${Makefile}) > Makefile.tem
640 (echo "site_makefile_frag =" ;
641 cat ${Makefile}) > Makefile.tem
643 mv Makefile.tem ${Makefile}
646 # Conditionalize the makefile for this host.
647 if [ -f ${srcdir}/${host_makefile_frag} ] ; then
648 (echo "host_makefile_frag = ${srcdir}/${host_makefile_frag}" ;
649 sed -e "/^####/ r ${srcdir}/${host_makefile_frag}" ${Makefile}) > Makefile.tem
651 (echo "host_makefile_frag =" ;
652 cat ${Makefile}) > Makefile.tem
654 mv Makefile.tem ${Makefile}
656 # Conditionalize the makefile for this target.
657 if [ -f ${srcdir}/${target_makefile_frag} ] ; then
658 (echo "target_makefile_frag = ${srcdir}/${target_makefile_frag}" ;
659 sed -e "/^####/ r ${srcdir}/${target_makefile_frag}" ${Makefile}) > Makefile.tem
661 (echo "target_makefile_frag =" ;
662 cat ${Makefile}) > Makefile.tem
664 mv Makefile.tem ${Makefile}
667 sed "s@^srcdir = \.@srcdir = ${srcdir}@" ${Makefile} > Makefile.tem
668 mv Makefile.tem ${Makefile}
671 if [ -n "${prefix}" ] ; then
672 sed "s:^prefix =.*$:prefix = ${prefix}:" ${Makefile} > Makefile.tem
673 mv Makefile.tem ${Makefile}
677 if [ -n "${datadir}" ] ; then
678 sed "s:^datadir =.*$:datadir = ${datadir}:" ${Makefile} > Makefile.tem
679 mv Makefile.tem ${Makefile}
683 sed "s:^SUBDIRS =.*$:SUBDIRS = ${configdirs}:" ${Makefile} > Makefile.tem
684 mv Makefile.tem ${Makefile}
687 sed "s:^NONSUBDIRS =.*$:NONSUBDIRS = ${noconfigdirs}:" ${Makefile} > Makefile.tem
688 mv Makefile.tem ${Makefile}
690 # remove any form feeds.
691 sed -e "s/
\f//" ${Makefile} > Makefile.tem
692 mv Makefile.tem ${Makefile}
694 # prepend warning about editting.
695 echo "# "${NO_EDIT} > ${Makefile}.tem
696 cat ${Makefile} >> ${Makefile}.tem
697 mv Makefile.tem ${Makefile}
700 if [ -f ${srcdir}/${host_makefile_frag} ] ; then
701 using="${using} and \"${host_makefile_frag}\""
703 if [ -f ${srcdir}/${target_makefile_frag} ] ; then
704 using="${using} and \"${target_makefile_frag}\""
706 if [ -n "${site}" -a \
707 -f ${srcdir}/${site_makefile_frag} ] ; then
708 using="${using} and \"${site_makefile_frag}\""
710 using=`echo "${using}" | sed 's/and/using/'`
711 using="Created \"${Makefile}\" in ${PWD}${using}."
713 if [ -n "${verbose}" -o -z "${recurring}" ] ; then
719 # describe the chosen configuration in config.status.
720 # Make that file a shellscript which will reestablish
721 # the same configuration. Used in Makefiles to rebuild
724 if [ -z "${norecursion}" ] ; then
725 arguments="${arguments} -norecursion"
730 # ${PWD} was configured as follows:
731 ${progname}" ${arguments} "
732 # ${using}" > config.status
733 chmod a+x config.status
739 # If there are subdirectories, then recur.
740 if [ -z "${norecursion}" -a -n "${configdirs}" ] ; then
741 for configdir in ${configdirs} ; do
742 if [ -n "${verbose}" ] ; then
743 echo Configuring ${configdir}...
746 if [ -d ${srcdir}/${configdir} ] ; then
747 if [ "${srcdir}" != "." ] ; then
748 if [ ! -d ./${configdir} ] ; then
756 ### figure out what to do with srcdir
758 ".") ;; # do nothing. We're building in place.
759 /*) srcdiroption="-srcdir=${srcdir}/${configdir}" ;; # absolute path
760 *) srcdiroption="-srcdir=../${srcdir}/${configdir}" ;; # otherwise relative
763 ### The recursion line is here.
764 if (${progname} -recurring ${host_alias} -target=${target_alias} \
765 ${verbose} ${subdirs} ${removing} ${prefixoption} \
766 ${tmpdiroption} ${namesubdiroption} ${datadiroption} \
767 ${srcdiroption}) ; then
774 elif [ -n "${verbose}" ] ; then
775 echo Warning: source directory \"${srcdir}/${configdir}\" is missing.
779 done # for each target
781 # Now build a Makefile for this host.
782 # if [ -n "${subdirs}" -a ! -n "${removing}" ] ; then
785 # if [ -n "${objdir}" ] ; then
790 # cat > GNUmakefile << 'E!O!F'
791 ## Makefile generated by configure for host ${host_alias}.
793 #ALL := $(shell ls -d T-*)
796 # $(foreach subdir,$(ALL),$(MAKE) -C $(subdir) \$@ &&) true
806 # trap cmd above handles this now:
807 #rm -f ${tmpfile}.com ${tmpfile}.tgt ${tmpfile}.hst ${tmpfile}.pos