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
61 floating_point=default
90 # or maybe grab from gcc/version.c
94 NO_EDIT="This file was generated automatically by configure. Do not edit."
96 ## this is a little touchy and won't always work, but...
98 ## if the argv[0] starts with a slash then it is an absolute name that can be
101 ## otherwise, if argv[0] has no slash in it, we can assume that it is on the
102 ## path. Since PATH might include "." we also add `pwd` to the end of PATH.
104 ## otherwise we prepend `pwd` to $0 and hope that will give us an absolute
110 if (echo $0 | grep '^/' > /dev/null) ; then
112 elif (echo $0 | grep '/' > /dev/null) ; then
116 PATH=$PATH:${PWD} ; export PATH
121 # handle things that might have args following as separate words
122 if [ -n "${next_prefix}" ] ; then prefix=${arg} ; prefixoption="-prefix=${prefix}" ; next_prefix=
123 elif [ -n "${next_datadir}" ] ; then datadir=${arg} ; datadiroption="-datadir=${datadir}" ; next_datadir=
124 # elif [ -n "${next_namesubdir}" ] ; then \
125 # namesubdir=${arg} ; namesubdiroption="--namesubdir=${namesubdir}" ; next_namesubdir=
126 # elif [ -n "${next_objdir}" ] ; then objdir=${arg} ; objdiroption="--objdir=${objdir}" ; next_objdir=
127 elif [ -n "${next_version_path}" ] ; then version_path=${arg} ; next_version_path=
128 elif [ -n "${next_site}" ] ; then site=${arg} ; next_site=
129 elif [ -n "${next_srcdir}" ] ; then srcdir=${arg} ; next_srcdir=
130 elif [ -n "${next_target}" ] ; then
132 if [ -z "${targets}" ] ; then
133 newtargets="${targets} ${arg}"
134 targets="${newtargets}"
136 echo '***' Can only configure for one target at a time.
139 elif [ -n "${next_tmpdir}" ] ; then
141 tmpdiroption="--tmpdir=${arg}"
146 -datadir=* | --datadir=* | --datadi=* | --datad=* | --data=* | --dat=* | --da=* | --d=*)
147 datadir=`echo ${arg} | sed 's/^[-a-z]*=//'`
150 -datadir | --datadir | --datadi | --datad | --data | --dat | --da | --d)
159 -host=* | --host=* | --hos=* | --ho=*)
160 # if [ -n "${hosts}" ] ; then
161 # subdirs="--subdirs"
164 if [ -z "${hosts}" ] ; then
165 newhosts="${hosts} `echo ${arg} | sed 's/^[-a-z]*=//'`"
168 echo '***' Can only configure for one host at a time.
172 # -namesubdir | --namesubdir | --namesubdi | --namesubd | --namesub | --namesu | --names | --name | --nam | --na)
173 # next_namesubdir=yes
175 # -namesubdir=* | --namesubdir=* | --namesubdi=* | --namesubd=* | --namesub=* | --namesu=* | --names=* | --name=* | --nam=* | --na=*)
176 # namesubdir=`echo ${arg} | sed 's/^[-a-z]*=//'`
177 # namesubdiroption=${arg}
182 -norecursion | --no*)
185 # -objdir=* | --objdir=* | --objdi=* | --objd=* | --obj=* | --ob=* | --o=*)
186 # objdiroption=${arg}
187 # objdir=`echo ${arg} | sed 's/^[-a-z]*=//'`
189 # -objdir | --objdir | --objdi | --objd | --obj | --ob | --o)
192 -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*)
193 prefix=`echo ${arg} | sed 's/^[-a-z]*=//'`
196 -prefix | --prefix | --prefi | --pref | --pre | --pr | --p)
199 -recurring | --recurring | --recurrin | --recurri | --recurr | --recur | --recu | --rec | --re)
201 arguments=`echo ${arguments} | sed "s:${arg}::"`
206 -site=* | --site=* | --sit=* | --si=*)
207 site=`echo ${arg} | sed 's/^[-a-z]*=//'`
209 -site | --site | --sit | --si)
212 -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*)
213 srcdir=`echo ${arg} | sed 's/^[-a-z]*=//'`
215 -srcdir | --srcdir | --srcdi | --srcd | --src | --sr)
221 -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=*)
222 # if [ -n "${targets}" ] ; then
223 # subdirs="--subdirs"
226 if [ -z "${targets}" ] ; then
227 newtargets="${targets} `echo ${arg} | sed 's/^[-a-z]*=//'`"
228 targets="${newtargets}"
230 echo '***' Can only configure for one target at a time.
234 -target | --target | --targe | --targ | --tar | --ta)
237 -tmpdir=* | --tmpdir=* | --tmpdi=* | --tmpd=* | --tmp=* | --tm=*)
239 TMPDIR=`echo ${arg} | sed 's/^[-a-z]*=//'`
241 -tmpdir | --tmpdir | --tmpdi | --tmpd | --tmp | --tm)
250 echo "Unrecognized option: \"${arg}\"". ;
255 # if [ -n "${hosts}" ] ; then
256 # subdirs="--subdirs"
259 if [ -z "${undefs}" ] ; then
260 newundefs="${undefs} ${arg}"
263 echo '***' Can only configure for one host and one target at a time.
271 if [ -n "${verbose}" ] ; then
275 # process host and target
276 if [ -z "${fatal}" ] ; then
277 # # Complain if an arg is missing
278 # if [ -z "${hosts}" ] ; then
280 # echo "configure: No HOST specified." ;
285 ### This is a bit twisted.
286 ### * if all three are specified, this is an error.
287 ### * if we have neither hosts, nor unadorned args, this is an error.
288 ### * if no hosts are specified, then the unadorned args are hosts, but if
289 ### there were none, this is an error.
290 ### * if no targets are specified, then the unadorned args are targets, but if
291 ### there were no unadorned args, then the hosts are also targets.
293 if [ -n "${hosts}" -a -n "${targets}" -a -n "${undefs}" ] ; then
294 echo '***' Can only configure for one host and one target at a time.
296 elif [ -z "${hosts}" -a -z "${undefs}" ] ; then
297 echo '***' You must tell me for which host you want to configure.
300 if [ -z "${hosts}" ] ; then
304 if [ -z "${targets}" ] ; then
305 if [ -n "${undefs}" ] ; then
314 if [ -n "${fatal}" -o "${hosts}" = "help" ] ; then
315 (echo "Usage: configure HOST" ;
317 echo "Options: [defaults in brackets]" ;
318 echo " -datadir=MYDIR configure for installation of host dependent files into MYDIR. [\"/usr/local\"]" ;
319 echo " -gas configure the compilers for use with gas. [native as]" ;
320 echo " -help print this message. [normal config]" ;
321 echo " -lang=LANG configure to build LANG. [gcc]" ;
322 echo " -nfp configure the compilers default to soft floating point. [hard float]" ;
323 echo " -norecursion configure this directory only. [recurse]" ;
324 # echo " -objdir=ODIR configure in a parallel tree rooted in ODIR. [rooted in \".\"]" ;
325 echo " -prefix=MYDIR configure for installation of host dependent files into MYDIR. [\"/usr/local\"]" ;
326 echo " -rm remove this configuration. [build a configuration]" ;
327 echo " -site configure with site specific makefile" ;
328 echo " -srcdir=DIR find the sources in DIR. [\".\" or \"..\"]" ;
329 # This is correctly aligned in the output, even though it isn't here.
330 # echo " -subdirs configure in subdirectories. [in source directories]" ;
331 echo " -target=TARGET configure for TARGET. [TARGET = HOST]" ;
332 echo " -tmpdir=TMPDIR create temporary files in TMPDIR. [ TMPDIR = \"/tmp\" ]" ;
334 echo "Where HOST and TARGET are something like \"vax\", \"sun3\", \"encore\", etc." ;
335 # echo "Asking for more than one \"--target\" implies \"--subdirs\". Any other" ;
336 # echo "options given will apply to all targets."
339 if [ -r config.status ] ; then
346 configsubr=`echo ${progname} | sed 's/configure$/config.subr/'`
348 if (${configsubr} `echo ${hosts} | sed -e 's/ .*//'`) >/dev/null 2>&1 ; then
351 echo '***' cannot find config.subr.
355 if [ -z "${srcdir}" ] ; then
356 if [ -r configure.in ] ; then
358 elif [ -r ../configure.in ] ; then
361 echo '***' "Can't find configure.in. Try using -srcdir=some_dir"
367 ### break up ${srcdir}/configure.in.
368 if [ -z "`grep '^# per\-host:' ${srcdir}/configure.in`" ] ; then
369 echo '***' ${srcdir}/configure.in has no "per-host:" line. 1>&2
373 if [ -z "`grep '^# per\-target:' ${srcdir}/configure.in`" ] ; then
374 echo '***' ${srcdir}/configure.in has no "per-target:" line. 1>&2
378 if [ -z "${TMPDIR}" ] ; then
379 TMPDIR=/tmp ; export TMPDIR
382 # keep this filename short for &%*%$*# 14 char file names
383 tmpfile=${TMPDIR}/cONf$$
384 trap "rm -f ${tmpfile}.com ${tmpfile}.tgt ${tmpfile}.hst ${tmpfile}.pos" 0
386 # split ${srcdir}/configure.in into common, per-host, per-target,
387 # and post-target parts. Post-target is optional.
388 sed -e '/^# per\-host:/,$d' ${srcdir}/configure.in > ${tmpfile}.com
389 sed -e '1,/^# per\-host:/d' -e '/^# per\-target:/,$d' ${srcdir}/configure.in > ${tmpfile}.hst
390 if grep '^# post-target:' ${srcdir}/configure.in >/dev/null ; then
391 sed -e '1,/^# per\-target:/d' -e '/^# post\-target:/,$d' ${srcdir}/configure.in > ${tmpfile}.tgt
392 sed -e '1,/^# post\-target:/d' ${srcdir}/configure.in > ${tmpfile}.pos
394 sed -e '1,/^# per\-target:/d' ${srcdir}/configure.in > ${tmpfile}.tgt
398 ### do common part of configure.in
402 # some sanity checks on configure.in
403 if [ -z "${srctrigger}" ] ; then
404 echo '***' srctrigger not set in ${PWD}/configure.in.
408 for host in ${hosts} ; do
410 if [ -z "${targets}" -o -n "${defaulttargets}" ] ; then
417 result=`${configsubr} ${host}`
418 host_cpu=`echo $result | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\1/'`
419 host_vendor=`echo $result | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\2/'`
420 host_os=`echo $result | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\3/'`
421 host=${host_cpu}-${host_vendor}-${host_os}
422 host_makefile_frag=config/mh-${host}
423 if [ ! -f ${host_makefile_frag} ]
425 host_makefile_frag=config/mh-${host_alias}
430 for target in ${targets} ; do
432 target_alias=${target}
433 result=`${configsubr} ${target}`
434 target_cpu=`echo $result | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\1/'`
435 target_vendor=`echo $result | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\2/'`
436 target_os=`echo $result | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\3/'`
437 target=${target_cpu}-${target_vendor}-${target_os}
438 target_makefile_frag=config/mt-${target}
439 if [ ! -f ${target_makefile_frag} ]
441 target_makefile_frag=config/mt-${target_alias}
446 if [ "${host_alias}" = "${target_alias}" ] ; then
447 subdirname=H-${host_alias}
449 subdirname=X-${host_alias}-${target_alias}
452 if [ -n "${namesubdir}" ] ; then
453 subdirname=${namesubdir}
456 if [ -n "${removing}" ] ; then
457 # if [ -n "${objdir}" ] ; then
458 # echo '***' --rm not supported for --objdir. Just \"rm -rf ${objdir}\" by hand.
462 # if [ -n "${subdirs}" ] ; then
463 # if [ -d "${subdirname}" ] ; then
464 # rm -rf ${hostsubdir}
466 # echo Warning: no ${PWD}/${hostsubdir} to remove.
469 rm -f ${Makefile} config.status ${links}
472 # if [ -n "${objdir}" ]; then
477 # if [ -n "${subdirs}" ] ; then
478 # # check for existing status before allowing forced subdirs.
479 # if [ -f ${Makefile} ] ; then
480 # echo '***' "${Makefile} already exists in source directory. ${PWD} not configured." 1>&2
484 # # use a subdir common to all targets for this host iff: this is a cross AND
485 # # this tool does not claim to be target dependent AND we have not been asked to name the subdir.
486 # if [ ${host_alias} != ${target_alias} -a -z "${target_dependent}" -a -z "${namesubdiroption}" ]
488 # if [ ! -d H-${host_alias} ] ; then mkdir H-${host_alias} ; fi
490 # if (${symbolic_link} ${subdirname} H-${host_alias} 2> /dev/null) ; then
492 # else # just give up. they lose.
493 # rmdir H-${host_alias}
494 # if [ ! -d ${subdirname} ] ; then mkdir ${subdirname} ; fi
496 # elif [ ! -d ${subdirname} ] ; then
497 # mkdir ${subdirname}
502 # if [ -z "${srcdir}" ] ; then
505 # elif [ "`echo H-*`" != "H-*" -a "`echo X-*`" != "X-*" ] ; then
506 # # if not subdir builds, then make sure none exist.
507 # # We might miss if there are explicitly named subdirs.
508 # echo '***' "Configured subdirs exist. ${PWD} not configured." 1>&2
514 # Find the source files, if location was not specified.
515 if [ -z "${srcdir}" ] ; then
518 if [ ! -r ${srctrigger} ] ; then
523 if [ ! -r ${srcdir}/${srctrigger} ] ; then
524 if [ -z "${srcdirdefaulted}" ] ; then
525 echo '***' "${progname}: Can't find ${srcname} sources in ${PWD}/${srcdir}" 1>&2
527 echo '***' "${progname}: Can't find ${srcname} sources in ${PWD}/. or ${PWD}/.." 1>&2
530 echo '***' \(At least ${srctrigger} is missing.\) 1>&2
534 # Set up the list of links to be made.
535 # ${links} is the list of link names, and ${files} is the list of names to link to.
538 while [ -n "${files}" ] ; do
539 # set file to car of files, files to cdr of files
540 set ${files}; file=$1; shift; files=$*
541 set ${links}; link=$1; shift; links=$*
543 if [ ! -r ${srcdir}/${file} ] ; then
544 echo '***' "${progname}: cannot create a link \"${link}\"," 1>&2
545 echo '***' "since the file \"${file}\" does not exist." 1>&2
551 # Make a symlink if possible, otherwise try a hard link
552 ${symbolic_link} ${srcdir}/${file} ${link} 2>/dev/null || ${hard_link} ${srcdir}/${file} ${link}
554 if [ ! -r ${link} ] ; then
555 echo '***' "${progname}: unable to link \"${link}\" to \"${srcdir}/${file}\"." 1>&2
559 if [ -n "${verbose}" ] ; then
560 echo "Linked \"${link}\" to \"${srcdir}/${file}\"."
564 # Create a .gdbinit file which runs the one in srcdir
565 # and tells GDB to look there for source files.
567 if [ -r ${srcdir}/.gdbinit ] ; then
572 echo "# "${NO_EDIT} > .gdbinit
573 echo "dir ." >> .gdbinit
574 echo "dir ${srcdir}" >> .gdbinit
575 echo "source ${srcdir}/.gdbinit" >> .gdbinit
580 # Install a makefile, and make it set VPATH
581 # if necessary so that the sources are found.
582 # Also change its value of srcdir.
584 # FIXME-someday: This business of always writing to .tem and mv back
585 # is so that I don't screw things up while developing. Once this
586 # template is stable, these should be optimized. xoxorich.
588 # Define macro CROSS_COMPILE in compilation if this is a cross-compiler.
589 if [ "${host}" != "${target}" ] ; then
590 echo "CROSS=-DCROSS_COMPILE" > ${Makefile}
591 echo "ALL=start.encap" >> ${Makefile}
593 echo "ALL=all.internal" > ${Makefile}
596 # set target, host, VPATH
597 echo "host_alias = ${host_alias}" >> ${Makefile}
598 echo "host_cpu = ${host_cpu}" >> ${Makefile}
599 echo "host_vendor = ${host_vendor}" >> ${Makefile}
600 echo "host_os = ${host_os}" >> ${Makefile}
601 echo "version_path = ${version_path}" >> ${Makefile}
602 echo "target_alias = ${target_alias}" >> ${Makefile}
603 echo "target_cpu = ${target_cpu}" >> ${Makefile}
604 echo "target_vendor = ${target_vendor}" >> ${Makefile}
605 echo "target_os = ${target_os}" >> ${Makefile}
607 # if [ -n "${subdirs}" ] ; then
608 # (echo "subdir = /${subdirname}" ;
609 # echo "unsubdir = ..") >> ${Makefile}
612 echo "unsubdir = .") >> ${Makefile}
615 # echo "workdir = ${PWD}" >> ${Makefile}
616 echo "VPATH = ${srcdir}" >> ${Makefile}
618 # add "Makefile.in" (or whatever it's called)
619 cat ${srcdir}/${Makefile_in} >> ${Makefile}
621 # Conditionalize the makefile for this site.
622 if [ -n "${site}" ] ; then
623 site_makefile_frag=config/ms-${site}
625 if [ -f ${srcdir}/${site_makefile_frag} ] ; then
626 (echo "site_makefile_frag = ${srcdir}/${site_makefile_frag}" ;
627 sed -e "/^####/ r ${srcdir}/${site_makefile_frag}" ${Makefile}) > Makefile.tem
629 (echo "site_makefile_frag =" ;
630 cat ${Makefile}) > Makefile.tem
632 mv Makefile.tem ${Makefile}
635 # Conditionalize the makefile for this host.
636 if [ -f ${srcdir}/${host_makefile_frag} ] ; then
637 (echo "host_makefile_frag = ${srcdir}/${host_makefile_frag}" ;
638 sed -e "/^####/ r ${srcdir}/${host_makefile_frag}" ${Makefile}) > Makefile.tem
640 (echo "host_makefile_frag =" ;
641 cat ${Makefile}) > Makefile.tem
643 mv Makefile.tem ${Makefile}
645 # Conditionalize the makefile for this target.
646 if [ -f ${srcdir}/${target_makefile_frag} ] ; then
647 (echo "target_makefile_frag = ${srcdir}/${target_makefile_frag}" ;
648 sed -e "/^####/ r ${srcdir}/${target_makefile_frag}" ${Makefile}) > Makefile.tem
650 (echo "target_makefile_frag =" ;
651 cat ${Makefile}) > Makefile.tem
653 mv Makefile.tem ${Makefile}
656 sed "s@^srcdir = \.@srcdir = ${srcdir}@" ${Makefile} > Makefile.tem
657 mv Makefile.tem ${Makefile}
660 if [ -n "${prefix}" ] ; then
661 sed "s:^prefix =.*$:prefix = ${prefix}:" ${Makefile} > Makefile.tem
662 mv Makefile.tem ${Makefile}
666 if [ -n "${datadir}" ] ; then
667 sed "s:^datadir =.*$:datadir = ${datadir}:" ${Makefile} > Makefile.tem
668 mv Makefile.tem ${Makefile}
672 sed "s:^SUBDIRS =.*$:SUBDIRS = ${configdirs}:" ${Makefile} > Makefile.tem
673 mv Makefile.tem ${Makefile}
676 sed "s:^NONSUBDIRS =.*$:NONSUBDIRS = ${noconfigdirs}:" ${Makefile} > Makefile.tem
677 mv Makefile.tem ${Makefile}
679 # remove any form feeds.
680 sed -e "s/
\f//" ${Makefile} > Makefile.tem
681 mv Makefile.tem ${Makefile}
683 # prepend warning about editting.
684 echo "# "${NO_EDIT} > ${Makefile}.tem
685 cat ${Makefile} >> ${Makefile}.tem
686 mv Makefile.tem ${Makefile}
689 if [ -f ${srcdir}/${host_makefile_frag} ] ; then
690 using="${using} and \"${host_makefile_frag}\""
692 if [ -f ${srcdir}/${target_makefile_frag} ] ; then
693 using="${using} and \"${target_makefile_frag}\""
695 if [ -n "${site}" -a \
696 -f ${srcdir}/${site_makefile_frag} ] ; then
697 using="${using} and \"${site_makefile_frag}\""
699 using=`echo "${using}" | sed 's/and/using/'`
700 using="Created \"${Makefile}\" in ${PWD}${using}."
702 if [ -n "${verbose}" -o -z "${recurring}" ] ; then
708 # describe the chosen configuration in config.status.
709 # Make that file a shellscript which will reestablish
710 # the same configuration. Used in Makefiles to rebuild
713 if [ -z "${norecursion}" ] ; then
714 arguments="${arguments} -norecursion"
719 # ${PWD} was configured as follows:
720 ${progname}" ${arguments} "
721 # ${using}" > config.status
722 chmod a+x config.status
728 # If there are subdirectories, then recur.
729 if [ -z "${norecursion}" -a -n "${configdirs}" ] ; then
730 for configdir in ${configdirs} ; do
731 if [ -n "${verbose}" ] ; then
732 echo Configuring ${configdir}...
735 if [ -d ${srcdir}/${configdir} ] ; then
736 if [ "${srcdir}" != "." ] ; then
737 if [ ! -d ./${configdir} ] ; then
745 ### figure out what to do with srcdir
747 ".") ;; # do nothing. We're building in place.
748 /*) srcdiroption="-srcdir=${srcdir}/${configdir}" ;; # absolute path
749 *) srcdiroption="-srcdir=../${srcdir}/${configdir}" ;; # otherwise relative
752 ### The recursion line is here.
753 if (${progname} -recurring ${host_alias} -target=${target_alias} \
754 ${verbose} ${subdirs} ${removing} ${prefixoption} \
755 ${tmpdiroption} ${namesubdiroption} ${datadiroption} \
756 ${srcdiroption}) ; then
763 elif [ -n "${verbose}" ] ; then
764 echo Warning: source directory \"${srcdir}/${configdir}\" is missing.
768 done # for each target
770 # Now build a Makefile for this host.
771 # if [ -n "${subdirs}" -a ! -n "${removing}" ] ; then
774 # if [ -n "${objdir}" ] ; then
779 # cat > GNUmakefile << 'E!O!F'
780 ## Makefile generated by configure for host ${host_alias}.
782 #ALL := $(shell ls -d T-*)
785 # $(foreach subdir,$(ALL),$(MAKE) -C $(subdir) \$@ &&) true
795 # trap cmd above handles this now:
796 #rm -f ${tmpfile}.com ${tmpfile}.tgt ${tmpfile}.hst ${tmpfile}.pos