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 # or maybe grab from gcc/version.c
95 NO_EDIT="This file was generated automatically by configure. Do not edit."
97 ## this is a little touchy and won't always work, but...
99 ## if the argv[0] starts with a slash then it is an absolute name that can be
102 ## otherwise, if argv[0] has no slash in it, we can assume that it is on the
103 ## path. Since PATH might include "." we also add `pwd` to the end of PATH.
105 ## otherwise we prepend `pwd` to $0 and hope that will give us an absolute
111 if (echo $0 | grep '^/' > /dev/null) ; then
113 elif (echo $0 | grep '/' > /dev/null) ; then
117 PATH=$PATH:${PWD} ; export PATH
122 # handle things that might have args following as separate words
123 if [ -n "${next_prefix}" ] ; then prefix=${arg} ; prefixoption="-prefix=${prefix}" ; next_prefix=
124 elif [ -n "${next_datadir}" ] ; then datadir=${arg} ; datadiroption="-datadir=${datadir}" ; next_datadir=
125 # elif [ -n "${next_namesubdir}" ] ; then \
126 # namesubdir=${arg} ; namesubdiroption="--namesubdir=${namesubdir}" ; next_namesubdir=
127 # elif [ -n "${next_objdir}" ] ; then objdir=${arg} ; objdiroption="--objdir=${objdir}" ; next_objdir=
128 elif [ -n "${next_version_path}" ] ; then version_path=${arg} ; next_version_path=
129 elif [ -n "${next_site}" ] ; then site=${arg} ; next_site=
130 elif [ -n "${next_srcdir}" ] ; then srcdir=${arg} ; next_srcdir=
131 elif [ -n "${next_target}" ] ; then
133 if [ -z "${targets}" ] ; then
134 newtargets="${targets} ${arg}"
135 targets="${newtargets}"
137 echo '***' Can only configure for one target at a time.
140 elif [ -n "${next_tmpdir}" ] ; then
142 tmpdiroption="--tmpdir=${arg}"
147 -datadir=* | --datadir=* | --datadi=* | --datad=* | --data=* | --dat=* | --da=* | --d=*)
148 datadir=`echo ${arg} | sed 's/^[-a-z]*=//'`
151 -datadir | --datadir | --datadi | --datad | --data | --dat | --da | --d)
160 -host=* | --host=* | --hos=* | --ho=*)
161 # if [ -n "${hosts}" ] ; then
162 # subdirs="--subdirs"
165 if [ -z "${hosts}" ] ; then
166 newhosts="${hosts} `echo ${arg} | sed 's/^[-a-z]*=//'`"
169 echo '***' Can only configure for one host at a time.
173 # -namesubdir | --namesubdir | --namesubdi | --namesubd | --namesub | --namesu | --names | --name | --nam | --na)
174 # next_namesubdir=yes
176 # -namesubdir=* | --namesubdir=* | --namesubdi=* | --namesubd=* | --namesub=* | --namesu=* | --names=* | --name=* | --nam=* | --na=*)
177 # namesubdir=`echo ${arg} | sed 's/^[-a-z]*=//'`
178 # namesubdiroption=${arg}
183 -norecursion | --no*)
186 # -objdir=* | --objdir=* | --objdi=* | --objd=* | --obj=* | --ob=* | --o=*)
187 # objdiroption=${arg}
188 # objdir=`echo ${arg} | sed 's/^[-a-z]*=//'`
190 # -objdir | --objdir | --objdi | --objd | --obj | --ob | --o)
193 -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*)
194 prefix=`echo ${arg} | sed 's/^[-a-z]*=//'`
197 -prefix | --prefix | --prefi | --pref | --pre | --pr | --p)
200 -recurring | --recurring | --recurrin | --recurri | --recurr | --recur | --recu | --rec | --re)
202 arguments=`echo ${arguments} | sed "s:${arg}::"`
207 -site=* | --site=* | --sit=* | --si=*)
208 site=`echo ${arg} | sed 's/^[-a-z]*=//'`
210 -site | --site | --sit | --si)
213 -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*)
214 srcdir=`echo ${arg} | sed 's/^[-a-z]*=//'`
216 -srcdir | --srcdir | --srcdi | --srcd | --src | --sr)
222 -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=*)
223 # if [ -n "${targets}" ] ; then
224 # subdirs="--subdirs"
227 if [ -z "${targets}" ] ; then
228 newtargets="${targets} `echo ${arg} | sed 's/^[-a-z]*=//'`"
229 targets="${newtargets}"
231 echo '***' Can only configure for one target at a time.
235 -target | --target | --targe | --targ | --tar | --ta)
238 -tmpdir=* | --tmpdir=* | --tmpdi=* | --tmpd=* | --tmp=* | --tm=*)
240 TMPDIR=`echo ${arg} | sed 's/^[-a-z]*=//'`
242 -tmpdir | --tmpdir | --tmpdi | --tmpd | --tmp | --tm)
248 -version | -V | --version | --V)
249 echo "This is Cygnus Configure version" `echo ${version} | sed 's/[ $:]//g'`
255 echo "Unrecognized option: \"${arg}\"". ;
260 # if [ -n "${hosts}" ] ; then
261 # subdirs="--subdirs"
264 if [ -z "${undefs}" ] ; then
265 newundefs="${undefs} ${arg}"
268 echo '***' Can only configure for one host and one target at a time.
276 if [ -n "${verbose}" ] ; then
280 # process host and target
281 if [ -z "${fatal}" ] ; then
282 # # Complain if an arg is missing
283 # if [ -z "${hosts}" ] ; then
285 # echo "configure: No HOST specified." ;
290 ### This is a bit twisted.
291 ### * if all three are specified, this is an error.
292 ### * if we have neither hosts, nor unadorned args, this is an error.
293 ### * if no hosts are specified, then the unadorned args are hosts, but if
294 ### there were none, this is an error.
295 ### * if no targets are specified, then the unadorned args are targets, but if
296 ### there were no unadorned args, then the hosts are also targets.
298 if [ -n "${hosts}" -a -n "${targets}" -a -n "${undefs}" ] ; then
299 echo '***' Can only configure for one host and one target at a time.
301 elif [ -z "${hosts}" -a -z "${undefs}" ] ; then
302 echo '***' You must tell me for which host you want to configure.
305 if [ -z "${hosts}" ] ; then
309 if [ -z "${targets}" ] ; then
310 if [ -n "${undefs}" ] ; then
319 if [ -n "${fatal}" -o "${hosts}" = "help" ] ; then
320 (echo "Usage: configure HOST" ;
322 echo "Options: [defaults in brackets]" ;
323 echo " -datadir=MYDIR configure for installation of host dependent files into MYDIR. [\"/usr/local\"]" ;
324 echo " -gas configure the compilers for use with gas. [native as]" ;
325 echo " -help print this message. [normal config]" ;
326 echo " -lang=LANG configure to build LANG. [gcc]" ;
327 echo " -nfp configure the compilers default to soft floating point. [hard float]" ;
328 echo " -norecursion configure this directory only. [recurse]" ;
329 # echo " -objdir=ODIR configure in a parallel tree rooted in ODIR. [rooted in \".\"]" ;
330 echo " -prefix=MYDIR configure for installation of host dependent files into MYDIR. [\"/usr/local\"]" ;
331 echo " -rm remove this configuration. [build a configuration]" ;
332 echo " -site configure with site specific makefile" ;
333 echo " -srcdir=DIR find the sources in DIR. [\".\" or \"..\"]" ;
334 # This is correctly aligned in the output, even though it isn't here.
335 # echo " -subdirs configure in subdirectories. [in source directories]" ;
336 echo " -target=TARGET configure for TARGET. [TARGET = HOST]" ;
337 echo " -tmpdir=TMPDIR create temporary files in TMPDIR. [ TMPDIR = \"/tmp\" ]" ;
339 echo "Where HOST and TARGET are something like \"vax\", \"sun3\", \"encore\", etc." ;
340 # echo "Asking for more than one \"--target\" implies \"--subdirs\". Any other" ;
341 # echo "options given will apply to all targets."
344 if [ -r config.status ] ; then
351 configsub=`echo ${progname} | sed 's/configure$/config.sub/'`
353 if (${configsub} `echo ${hosts} | sed -e 's/ .*//'`) >/dev/null 2>&1 ; then
356 echo '***' cannot find config.sub.
360 if [ -z "${srcdir}" ] ; then
361 if [ -r configure.in ] ; then
363 elif [ -r ../configure.in ] ; then
366 echo '***' "Can't find configure.in. Try using -srcdir=some_dir"
372 ### break up ${srcdir}/configure.in.
373 if [ -z "`grep '^# per\-host:' ${srcdir}/configure.in`" ] ; then
374 echo '***' ${srcdir}/configure.in has no "per-host:" line. 1>&2
378 if [ -z "`grep '^# per\-target:' ${srcdir}/configure.in`" ] ; then
379 echo '***' ${srcdir}/configure.in has no "per-target:" line. 1>&2
383 if [ -z "${TMPDIR}" ] ; then
384 TMPDIR=/tmp ; export TMPDIR
387 # keep this filename short for &%*%$*# 14 char file names
388 tmpfile=${TMPDIR}/cONf$$
389 trap "rm -f ${tmpfile}.com ${tmpfile}.tgt ${tmpfile}.hst ${tmpfile}.pos" 0
391 # split ${srcdir}/configure.in into common, per-host, per-target,
392 # and post-target parts. Post-target is optional.
393 sed -e '/^# per\-host:/,$d' ${srcdir}/configure.in > ${tmpfile}.com
394 sed -e '1,/^# per\-host:/d' -e '/^# per\-target:/,$d' ${srcdir}/configure.in > ${tmpfile}.hst
395 if grep '^# post-target:' ${srcdir}/configure.in >/dev/null ; then
396 sed -e '1,/^# per\-target:/d' -e '/^# post\-target:/,$d' ${srcdir}/configure.in > ${tmpfile}.tgt
397 sed -e '1,/^# post\-target:/d' ${srcdir}/configure.in > ${tmpfile}.pos
399 sed -e '1,/^# per\-target:/d' ${srcdir}/configure.in > ${tmpfile}.tgt
403 ### do common part of configure.in
407 # some sanity checks on configure.in
408 if [ -z "${srctrigger}" ] ; then
409 echo '***' srctrigger not set in ${PWD}/configure.in.
413 for host in ${hosts} ; do
415 if [ -z "${targets}" -o -n "${defaulttargets}" ] ; then
422 result=`${configsub} ${host}`
423 host_cpu=`echo $result | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\1/'`
424 host_vendor=`echo $result | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\2/'`
425 host_os=`echo $result | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\3/'`
426 host=${host_cpu}-${host_vendor}-${host_os}
427 host_makefile_frag=config/mh-${host}
428 if [ ! -f ${host_makefile_frag} ]
430 host_makefile_frag=config/mh-${host_alias}
435 for target in ${targets} ; do
437 target_alias=${target}
438 result=`${configsub} ${target}`
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}
443 target_makefile_frag=config/mt-${target}
444 if [ ! -f ${target_makefile_frag} ]
446 target_makefile_frag=config/mt-${target_alias}
451 if [ "${host_alias}" = "${target_alias}" ] ; then
452 subdirname=H-${host_alias}
454 subdirname=X-${host_alias}-${target_alias}
457 if [ -n "${namesubdir}" ] ; then
458 subdirname=${namesubdir}
461 if [ -n "${removing}" ] ; then
462 # if [ -n "${objdir}" ] ; then
463 # echo '***' --rm not supported for --objdir. Just \"rm -rf ${objdir}\" by hand.
467 # if [ -n "${subdirs}" ] ; then
468 # if [ -d "${subdirname}" ] ; then
469 # rm -rf ${hostsubdir}
471 # echo Warning: no ${PWD}/${hostsubdir} to remove.
474 rm -f ${Makefile} config.status ${links}
477 # if [ -n "${objdir}" ]; then
482 # if [ -n "${subdirs}" ] ; then
483 # # check for existing status before allowing forced subdirs.
484 # if [ -f ${Makefile} ] ; then
485 # echo '***' "${Makefile} already exists in source directory. ${PWD} not configured." 1>&2
489 # # use a subdir common to all targets for this host iff: this is a cross AND
490 # # this tool does not claim to be target dependent AND we have not been asked to name the subdir.
491 # if [ ${host_alias} != ${target_alias} -a -z "${target_dependent}" -a -z "${namesubdiroption}" ]
493 # if [ ! -d H-${host_alias} ] ; then mkdir H-${host_alias} ; fi
495 # if (${symbolic_link} ${subdirname} H-${host_alias} 2> /dev/null) ; then
497 # else # just give up. they lose.
498 # rmdir H-${host_alias}
499 # if [ ! -d ${subdirname} ] ; then mkdir ${subdirname} ; fi
501 # elif [ ! -d ${subdirname} ] ; then
502 # mkdir ${subdirname}
507 # if [ -z "${srcdir}" ] ; then
510 # elif [ "`echo H-*`" != "H-*" -a "`echo X-*`" != "X-*" ] ; then
511 # # if not subdir builds, then make sure none exist.
512 # # We might miss if there are explicitly named subdirs.
513 # echo '***' "Configured subdirs exist. ${PWD} not configured." 1>&2
519 # Find the source files, if location was not specified.
520 if [ -z "${srcdir}" ] ; then
523 if [ ! -r ${srctrigger} ] ; then
528 if [ ! -r ${srcdir}/${srctrigger} ] ; then
529 if [ -z "${srcdirdefaulted}" ] ; then
530 echo '***' "${progname}: Can't find ${srcname} sources in ${PWD}/${srcdir}" 1>&2
532 echo '***' "${progname}: Can't find ${srcname} sources in ${PWD}/. or ${PWD}/.." 1>&2
535 echo '***' \(At least ${srctrigger} is missing.\) 1>&2
539 # Set up the list of links to be made.
540 # ${links} is the list of link names, and ${files} is the list of names to link to.
543 while [ -n "${files}" ] ; do
544 # set file to car of files, files to cdr of files
545 set ${files}; file=$1; shift; files=$*
546 set ${links}; link=$1; shift; links=$*
548 if [ ! -r ${srcdir}/${file} ] ; then
549 echo '***' "${progname}: cannot create a link \"${link}\"," 1>&2
550 echo '***' "since the file \"${file}\" does not exist." 1>&2
556 # Make a symlink if possible, otherwise try a hard link
557 ${symbolic_link} ${srcdir}/${file} ${link} 2>/dev/null || ${hard_link} ${srcdir}/${file} ${link}
559 if [ ! -r ${link} ] ; then
560 echo '***' "${progname}: unable to link \"${link}\" to \"${srcdir}/${file}\"." 1>&2
564 if [ -n "${verbose}" ] ; then
565 echo "Linked \"${link}\" to \"${srcdir}/${file}\"."
569 # Create a .gdbinit file which runs the one in srcdir
570 # and tells GDB to look there for source files.
572 if [ -r ${srcdir}/.gdbinit ] ; then
577 echo "# "${NO_EDIT} > .gdbinit
578 echo "dir ." >> .gdbinit
579 echo "dir ${srcdir}" >> .gdbinit
580 echo "source ${srcdir}/.gdbinit" >> .gdbinit
585 # Install a makefile, and make it set VPATH
586 # if necessary so that the sources are found.
587 # Also change its value of srcdir.
589 # FIXME-someday: This business of always writing to .tem and mv back
590 # is so that I don't screw things up while developing. Once this
591 # template is stable, these should be optimized. xoxorich.
593 # Define macro CROSS_COMPILE in compilation if this is a cross-compiler.
594 if [ "${host}" != "${target}" ] ; then
595 echo "CROSS=-DCROSS_COMPILE" > ${Makefile}
596 echo "ALL=all.cross" >> ${Makefile}
598 echo "ALL=all.internal" > ${Makefile}
601 # set target, host, VPATH
602 echo "host_alias = ${host_alias}" >> ${Makefile}
603 echo "host_cpu = ${host_cpu}" >> ${Makefile}
604 echo "host_vendor = ${host_vendor}" >> ${Makefile}
605 echo "host_os = ${host_os}" >> ${Makefile}
606 echo "version_path = ${version_path}" >> ${Makefile}
607 echo "target_alias = ${target_alias}" >> ${Makefile}
608 echo "target_cpu = ${target_cpu}" >> ${Makefile}
609 echo "target_vendor = ${target_vendor}" >> ${Makefile}
610 echo "target_os = ${target_os}" >> ${Makefile}
612 # if [ -n "${subdirs}" ] ; then
613 # (echo "subdir = /${subdirname}" ;
614 # echo "unsubdir = ..") >> ${Makefile}
617 echo "unsubdir = .") >> ${Makefile}
620 # echo "workdir = ${PWD}" >> ${Makefile}
621 echo "VPATH = ${srcdir}" >> ${Makefile}
623 # add "Makefile.in" (or whatever it's called)
624 cat ${srcdir}/${Makefile_in} >> ${Makefile}
626 # Conditionalize the makefile for this site.
627 if [ -n "${site}" ] ; then
628 site_makefile_frag=config/ms-${site}
630 if [ -f ${srcdir}/${site_makefile_frag} ] ; then
631 (echo "site_makefile_frag = ${srcdir}/${site_makefile_frag}" ;
632 sed -e "/^####/ r ${srcdir}/${site_makefile_frag}" ${Makefile}) > Makefile.tem
634 (echo "site_makefile_frag =" ;
635 cat ${Makefile}) > Makefile.tem
637 mv Makefile.tem ${Makefile}
640 # Conditionalize the makefile for this host.
641 if [ -f ${srcdir}/${host_makefile_frag} ] ; then
642 (echo "host_makefile_frag = ${srcdir}/${host_makefile_frag}" ;
643 sed -e "/^####/ r ${srcdir}/${host_makefile_frag}" ${Makefile}) > Makefile.tem
645 (echo "host_makefile_frag =" ;
646 cat ${Makefile}) > Makefile.tem
648 mv Makefile.tem ${Makefile}
650 # Conditionalize the makefile for this target.
651 if [ -f ${srcdir}/${target_makefile_frag} ] ; then
652 (echo "target_makefile_frag = ${srcdir}/${target_makefile_frag}" ;
653 sed -e "/^####/ r ${srcdir}/${target_makefile_frag}" ${Makefile}) > Makefile.tem
655 (echo "target_makefile_frag =" ;
656 cat ${Makefile}) > Makefile.tem
658 mv Makefile.tem ${Makefile}
661 sed "s@^srcdir[ ]*=.*$@srcdir = ${srcdir}@" ${Makefile} > Makefile.tem
662 mv Makefile.tem ${Makefile}
665 if [ -n "${prefix}" ] ; then
666 sed "s:^prefix[ ]*=.*$:prefix = ${prefix}:" ${Makefile} > Makefile.tem
667 mv Makefile.tem ${Makefile}
671 if [ -n "${datadir}" ] ; then
672 sed "s:^datadir[ ]*=.*$:datadir = ${datadir}:" ${Makefile} > Makefile.tem
673 mv Makefile.tem ${Makefile}
677 sed "s:^SUBDIRS[ ]*=.*$:SUBDIRS = ${configdirs}:" ${Makefile} > Makefile.tem
678 mv Makefile.tem ${Makefile}
681 sed "s:^NONSUBDIRS[ ]*=.*$:NONSUBDIRS = ${noconfigdirs}:" ${Makefile} > Makefile.tem
682 mv Makefile.tem ${Makefile}
684 # remove any form feeds.
685 sed -e "s/
\f//" ${Makefile} > Makefile.tem
686 mv Makefile.tem ${Makefile}
688 # prepend warning about editting.
689 echo "# "${NO_EDIT} > ${Makefile}.tem
690 cat ${Makefile} >> ${Makefile}.tem
691 mv Makefile.tem ${Makefile}
694 if [ -f ${srcdir}/${host_makefile_frag} ] ; then
695 using="${using} and \"${host_makefile_frag}\""
697 if [ -f ${srcdir}/${target_makefile_frag} ] ; then
698 using="${using} and \"${target_makefile_frag}\""
700 if [ -n "${site}" -a \
701 -f ${srcdir}/${site_makefile_frag} ] ; then
702 using="${using} and \"${site_makefile_frag}\""
704 using=`echo "${using}" | sed 's/and/using/'`
705 using="Created \"${Makefile}\" in ${PWD}${using}."
707 if [ -n "${verbose}" -o -z "${recurring}" ] ; then
713 # describe the chosen configuration in config.status.
714 # Make that file a shellscript which will reestablish
715 # the same configuration. Used in Makefiles to rebuild
718 if [ -z "${norecursion}" ] ; then
719 arguments="${arguments} -norecursion"
724 # ${PWD} was configured as follows:
725 ${progname}" ${arguments} "
726 # ${using}" > config.status
727 chmod a+x config.status
733 # If there are subdirectories, then recur.
734 if [ -z "${norecursion}" -a -n "${configdirs}" ] ; then
735 for configdir in ${configdirs} ; do
736 if [ -n "${verbose}" ] ; then
737 echo Configuring ${configdir}...
740 if [ -d ${srcdir}/${configdir} ] ; then
741 if [ "${srcdir}" != "." ] ; then
742 if [ ! -d ./${configdir} ] ; then
750 ### figure out what to do with srcdir
752 ".") ;; # do nothing. We're building in place.
753 /*) srcdiroption="-srcdir=${srcdir}/${configdir}" ;; # absolute path
754 *) srcdiroption="-srcdir=../${srcdir}/${configdir}" ;; # otherwise relative
757 ### The recursion line is here.
758 if (${progname} -recurring ${host_alias} -target=${target_alias} \
759 ${verbose} ${subdirs} ${removing} ${prefixoption} \
760 ${tmpdiroption} ${namesubdiroption} ${datadiroption} \
761 ${srcdiroption}) ; then
768 elif [ -n "${verbose}" ] ; then
769 echo Warning: source directory \"${srcdir}/${configdir}\" is missing.
773 done # for each target
775 # Now build a Makefile for this host.
776 # if [ -n "${subdirs}" -a ! -n "${removing}" ] ; then
779 # if [ -n "${objdir}" ] ; then
784 # cat > GNUmakefile << 'E!O!F'
785 ## Makefile generated by configure for host ${host_alias}.
787 #ALL := $(shell ls -d T-*)
790 # $(foreach subdir,$(ALL),$(MAKE) -C $(subdir) \$@ &&) true
800 # trap cmd above handles this now:
801 #rm -f ${tmpfile}.com ${tmpfile}.tgt ${tmpfile}.hst ${tmpfile}.pos