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:
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
68 program_prefix_option=
82 NO_EDIT="This file was generated automatically by configure. Do not edit."
84 ## this is a little touchy and won't always work, but...
86 ## if the argv[0] starts with a slash then it is an absolute name that can (and
87 ## must) be used as is.
89 ## otherwise, if argv[0] has no slash in it, we can assume that it is on the
90 ## path. Since PATH might include "." we also add `pwd` to the end of PATH.
100 PATH=$PATH:${PWD} ; export PATH
106 # handle things that might have args following as separate words
107 if [ -n "${next_prefix}" ] ; then prefix=${arg} ; prefixoption="-prefix=${prefix}" ; next_prefix=
108 elif [ -n "${next_exec_prefix}" ] ; then
110 exec_prefixoption="-exec_prefix=${exec_prefix}"
112 elif [ -n "${next_site}" ] ; then site=${arg} ; site_option=-site=${site} ; next_site=
113 # remove any possible trailing slash from srcdir. See note below.
114 elif [ -n "${next_srcdir}" ] ; then srcdir=`echo ${arg} | sed -e 's:/$::'` ; next_srcdir=
115 elif [ -n "${next_program_prefix}" ] ; then
116 program_prefix=${arg}
117 program_prefixoption="-program_prefix=${program_prefix}"
119 elif [ -n "${next_target}" ] ; then
121 case "${target_alias}" in
123 target_alias="${arg}"
126 echo '***' Can only configure for one target at a time. 1>&2
130 elif [ -n "${next_tmpdir}" ] ; then
132 tmpdiroption="--tmpdir=${arg}"
137 -exec_prefix=* | --exec_prefix=* | --exec_prefi=* | --exec_pref=* | --exec_pre=* | --exec_pr=* | --exec_p=* | --exec_=* | --exec=* | --exe=* | --ex=* | --e=*)
138 exec_prefix=`echo ${arg} | sed 's/^[-a-z_]*=//'`
139 exec_prefixoption=${arg}
141 -exec_prefix | --exec_prefix | --exec_prefi | --exec_pref | --exec_pre | --exec_pr | --exec_p | --exec_ | --exec | --exe | --ex | --e)
150 -host=* | --host=* | --hos=* | --ho=*)
151 case "${host_alias}" in
153 host_alias="`echo ${arg} | sed 's/^[-a-z]*=//'`"
156 echo '***' Can only configure for one host at a time. 1>&2
164 -norecursion | --no*)
167 -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=*)
168 prefix=`echo ${arg} | sed 's/^[-a-z]*=//'`
171 -prefix | --prefix | --prefi | --pref | --pre)
174 -program_prefix=* | --program_prefix=* | --program_prefi=* | --program_pref=* | --program_pre=* | --program_pr=* | --program_p=* | --program_=* | --program=* | --progra=* | --progr=* | --prog=* | --pro=*)
175 program_prefix=`echo ${arg} | sed 's/^[-a-z]*=//'`
176 program_prefixoption=${arg}
178 -program_prefix | --program_prefix | --program_prefi | --program_pref | --program_pre | --program_pr | --program_p | --program_ | --program | --progra | --progr | --prog | --pro)
179 next_program_prefix=yes
181 -s | -silent | --silent | --silen | --sile | --sil)
183 arguments=`echo ${arguments} | sed "s:${arg}::"`
185 -site=* | --site=* | --sit=* | --si=*)
187 site=`echo ${arg} | sed 's/^[-a-z]*=//'`
189 -site | --site | --sit)
192 # remove trailing slashes. Otherwise, when the file name gets
193 # bolted into an object file as debug info, it has two slashes in
194 # it. Ordinarily this is ok, but emacs takes double slash to
195 # mean "forget the first part".
196 -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*)
197 srcdir=`echo ${arg} | sed 's/^[-a-z]*=//' | sed -e 's:/$::'`
199 -srcdir | --srcdir | --srcdi | --srcd | --src | --sr)
202 -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=*)
203 case "${target_alias}" in
204 "") target_alias="`echo ${arg} | sed 's/^[-a-z]*=//'`" ;;
206 echo '***' Can only configure for one target at a time. 1>&2
211 -target | --target | --targe | --targ | --tar | --ta)
214 -tmpdir=* | --tmpdir=* | --tmpdi=* | --tmpd=* | --tmp=* | --tm=*)
216 TMPDIR=`echo ${arg} | sed 's/^[-a-z]*=//'`
218 -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/'`
324 if ${configsub} `echo ${host_alias} | sed -e 's/ .*//'` >/dev/null 2>&1 ; then
327 echo '***' cannot find config.sub. 1>&2
333 if [ -r configure.in ] ; then
336 if [ -r ${progname}.in ] ; then
337 srcdir=`echo ${progname} | sed 's:/configure$::'`
339 echo '***' "Can't find configure.in. Try using -srcdir=some_dir" 1>&2
347 ### warn about some conflicting configurations.
352 if [ -f ${srcdir}/config.status ] ; then
353 echo '***' Cannot configure here in \"${PWD}\" when \"${srcdir}\" is currently configured. 1>&2
358 # default exec_prefix
359 case "${exec_prefix}" in
360 "") exec_prefix="$(prefix)" ;;
364 ### break up ${srcdir}/configure.in.
365 case "`grep '^# per\-host:' ${srcdir}/configure.in`" in
367 echo '***' ${srcdir}/configure.in has no "per-host:" line. 1>&2
373 case "`grep '^# per\-target:' ${srcdir}/configure.in`" in
375 echo '***' ${srcdir}/configure.in has no "per-target:" line. 1>&2
382 "") TMPDIR=/tmp ; export TMPDIR ;;
386 # keep this filename short for &%*%$*# 14 char file names
387 tmpfile=${TMPDIR}/cONf$$
388 trap "rm -f ${tmpfile}.com ${tmpfile}.tgt ${tmpfile}.hst ${tmpfile}.pos" 0
390 # split ${srcdir}/configure.in into common, per-host, per-target,
391 # and post-target parts. Post-target is optional.
392 sed -e '/^# per\-host:/,$d' ${srcdir}/configure.in > ${tmpfile}.com
393 sed -e '1,/^# per\-host:/d' -e '/^# per\-target:/,$d' ${srcdir}/configure.in > ${tmpfile}.hst
394 if grep '^# post-target:' ${srcdir}/configure.in >/dev/null ; then
395 sed -e '1,/^# per\-target:/d' -e '/^# post\-target:/,$d' ${srcdir}/configure.in > ${tmpfile}.tgt
396 sed -e '1,/^# post\-target:/d' ${srcdir}/configure.in > ${tmpfile}.pos
398 sed -e '1,/^# per\-target:/d' ${srcdir}/configure.in > ${tmpfile}.tgt
402 ### do common part of configure.in
406 # some sanity checks on configure.in
407 case "${srctrigger}" in
409 echo '***' srctrigger not set in ${PWD}/configure.in. 1>&2
415 result=`${configsub} ${host_alias}`
416 host_cpu=`echo $result | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\1/'`
417 host_vendor=`echo $result | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\2/'`
418 host_os=`echo $result | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\3/'`
419 host=${host_cpu}-${host_vendor}-${host_os}
423 result=`${configsub} ${target_alias}`
424 target_cpu=`echo $result | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\1/'`
425 target_vendor=`echo $result | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\2/'`
426 target_os=`echo $result | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\3/'`
427 target=${target_cpu}-${target_vendor}-${target_os}
431 # Find the source files, if location was not specified.
436 if [ ! -r ${srctrigger} ] ; then
443 if [ ! -r ${srcdir}/${srctrigger} ] ; then
444 case "${srcdirdefaulted}" in
445 "") echo '***' "${progname}: Can't find ${srcname} sources in ${PWD}/${srcdir}" 1>&2 ;;
446 *) echo '***' "${progname}: Can't find ${srcname} sources in ${PWD}/. or ${PWD}/.." 1>&2 ;;
449 echo '***' \(At least ${srctrigger} is missing.\) 1>&2
453 # Set up the list of links to be made.
454 # ${links} is the list of link names, and ${files} is the list of names to link to.
457 configlinks="${links}"
458 while [ -n "${files}" ] ; do
459 # set file to car of files, files to cdr of files
460 set ${files}; file=$1; shift; files=$*
461 set ${links}; link=$1; shift; links=$*
463 if [ ! -r ${srcdir}/${file} ] ; then
464 echo '***' "${progname}: cannot create a link \"${link}\"," 1>&2
465 echo '***' "since the file \"${file}\" does not exist." 1>&2
471 # Make a symlink if possible, otherwise try a hard link
472 ${symbolic_link} ${srcdir}/${file} ${link} 2>/dev/null || ${hard_link} ${srcdir}/${file} ${link}
474 if [ ! -r ${link} ] ; then
475 echo '***' "${progname}: unable to link \"${link}\" to \"${srcdir}/${file}\"." 1>&2
481 *) echo "Linked \"${link}\" to \"${srcdir}/${file}\"." ;;
485 # Create a .gdbinit file which runs the one in srcdir
486 # and tells GDB to look there for source files.
488 if [ -r ${srcdir}/.gdbinit ] ; then
492 *) cat > .gdbinit <<EOF
493 # ${NO_EDIT} > .gdbinit
496 source ${srcdir}/.gdbinit
502 # Install a makefile, and make it set VPATH
503 # if necessary so that the sources are found.
504 # Also change its value of srcdir.
505 # NOTE: Makefile generation constitutes the majority of the time in configure. Hence, this section has
506 # been somewhat optimized and is perhaps a bit twisty.
508 # code is order so as to try to sed the smallest input files we know.
510 # the three makefile fragments MUST end up in the resulting Makefile in this order: target, host, and site.
511 # so do these separately because I don't trust the order of sed -e expressions.
513 # Conditionalize for this site from "Makefile.in" (or whatever it's called) into Makefile.tem
515 "") cp ${srcdir}/${Makefile_in} Makefile.tem ;;
517 site_makefile_frag=${srcdir}/config/ms-${site}
519 if [ -f ${site_makefile_frag} ] ; then
520 sed -e "/^####/ r ${site_makefile_frag}" ${srcdir}/${Makefile_in} \
523 cp ${srcdir}/${Makefile_in} Makefile.tem
528 # working copy now in Makefile.tem
530 # Conditionalize the makefile for this host.
531 case "${host_makefile_frag}" in
532 "") mv Makefile.tem ${Makefile} ;;
534 host_makefile_frag=${srcdir}/${host_makefile_frag}
535 if [ -f ${host_makefile_frag} ] ; then
536 sed -e "/^####/ r ${host_makefile_frag}" Makefile.tem > ${Makefile}
538 echo '***' Expected host makefile fragment \"${host_makefile_frag}\" 1>&2
539 echo '***' is missing in ${PWD}. 1>&2
540 mv Makefile.tem ${Makefile}
543 # working copy now in ${Makefile}
545 # Conditionalize the makefile for this target.
546 case "${target_makefile_frag}" in
547 "") mv ${Makefile} Makefile.tem ;;
549 target_makefile_frag=${srcdir}/${target_makefile_frag}
550 if [ -f ${target_makefile_frag} ] ; then
551 sed -e "/^####/ r ${target_makefile_frag}" ${Makefile} > Makefile.tem
553 mv ${Makefile} Makefile.tem
554 target_makefile_frag=
558 # real copy now in Makefile.tem
560 # prepend warning about editting, and a bunch of variables.
561 cat > ${Makefile} <<EOF
563 host_alias = ${host_alias}
564 host_cpu = ${host_cpu}
565 host_vendor = ${host_vendor}
567 target_alias = ${target_alias}
568 target_cpu = ${target_cpu}
569 target_vendor = ${target_vendor}
570 target_os = ${target_os}
571 target_makefile_frag = ${target_makefile_frag}
572 host_makefile_frag = ${host_makefile_frag}
573 site_makefile_frag = ${site_makefile_frag}
574 links = ${configlinks}
578 # fixme: this shouldn't be in configure.
579 # Define macro CROSS_COMPILE in compilation if this is a cross-compiler.
580 case "${host_alias}" in
583 echo "ALL=all.internal" >> ${Makefile}
586 echo "CROSS=-DCROSS_COMPILE" >> ${Makefile}
587 echo "ALL=all.cross" >> ${Makefile}
588 case "${program_prefix}" in
589 "") program_prefix=${target_alias}- ;;
593 tooldir="$(libdir)/${target_alias}"
597 # reset prefix, exec_prefix, srcdir, SUBDIRS, NONSUBDIRS, remove any form
599 sed -e "s:^prefix[ ]*=.*$:prefix = ${prefix}:" \
600 -e "s:^exec_prefix[ ]*=.*$:exec_prefix = ${exec_prefix}:" \
601 -e "s:^srcdir[ ]*=.*$:srcdir = ${srcdir}:" \
602 -e "s:^SUBDIRS[ ]*=.*$:SUBDIRS = ${configdirs}:" \
603 -e "s:^NONSUBDIRS[ ]*=.*$:NONSUBDIRS = ${noconfigdirs}:" \
605 -e "s:^program_prefix[ ]*=.*$:program_prefix = ${program_prefix}:" \
606 -e "s:^tooldir[ ]*=.*$:tooldir = ${tooldir}:" \
607 Makefile.tem >> ${Makefile}
608 # final copy now in ${Makefile}
612 if [ -n "${verbose}" -o -z "${silent}" ] ; then
613 case "${host_makefile_frag}" in
615 *) using="and \"${host_makefile_frag}\"" ;;
618 case "${target_makefile_frag}" in
620 *) using="${using} and \"${target_makefile_frag}\"" ;;
623 case "${site_makefile_frag}" in
625 *) using="${using} and \"${site_makefile_frag}\"" ;;
628 echo "Created \"${Makefile}\" in" ${PWD} `echo "${using}" | sed 's/and/using/'`
633 # describe the chosen configuration in config.status.
634 # Make that file a shellscript which will reestablish
635 # the same configuration. Used in Makefiles to rebuild
638 case "${norecursion}" in
639 "") arguments="${arguments} -norecursion" ;;
645 # ${PWD} was configured as follows:
646 ${progname}" ${arguments} "
647 # ${using}" > config.status
648 chmod a+x config.status
650 # If there are subdirectories, then recur.
651 if [ -z "${norecursion}" -a -n "${configdirs}" ] ; then
652 for configdir in ${configdirs} ; do
655 *) echo Configuring ${configdir}... ;;
658 if [ -d ${srcdir}/${configdir} ] ; then
662 if [ ! -d ./${configdir} ] ; then
671 ### figure out what to do with srcdir
673 ".") newsrcdir=${srcdir} ;; # no -srcdir option. We're building in place.
675 newsrcdir=${srcdir}/${configdir}
676 srcdiroption="-srcdir=${newsrcdir}"
678 *) # otherwise relative
679 newsrcdir=../${srcdir}/${configdir}
680 srcdiroption="-srcdir=${newsrcdir}"
684 ### check for guested configure, otherwise fix possibly relative progname
685 if [ -f ${newsrcdir}/configure ] ; then
686 recprog=${newsrcdir}/configure
688 case "${progname}" in
689 /*) recprog=${progname} ;;
690 *) recprog=../${progname} ;;
694 ### The recursion line is here.
695 if ${recprog} -s ${host_alias} -target=${target_alias} \
696 ${verbose} ${prefixoption} ${tmpdiroption} ${exec_prefixoption} \
697 ${srcdiroption} ${program_prefixoption} ${site_option} ; then
707 *) echo Warning: source directory \"${srcdir}/${configdir}\" is missing. ;;
715 # trap cmd above handles this now:
716 #rm -f ${tmpfile}.com ${tmpfile}.tgt ${tmpfile}.hst ${tmpfile}.pos