4 # Copyright (C) 1988, 1990, 1991 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. */
24 # Please email any bugs, comments, and/or additions to this file to:
25 # configure@cygnus.com
28 # Shell script to create proper links to machine-dependent files in
29 # preparation for compilation.
31 # If configure succeeds, it leaves its status in config.status.
32 # If configure fails after disturbing the status quo,
33 # config.status is removed.
36 # NOTE: This script contains support for a Cygnus experimental feature, called
37 # +subdirs, which is currently, tentatively, de-supported.
39 export PATH || (echo "OOPS, this isn't sh. Desperation time. I will feed myself to sh."; sh $0 $argv; kill $$)
48 #symbolic_link="echo ln -s"
50 # clear some things potentially inherited from environment.
53 Makefile_in=Makefile.in
61 floating_point=default
91 NO_EDIT="This file was generated automatically by configure. Do not edit."
93 ## this is a little touchy and won't always work, but...
95 ## if the argv[0] starts with a slash then it is an absolute name that can be
98 ## otherwise, if argv[0] has no slash in it, we can assume that it is on the
99 ## path. Since PATH might include "." we also add `pwd` to the end of PATH.
101 ## otherwise we prepend `pwd` to $0 and hope that will give us an absolute
107 if (echo $0 | grep '^/' > /dev/null) ; then
109 elif (echo $0 | grep '/' > /dev/null) ; then
113 PATH=$PATH:${PWD} ; export PATH
118 # handle things that might have args following as separate words
119 if [ -n "${next_prefix}" ] ; then prefix=${arg} ; prefixoption="-prefix=${prefix}" ; next_prefix=
120 elif [ -n "${next_datadir}" ] ; then datadir=${arg} ; datadiroption="-datadir=${datadir}" ; next_datadir=
121 # elif [ -n "${next_namesubdir}" ] ; then \
122 # namesubdir=${arg} ; namesubdiroption="--namesubdir=${namesubdir}" ; next_namesubdir=
123 # elif [ -n "${next_objdir}" ] ; then objdir=${arg} ; objdiroption="--objdir=${objdir}" ; next_objdir=
124 elif [ -n "${next_site}" ] ; then site=${arg} ; next_site=
125 elif [ -n "${next_srcdir}" ] ; then srcdir=${arg} ; next_srcdir=
126 elif [ -n "${next_target}" ] ; then
128 if [ -z "${targets}" ] ; then
129 newtargets="${targets} ${arg}"
130 targets="${newtargets}"
132 echo '***' Can only configure for one target at a time.
135 elif [ -n "${next_tmpdir}" ] ; then
137 tmpdiroption="--tmpdir=${arg}"
142 -datadir=* | --datadir=* | --datadi=* | --datad=* | --data=* | --dat=* | --da=* | --d=*)
143 datadir=`echo ${arg} | sed 's/^[-a-z]*=//'`
146 -datadir | --datadir | --datadi | --datad | --data | --dat | --da | --d)
155 -host=* | --host=* | --hos=* | --ho=*)
156 # if [ -n "${hosts}" ] ; then
157 # subdirs="--subdirs"
160 if [ -z "${hosts}" ] ; then
161 newhosts="${hosts} `echo ${arg} | sed 's/^[-a-z]*=//'`"
164 echo '***' Can only configure for one host at a time.
168 # -namesubdir | --namesubdir | --namesubdi | --namesubd | --namesub | --namesu | --names | --name | --nam | --na)
169 # next_namesubdir=yes
171 # -namesubdir=* | --namesubdir=* | --namesubdi=* | --namesubd=* | --namesub=* | --namesu=* | --names=* | --name=* | --nam=* | --na=*)
172 # namesubdir=`echo ${arg} | sed 's/^[-a-z]*=//'`
173 # namesubdiroption=${arg}
178 -norecursion | --no*)
181 # -objdir=* | --objdir=* | --objdi=* | --objd=* | --obj=* | --ob=* | --o=*)
182 # objdiroption=${arg}
183 # objdir=`echo ${arg} | sed 's/^[-a-z]*=//'`
185 # -objdir | --objdir | --objdi | --objd | --obj | --ob | --o)
188 -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*)
189 prefix=`echo ${arg} | sed 's/^[-a-z]*=//'`
192 -prefix | --prefix | --prefi | --pref | --pre | --pr | --p)
195 -recurring | --recurring | --recurrin | --recurri | --recurr | --recur | --recu | --rec | --re)
197 arguments=`echo ${arguments} | sed "s:${arg}::"`
202 -site=* | --site=* | --sit=* | --si=*)
203 site=`echo ${arg} | sed 's/^[-a-z]*=//'`
205 -site | --site | --sit | --si)
208 -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*)
209 srcdir=`echo ${arg} | sed 's/^[-a-z]*=//'`
211 -srcdir | --srcdir | --srcdi | --srcd | --src | --sr)
217 -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=*)
218 # if [ -n "${targets}" ] ; then
219 # subdirs="--subdirs"
222 if [ -z "${targets}" ] ; then
223 newtargets="${targets} `echo ${arg} | sed 's/^[-a-z]*=//'`"
224 targets="${newtargets}"
226 echo '***' Can only configure for one target at a time.
230 -target | --target | --targe | --targ | --tar | --ta)
233 -tmpdir=* | --tmpdir=* | --tmpdi=* | --tmpd=* | --tmp=* | --tm=*)
235 TMPDIR=`echo ${arg} | sed 's/^[-a-z]*=//'`
237 -tmpdir | --tmpdir | --tmpdi | --tmpd | --tmp | --tm)
243 -version | -V | --version | --V)
244 echo "This is Cygnus Configure version" `echo ${version} | sed 's/[ $:]//g'`
250 echo "Unrecognized option: \"${arg}\"". ;
255 # if [ -n "${hosts}" ] ; then
256 # subdirs="--subdirs"
259 if [ -z "${undefs}" ] ; then
260 newundefs="${undefs} ${arg}"
263 echo '***' Can only configure for one host and one target at a time.
271 # process host and target
272 if [ -z "${fatal}" ] ; then
273 # # Complain if an arg is missing
274 # if [ -z "${hosts}" ] ; then
276 # echo "configure: No HOST specified." ;
281 ### This is a bit twisted.
282 ### * if all three are specified, this is an error.
283 ### * if we have neither hosts, nor unadorned args, this is an error.
284 ### * if no hosts are specified, then the unadorned args are hosts, but if
285 ### there were none, this is an error.
286 ### * if no targets are specified, then the unadorned args are targets, but if
287 ### there were no unadorned args, then the hosts are also targets.
289 if [ -n "${hosts}" -a -n "${targets}" -a -n "${undefs}" ] ; then
290 echo '***' Can only configure for one host and one target at a time.
292 elif [ -z "${hosts}" -a -z "${undefs}" ] ; then
293 echo '***' You must tell me for which host you want to configure.
296 if [ -z "${hosts}" ] ; then
300 if [ -z "${targets}" ] ; then
301 if [ -n "${undefs}" ] ; then
310 if [ -n "${fatal}" -o "${hosts}" = "help" ] ; then
311 (echo "Usage: configure HOST" ;
313 echo "Options: [defaults in brackets]" ;
314 echo " -datadir=MYDIR configure for installation of host dependent files into MYDIR. [\"/usr/local\"]" ;
315 echo " -gas configure the compilers for use with gas. [native as]" ;
316 echo " -help print this message. [normal config]" ;
317 echo " -lang=LANG configure to build LANG. [gcc]" ;
318 echo " -nfp configure the compilers default to soft floating point. [hard float]" ;
319 echo " -norecursion configure this directory only. [recurse]" ;
320 # echo " -objdir=ODIR configure in a parallel tree rooted in ODIR. [rooted in \".\"]" ;
321 echo " -prefix=MYDIR configure for installation of host dependent files into MYDIR. [\"/usr/local\"]" ;
322 echo " -rm remove this configuration. [build a configuration]" ;
323 echo " -site configure with site specific makefile" ;
324 echo " -srcdir=DIR find the sources in DIR. [\".\" or \"..\"]" ;
325 # This is correctly aligned in the output, even though it isn't here.
326 # echo " -subdirs configure in subdirectories. [in source directories]" ;
327 echo " -target=TARGET configure for TARGET. [TARGET = HOST]" ;
328 echo " -tmpdir=TMPDIR create temporary files in TMPDIR. [ TMPDIR = \"/tmp\" ]" ;
330 echo "Where HOST and TARGET are something like \"vax\", \"sun3\", \"encore\", etc." ;
331 # echo "Asking for more than one \"--target\" implies \"--subdirs\". Any other" ;
332 # echo "options given will apply to all targets."
335 if [ -r config.status ] ; then
342 configsub=`echo ${progname} | sed 's/configure$/config.sub/'`
344 if (${configsub} `echo ${hosts} | sed -e 's/ .*//'`) >/dev/null 2>&1 ; then
347 echo '***' cannot find config.sub.
351 if [ -z "${srcdir}" ] ; then
352 if [ -r configure.in ] ; then
355 echo '***' "Can't find configure.in. Try using -srcdir=some_dir"
361 ### break up ${srcdir}/configure.in.
362 if [ -z "`grep '^# per\-host:' ${srcdir}/configure.in`" ] ; then
363 echo '***' ${srcdir}/configure.in has no "per-host:" line. 1>&2
367 if [ -z "`grep '^# per\-target:' ${srcdir}/configure.in`" ] ; then
368 echo '***' ${srcdir}/configure.in has no "per-target:" line. 1>&2
372 if [ -z "${TMPDIR}" ] ; then
373 TMPDIR=/tmp ; export TMPDIR
376 # keep this filename short for &%*%$*# 14 char file names
377 tmpfile=${TMPDIR}/cONf$$
378 trap "rm -f ${tmpfile}.com ${tmpfile}.tgt ${tmpfile}.hst ${tmpfile}.pos" 0
380 # split ${srcdir}/configure.in into common, per-host, per-target,
381 # and post-target parts. Post-target is optional.
382 sed -e '/^# per\-host:/,$d' ${srcdir}/configure.in > ${tmpfile}.com
383 sed -e '1,/^# per\-host:/d' -e '/^# per\-target:/,$d' ${srcdir}/configure.in > ${tmpfile}.hst
384 if grep '^# post-target:' ${srcdir}/configure.in >/dev/null ; then
385 sed -e '1,/^# per\-target:/d' -e '/^# post\-target:/,$d' ${srcdir}/configure.in > ${tmpfile}.tgt
386 sed -e '1,/^# post\-target:/d' ${srcdir}/configure.in > ${tmpfile}.pos
388 sed -e '1,/^# per\-target:/d' ${srcdir}/configure.in > ${tmpfile}.tgt
392 ### do common part of configure.in
396 # some sanity checks on configure.in
397 if [ -z "${srctrigger}" ] ; then
398 echo '***' srctrigger not set in ${PWD}/configure.in.
402 for host in ${hosts} ; do
404 if [ -z "${targets}" -o -n "${defaulttargets}" ] ; then
411 result=`${configsub} ${host}`
412 host_cpu=`echo $result | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\1/'`
413 host_vendor=`echo $result | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\2/'`
414 host_os=`echo $result | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\3/'`
415 host=${host_cpu}-${host_vendor}-${host_os}
416 host_makefile_frag=config/mh-${host}
417 if [ ! -f ${host_makefile_frag} ]
419 host_makefile_frag=config/mh-${host_alias}
424 for target in ${targets} ; do
426 target_alias=${target}
427 result=`${configsub} ${target}`
428 target_cpu=`echo $result | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\1/'`
429 target_vendor=`echo $result | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\2/'`
430 target_os=`echo $result | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\3/'`
431 target=${target_cpu}-${target_vendor}-${target_os}
432 target_makefile_frag=config/mt-${target}
433 if [ ! -f ${target_makefile_frag} ]
435 target_makefile_frag=config/mt-${target_alias}
440 if [ "${host_alias}" = "${target_alias}" ] ; then
441 subdirname=H-${host_alias}
443 subdirname=X-${host_alias}-${target_alias}
446 if [ -n "${namesubdir}" ] ; then
447 subdirname=${namesubdir}
450 if [ -n "${removing}" ] ; then
451 # if [ -n "${objdir}" ] ; then
452 # echo '***' --rm not supported for --objdir. Just \"rm -rf ${objdir}\" by hand.
456 # if [ -n "${subdirs}" ] ; then
457 # if [ -d "${subdirname}" ] ; then
458 # rm -rf ${hostsubdir}
460 # echo Warning: no ${PWD}/${hostsubdir} to remove.
463 rm -f ${Makefile} config.status ${links}
466 # if [ -n "${objdir}" ]; then
471 # if [ -n "${subdirs}" ] ; then
472 # # check for existing status before allowing forced subdirs.
473 # if [ -f ${Makefile} ] ; then
474 # echo '***' "${Makefile} already exists in source directory. ${PWD} not configured." 1>&2
478 # # use a subdir common to all targets for this host iff: this is a cross AND
479 # # this tool does not claim to be target dependent AND we have not been asked to name the subdir.
480 # if [ ${host_alias} != ${target_alias} -a -z "${target_dependent}" -a -z "${namesubdiroption}" ]
482 # if [ ! -d H-${host_alias} ] ; then mkdir H-${host_alias} ; fi
484 # if (${symbolic_link} ${subdirname} H-${host_alias} 2> /dev/null) ; then
486 # else # just give up. they lose.
487 # rmdir H-${host_alias}
488 # if [ ! -d ${subdirname} ] ; then mkdir ${subdirname} ; fi
490 # elif [ ! -d ${subdirname} ] ; then
491 # mkdir ${subdirname}
496 # if [ -z "${srcdir}" ] ; then
499 # elif [ "`echo H-*`" != "H-*" -a "`echo X-*`" != "X-*" ] ; then
500 # # if not subdir builds, then make sure none exist.
501 # # We might miss if there are explicitly named subdirs.
502 # echo '***' "Configured subdirs exist. ${PWD} not configured." 1>&2
508 # Find the source files, if location was not specified.
509 if [ -z "${srcdir}" ] ; then
512 if [ ! -r ${srctrigger} ] ; then
517 if [ ! -r ${srcdir}/${srctrigger} ] ; then
518 if [ -z "${srcdirdefaulted}" ] ; then
519 echo '***' "${progname}: Can't find ${srcname} sources in ${PWD}/${srcdir}" 1>&2
521 echo '***' "${progname}: Can't find ${srcname} sources in ${PWD}/. or ${PWD}/.." 1>&2
524 echo '***' \(At least ${srctrigger} is missing.\) 1>&2
528 # Set up the list of links to be made.
529 # ${links} is the list of link names, and ${files} is the list of names to link to.
532 while [ -n "${files}" ] ; do
533 # set file to car of files, files to cdr of files
534 set ${files}; file=$1; shift; files=$*
535 set ${links}; link=$1; shift; links=$*
537 if [ ! -r ${srcdir}/${file} ] ; then
538 echo '***' "${progname}: cannot create a link \"${link}\"," 1>&2
539 echo '***' "since the file \"${file}\" does not exist." 1>&2
545 # Make a symlink if possible, otherwise try a hard link
546 ${symbolic_link} ${srcdir}/${file} ${link} 2>/dev/null || ${hard_link} ${srcdir}/${file} ${link}
548 if [ ! -r ${link} ] ; then
549 echo '***' "${progname}: unable to link \"${link}\" to \"${srcdir}/${file}\"." 1>&2
553 if [ -n "${verbose}" ] ; then
554 echo "Linked \"${link}\" to \"${srcdir}/${file}\"."
558 # Create a .gdbinit file which runs the one in srcdir
559 # and tells GDB to look there for source files.
561 if [ -r ${srcdir}/.gdbinit ] ; then
566 echo "# "${NO_EDIT} > .gdbinit
567 echo "dir ." >> .gdbinit
568 echo "dir ${srcdir}" >> .gdbinit
569 echo "source ${srcdir}/.gdbinit" >> .gdbinit
574 # Install a makefile, and make it set VPATH
575 # if necessary so that the sources are found.
576 # Also change its value of srcdir.
578 # FIXME-someday: This business of always writing to .tem and mv back
579 # is so that I don't screw things up while developing. Once this
580 # template is stable, these should be optimized. xoxorich.
582 # Define macro CROSS_COMPILE in compilation if this is a cross-compiler.
583 if [ "${host}" != "${target}" ] ; then
584 echo "CROSS=-DCROSS_COMPILE" > ${Makefile}
585 echo "ALL=all.cross" >> ${Makefile}
587 echo "ALL=all.internal" > ${Makefile}
590 # set target, host, VPATH
591 echo "host_alias = ${host_alias}" >> ${Makefile}
592 echo "host_cpu = ${host_cpu}" >> ${Makefile}
593 echo "host_vendor = ${host_vendor}" >> ${Makefile}
594 echo "host_os = ${host_os}" >> ${Makefile}
596 echo "target_alias = ${target_alias}" >> ${Makefile}
597 echo "target_cpu = ${target_cpu}" >> ${Makefile}
598 echo "target_vendor = ${target_vendor}" >> ${Makefile}
599 echo "target_os = ${target_os}" >> ${Makefile}
601 # if [ -n "${subdirs}" ] ; then
602 # (echo "subdir = /${subdirname}" ;
603 # echo "unsubdir = ..") >> ${Makefile}
606 echo "unsubdir = .") >> ${Makefile}
609 # echo "workdir = ${PWD}" >> ${Makefile}
610 echo "VPATH = ${srcdir}" >> ${Makefile}
612 # add "Makefile.in" (or whatever it's called)
613 cat ${srcdir}/${Makefile_in} >> ${Makefile}
615 # Conditionalize the makefile for this site.
616 if [ -n "${site}" ] ; then
617 site_makefile_frag=config/ms-${site}
619 if [ -f ${srcdir}/${site_makefile_frag} ] ; then
620 (echo "site_makefile_frag = ${srcdir}/${site_makefile_frag}" ;
621 sed -e "/^####/ r ${srcdir}/${site_makefile_frag}" ${Makefile}) > Makefile.tem
623 (echo "site_makefile_frag =" ;
624 cat ${Makefile}) > Makefile.tem
626 mv Makefile.tem ${Makefile}
629 # Conditionalize the makefile for this host.
630 if [ -f ${srcdir}/${host_makefile_frag} ] ; then
631 (echo "host_makefile_frag = ${srcdir}/${host_makefile_frag}" ;
632 sed -e "/^####/ r ${srcdir}/${host_makefile_frag}" ${Makefile}) > Makefile.tem
634 (echo "host_makefile_frag =" ;
635 cat ${Makefile}) > Makefile.tem
637 mv Makefile.tem ${Makefile}
639 # Conditionalize the makefile for this target.
640 if [ -f ${srcdir}/${target_makefile_frag} ] ; then
641 (echo "target_makefile_frag = ${srcdir}/${target_makefile_frag}" ;
642 sed -e "/^####/ r ${srcdir}/${target_makefile_frag}" ${Makefile}) > Makefile.tem
644 (echo "target_makefile_frag =" ;
645 cat ${Makefile}) > Makefile.tem
647 mv Makefile.tem ${Makefile}
650 sed "s:^srcdir[ ]*=.*$:srcdir = ${srcdir}:" ${Makefile} > Makefile.tem
651 mv Makefile.tem ${Makefile}
654 if [ -n "${prefix}" ] ; then
655 sed "s:^prefix[ ]*=.*$:prefix = ${prefix}:" ${Makefile} > Makefile.tem
656 mv Makefile.tem ${Makefile}
660 if [ -n "${datadir}" ] ; then
661 sed "s:^datadir[ ]*=.*$:datadir = ${datadir}:" ${Makefile} > Makefile.tem
662 mv Makefile.tem ${Makefile}
666 sed "s:^SUBDIRS[ ]*=.*$:SUBDIRS = ${configdirs}:" ${Makefile} > Makefile.tem
667 mv Makefile.tem ${Makefile}
670 sed "s:^NONSUBDIRS[ ]*=.*$:NONSUBDIRS = ${noconfigdirs}:" ${Makefile} > Makefile.tem
671 mv Makefile.tem ${Makefile}
673 # remove any form feeds.
674 sed -e "s/
\f//" ${Makefile} > Makefile.tem
675 mv Makefile.tem ${Makefile}
677 # prepend warning about editting.
678 echo "# "${NO_EDIT} > ${Makefile}.tem
679 cat ${Makefile} >> ${Makefile}.tem
680 mv Makefile.tem ${Makefile}
683 if [ -f ${srcdir}/${host_makefile_frag} ] ; then
684 using="${using} and \"${host_makefile_frag}\""
686 if [ -f ${srcdir}/${target_makefile_frag} ] ; then
687 using="${using} and \"${target_makefile_frag}\""
689 if [ -n "${site}" -a \
690 -f ${srcdir}/${site_makefile_frag} ] ; then
691 using="${using} and \"${site_makefile_frag}\""
693 using=`echo "${using}" | sed 's/and/using/'`
694 using="Created \"${Makefile}\" in ${PWD}${using}."
696 if [ -n "${verbose}" -o -z "${recurring}" ] ; then
702 # describe the chosen configuration in config.status.
703 # Make that file a shellscript which will reestablish
704 # the same configuration. Used in Makefiles to rebuild
707 if [ -z "${norecursion}" ] ; then
708 arguments="${arguments} -norecursion"
713 # ${PWD} was configured as follows:
714 ${progname}" ${arguments} "
715 # ${using}" > config.status
716 chmod a+x config.status
722 # If there are subdirectories, then recur.
723 if [ -z "${norecursion}" -a -n "${configdirs}" ] ; then
724 for configdir in ${configdirs} ; do
725 if [ -n "${verbose}" ] ; then
726 echo Configuring ${configdir}...
729 if [ -d ${srcdir}/${configdir} ] ; then
730 if [ "${srcdir}" != "." ] ; then
731 if [ ! -d ./${configdir} ] ; then
739 ### figure out what to do with srcdir
741 ".") ;; # do nothing. We're building in place.
742 /*) srcdiroption="-srcdir=${srcdir}/${configdir}" ;; # absolute path
743 *) srcdiroption="-srcdir=../${srcdir}/${configdir}" ;; # otherwise relative
746 ### The recursion line is here.
747 if [ -x configure ] ; then
748 recprog=`pwd`/configure
753 if (${recprog} -recurring ${host_alias} -target=${target_alias} \
754 ${verbose} ${subdirs} ${removing} ${prefixoption} \
755 ${tmpdiroption} ${namesubdiroption} ${datadiroption} \
756 ${srcdiroption}) ; then
763 elif [ -n "${verbose}" ] ; then
764 echo Warning: source directory \"${srcdir}/${configdir}\" is missing.
768 done # for each target
770 # Now build a Makefile for this host.
771 # if [ -n "${subdirs}" -a ! -n "${removing}" ] ; then
774 # if [ -n "${objdir}" ] ; then
779 # cat > GNUmakefile << 'E!O!F'
780 ## Makefile generated by configure for host ${host_alias}.
782 #ALL := $(shell ls -d T-*)
785 # $(foreach subdir,$(ALL),$(MAKE) -C $(subdir) \$@ &&) true
795 # trap cmd above handles this now:
796 #rm -f ${tmpfile}.com ${tmpfile}.tgt ${tmpfile}.hst ${tmpfile}.pos