4 # Copyright (C) 1988, 1990, 1991, 1992 Free Software Foundation, Inc.
6 # This program is free software; you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; either version 2 of the License, or
9 # (at your option) any later version.
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License
17 # along with this program; if not, write to the Free Software
18 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
20 # Please email any bugs, comments, and/or additions to this file to:
21 # configure@cygnus.com
23 # This file was written by K. Richard Pixley.
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 export PATH || (echo "OOPS, this isn't sh. Desperation time. I will feed myself to sh."; sh $0 $argv; kill $$)
43 #symbolic_link="echo ln -s"
45 # clear some things potentially inherited from environment.
48 Makefile_in=Makefile.in
54 floating_point=default
69 program_prefix_option=
84 NO_EDIT="This file was generated automatically by configure. Do not edit."
86 ## this is a little touchy and won't always work, but...
88 ## if the argv[0] starts with a slash then it is an absolute name that can (and
89 ## must) be used as is.
91 ## otherwise, if argv[0] has no slash in it, we can assume that it is on the
92 ## path. Since PATH might include "." we also add `pwd` to the end of PATH.
102 PATH=$PATH:${PWD} ; export PATH
108 # handle things that might have args following as separate words
109 if [ -n "${next_prefix}" ] ; then prefix=${arg} ; prefixoption="-prefix=${prefix}" ; next_prefix=
110 elif [ -n "${next_exec_prefix}" ] ; then
112 exec_prefixoption="-exec_prefix=${exec_prefix}"
114 elif [ -n "${next_site}" ] ; then site=${arg} ; site_option=-site=${site} ; next_site=
115 # remove any possible trailing slash from srcdir. See note below.
116 elif [ -n "${next_srcdir}" ] ; then srcdir=`echo ${arg} | sed -e 's:/$::'` ; next_srcdir=
117 elif [ -n "${next_program_prefix}" ] ; then
118 program_prefix=${arg}
119 program_prefixoption="-program_prefix=${program_prefix}"
121 elif [ -n "${next_target}" ] ; then
123 case "${target_alias}" in
125 target_alias="${arg}"
128 echo '***' Can only configure for one target at a time. 1>&2
132 elif [ -n "${next_tmpdir}" ] ; then
134 tmpdiroption="--tmpdir=${arg}"
139 -exec_prefix=* | --exec_prefix=* | --exec_prefi=* | --exec_pref=* | --exec_pre=* | --exec_pr=* | --exec_p=* | --exec_=* | --exec=* | --exe=* | --ex=* | --e=*)
140 exec_prefix=`echo ${arg} | sed 's/^[-a-z_]*=//'`
141 exec_prefixoption=${arg}
143 -exec_prefix | --exec_prefix | --exec_prefi | --exec_pref | --exec_pre | --exec_pr | --exec_p | --exec_ | --exec | --exe | --ex | --e)
152 -host=* | --host=* | --hos=* | --ho=*)
153 case "${host_alias}" in
155 host_alias="`echo ${arg} | sed 's/^[-a-z]*=//'`"
158 echo '***' Can only configure for one host at a time. 1>&2
166 -norecursion | --no*)
169 -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=*)
170 prefix=`echo ${arg} | sed 's/^[-a-z]*=//'`
173 -prefix | --prefix | --prefi | --pref | --pre)
176 -rm | --rm) removing=${arg} ;;
177 -program_prefix=* | --program_prefix=* | --program_prefi=* | --program_pref=* | --program_pre=* | --program_pr=* | --program_p=* | --program_=* | --program=* | --progra=* | --progr=* | --prog=* | --pro=*)
178 program_prefix=`echo ${arg} | sed 's/^[-a-z]*=//'`
179 program_prefixoption=${arg}
181 -program_prefix | --program_prefix | --program_prefi | --program_pref | --program_pre | --program_pr | --program_p | --program_ | --program | --progra | --progr | --prog | --pro)
182 next_program_prefix=yes
184 -site=* | --site=* | --sit=* | --si=*)
186 site=`echo ${arg} | sed 's/^[-a-z]*=//'`
188 -site | --site | --sit)
191 # remove trailing slashes. Otherwise, when the file name gets
192 # bolted into an object file as debug info, it has two slashes in
193 # it. Ordinarily this is ok, but emacs takes double slash to
194 # mean "forget the first part".
195 -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*)
196 srcdir=`echo ${arg} | sed 's/^[-a-z]*=//' | sed -e 's:/$::'`
198 -srcdir | --srcdir | --srcdi | --srcd | --src | --sr)
201 -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=*)
202 case "${target_alias}" in
203 "") target_alias="`echo ${arg} | sed 's/^[-a-z]*=//'`" ;;
205 echo '***' Can only configure for one target at a time. 1>&2
210 -target | --target | --targe | --targ | --tar | --ta)
213 -tmpdir=* | --tmpdir=* | --tmpdi=* | --tmpd=* | --tmp=* | --tm=*)
215 TMPDIR=`echo ${arg} | sed 's/^[-a-z]*=//'`
217 -tmpdir | --tmpdir | --tmpdi | --tmpd | --tmp | --tm)
224 -version | -V | --version | --V)
225 echo "This is Cygnus Configure version" `echo ${version} | sed 's/[ $:]//g'`
231 echo "Unrecognized option: \"${arg}\"". ;
241 echo '***' Can only configure for one host and one target at a time. 1>&2
250 # process host and target
253 # # Complain if an arg is missing
254 # if [ -z "${host_alias}" ] ; then
256 # echo "configure: No HOST specified." ;
261 ### This is a bit twisted.
262 ### * if all three are specified, this is an error.
263 ### * if we have neither hosts, nor unadorned args, this is an error.
264 ### * if no hosts are specified, then the unadorned args are hosts, but if
265 ### there were none, this is an error.
266 ### * if no targets are specified, then the unadorned args are targets, but if
267 ### there were no unadorned args, then the hosts are also targets.
269 if [ -n "${host_alias}" -a -n "${target_alias}" -a -n "${undefs}" ] ; then
270 echo '***' Can only configure for one host and one target at a time. 1>&2
272 elif [ -z "${host_alias}" -a -z "${undefs}" ] ; then
273 echo '***' You must tell me for which host you want to configure. 1>&2
276 case "${host_alias}" in
277 "") host_alias=${undefs} ;;
281 case "${target_alias}" in
284 "") target_alias=${host_alias} ;;
285 *) target_alias=${undefs} ;;
295 if [ -n "${fatal}" -o "${host_alias}" = "help" ] ; then
296 (echo "Usage: configure HOST" ;
298 echo "Options: [defaults in brackets]" ;
299 echo " -exec_prefix=MYDIR configure for installation of host dependent files into MYDIR. [\"/usr/local\"]" ;
300 echo " -gas configure the compilers for use with gas. [native as]" ;
301 echo " -help print this message. [normal config]" ;
302 echo " -lang=LANG configure to build LANG. [gcc]" ;
303 echo " -nfp configure the compilers default to soft floating point. [hard float]" ;
304 echo " -norecursion configure this directory only. [recurse]" ;
305 echo " -prefix=MYDIR configure for installation of host dependent files into MYDIR. [\"/usr/local\"]" ;
306 echo " -program_prefix=FOO install programs with FOO prepended to their names. [ \"\" ]" ;
307 echo " -site=SITE configure with site specific makefile for SITE" ;
308 echo " -srcdir=DIR find the sources in DIR. [\".\" or \"..\"]" ;
309 echo " -target=TARGET configure for TARGET. [TARGET = HOST]" ;
310 echo " -tmpdir=TMPDIR create temporary files in TMPDIR. [ TMPDIR = \"/tmp\" ]" ;
312 echo "Where HOST and TARGET are something like \"vax\", \"sun3\", \"encore\", etc." ;
315 if [ -r config.status ] ; then
322 configsub=`echo ${progname} | sed 's/configure$/config.sub/'`
323 moveifchange=`echo ${progname} | sed 's/configure$/move-if-change/'`
325 # this is a hack. sun4 must always be a valid host alias or this will fail.
326 if ${configsub} sun4 >/dev/null 2>&1 ; then
329 echo '***' cannot find config.sub. 1>&2
334 if ${moveifchange} config.junk config.trash ; then
337 echo '***' cannot find move-if-change. 1>&2
340 rm -f config.junk config.trash
344 if [ -r configure.in ] ; then
347 if [ -r ${progname}.in ] ; then
348 srcdir=`echo ${progname} | sed 's:/configure$::'`
350 echo '***' "Can't find configure.in. Try using -srcdir=some_dir" 1>&2
358 ### warn about some conflicting configurations.
363 if [ -f ${srcdir}/config.status ] ; then
364 echo '***' Cannot configure here in \"${PWD}\" when \"${srcdir}\" is currently configured. 1>&2
369 # default exec_prefix
370 case "${exec_prefix}" in
371 "") exec_prefix="\$(prefix)" ;;
375 ### break up ${srcdir}/configure.in.
376 case "`grep '^# per\-host:' ${srcdir}/configure.in`" in
378 echo '***' ${srcdir}/configure.in has no "per-host:" line. 1>&2
384 case "`grep '^# per\-target:' ${srcdir}/configure.in`" in
386 echo '***' ${srcdir}/configure.in has no "per-target:" line. 1>&2
393 "") TMPDIR=/tmp ; export TMPDIR ;;
397 # keep this filename short for &%*%$*# 14 char file names
398 tmpfile=${TMPDIR}/cONf$$
399 trap "rm -f ${tmpfile}.com ${tmpfile}.tgt ${tmpfile}.hst ${tmpfile}.pos" 0
401 # split ${srcdir}/configure.in into common, per-host, per-target,
402 # and post-target parts. Post-target is optional.
403 sed -e '/^# per\-host:/,$d' ${srcdir}/configure.in > ${tmpfile}.com
404 sed -e '1,/^# per\-host:/d' -e '/^# per\-target:/,$d' ${srcdir}/configure.in > ${tmpfile}.hst
405 if grep '^# post-target:' ${srcdir}/configure.in >/dev/null ; then
406 sed -e '1,/^# per\-target:/d' -e '/^# post\-target:/,$d' ${srcdir}/configure.in > ${tmpfile}.tgt
407 sed -e '1,/^# post\-target:/d' ${srcdir}/configure.in > ${tmpfile}.pos
409 sed -e '1,/^# per\-target:/d' ${srcdir}/configure.in > ${tmpfile}.tgt
413 ### do common part of configure.in
417 # some sanity checks on configure.in
418 case "${srctrigger}" in
420 echo '***' srctrigger not set in ${PWD}/configure.in. 1>&2
426 result=`${configsub} ${host_alias}`
427 host_cpu=`echo $result | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\1/'`
428 host_vendor=`echo $result | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\2/'`
429 host_os=`echo $result | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\3/'`
430 host=${host_cpu}-${host_vendor}-${host_os}
434 result=`${configsub} ${target_alias}`
435 target_cpu=`echo $result | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\1/'`
436 target_vendor=`echo $result | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\2/'`
437 target_os=`echo $result | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\3/'`
438 target=${target_cpu}-${target_vendor}-${target_os}
442 # Find the source files, if location was not specified.
447 if [ ! -r ${srctrigger} ] ; then
454 if [ ! -r ${srcdir}/${srctrigger} ] ; then
455 case "${srcdirdefaulted}" in
456 "") echo '***' "${progname}: Can't find ${srcname} sources in ${PWD}/${srcdir}" 1>&2 ;;
457 *) echo '***' "${progname}: Can't find ${srcname} sources in ${PWD}/. or ${PWD}/.." 1>&2 ;;
460 echo '***' \(At least ${srctrigger} is missing.\) 1>&2
464 for subdir in . ${subdirs} ; do
466 # ${subdir} is relative path from . to the directory we're currently
468 # ${invsubdir} is inverse of ${subdir), *with* trailing /, if needed.
469 invsubdir=`echo ${subdir}/ | sed -e 's|\./||g' -e 's|[^/]*/|../|g'`
471 ### figure out what to do with srcdir
473 ".") # no -srcdir option. We're building in place.
476 makesrcdir=`echo ${srcdir}/${subdir} | sed -e 's|/\.$||'`
478 *) # otherwise relative
480 .) makesrcdir=${srcdir} ;;
481 *) makesrcdir=`echo ${subdir} | sed -e 's:[^./][^./]*:..:g'`/${srcdir}/${subdir} ;;
486 if [ "${subdir}/" != "./" ] ; then
487 Makefile=${subdir}/Makefile
490 if [ ! -d ${subdir} ] ; then
494 case "${removing}" in
498 *) eval echo Building in ${subdir} ${redirect} ;;
501 # FIXME Should this be done recursively ??? (Useful for e.g. gdbtest)
502 # Set up the list of links to be made.
503 # ${links} is the list of link names, and ${files} is the list of names to link to.
506 configlinks="${links}"
507 if [ -r ${subdir}/config.status ] ; then
508 mv -f ${subdir}/config.status ${subdir}/config.back
510 while [ -n "${files}" ] ; do
511 # set file to car of files, files to cdr of files
512 set ${files}; file=$1; shift; files=$*
513 set ${links}; link=$1; shift; links=$*
515 if [ ! -r ${srcdir}/${file} ] ; then
516 echo '***' "${progname}: cannot create a link \"${link}\"," 1>&2
517 echo '***' "since the file \"${file}\" does not exist." 1>&2
522 # Make a symlink if possible, otherwise try a hard link
523 ${symbolic_link} ${srcdir}/${file} ${link} 2>/dev/null || ${hard_link} ${srcdir}/${file} ${link}
525 if [ ! -r ${link} ] ; then
526 echo '***' "${progname}: unable to link \"${link}\" to \"${srcdir}/${file}\"." 1>&2
530 echo "Linked \"${link}\" to \"${srcdir}/${file}\"."
533 # Create a .gdbinit file which runs the one in srcdir
534 # and tells GDB to look there for source files.
536 if [ -r ${srcdir}/${subdir}/.gdbinit ] ; then
539 *) cat > ${subdir}/.gdbinit <<EOF
543 source ${makesrcdir}/.gdbinit
549 # Install a makefile, and make it set VPATH
550 # if necessary so that the sources are found.
551 # Also change its value of srcdir.
552 # NOTE: Makefile generation constitutes the majority of the time in configure. Hence, this section has
553 # been somewhat optimized and is perhaps a bit twisty.
555 # code is order so as to try to sed the smallest input files we know.
557 # the three makefile fragments MUST end up in the resulting Makefile in this order: target, host, and site.
558 # so do these separately because I don't trust the order of sed -e expressions.
560 # Conditionalize for this site from "Makefile.in" (or whatever it's called) into Makefile.tem
563 "") cp ${srcdir}/${subdir}/${Makefile_in} ${subdir}/Makefile.tem ;;
565 site_makefile_frag=${srcdir}/config/ms-${site}
567 if [ -f ${site_makefile_frag} ] ; then
568 sed -e "/^####/ r ${site_makefile_frag}" ${srcdir}/${subdir}/${Makefile_in} \
569 > ${subdir}/Makefile.tem
571 cp ${srcdir}/${subdir}/${Makefile_in} ${subdir}/Makefile.tem
576 # working copy now in ${subdir}/Makefile.tem
578 # Conditionalize the makefile for this host.
580 case "${host_makefile_frag}" in
581 "") mv ${subdir}/Makefile.tem ${Makefile} ;;
583 if [ ! -f ${host_makefile_frag} ] ; then
584 host_makefile_frag=${srcdir}/${host_makefile_frag}
586 if [ -f ${host_makefile_frag} ] ; then
587 sed -e "/^####/ r ${host_makefile_frag}" ${subdir}/Makefile.tem > ${Makefile}
589 echo '***' Expected host makefile fragment \"${host_makefile_frag}\" 1>&2
590 echo '***' is missing in ${PWD}. 1>&2
591 mv ${subdir}/Makefile.tem ${Makefile}
594 # working copy now in ${Makefile}
596 # Conditionalize the makefile for this target.
598 case "${target_makefile_frag}" in
599 "") mv ${Makefile} ${subdir}/Makefile.tem ;;
601 target_makefile_frag=${srcdir}/${target_makefile_frag}
602 if [ -f ${target_makefile_frag} ] ; then
603 sed -e "/^####/ r ${target_makefile_frag}" ${Makefile} > ${subdir}/Makefile.tem
605 mv ${Makefile} ${subdir}/Makefile.tem
606 target_makefile_frag=
610 # real copy now in ${subdir}/Makefile.tem
612 # prepend warning about editting, and a bunch of variables.
614 cat > ${Makefile} <<EOF
616 VPATH = ${makesrcdir}
617 links = ${configlinks}
618 host_alias = ${host_alias}
619 host_cpu = ${host_cpu}
620 host_vendor = ${host_vendor}
622 target_alias = ${target_alias}
623 target_cpu = ${target_cpu}
624 target_vendor = ${target_vendor}
625 target_os = ${target_os}
627 if [ "${target_makefile_frag}" != "" ] ; then
628 echo target_makefile_frag = ${invsubdir}${target_makefile_frag} >>${Makefile}
630 if [ "${host_makefile_frag}" != "" ] ; then
631 echo host_makefile_frag = ${invsubdir}${host_makefile_frag} >>${Makefile}
633 if [ "${site_makefile_frag}" != "" ] ; then
634 echo site_makefile_frag = ${invsubdir}${site_makefile_frag} >>${Makefile}
637 # fixme: this shouldn't be in configure.
638 # Define macro CROSS_COMPILE in compilation if this is a cross-compiler.
639 case "${host_alias}" in
642 echo "ALL=all.internal" >> ${Makefile}
645 echo "CROSS=-DCROSS_COMPILE" >> ${Makefile}
646 echo "ALL=all.cross" >> ${Makefile}
647 case "${program_prefix}" in
648 "") program_prefix=${target_alias}- ;;
652 tooldir="\$(libdir)/${target_alias}"
656 # reset prefix, exec_prefix, srcdir, SUBDIRS, NONSUBDIRS,
657 # remove any form feeds.
658 if [ -z "${subdirs}" ]; then
659 sed -e "s:^SUBDIRS[ ]*=.*$:SUBDIRS = ${configdirs}:" \
660 -e "s:^NONSUBDIRS[ ]*=.*$:NONSUBDIRS = ${noconfigdirs}:" \
661 ${subdir}/Makefile.tem > ${subdir}/Makefile.tem2
662 mv ${subdir}/Makefile.tem2 ${subdir}/Makefile.tem
664 sed -e "s:^prefix[ ]*=.*$:prefix = ${prefix}:" \
665 -e "s:^exec_prefix[ ]*=.*$:exec_prefix = ${exec_prefix}:" \
666 -e "s:^srcdir[ ]*=.*$:srcdir = ${makesrcdir}:" \
668 -e "s:^program_prefix[ ]*=.*$:program_prefix = ${program_prefix}:" \
669 -e "s:^tooldir[ ]*=.*$:tooldir = ${tooldir}:" \
670 ${subdir}/Makefile.tem >> ${Makefile}
671 # final copy now in ${Makefile}
673 rm -f ${subdir}/Makefile.tem
675 case "${host_makefile_frag}" in
677 *) using="and \"${host_makefile_frag}\"" ;;
680 case "${target_makefile_frag}" in
682 *) using="${using} and \"${target_makefile_frag}\"" ;;
685 case "${site_makefile_frag}" in
687 *) using="${using} and \"${site_makefile_frag}\"" ;;
690 newusing=`echo "${using}" | sed 's/and/using/'`
692 echo "Created \"${Makefile}\" in" ${PWD} ${using}
696 # describe the chosen configuration in config.status.
697 # Make that file a shellscript which will reestablish
698 # the same configuration. Used in Makefiles to rebuild
701 case "${norecursion}" in
702 "") arguments="${arguments} -norecursion" ;;
706 if [ ${subdir} = . ] ; then
709 # ${PWD} was configured as follows:
710 ${progname}" ${arguments} "
711 # ${using}" > ${subdir}/config.new
715 # ${PWD}/${subdir} was configured as follows:
717 ${progname}" ${arguments} "
718 # ${using}" > ${subdir}/config.new
720 chmod a+x ${subdir}/config.new
721 if [ -r ${subdir}/config.back ] ; then
722 mv -f ${subdir}/config.back ${subdir}/config.status
724 ${moveifchange} ${subdir}/config.new ${subdir}/config.status
727 *) rm -f ${Makefile} ${subdir}/config.status ${links} ;;
731 # If there are subdirectories, then recur.
732 if [ -z "${norecursion}" -a -n "${configdirs}" ] ; then
733 for configdir in ${configdirs} ; do
734 eval echo Configuring ${configdir}... ${redirect}
736 if [ -d ${srcdir}/${configdir} ] ; then
740 if [ ! -d ./${configdir} ] ; then
749 ### figure out what to do with srcdir
751 ".") newsrcdir=${srcdir} ;; # no -srcdir option. We're building in place.
753 newsrcdir=${srcdir}/${configdir}
754 srcdiroption="-srcdir=${newsrcdir}"
756 *) # otherwise relative
757 newsrcdir=../${srcdir}/${configdir}
758 srcdiroption="-srcdir=${newsrcdir}"
762 ### check for guested configure, otherwise fix possibly relative progname
763 if [ -f ${newsrcdir}/configure ] ; then
764 recprog=${newsrcdir}/configure
766 case "${progname}" in
767 /*) recprog=${progname} ;;
768 *) recprog=../${progname} ;;
772 ### The recursion line is here.
773 if eval ${recprog} ${verbose} ${host_alias} -target=${target_alias} \
774 ${prefixoption} ${tmpdiroption} ${exec_prefixoption} \
775 ${srcdiroption} ${program_prefixoption} ${site_option} ${removing} ${redirect} ; then
783 eval echo Warning: source directory \"${srcdir}/${configdir}\" is missing. ${redirect}