4 # Copyright (C) 1988, 1990, 1991, 1992 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. */
22 # Please email any bugs, comments, and/or additions to this file to:
23 # configure@cygnus.com
26 # Shell script to create proper links to machine-dependent files in
27 # preparation for compilation.
29 # If configure succeeds, it leaves its status in config.status.
30 # If configure fails after disturbing the status quo,
31 # config.status is removed.
34 # NOTE: This script contains support for a Cygnus experimental feature, called
35 # +subdirs, which is currently, tentatively, de-supported.
37 export PATH || (echo "OOPS, this isn't sh. Desperation time. I will feed myself to sh."; sh $0 $argv; kill $$)
46 #symbolic_link="echo ln -s"
48 # clear some things potentially inherited from environment.
51 Makefile_in=Makefile.in
59 floating_point=default
89 NO_EDIT="This file was generated automatically by configure. Do not edit."
91 ## this is a little touchy and won't always work, but...
93 ## if the argv[0] starts with a slash then it is an absolute name that can be
96 ## otherwise, if argv[0] has no slash in it, we can assume that it is on the
97 ## path. Since PATH might include "." we also add `pwd` to the end of PATH.
99 ## otherwise we prepend `pwd` to $0 and hope that will give us an absolute
105 if echo $0 | grep '^/' > /dev/null ; then
107 elif echo $0 | grep '/' > /dev/null ; then
111 PATH=$PATH:${PWD} ; export PATH
116 # handle things that might have args following as separate words
117 if [ -n "${next_prefix}" ] ; then prefix=${arg} ; prefixoption="-prefix=${prefix}" ; next_prefix=
118 elif [ -n "${next_datadir}" ] ; then datadir=${arg} ; datadiroption="-datadir=${datadir}" ; next_datadir=
119 # elif [ -n "${next_namesubdir}" ] ; then \
120 # namesubdir=${arg} ; namesubdiroption="--namesubdir=${namesubdir}" ; next_namesubdir=
121 # elif [ -n "${next_objdir}" ] ; then objdir=${arg} ; objdiroption="--objdir=${objdir}" ; next_objdir=
122 elif [ -n "${next_site}" ] ; then site=${arg} ; next_site=
123 elif [ -n "${next_srcdir}" ] ; then srcdir=${arg} ; next_srcdir=
124 elif [ -n "${next_target}" ] ; then
126 if [ -z "${targets}" ] ; then
127 newtargets="${targets} ${arg}"
128 targets="${newtargets}"
130 echo '***' Can only configure for one target at a time.
133 elif [ -n "${next_tmpdir}" ] ; then
135 tmpdiroption="--tmpdir=${arg}"
140 -datadir=* | --datadir=* | --datadi=* | --datad=* | --data=* | --dat=* | --da=* | --d=*)
141 datadir=`echo ${arg} | sed 's/^[-a-z]*=//'`
144 -datadir | --datadir | --datadi | --datad | --data | --dat | --da | --d)
153 -host=* | --host=* | --hos=* | --ho=*)
154 # if [ -n "${hosts}" ] ; then
155 # subdirs="--subdirs"
158 if [ -z "${hosts}" ] ; then
159 newhosts="${hosts} `echo ${arg} | sed 's/^[-a-z]*=//'`"
162 echo '***' Can only configure for one host at a time.
166 # -namesubdir | --namesubdir | --namesubdi | --namesubd | --namesub | --namesu | --names | --name | --nam | --na)
167 # next_namesubdir=yes
169 # -namesubdir=* | --namesubdir=* | --namesubdi=* | --namesubd=* | --namesub=* | --namesu=* | --names=* | --name=* | --nam=* | --na=*)
170 # namesubdir=`echo ${arg} | sed 's/^[-a-z]*=//'`
171 # namesubdiroption=${arg}
176 -norecursion | --no*)
179 # -objdir=* | --objdir=* | --objdi=* | --objd=* | --obj=* | --ob=* | --o=*)
180 # objdiroption=${arg}
181 # objdir=`echo ${arg} | sed 's/^[-a-z]*=//'`
183 # -objdir | --objdir | --objdi | --objd | --obj | --ob | --o)
186 -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*)
187 prefix=`echo ${arg} | sed 's/^[-a-z]*=//'`
190 -prefix | --prefix | --prefi | --pref | --pre | --pr | --p)
193 -recurring | --recurring | --recurrin | --recurri | --recurr | --recur | --recu | --rec | --re)
195 arguments=`echo ${arguments} | sed "s:${arg}::"`
200 -site=* | --site=* | --sit=* | --si=*)
201 site=`echo ${arg} | sed 's/^[-a-z]*=//'`
203 -site | --site | --sit | --si)
206 -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*)
207 srcdir=`echo ${arg} | sed 's/^[-a-z]*=//'`
209 -srcdir | --srcdir | --srcdi | --srcd | --src | --sr)
215 -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=*)
216 # if [ -n "${targets}" ] ; then
217 # subdirs="--subdirs"
220 if [ -z "${targets}" ] ; then
221 newtargets="${targets} `echo ${arg} | sed 's/^[-a-z]*=//'`"
222 targets="${newtargets}"
224 echo '***' Can only configure for one target at a time.
228 -target | --target | --targe | --targ | --tar | --ta)
231 -tmpdir=* | --tmpdir=* | --tmpdi=* | --tmpd=* | --tmp=* | --tm=*)
233 TMPDIR=`echo ${arg} | sed 's/^[-a-z]*=//'`
235 -tmpdir | --tmpdir | --tmpdi | --tmpd | --tmp | --tm)
241 -version | -V | --version | --V)
242 echo "This is Cygnus Configure version" `echo ${version} | sed 's/[ $:]//g'`
248 echo "Unrecognized option: \"${arg}\"". ;
253 # if [ -n "${hosts}" ] ; then
254 # subdirs="--subdirs"
257 if [ -z "${undefs}" ] ; then
258 newundefs="${undefs} ${arg}"
261 echo '***' Can only configure for one host and one target at a time.
269 # process host and target
270 if [ -z "${fatal}" ] ; then
271 # # Complain if an arg is missing
272 # if [ -z "${hosts}" ] ; then
274 # echo "configure: No HOST specified." ;
279 ### This is a bit twisted.
280 ### * if all three are specified, this is an error.
281 ### * if we have neither hosts, nor unadorned args, this is an error.
282 ### * if no hosts are specified, then the unadorned args are hosts, but if
283 ### there were none, this is an error.
284 ### * if no targets are specified, then the unadorned args are targets, but if
285 ### there were no unadorned args, then the hosts are also targets.
287 if [ -n "${hosts}" -a -n "${targets}" -a -n "${undefs}" ] ; then
288 echo '***' Can only configure for one host and one target at a time.
290 elif [ -z "${hosts}" -a -z "${undefs}" ] ; then
291 echo '***' You must tell me for which host you want to configure.
294 if [ -z "${hosts}" ] ; then
298 if [ -z "${targets}" ] ; then
299 if [ -n "${undefs}" ] ; then
308 if [ -n "${fatal}" -o "${hosts}" = "help" ] ; then
309 (echo "Usage: configure HOST" ;
311 echo "Options: [defaults in brackets]" ;
312 echo " -datadir=MYDIR configure for installation of host dependent files into MYDIR. [\"/usr/local\"]" ;
313 echo " -gas configure the compilers for use with gas. [native as]" ;
314 echo " -help print this message. [normal config]" ;
315 echo " -lang=LANG configure to build LANG. [gcc]" ;
316 echo " -nfp configure the compilers default to soft floating point. [hard float]" ;
317 echo " -norecursion configure this directory only. [recurse]" ;
318 # echo " -objdir=ODIR configure in a parallel tree rooted in ODIR. [rooted in \".\"]" ;
319 echo " -prefix=MYDIR configure for installation of host dependent files into MYDIR. [\"/usr/local\"]" ;
320 echo " -rm remove this configuration. [build a configuration]" ;
321 echo " -site configure with site specific makefile" ;
322 echo " -srcdir=DIR find the sources in DIR. [\".\" or \"..\"]" ;
323 # This is correctly aligned in the output, even though it isn't here.
324 # echo " -subdirs configure in subdirectories. [in source directories]" ;
325 echo " -target=TARGET configure for TARGET. [TARGET = HOST]" ;
326 echo " -tmpdir=TMPDIR create temporary files in TMPDIR. [ TMPDIR = \"/tmp\" ]" ;
328 echo "Where HOST and TARGET are something like \"vax\", \"sun3\", \"encore\", etc." ;
329 # echo "Asking for more than one \"--target\" implies \"--subdirs\". Any other" ;
330 # echo "options given will apply to all targets."
333 if [ -r config.status ] ; then
340 configsub=`echo ${progname} | sed 's/configure$/config.sub/'`
342 if ${configsub} `echo ${hosts} | sed -e 's/ .*//'` >/dev/null 2>&1 ; then
345 echo '***' cannot find config.sub.
349 if [ -z "${srcdir}" ] ; then
350 if [ -r configure.in ] ; then
353 echo '***' "Can't find configure.in. Try using -srcdir=some_dir"
359 ### break up ${srcdir}/configure.in.
360 if [ -z "`grep '^# per\-host:' ${srcdir}/configure.in`" ] ; then
361 echo '***' ${srcdir}/configure.in has no "per-host:" line. 1>&2
365 if [ -z "`grep '^# per\-target:' ${srcdir}/configure.in`" ] ; then
366 echo '***' ${srcdir}/configure.in has no "per-target:" line. 1>&2
370 if [ -z "${TMPDIR}" ] ; then
371 TMPDIR=/tmp ; export TMPDIR
374 # keep this filename short for &%*%$*# 14 char file names
375 tmpfile=${TMPDIR}/cONf$$
376 trap "rm -f ${tmpfile}.com ${tmpfile}.tgt ${tmpfile}.hst ${tmpfile}.pos" 0
378 # split ${srcdir}/configure.in into common, per-host, per-target,
379 # and post-target parts. Post-target is optional.
380 sed -e '/^# per\-host:/,$d' ${srcdir}/configure.in > ${tmpfile}.com
381 sed -e '1,/^# per\-host:/d' -e '/^# per\-target:/,$d' ${srcdir}/configure.in > ${tmpfile}.hst
382 if grep '^# post-target:' ${srcdir}/configure.in >/dev/null ; then
383 sed -e '1,/^# per\-target:/d' -e '/^# post\-target:/,$d' ${srcdir}/configure.in > ${tmpfile}.tgt
384 sed -e '1,/^# post\-target:/d' ${srcdir}/configure.in > ${tmpfile}.pos
386 sed -e '1,/^# per\-target:/d' ${srcdir}/configure.in > ${tmpfile}.tgt
390 ### do common part of configure.in
394 # some sanity checks on configure.in
395 if [ -z "${srctrigger}" ] ; then
396 echo '***' srctrigger not set in ${PWD}/configure.in.
400 for host in ${hosts} ; do
402 if [ -z "${targets}" -o -n "${defaulttargets}" ] ; then
409 result=`${configsub} ${host}`
410 host_cpu=`echo $result | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\1/'`
411 host_vendor=`echo $result | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\2/'`
412 host_os=`echo $result | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\3/'`
413 host=${host_cpu}-${host_vendor}-${host_os}
414 host_makefile_frag=config/mh-${host}
415 if [ ! -f ${host_makefile_frag} ]
417 host_makefile_frag=config/mh-${host_alias}
422 for target in ${targets} ; do
424 target_alias=${target}
425 result=`${configsub} ${target}`
426 target_cpu=`echo $result | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\1/'`
427 target_vendor=`echo $result | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\2/'`
428 target_os=`echo $result | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\3/'`
429 target=${target_cpu}-${target_vendor}-${target_os}
430 target_makefile_frag=config/mt-${target}
431 if [ ! -f ${target_makefile_frag} ]
433 target_makefile_frag=config/mt-${target_alias}
438 if [ "${host_alias}" = "${target_alias}" ] ; then
439 subdirname=H-${host_alias}
441 subdirname=X-${host_alias}-${target_alias}
444 if [ -n "${namesubdir}" ] ; then
445 subdirname=${namesubdir}
448 if [ -n "${removing}" ] ; then
449 # if [ -n "${objdir}" ] ; then
450 # echo '***' --rm not supported for --objdir. Just \"rm -rf ${objdir}\" by hand.
454 # if [ -n "${subdirs}" ] ; then
455 # if [ -d "${subdirname}" ] ; then
456 # rm -rf ${hostsubdir}
458 # echo Warning: no ${PWD}/${hostsubdir} to remove.
461 rm -f ${Makefile} config.status ${links}
464 # if [ -n "${objdir}" ]; then
469 # if [ -n "${subdirs}" ] ; then
470 # # check for existing status before allowing forced subdirs.
471 # if [ -f ${Makefile} ] ; then
472 # echo '***' "${Makefile} already exists in source directory. ${PWD} not configured." 1>&2
476 # # use a subdir common to all targets for this host iff: this is a cross AND
477 # # this tool does not claim to be target dependent AND we have not been asked to name the subdir.
478 # if [ ${host_alias} != ${target_alias} -a -z "${target_dependent}" -a -z "${namesubdiroption}" ]
480 # if [ ! -d H-${host_alias} ] ; then mkdir H-${host_alias} ; fi
482 # if ${symbolic_link} ${subdirname} H-${host_alias} 2> /dev/null ; then
484 # else # just give up. they lose.
485 # rmdir H-${host_alias}
486 # if [ ! -d ${subdirname} ] ; then mkdir ${subdirname} ; fi
488 # elif [ ! -d ${subdirname} ] ; then
489 # mkdir ${subdirname}
494 # if [ -z "${srcdir}" ] ; then
497 # elif [ "`echo H-*`" != "H-*" -a "`echo X-*`" != "X-*" ] ; then
498 # # if not subdir builds, then make sure none exist.
499 # # We might miss if there are explicitly named subdirs.
500 # echo '***' "Configured subdirs exist. ${PWD} not configured." 1>&2
506 # Find the source files, if location was not specified.
507 if [ -z "${srcdir}" ] ; then
510 if [ ! -r ${srctrigger} ] ; then
515 if [ ! -r ${srcdir}/${srctrigger} ] ; then
516 if [ -z "${srcdirdefaulted}" ] ; then
517 echo '***' "${progname}: Can't find ${srcname} sources in ${PWD}/${srcdir}" 1>&2
519 echo '***' "${progname}: Can't find ${srcname} sources in ${PWD}/. or ${PWD}/.." 1>&2
522 echo '***' \(At least ${srctrigger} is missing.\) 1>&2
526 # Set up the list of links to be made.
527 # ${links} is the list of link names, and ${files} is the list of names to link to.
530 while [ -n "${files}" ] ; do
531 # set file to car of files, files to cdr of files
532 set ${files}; file=$1; shift; files=$*
533 set ${links}; link=$1; shift; links=$*
535 if [ ! -r ${srcdir}/${file} ] ; then
536 echo '***' "${progname}: cannot create a link \"${link}\"," 1>&2
537 echo '***' "since the file \"${file}\" does not exist." 1>&2
543 # Make a symlink if possible, otherwise try a hard link
544 ${symbolic_link} ${srcdir}/${file} ${link} 2>/dev/null || ${hard_link} ${srcdir}/${file} ${link}
546 if [ ! -r ${link} ] ; then
547 echo '***' "${progname}: unable to link \"${link}\" to \"${srcdir}/${file}\"." 1>&2
551 if [ -n "${verbose}" ] ; then
552 echo "Linked \"${link}\" to \"${srcdir}/${file}\"."
556 # Create a .gdbinit file which runs the one in srcdir
557 # and tells GDB to look there for source files.
559 if [ -r ${srcdir}/.gdbinit ] ; then
564 echo "# "${NO_EDIT} > .gdbinit
565 echo "dir ." >> .gdbinit
566 echo "dir ${srcdir}" >> .gdbinit
567 echo "source ${srcdir}/.gdbinit" >> .gdbinit
572 # Install a makefile, and make it set VPATH
573 # if necessary so that the sources are found.
574 # Also change its value of srcdir.
576 # FIXME-someday: This business of always writing to .tem and mv back
577 # is so that I don't screw things up while developing. Once this
578 # template is stable, these should be optimized. xoxorich.
580 # Define macro CROSS_COMPILE in compilation if this is a cross-compiler.
581 if [ "${host}" != "${target}" ] ; then
582 echo "CROSS=-DCROSS_COMPILE" > ${Makefile}
583 echo "ALL=all.cross" >> ${Makefile}
585 echo "ALL=all.internal" > ${Makefile}
588 # set target, host, VPATH
589 echo "host_alias = ${host_alias}" >> ${Makefile}
590 echo "host_cpu = ${host_cpu}" >> ${Makefile}
591 echo "host_vendor = ${host_vendor}" >> ${Makefile}
592 echo "host_os = ${host_os}" >> ${Makefile}
594 echo "target_alias = ${target_alias}" >> ${Makefile}
595 echo "target_cpu = ${target_cpu}" >> ${Makefile}
596 echo "target_vendor = ${target_vendor}" >> ${Makefile}
597 echo "target_os = ${target_os}" >> ${Makefile}
599 # if [ -n "${subdirs}" ] ; then
600 # echo "subdir = /${subdirname}" >> ${Makefile}
601 # echo "unsubdir = .." >> ${Makefile}
603 echo "subdir =" >> ${Makefile}
604 echo "unsubdir = ." >> ${Makefile}
607 # echo "workdir = ${PWD}" >> ${Makefile}
608 echo "VPATH = ${srcdir}" >> ${Makefile}
610 # add "Makefile.in" (or whatever it's called)
611 cat ${srcdir}/${Makefile_in} >> ${Makefile}
613 # Conditionalize the makefile for this site.
614 if [ -n "${site}" ] ; then
615 site_makefile_frag=config/ms-${site}
617 if [ -f ${srcdir}/${site_makefile_frag} ] ; then
618 echo "site_makefile_frag = ${srcdir}/${site_makefile_frag}" > Makefile.tem
619 sed -e "/^####/ r ${srcdir}/${site_makefile_frag}" ${Makefile} >> Makefile.tem
621 echo "site_makefile_frag =" > Makefile.tem
622 cat ${Makefile} >> Makefile.tem
624 mv Makefile.tem ${Makefile}
627 # Conditionalize the makefile for this host.
628 if [ -f ${srcdir}/${host_makefile_frag} ] ; then
629 echo "host_makefile_frag = ${srcdir}/${host_makefile_frag}" > Makefile.tem
630 sed -e "/^####/ r ${srcdir}/${host_makefile_frag}" ${Makefile} >> Makefile.tem
632 echo "host_makefile_frag =" > Makefile.tem
633 cat ${Makefile} >> Makefile.tem
635 mv Makefile.tem ${Makefile}
637 # Conditionalize the makefile for this target.
638 if [ -f ${srcdir}/${target_makefile_frag} ] ; then
639 echo "target_makefile_frag = ${srcdir}/${target_makefile_frag}" > Makefile.tem
640 sed -e "/^####/ r ${srcdir}/${target_makefile_frag}" ${Makefile} >> Makefile.tem
642 echo "target_makefile_frag =" > Makefile.tem
643 cat ${Makefile} >> Makefile.tem
645 mv Makefile.tem ${Makefile}
648 sed "s:^srcdir[ ]*=.*$:srcdir = ${srcdir}:" ${Makefile} > Makefile.tem
649 mv Makefile.tem ${Makefile}
652 if [ -n "${prefix}" ] ; then
653 sed "s:^prefix[ ]*=.*$:prefix = ${prefix}:" ${Makefile} > Makefile.tem
654 mv Makefile.tem ${Makefile}
658 if [ -n "${datadir}" ] ; then
659 sed "s:^datadir[ ]*=.*$:datadir = ${datadir}:" ${Makefile} > Makefile.tem
660 mv Makefile.tem ${Makefile}
664 sed "s:^SUBDIRS[ ]*=.*$:SUBDIRS = ${configdirs}:" ${Makefile} > Makefile.tem
665 mv Makefile.tem ${Makefile}
668 sed "s:^NONSUBDIRS[ ]*=.*$:NONSUBDIRS = ${noconfigdirs}:" ${Makefile} > Makefile.tem
669 mv Makefile.tem ${Makefile}
671 # remove any form feeds.
672 sed -e "s/
\f//" ${Makefile} > Makefile.tem
673 mv Makefile.tem ${Makefile}
675 # prepend warning about editting.
676 echo "# "${NO_EDIT} > ${Makefile}.tem
677 cat ${Makefile} >> ${Makefile}.tem
678 mv Makefile.tem ${Makefile}
681 if [ -f ${srcdir}/${host_makefile_frag} ] ; then
682 using="${using} and \"${host_makefile_frag}\""
684 if [ -f ${srcdir}/${target_makefile_frag} ] ; then
685 using="${using} and \"${target_makefile_frag}\""
687 if [ -n "${site}" -a \
688 -f ${srcdir}/${site_makefile_frag} ] ; then
689 using="${using} and \"${site_makefile_frag}\""
691 using=`echo "${using}" | sed 's/and/using/'`
692 using="Created \"${Makefile}\" in ${PWD}${using}."
694 if [ -n "${verbose}" -o -z "${recurring}" ] ; then
700 # describe the chosen configuration in config.status.
701 # Make that file a shellscript which will reestablish
702 # the same configuration. Used in Makefiles to rebuild
705 if [ -z "${norecursion}" ] ; then
706 arguments="${arguments} -norecursion"
711 # ${PWD} was configured as follows:
712 ${progname}" ${arguments} "
713 # ${using}" > config.status
714 chmod a+x config.status
720 # If there are subdirectories, then recur.
721 if [ -z "${norecursion}" -a -n "${configdirs}" ] ; then
722 for configdir in ${configdirs} ; do
723 if [ -n "${verbose}" ] ; then
724 echo Configuring ${configdir}...
727 if [ -d ${srcdir}/${configdir} ] ; then
728 if [ "${srcdir}" != "." ] ; then
729 if [ ! -d ./${configdir} ] ; then
737 ### figure out what to do with srcdir
739 ".") ;; # do nothing. We're building in place.
740 /*) srcdiroption="-srcdir=${srcdir}/${configdir}" ;; # absolute path
741 *) srcdiroption="-srcdir=../${srcdir}/${configdir}" ;; # otherwise relative
744 ### The recursion line is here.
745 if [ -f configure ] ; then
746 recprog=`pwd`/configure
751 if ${recprog} -recurring ${host_alias} -target=${target_alias} \
752 ${verbose} ${subdirs} ${removing} ${prefixoption} \
753 ${tmpdiroption} ${namesubdiroption} ${datadiroption} \
754 ${srcdiroption} ; then
761 elif [ -n "${verbose}" ] ; then
762 echo Warning: source directory \"${srcdir}/${configdir}\" is missing.
766 done # for each target
768 # Now build a Makefile for this host.
769 # if [ -n "${subdirs}" -a ! -n "${removing}" ] ; then
772 # if [ -n "${objdir}" ] ; then
777 # cat > GNUmakefile << 'E!O!F'
778 ## Makefile generated by configure for host ${host_alias}.
780 #ALL := $(shell ls -d T-*)
783 # $(foreach subdir,$(ALL),$(MAKE) -C $(subdir) \$@ &&) true
793 # trap cmd above handles this now:
794 #rm -f ${tmpfile}.com ${tmpfile}.tgt ${tmpfile}.hst ${tmpfile}.pos