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
70 program_prefix_option
=
85 NO_EDIT
="This file was generated automatically by configure. Do not edit."
87 ## this is a little touchy and won't always work, but...
89 ## if the argv[0] starts with a slash then it is an absolute name that can (and
90 ## must) be used as is.
92 ## otherwise, if argv[0] has no slash in it, we can assume that it is on the
93 ## path. Since PATH might include "." we also add `pwd` to the end of PATH.
103 PATH
=$PATH:${PWD} ; export PATH
109 # handle things that might have args following as separate words
110 if [ -n "${next_prefix}" ] ; then prefix=${arg} ; prefixoption="-prefix=${prefix}" ; next_prefix
=
111 elif [ -n "${next_exec_prefix}" ] ; then
113 exec_prefixoption
="-exec_prefix=${exec_prefix}"
115 elif [ -n "${next_site}" ] ; then site=${arg} ; site_option=-site=${site} ; next_site=
116 # remove any possible trailing slash from srcdir. See note below.
117 elif [ -n "${next_srcdir}" ] ; then srcdir=`echo ${arg} | sed -e 's:/$::'` ; next_srcdir=
118 elif [ -n "${next_program_prefix}" ] ; then
119 program_prefix=${arg}
120 program_prefixoption="-program_prefix=${program_prefix}"
122 elif [ -n "${next_target}" ] ; then
124 case "${target_alias}" in
126 target_alias="${arg}"
129 echo '***' Can only configure for one target at a time. 1>&2
133 elif [ -n "${next_tmpdir}" ] ; then
135 tmpdiroption="--tmpdir=${arg}"
140 -exec_prefix=* | --exec_prefix=* | --exec_prefi=* | --exec_pref=* | --exec_pre=* | --exec_pr=* | --exec_p=* | --exec_=* | --exec=* | --exe=* | --ex=* | --e=*)
141 exec_prefix=`echo ${arg} | sed 's/^[-a-z_]*=//'`
142 exec_prefixoption=${arg}
144 -exec_prefix | --exec_prefix | --exec_prefi | --exec_pref | --exec_pre | --exec_pr | --exec_p | --exec_ | --exec | --exe | --ex | --e)
153 -host=* | --host=* | --hos=* | --ho=*)
154 case "${host_alias}" in
156 host_alias="`echo ${arg} | sed 's/^[-a-z]*=//'`"
159 echo '***' Can only configure for one host at a time. 1>&2
167 -norecursion | --no*)
170 -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=*)
171 prefix=`echo ${arg} | sed 's/^[-a-z]*=//'`
174 -prefix | --prefix | --prefi | --pref | --pre)
177 -rm | --rm) removing=${arg} ;;
178 -program_prefix=* | --program_prefix=* | --program_prefi=* | --program_pref=* | --program_pre=* | --program_pr=* | --program_p=* | --program_=* | --program=* | --progra=* | --progr=* | --prog=* | --pro=*)
179 program_prefix=`echo ${arg} | sed 's/^[-a-z]*=//'`
180 program_prefixoption=${arg}
182 -program_prefix | --program_prefix | --program_prefi | --program_pref | --program_pre | --program_pr | --program_p | --program_ | --program | --progra | --progr | --prog | --pro)
183 next_program_prefix=yes
185 -s | -silent | --silent | --silen | --sile | --sil)
187 arguments=`echo ${arguments} | sed "s
:${arg}::"`
189 -site=* | --site=* | --sit=* | --si=*)
191 site=`echo ${arg} | sed 's/^[-a-z]*=//'`
193 -site | --site | --sit)
196 # remove trailing slashes. Otherwise, when the file name gets
197 # bolted into an object file as debug info, it has two slashes in
198 # it. Ordinarily this is ok, but emacs takes double slash to
199 # mean "forget the first part
".
200 -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*)
201 srcdir=`echo ${arg} | sed 's/^[-a-z]*=//' | sed -e 's:/$::'`
203 -srcdir | --srcdir | --srcdi | --srcd | --src | --sr)
206 -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=*)
207 case "${target_alias}" in
208 "") target_alias="`echo ${arg} | sed 's/^[-a-z]*=//'`" ;;
210 echo '***' Can only configure for one target at a time. 1>&2
215 -target | --target | --targe | --targ | --tar | --ta)
218 -tmpdir=* | --tmpdir=* | --tmpdi=* | --tmpd=* | --tmp=* | --tm=*)
220 TMPDIR=`echo ${arg} | sed 's/^[-a-z]*=//'`
222 -tmpdir | --tmpdir | --tmpdi | --tmpd | --tmp | --tm)
228 -version | -V | --version | --V)
229 echo "This is Cygnus Configure version
" `echo ${version} | sed 's/[ $:]//g'`
235 echo "Unrecognized option
: \"${arg}\"". ;
245 echo '***' Can only configure for one host and one target at a time. 1>&2
254 # process host and target
257 # # Complain if an arg is missing
258 # if [ -z "${host_alias}" ] ; then
260 # echo "configure
: No HOST specified.
" ;
265 ### This is a bit twisted.
266 ### * if all three are specified, this is an error.
267 ### * if we have neither hosts, nor unadorned args, this is an error.
268 ### * if no hosts are specified, then the unadorned args are hosts, but if
269 ### there were none, this is an error.
270 ### * if no targets are specified, then the unadorned args are targets, but if
271 ### there were no unadorned args, then the hosts are also targets.
273 if [ -n "${host_alias}" -a -n "${target_alias}" -a -n "${undefs}" ] ; then
274 echo '***' Can only configure for one host and one target at a time. 1>&2
276 elif [ -z "${host_alias}" -a -z "${undefs}" ] ; then
277 echo '***' You must tell me for which host you want to configure. 1>&2
280 case "${host_alias}" in
281 "") host_alias=${undefs} ;;
285 case "${target_alias}" in
288 "") target_alias=${host_alias} ;;
289 *) target_alias=${undefs} ;;
299 if [ -n "${fatal}" -o "${host_alias}" = "help" ] ; then
300 (echo "Usage
: configure HOST
" ;
302 echo "Options
: [defaults
in brackets
]" ;
303 echo " -exec_prefix=MYDIR configure
for installation of
host dependent files into MYDIR.
[\"/usr
/local\"]" ;
304 echo " -gas configure the compilers
for use with gas.
[native as
]" ;
305 echo " -help print this message.
[normal config
]" ;
306 echo " -lang=LANG configure to build LANG.
[gcc
]" ;
307 echo " -nfp configure the compilers default to soft floating point.
[hard float
]" ;
308 echo " -norecursion configure this directory only.
[recurse
]" ;
309 echo " -prefix=MYDIR configure
for installation of
host dependent files into MYDIR.
[\"/usr
/local\"]" ;
310 echo " -program_prefix=FOO
install programs with FOO prepended to their names.
[ \"\" ]" ;
311 echo " -site=SITE configure with site specific makefile
for SITE
" ;
312 echo " -srcdir=DIR
find the sources
in DIR.
[\".
\" or
\"..
\"]" ;
313 echo " -target=TARGET configure
for TARGET.
[TARGET
= HOST
]" ;
314 echo " -tmpdir=TMPDIR create temporary files
in TMPDIR.
[ TMPDIR
= \"/tmp
\" ]" ;
316 echo "Where HOST and TARGET are something like
\"vax
\", \"sun3
\", \"encore
\", etc.
" ;
319 if [ -r config.status ] ; then
326 configsub=`echo ${progname} | sed 's/configure$/config.sub/'`
327 moveifchange=`echo ${progname} | sed 's/configure$/move-if-change/'`
329 # this is a hack. sun4 must always be a valid host alias or this will fail.
330 if ${configsub} sun4 >/dev/null 2>&1 ; then
333 echo '***' cannot find config.sub. 1>&2
338 if ${moveifchange} config.junk config.trash ; then
341 echo '***' cannot find move-if-change. 1>&2
344 rm -f config.junk config.trash
348 if [ -r configure.in ] ; then
351 if [ -r ${progname}.in ] ; then
352 srcdir=`echo ${progname} | sed 's:/configure$::'`
354 echo '***' "Can
't find configure.in. Try using -srcdir=some_dir" 1>&2
362 ### warn about some conflicting configurations.
367 if [ -f ${srcdir}/config.status ] ; then
368 echo '***' Cannot configure here in \"${PWD}\" when \"${srcdir}\" is currently configured. 1>&2
373 # default exec_prefix
374 case "${exec_prefix}" in
375 "") exec_prefix="\$(prefix)" ;;
379 ### break up ${srcdir}/configure.in.
380 case "`grep '^
# per\-host:' ${srcdir}/configure.in`" in
382 echo '***' ${srcdir}/configure.
in has no
"per-host:" line.
1>&2
388 case "`grep '^# per\-target:' ${srcdir}/configure.in`" in
390 echo '***' ${srcdir}/configure.
in has no
"per-target:" line.
1>&2
397 "") TMPDIR
=/tmp
; export TMPDIR
;;
401 # keep this filename short for &%*%$*# 14 char file names
402 tmpfile
=${TMPDIR}/cONf$$
403 trap "rm -f ${tmpfile}.com ${tmpfile}.tgt ${tmpfile}.hst ${tmpfile}.pos" 0
405 # split ${srcdir}/configure.in into common, per-host, per-target,
406 # and post-target parts. Post-target is optional.
407 sed -e '/^# per\-host:/,$d' ${srcdir}/configure.
in > ${tmpfile}.com
408 sed -e '1,/^# per\-host:/d' -e '/^# per\-target:/,$d' ${srcdir}/configure.
in > ${tmpfile}.hst
409 if grep '^# post-target:' ${srcdir}/configure.
in >/dev
/null
; then
410 sed -e '1,/^# per\-target:/d' -e '/^# post\-target:/,$d' ${srcdir}/configure.
in > ${tmpfile}.tgt
411 sed -e '1,/^# post\-target:/d' ${srcdir}/configure.
in > ${tmpfile}.pos
413 sed -e '1,/^# per\-target:/d' ${srcdir}/configure.
in > ${tmpfile}.tgt
417 ### do common part of configure.in
421 # some sanity checks on configure.in
422 case "${srctrigger}" in
424 echo '***' srctrigger not
set in ${PWD}/configure.
in.
1>&2
430 result
=`${configsub} ${host_alias}`
431 host_cpu
=`echo $result | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\1/'`
432 host_vendor
=`echo $result | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\2/'`
433 host_os
=`echo $result | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\3/'`
434 host=${host_cpu}-${host_vendor}-${host_os}
438 result
=`${configsub} ${target_alias}`
439 target_cpu
=`echo $result | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\1/'`
440 target_vendor
=`echo $result | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\2/'`
441 target_os
=`echo $result | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\3/'`
442 target
=${target_cpu}-${target_vendor}-${target_os}
446 # Find the source files, if location was not specified.
451 if [ ! -r ${srctrigger} ] ; then
458 if [ ! -r ${srcdir}/${srctrigger} ] ; then
459 case "${srcdirdefaulted}" in
460 "") echo '***' "${progname}: Can't find ${srcname} sources in ${PWD}/${srcdir}" 1>&2 ;;
461 *) echo '***' "${progname}: Can't find ${srcname} sources in ${PWD}/. or ${PWD}/.." 1>&2 ;;
464 echo '***' \
(At least
${srctrigger} is missing.\
) 1>&2
468 for subdir
in .
${subdirs} ; do
470 # ${subdir} is relative path from . to the directory we're currently
472 # ${invsubdir} is inverse of ${subdir), *with* trailing /, if needed.
473 invsubdir
=`echo ${subdir}/ | sed -e 's|\./||g' -e 's|[^/]*/|../|g'`
475 ### figure out what to do with srcdir
477 ".") # no -srcdir option. We're building in place.
480 makesrcdir
=`echo ${srcdir}/${subdir} | sed -e 's|/\.$||'`
482 *) # otherwise relative
484 .
) makesrcdir
=${srcdir} ;;
485 *) makesrcdir
=..
/${srcdir}/${subdir} ;;
490 if [ "${subdir}/" != "./" ] ; then
491 Makefile
=${subdir}/Makefile
494 if [ ! -d ${subdir} ] ; then
498 case "${removing}" in
500 if [ -n "${verbose}" -o -z "${silent}" ] ; then
501 echo Building
in ${subdir}
503 # FIXME Should this be done recursively ??? (Useful for e.g. gdbtest)
504 # Set up the list of links to be made.
505 # ${links} is the list of link names, and ${files} is the list of names to link to.
508 configlinks
="${links}"
509 if [ -r config.status
] ; then
510 mv -f ${subdir}/config.status
${subdir}/config.back
512 while [ -n "${files}" ] ; do
513 # set file to car of files, files to cdr of files
514 set ${files}; file=$1; shift; files
=$
*
515 set ${links}; link
=$1; shift; links
=$
*
517 if [ ! -r ${srcdir}/${file} ] ; then
518 echo '***' "${progname}: cannot create a link \"${link}\"," 1>&2
519 echo '***' "since the file \"${file}\" does not exist." 1>&2
524 # Make a symlink if possible, otherwise try a hard link
525 ${symbolic_link} ${srcdir}/${file} ${link} 2>/dev/null || ${hard_link} ${srcdir}/${file} ${link}
527 if [ ! -r ${link} ] ; then
528 echo '***' "${progname}: unable to link \"${link}\" to \"${srcdir}/${file}\"." 1>&2
534 *) echo "Linked \"${link}\" to \"${srcdir}/${file}\"." ;;
538 # Create a .gdbinit file which runs the one in srcdir
539 # and tells GDB to look there for source files.
541 if [ -r ${srcdir}/${subdir}/.gdbinit
] ; then
545 *) cat > ${subdir}/.gdbinit
<<EOF
549 source ${makesrcdir}/.gdbinit
555 # Install a makefile, and make it set VPATH
556 # if necessary so that the sources are found.
557 # Also change its value of srcdir.
558 # NOTE: Makefile generation constitutes the majority of the time in configure. Hence, this section has
559 # been somewhat optimized and is perhaps a bit twisty.
561 # code is order so as to try to sed the smallest input files we know.
563 # the three makefile fragments MUST end up in the resulting Makefile in this order: target, host, and site.
564 # so do these separately because I don't trust the order of sed -e expressions.
566 # Conditionalize for this site from "Makefile.in" (or whatever it's called) into Makefile.tem
569 "") cp ${srcdir}/${subdir}/${Makefile_in} ${subdir}/Makefile.tem
;;
571 site_makefile_frag
=${srcdir}/config
/ms-
${site}
573 if [ -f ${site_makefile_frag} ] ; then
574 sed -e "/^####/ r ${site_makefile_frag}" ${srcdir}/${subdir}/${Makefile_in} \
575 > ${subdir}/Makefile.tem
577 cp ${srcdir}/${subdir}/${Makefile_in} ${subdir}/Makefile.tem
582 # working copy now in ${subdir}/Makefile.tem
584 # Conditionalize the makefile for this host.
586 case "${host_makefile_frag}" in
587 "") mv ${subdir}/Makefile.tem ${Makefile} ;;
589 if [ ! -f ${host_makefile_frag} ] ; then
590 host_makefile_frag=${srcdir}/${host_makefile_frag}
592 if [ -f ${host_makefile_frag} ] ; then
593 sed -e "/^
####/ r ${host_makefile_frag}" ${subdir}/Makefile.tem > ${Makefile}
595 echo '***' Expected
host makefile fragment
\"${host_makefile_frag}\" 1>&2
596 echo '***' is missing
in ${PWD}.
1>&2
597 mv ${subdir}/Makefile.tem
${Makefile}
600 # working copy now in ${Makefile}
602 # Conditionalize the makefile for this target.
604 case "${target_makefile_frag}" in
605 "") mv ${Makefile} ${subdir}/Makefile.tem
;;
607 target_makefile_frag
=${srcdir}/${target_makefile_frag}
608 if [ -f ${target_makefile_frag} ] ; then
609 sed -e "/^####/ r ${target_makefile_frag}" ${Makefile} > ${subdir}/Makefile.tem
611 mv ${Makefile} ${subdir}/Makefile.tem
612 target_makefile_frag=
616 # real copy now in ${subdir}/Makefile.tem
618 # prepend warning about editting, and a bunch of variables.
620 cat > ${Makefile} <<EOF
622 VPATH = ${makesrcdir}
623 links = ${configlinks}
624 host_alias = ${host_alias}
625 host_cpu = ${host_cpu}
626 host_vendor = ${host_vendor}
628 target_alias = ${target_alias}
629 target_cpu = ${target_cpu}
630 target_vendor = ${target_vendor}
631 target_os = ${target_os}
633 if [ "${target_makefile_frag}" != "" ] ; then
634 echo target_makefile_frag = ${invsubdir}${target_makefile_frag} >>${Makefile}
636 if [ "${host_makefile_frag}" != "" ] ; then
637 echo host_makefile_frag = ${invsubdir}${host_makefile_frag} >>${Makefile}
639 if [ "${site_makefile_frag}" != "" ] ; then
640 echo site_makefile_frag = ${invsubdir}${site_makefile_frag} >>${Makefile}
643 # fixme: this shouldn't be in configure.
644 # Define macro CROSS_COMPILE in compilation if this is a cross-compiler.
645 case "${host_alias}" in
648 echo "ALL
=all.internal
" >> ${Makefile}
651 echo "CROSS
=-DCROSS_COMPILE" >> ${Makefile}
652 echo "ALL
=all.cross
" >> ${Makefile}
653 case "${program_prefix}" in
654 "") program_prefix=${target_alias}- ;;
658 tooldir="\$
(libdir
)/${target_alias}"
662 # reset prefix, exec_prefix, srcdir, SUBDIRS, NONSUBDIRS,
663 # remove any form feeds.
664 if [ -z "${subdirs}" ]; then
665 sed -e "s
:^SUBDIRS
[ ]*=.
*$
:SUBDIRS
= ${configdirs}:" \
666 -e "s
:^NONSUBDIRS
[ ]*=.
*$
:NONSUBDIRS
= ${noconfigdirs}:" \
667 ${subdir}/Makefile.tem > ${subdir}/Makefile.tem2
668 mv ${subdir}/Makefile.tem2 ${subdir}/Makefile.tem
670 sed -e "s
:^prefix
[ ]*=.
*$
:prefix
= ${prefix}:" \
671 -e "s
:^exec_prefix
[ ]*=.
*$
:exec_prefix
= ${exec_prefix}:" \
672 -e "s
:^srcdir
[ ]*=.
*$
:srcdir
= ${makesrcdir}:" \
674 -e "s
:^program_prefix
[ ]*=.
*$
:program_prefix
= ${program_prefix}:" \
675 -e "s
:^tooldir
[ ]*=.
*$
:tooldir
= ${tooldir}:" \
676 ${subdir}/Makefile.tem >> ${Makefile}
677 # final copy now in ${Makefile}
679 rm -f ${subdir}/Makefile.tem
681 if [ -n "${verbose}" -o -z "${silent}" ] ; then
682 case "${host_makefile_frag}" in
684 *) using="and
\"${host_makefile_frag}\"" ;;
687 case "${target_makefile_frag}" in
689 *) using="${using} and
\"${target_makefile_frag}\"" ;;
692 case "${site_makefile_frag}" in
694 *) using="${using} and
\"${site_makefile_frag}\"" ;;
697 newusing=`echo "${using}" | sed 's/and/using/'`
699 echo "Created
\"${Makefile}\" in" ${PWD} ${using}
704 # describe the chosen configuration in config.status.
705 # Make that file a shellscript which will reestablish
706 # the same configuration. Used in Makefiles to rebuild
709 case "${norecursion}" in
710 "") arguments
="${arguments} -norecursion" ;;
714 if [ ${subdir} = .
] ; then
717 # ${PWD} was configured as follows:
718 ${progname}" ${arguments} "
719 # ${using}" > ${subdir}/config.new
723 # ${PWD}/${subdir} was configured as follows:
725 ${progname}" ${arguments} "
726 # ${using}" > ${subdir}/config.new
728 chmod a
+x
${subdir}/config.new
729 if [ -r config.back
] ; then
730 mv -f ${subdir}/config.back
${subdir}/config.status
732 ${moveifchange} ${subdir}/config.new ${subdir}/config.status
735 *) rm -f ${Makefile} ${subdir}/config.status ${links} ;;
739 # If there are subdirectories, then recur.
740 if [ -z "${norecursion}" -a -n "${configdirs}" ] ; then
741 for configdir
in ${configdirs} ; do
744 *) echo Configuring
${configdir}...
;;
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 ${recprog} -s ${host_alias} -target=${target_alias} \
785 ${verbose} ${prefixoption} ${tmpdiroption} ${exec_prefixoption} \
786 ${srcdiroption} ${program_prefixoption} ${site_option} ${removing} ; then
796 *) echo Warning
: source directory
\"${srcdir}/${configdir}\" is missing.
;;
804 # trap cmd above handles this now:
805 #rm -f ${tmpfile}.com ${tmpfile}.tgt ${tmpfile}.hst ${tmpfile}.pos