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.
101 PATH=$PATH:${PWD=`pwd`} ; export PATH
107 # handle things that might have args following as separate words
108 if [ -n "${next_prefix}" ] ; then prefix=${arg} ; prefixoption="-prefix=${prefix}" ; next_prefix=
109 elif [ -n "${next_exec_prefix}" ] ; then
111 exec_prefixoption="-exec_prefix=${exec_prefix}"
113 elif [ -n "${next_site}" ] ; then site=${arg} ; site_option=-site=${site} ; next_site=
114 # remove any possible trailing slash from srcdir. See note below.
115 elif [ -n "${next_srcdir}" ] ; then srcdir=`echo ${arg} | sed -e 's:/$::'` ; next_srcdir=
116 elif [ -n "${next_program_prefix}" ] ; then
117 program_prefix=${arg}
118 program_prefixoption="-program_prefix=${program_prefix}"
120 elif [ -n "${next_target}" ] ; then
122 case "${target_alias}" in
124 target_alias="${arg}"
127 echo '***' Can only configure for one target at a time. 1>&2
131 elif [ -n "${next_tmpdir}" ] ; then
133 tmpdiroption="--tmpdir=${arg}"
138 -exec_prefix=* | --exec_prefix=* | --exec_prefi=* | --exec_pref=* | --exec_pre=* | --exec_pr=* | --exec_p=* | --exec_=* | --exec=* | --exe=* | --ex=* | --e=*)
139 exec_prefix=`echo ${arg} | sed 's/^[-a-z_]*=//'`
140 exec_prefixoption=${arg}
142 -exec_prefix | --exec_prefix | --exec_prefi | --exec_pref | --exec_pre | --exec_pr | --exec_p | --exec_ | --exec | --exe | --ex | --e)
151 -host=* | --host=* | --hos=* | --ho=*)
152 case "${host_alias}" in
154 host_alias="`echo ${arg} | sed 's/^[-a-z]*=//'`"
157 echo '***' Can only configure for one host at a time. 1>&2
165 -norecursion | --no*)
168 -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=*)
169 prefix=`echo ${arg} | sed 's/^[-a-z]*=//'`
172 -prefix | --prefix | --prefi | --pref | --pre)
175 -rm | --rm) removing=${arg} ;;
176 -program_prefix=* | --program_prefix=* | --program_prefi=* | --program_pref=* | --program_pre=* | --program_pr=* | --program_p=* | --program_=* | --program=* | --progra=* | --progr=* | --prog=* | --pro=*)
177 program_prefix=`echo ${arg} | sed 's/^[-a-z]*=//'`
178 program_prefixoption=${arg}
180 -program_prefix | --program_prefix | --program_prefi | --program_pref | --program_pre | --program_pr | --program_p | --program_ | --program | --progra | --progr | --prog | --pro)
181 next_program_prefix=yes
183 -site=* | --site=* | --sit=* | --si=*)
185 site=`echo ${arg} | sed 's/^[-a-z]*=//'`
187 -site | --site | --sit)
190 # remove trailing slashes. Otherwise, when the file name gets
191 # bolted into an object file as debug info, it has two slashes in
192 # it. Ordinarily this is ok, but emacs takes double slash to
193 # mean "forget the first part".
194 -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*)
195 srcdir=`echo ${arg} | sed 's/^[-a-z]*=//' | sed -e 's:/$::'`
197 -srcdir | --srcdir | --srcdi | --srcd | --src | --sr)
200 -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=*)
201 case "${target_alias}" in
202 "") target_alias="`echo ${arg} | sed 's/^[-a-z]*=//'`" ;;
204 echo '***' Can only configure for one target at a time. 1>&2
209 -target | --target | --targe | --targ | --tar | --ta)
212 -tmpdir=* | --tmpdir=* | --tmpdi=* | --tmpd=* | --tmp=* | --tm=*)
214 TMPDIR=`echo ${arg} | sed 's/^[-a-z]*=//'`
216 -tmpdir | --tmpdir | --tmpdi | --tmpd | --tmp | --tm)
223 -version | -V | --version | --V)
224 echo "This is Cygnus Configure version" `echo ${version} | sed 's/[ $:]//g'`
230 echo "Unrecognized option: \"${arg}\"". ;
240 echo '***' Can only configure for one host and one target at a time. 1>&2
249 # process host and target
252 # # Complain if an arg is missing
253 # if [ -z "${host_alias}" ] ; then
255 # echo "configure: No HOST specified." ;
260 ### This is a bit twisted.
261 ### * if all three are specified, this is an error.
262 ### * if we have neither hosts, nor unadorned args, this is an error.
263 ### * if no hosts are specified, then the unadorned args are hosts, but if
264 ### there were none, this is an error.
265 ### * if no targets are specified, then the unadorned args are targets, but if
266 ### there were no unadorned args, then the hosts are also targets.
268 if [ -n "${host_alias}" -a -n "${target_alias}" -a -n "${undefs}" ] ; then
269 echo '***' Can only configure for one host and one target at a time. 1>&2
271 elif [ -z "${host_alias}" -a -z "${undefs}" ] ; then
272 echo '***' You must tell me for which host you want to configure. 1>&2
275 case "${host_alias}" in
276 "") host_alias=${undefs} ;;
280 case "${target_alias}" in
283 "") target_alias=${host_alias} ;;
284 *) target_alias=${undefs} ;;
294 if [ -n "${fatal}" -o "${host_alias}" = "help" ] ; then
295 (echo "Usage: configure HOST" ;
297 echo "Options: [defaults in brackets]" ;
298 echo " -exec_prefix=MYDIR configure for installation of host dependent files into MYDIR. [\"/usr/local\"]" ;
299 echo " -gas configure the compilers for use with gas. [native as]" ;
300 echo " -help print this message. [normal config]" ;
301 echo " -lang=LANG configure to build LANG. [gcc]" ;
302 echo " -nfp configure the compilers default to soft floating point. [hard float]" ;
303 echo " -norecursion configure this directory only. [recurse]" ;
304 echo " -prefix=MYDIR configure for installation of host dependent files into MYDIR. [\"/usr/local\"]" ;
305 echo " -program_prefix=FOO install programs with FOO prepended to their names. [ \"\" ]" ;
306 echo " -site=SITE configure with site specific makefile for SITE" ;
307 echo " -srcdir=DIR find the sources in DIR. [\".\" or \"..\"]" ;
308 echo " -target=TARGET configure for TARGET. [TARGET = HOST]" ;
309 echo " -tmpdir=TMPDIR create temporary files in TMPDIR. [ TMPDIR = \"/tmp\" ]" ;
311 echo "Where HOST and TARGET are something like \"vax\", \"sun3\", \"encore\", etc." ;
314 if [ -r config.status ] ; then
321 configsub=`echo ${progname} | sed 's/configure$/config.sub/'`
322 moveifchange=`echo ${progname} | sed 's/configure$/move-if-change/'`
324 # this is a hack. sun4 must always be a valid host alias or this will fail.
325 if ${configsub} sun4 >/dev/null 2>&1 ; then
328 echo '***' cannot find config.sub. 1>&2
333 if ${moveifchange} config.junk config.trash ; then
336 echo '***' cannot find move-if-change. 1>&2
339 rm -f config.junk config.trash
343 if [ -r configure.in ] ; then
346 if [ -r ${progname}.in ] ; then
347 srcdir=`echo ${progname} | sed 's:/configure$::'`
349 echo '***' "Can't find configure.in. Try using -srcdir=some_dir" 1>&2
357 ### warn about some conflicting configurations.
362 if [ -f ${srcdir}/config.status ] ; then
363 echo '***' Cannot configure here in \"${PWD=`pwd`}\" when \"${srcdir}\" is currently configured. 1>&2
368 # default exec_prefix
369 case "${exec_prefix}" in
370 "") exec_prefix="\$(prefix)" ;;
374 ### break up ${srcdir}/configure.in.
375 case "`grep '^# per\-host:' ${srcdir}/configure.in`" in
377 echo '***' ${srcdir}/configure.in has no "per-host:" line. 1>&2
383 case "`grep '^# per\-target:' ${srcdir}/configure.in`" in
385 echo '***' ${srcdir}/configure.in has no "per-target:" line. 1>&2
392 "") TMPDIR=/tmp ; export TMPDIR ;;
396 # keep this filename short for &%*%$*# 14 char file names
397 tmpfile=${TMPDIR}/cONf$$
398 trap "rm -f ${tmpfile}.com ${tmpfile}.tgt ${tmpfile}.hst ${tmpfile}.pos" 0
400 # split ${srcdir}/configure.in into common, per-host, per-target,
401 # and post-target parts. Post-target is optional.
402 sed -e '/^# per\-host:/,$d' ${srcdir}/configure.in > ${tmpfile}.com
403 sed -e '1,/^# per\-host:/d' -e '/^# per\-target:/,$d' ${srcdir}/configure.in > ${tmpfile}.hst
404 if grep '^# post-target:' ${srcdir}/configure.in >/dev/null ; then
405 sed -e '1,/^# per\-target:/d' -e '/^# post\-target:/,$d' ${srcdir}/configure.in > ${tmpfile}.tgt
406 sed -e '1,/^# post\-target:/d' ${srcdir}/configure.in > ${tmpfile}.pos
408 sed -e '1,/^# per\-target:/d' ${srcdir}/configure.in > ${tmpfile}.tgt
412 ### do common part of configure.in
416 # some sanity checks on configure.in
417 case "${srctrigger}" in
419 echo '***' srctrigger not set in ${PWD=`pwd`}/configure.in. 1>&2
425 result=`${configsub} ${host_alias}`
426 host_cpu=`echo $result | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\1/'`
427 host_vendor=`echo $result | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\2/'`
428 host_os=`echo $result | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\3/'`
429 host=${host_cpu}-${host_vendor}-${host_os}
433 result=`${configsub} ${target_alias}`
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}
441 # Find the source files, if location was not specified.
446 if [ ! -r ${srctrigger} ] ; then
453 if [ ! -r ${srcdir}/${srctrigger} ] ; then
454 case "${srcdirdefaulted}" in
455 "") echo '***' "${progname}: Can't find ${srcname} sources in ${PWD=`pwd`}/${srcdir}" 1>&2 ;;
456 *) echo '***' "${progname}: Can't find ${srcname} sources in ${PWD=`pwd`}/. or ${PWD=`pwd`}/.." 1>&2 ;;
459 echo '***' \(At least ${srctrigger} is missing.\) 1>&2
463 for subdir in . ${subdirs} ; do
465 # ${subdir} is relative path from . to the directory we're currently
467 # ${invsubdir} is inverse of ${subdir), *with* trailing /, if needed.
468 invsubdir=`echo ${subdir}/ | sed -e 's|\./||g' -e 's|[^/]*/|../|g'`
470 ### figure out what to do with srcdir
472 ".") # no -srcdir option. We're building in place.
475 makesrcdir=`echo ${srcdir}/${subdir} | sed -e 's|/\.$||'`
477 *) # otherwise relative
479 .) makesrcdir=${srcdir} ;;
480 *) makesrcdir=`echo ${subdir} | sed -e 's:[^./][^./]*:..:g'`/${srcdir}/${subdir} ;;
485 if [ "${subdir}/" != "./" ] ; then
486 Makefile=${subdir}/Makefile
489 if [ ! -d ${subdir} ] ; then
493 case "${removing}" in
497 *) eval echo Building in ${subdir} ${redirect} ;;
500 # FIXME Should this be done recursively ??? (Useful for e.g. gdbtest)
501 # Set up the list of links to be made.
502 # ${links} is the list of link names, and ${files} is the list of names to link to.
505 configlinks="${links}"
506 if [ -r ${subdir}/config.status ] ; then
507 mv -f ${subdir}/config.status ${subdir}/config.back
509 while [ -n "${files}" ] ; do
510 # set file to car of files, files to cdr of files
511 set ${files}; file=$1; shift; files=$*
512 set ${links}; link=$1; shift; links=$*
514 if [ ! -r ${srcdir}/${file} ] ; then
515 echo '***' "${progname}: cannot create a link \"${link}\"," 1>&2
516 echo '***' "since the file \"${file}\" does not exist." 1>&2
521 # Make a symlink if possible, otherwise try a hard link
522 ${symbolic_link} ${srcdir}/${file} ${link} 2>/dev/null || ${hard_link} ${srcdir}/${file} ${link}
524 if [ ! -r ${link} ] ; then
525 echo '***' "${progname}: unable to link \"${link}\" to \"${srcdir}/${file}\"." 1>&2
529 echo "Linked \"${link}\" to \"${srcdir}/${file}\"."
532 # Create a .gdbinit file which runs the one in srcdir
533 # and tells GDB to look there for source files.
535 if [ -r ${srcdir}/${subdir}/.gdbinit ] ; then
538 *) cat > ${subdir}/.gdbinit <<EOF
542 source ${makesrcdir}/.gdbinit
548 # Install a makefile, and make it set VPATH
549 # if necessary so that the sources are found.
550 # Also change its value of srcdir.
551 # NOTE: Makefile generation constitutes the majority of the time in configure. Hence, this section has
552 # been somewhat optimized and is perhaps a bit twisty.
554 # code is order so as to try to sed the smallest input files we know.
556 # the three makefile fragments MUST end up in the resulting Makefile in this order: target, host, and site.
557 # so do these separately because I don't trust the order of sed -e expressions.
559 # Conditionalize for this site from "Makefile.in" (or whatever it's called) into Makefile.tem
562 "") cp ${srcdir}/${subdir}/${Makefile_in} ${subdir}/Makefile.tem ;;
564 site_makefile_frag=${srcdir}/config/ms-${site}
566 if [ -f ${site_makefile_frag} ] ; then
567 sed -e "/^####/ r ${site_makefile_frag}" ${srcdir}/${subdir}/${Makefile_in} \
568 > ${subdir}/Makefile.tem
570 cp ${srcdir}/${subdir}/${Makefile_in} ${subdir}/Makefile.tem
575 # working copy now in ${subdir}/Makefile.tem
577 # Conditionalize the makefile for this host.
579 case "${host_makefile_frag}" in
580 "") mv ${subdir}/Makefile.tem ${Makefile} ;;
582 if [ ! -f ${host_makefile_frag} ] ; then
583 host_makefile_frag=${srcdir}/${host_makefile_frag}
585 if [ -f ${host_makefile_frag} ] ; then
586 sed -e "/^####/ r ${host_makefile_frag}" ${subdir}/Makefile.tem > ${Makefile}
588 echo '***' Expected host makefile fragment \"${host_makefile_frag}\" 1>&2
589 echo '***' is missing in ${PWD=`pwd`}. 1>&2
590 mv ${subdir}/Makefile.tem ${Makefile}
593 # working copy now in ${Makefile}
595 # Conditionalize the makefile for this target.
597 case "${target_makefile_frag}" in
598 "") mv ${Makefile} ${subdir}/Makefile.tem ;;
600 if [ ! -f ${target_makefile_frag} ] ; then
601 target_makefile_frag=${srcdir}/${target_makefile_frag}
603 if [ -f ${target_makefile_frag} ] ; then
604 sed -e "/^####/ r ${target_makefile_frag}" ${Makefile} > ${subdir}/Makefile.tem
606 mv ${Makefile} ${subdir}/Makefile.tem
607 target_makefile_frag=
611 # real copy now in ${subdir}/Makefile.tem
613 # prepend warning about editting, and a bunch of variables.
615 cat > ${Makefile} <<EOF
617 VPATH = ${makesrcdir}
618 links = ${configlinks}
619 host_alias = ${host_alias}
620 host_cpu = ${host_cpu}
621 host_vendor = ${host_vendor}
623 target_alias = ${target_alias}
624 target_cpu = ${target_cpu}
625 target_vendor = ${target_vendor}
626 target_os = ${target_os}
628 case "${target_makefile_frag}" in
631 echo target_makefile_frag = ${target_makefile_frag} >>${Makefile} ;;
633 echo target_makefile_frag = ${invsubdir}${target_makefile_frag} >>${Makefile} ;;
636 case "${host_makefile_frag}" in
639 echo host_makefile_frag = ${host_makefile_frag} >>${Makefile} ;;
641 echo host_makefile_frag = ${invsubdir}${host_makefile_frag} >>${Makefile} ;;
644 if [ "${site_makefile_frag}" != "" ] ; then
645 echo site_makefile_frag = ${invsubdir}${site_makefile_frag} >>${Makefile}
648 # fixme: this shouldn't be in configure.
649 # Define macro CROSS_COMPILE in compilation if this is a cross-compiler.
650 case "${host_alias}" in
653 echo "ALL=all.internal" >> ${Makefile}
656 echo "CROSS=-DCROSS_COMPILE" >> ${Makefile}
657 echo "ALL=all.cross" >> ${Makefile}
658 case "${program_prefix}" in
659 "") program_prefix=${target_alias}- ;;
663 tooldir="\$(libdir)/${target_alias}"
667 # reset prefix, exec_prefix, srcdir, SUBDIRS, NONSUBDIRS,
668 # remove any form feeds.
669 if [ -z "${subdirs}" ]; then
670 sed -e "s:^SUBDIRS[ ]*=.*$:SUBDIRS = ${configdirs}:" \
671 -e "s:^NONSUBDIRS[ ]*=.*$:NONSUBDIRS = ${noconfigdirs}:" \
672 ${subdir}/Makefile.tem > ${subdir}/Makefile.tem2
673 mv ${subdir}/Makefile.tem2 ${subdir}/Makefile.tem
675 sed -e "s:^prefix[ ]*=.*$:prefix = ${prefix}:" \
676 -e "s:^exec_prefix[ ]*=.*$:exec_prefix = ${exec_prefix}:" \
677 -e "s:^srcdir[ ]*=.*$:srcdir = ${makesrcdir}:" \
679 -e "s:^program_prefix[ ]*=.*$:program_prefix = ${program_prefix}:" \
680 -e "s:^tooldir[ ]*=.*$:tooldir = ${tooldir}:" \
681 ${subdir}/Makefile.tem >> ${Makefile}
682 # final copy now in ${Makefile}
684 rm -f ${subdir}/Makefile.tem
686 case "${host_makefile_frag}" in
688 *) using="and \"${host_makefile_frag}\"" ;;
691 case "${target_makefile_frag}" in
693 *) using="${using} and \"${target_makefile_frag}\"" ;;
696 case "${site_makefile_frag}" in
698 *) using="${using} and \"${site_makefile_frag}\"" ;;
701 newusing=`echo "${using}" | sed 's/and/using/'`
703 echo "Created \"${Makefile}\" in" ${PWD=`pwd`} ${using}
707 # describe the chosen configuration in config.status.
708 # Make that file a shellscript which will reestablish
709 # the same configuration. Used in Makefiles to rebuild
712 case "${norecursion}" in
713 "") arguments="${arguments} -norecursion" ;;
717 if [ ${subdir} = . ] ; then
720 # This directory was configured as follows:
721 ${progname}" ${arguments} "
722 # ${using}" > ${subdir}/config.new
726 # This directory was configured as follows:
728 ${progname}" ${arguments} "
729 # ${using}" > ${subdir}/config.new
731 chmod a+x ${subdir}/config.new
732 if [ -r ${subdir}/config.back ] ; then
733 mv -f ${subdir}/config.back ${subdir}/config.status
735 ${moveifchange} ${subdir}/config.new ${subdir}/config.status
738 *) rm -f ${Makefile} ${subdir}/config.status ${links} ;;
742 # If there are subdirectories, then recur.
743 if [ -z "${norecursion}" -a -n "${configdirs}" ] ; then
744 for configdir in ${configdirs} ; do
745 eval echo Configuring ${configdir}... ${redirect}
747 if [ -d ${srcdir}/${configdir} ] ; then
751 if [ ! -d ./${configdir} ] ; then
760 ### figure out what to do with srcdir
762 ".") newsrcdir=${srcdir} ;; # no -srcdir option. We're building in place.
764 newsrcdir=${srcdir}/${configdir}
765 srcdiroption="-srcdir=${newsrcdir}"
767 *) # otherwise relative
768 newsrcdir=../${srcdir}/${configdir}
769 srcdiroption="-srcdir=${newsrcdir}"
773 ### check for guested configure, otherwise fix possibly relative progname
774 if [ -f ${newsrcdir}/configure ] ; then
775 recprog=${newsrcdir}/configure
777 case "${progname}" in
778 /*) recprog=${progname} ;;
779 *) recprog=../${progname} ;;
783 ### The recursion line is here.
784 if eval ${recprog} ${verbose} ${host_alias} -target=${target_alias} \
785 ${prefixoption} ${tmpdiroption} ${exec_prefixoption} \
786 ${srcdiroption} ${program_prefixoption} ${site_option} ${removing} ${redirect} ; then
794 eval echo Warning: source directory \"${srcdir}/${configdir}\" is missing. ${redirect}