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. */
25 # Shell script to create proper links to machine-dependent files in
26 # preparation for compilation.
28 # If configure succeeds, it leaves its status in config.status.
29 # If configure fails after disturbing the status quo,
30 # config.status is removed.
40 #symbolic_link="echo ln -s"
44 # clear some things potentially inherited from environment.
52 Makefile_in
=Makefile.
in
73 -destdir=* |
+destdir
=* |
+destdi
=* |
+destd
=* |
+dest
=* |
+des
=* |
+de
=* |
+d
=*)
74 destdir
=`echo ${arg} | sed 's/[+-]d[a-z]*=//'`
76 -languages=* |
+languages
=* |
+language
=* |
+languag
=* \
77 |
+langua
=* |
+langu
=* |
+lang
=* |
+lan
=* |
+la
=* \
79 languages
="${languages} `echo ${arg} | sed 's/[+-]l[a-z]*=//'`"
93 -recurring |
+recurring |
+recurrin |
+recurri |
+recurr |
+recur |
+recu |
+rec |
+re
)
99 # -srcdir=* | +srcdir=* | +srcdi=* | +srcd=* | +src=* | +sr=* | +s=*)
100 # srcdir=`echo ${arg} | sed 's/[+-]s[a-z]*=//'`
102 -subdirs |
+f
* |
+su
*)
105 -target=* |
+target
=* |
+targe
=* |
+targ
=* |
+tar=* |
+ta
=*)
106 if [ -n "${targets}" ] ; then
110 newtargets
="${targets} `echo ${arg} | sed 's/[+-]t[a-z]*=//'`"
111 targets
="${newtargets}"
113 -template=* |
+template
=* |
+templat
=* |
+templa
=* |
+templ
=* |
+temp
=* |
+tem
=* |
+te
=*)
114 template
=`echo ${arg} | sed 's/[+-]template=//'`
121 echo "Unrecognized option: \"${arg}\"".
;
126 if [ -n "${hosts}" ] ; then
130 newhosts
="${hosts} ${arg}"
136 if [ -n "${verbose}" ] ; then
137 echo `pwd`/configure $
*
140 # process host and target only if not rebuilding configure itself or removing.
141 if [ -z "${template}" -a -z "${removing}" -a -z "${fatal}" ] ; then
142 # Complain if an arg is missing
143 if [ -z "${hosts}" ] ; then
145 echo "configure: No HOST specified." ;
151 if [ -n "${fatal}" -o "${hosts}" = "help" ] ; then
152 (echo "Usage: configure HOST" ;
154 echo "Options: [defaults in brackets]" ;
155 echo " +ansi configure w/ANSI library. [no ansi lib]" ;
156 echo " +destdir=MYDIR configure for installation into MYDIR. [/usr/local]" ;
157 echo " +subdirs configure in subdirectories. [in source directories]" ;
158 echo " +lang=LANG configure to build LANG. [gcc]" ;
159 echo " +help print this message. [normal config]" ;
160 echo " +gas configure the compilers for use with gas. [native as]" ;
161 echo " +nfp configure the compilers default to soft floating point. [hard float]" ;
162 echo " +norecursion configure this directory only. [recurse]" ;
163 echo " +rm remove this configuration. [build a configuration]" ;
164 echo " +target=TARGET configure for TARGET. [TARGET = HOST]" ;
165 echo " +template=TEM rebuild configure using TEM. [normal config]" ;
167 echo "Where HOST and TARGET are something like \"vax\", \"sun3\", \"encore\", etc." ;
168 echo "Asking for more than one \"+target\" implies \"+subdirs\". Any other" ;
169 echo "options given will apply to all targets.") 1>&2
171 if [ -r config.status
] ; then
178 #### configure.in common parts come in here.
182 ## end of common part.
184 # are we rebuilding config itself?
185 if [ -n "${template}" ] ; then
186 if [ ! -r ${template} ] ; then
187 echo '***' "Can't find template ${template}." 1>&2
192 sed -e '/^#### configure.in common parts come in here.$/,/^## end of common part.$/c\
193 #### configure.in common parts come in here.\
194 ## end of common part.' \
195 -e '/^#### configure.in per-host parts come in here.$/,/^## end of per-host part.$/c\
196 #### configure.in per-host parts come in here.\
197 ## end of per-host part.' \
198 -e '/^#### configure.in per-target parts come in here.$/,/^## end of per-target part.$/c\
199 #### configure.in per-target parts come in here.\
200 ## end of per-target part.' \
201 -e '/^#### configure.in post-target parts come in here.$/,/^## end of post-target part.$/c\
202 #### configure.in post-target parts come in here.\
203 ## end of post-target part.' \
204 < ${template} > template.new
206 if [ -r configure.
in ] ; then
207 if [ -z "`grep '^# per\-host:' configure.in`" ] ; then
208 echo '***' `pwd`/configure.
in has no
"per-host:" line.
1>&2
212 if [ -z "`grep '^# per\-target:' configure.in`" ] ; then
213 echo '***' `pwd`/configure.
in has no
"per-target:" line.
1>&2
217 # split configure.in into common, per-host, per-target,
218 # and post-target parts. Post-target is optional.
219 sed -e '/^# per\-host:/,$d' configure.
in > configure.com
220 sed -e '1,/^# per\-host:/d' -e '/^# per\-target:/,$d' configure.
in > configure.hst
221 if grep -s '^# post-target:' configure.
in ; then
222 sed -e '1,/^# per\-target:/d' -e '/^# post\-target:/,$d' configure.
in > configure.tgt
223 sed -e '1,/^# post\-target:/d' configure.
in > configure.pos
225 sed -e '1,/^# per\-target:/d' configure.
in > configure.tgt
230 sed -e '/^#### configure.in common parts come in here.$/ r configure.com' \
231 -e '/^#### configure.in per\-host parts come in here.$/ r configure.hst' \
232 -e '/^#### configure.in per\-target parts come in here.$/ r configure.tgt' \
233 -e '/^#### configure.in post\-target parts come in here.$/ r configure.pos' \
234 template.new
> configure.new
236 rm -f configure.com configure.tgt configure.hst configure.pos
238 echo Warning
: no configure.
in in `pwd`
239 cat ${template} >> configure
242 chmod a
+x configure.new
244 # mv configure configure.old
245 mv configure.new configure
247 if [ -n "${verbose}" ] ; then
248 echo Rebuilt configure
in `pwd`
251 # Now update config.sub from the template directory.
252 if echo "$template" |
grep -s 'configure$' ; then
253 cp `echo "$template" | sed s/configure$/config.sub/` .
/config.sub.new
254 # mv config.sub config.sub.old
255 mv config.sub.new config.sub
257 if [ -n "${verbose}" ] ; then
258 echo Rebuilt config.sub
in `pwd`
262 if [ -z "${norecursion}" ] ; then
263 # If template is relative path, make it absolute for recurring.
264 if echo "${template}" |
grep -s '^/' ; then
267 template
=`pwd`/${template}
270 while [ -n "${configdirs}" ] ; do
271 # set configdir to car of configdirs, configdirs to cdr of configdirs
272 set ${configdirs}; configdir
=$1; shift; configdirs
=$
*
274 if [ "`echo ${configdir}.*`" != "${configdir}.*" ] ; then
275 targetspecificdirs
=${configdir}.
*
280 for i
in ${configdir} ${targetspecificdirs} ; do
282 if [ -r $i/configure
] ; then
284 .
/configure
+template
=${template} ${verbose})
286 echo Warning
: No configure
script in `pwd`/$i
289 if [ -n "${verbose}" ] ; then
290 echo Warning
: directory
$i is missing.
300 # some sanity checks on configure.in
301 if [ -z "${srctrigger}" ] ; then
302 echo Warning
: srctrigger not
set in configure.
in.
`pwd` not configured.
306 for host in ${hosts} ; do
308 if [ -z "${targets}" -o -n "${defaulttargets}" ] ; then
315 result
=`/bin/sh ./config.sub ${host}`
316 host_cpu
=`echo $result | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\1/'`
317 host_vendor
=`echo $result | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\2/'`
318 host_os
=`echo $result | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\3/'`
319 host=${host_cpu}-${host_vendor}-${host_os}
320 host_makefile_frag
=config
/hmake-
${host}
322 #### configure.in per-host parts come in here.
324 # map host info into gdb names.
326 case "${host_cpu}" in
329 case "${host_vendor}" in
333 gas
) gdb_host
=altosgas
;;
339 hpux
) gdb_host
=hp300hpux
;;
340 bsd
) gdb_host
=hp300bsd
;;
345 sony
) gdb_host
=news
;;
348 sunos3
) gdb_host
=sun3os3
;;
349 sunos4
) gdb_host
=sun3os4
;;
357 case "${host_vendor}" in
360 sunos3
) gdb_host
=sun2os3
;;
361 sunos4
) gdb_host
=sun2os4
;;
369 sunos3
) gdb_host
=sun4os3
;;
370 sunos4
) gdb_host
=sun4os4
;;
376 case "${host_vendor}" in
377 sony
) gdb_host
=news1000
;;
382 case "${host_vendor}" in
383 sony
) gdb_host
=bigmips
;;
384 dec
) gdb_host
=dec3100
;;
385 little
) gdb_host
=littlemips
;;
386 sgi
) gdb_host
=irix3
;;
391 case "${host_vendor}" in
392 sun
) gdb_host
=sun386
;;
393 sco
) gdb_host
=i386sco
;;
394 sequent
) gdb_host
=symmetry
;;
397 sysv
) gdb_host
=i386v
;;
398 sysv32
) gdb_host
=i386v32
;;
404 c1 | c2
) gdb_host
=convex
;;
407 case "${host_vendor}" in
408 umax
) gdb_host
=umax
;;
420 arm | vax | m88k | merlin | none | np1 | pn | pyramid | tahoe
)
431 if [ ! -f xconfig
/${gdb_host} ]; then
432 echo '***' "Gdb does not support host ${host}" 1>&2
436 # We really shouldn't depend on there being a space after XM_FILE= ...
437 hostfile
=`awk '$1 == "XM_FILE=" { print $2 }' <xconfig/${gdb_host}`
439 ## end of per-host part.
441 for target
in ${targets} ; do
443 target_alias
=${target}
444 result
=`/bin/sh ./config.sub ${target}`
445 target_cpu
=`echo $result | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\1/'`
446 target_vendor
=`echo $result | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\2/'`
447 target_os
=`echo $result | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\3/'`
448 target
=${target_cpu}-${target_vendor}-${target_os}
449 target_makefile_frag
=config
/tmake-
${target}
451 #### configure.in per-target parts come in here.
453 case "${target_cpu}" in
456 case "${target_vendor}" in
457 att
) gdb_target
=3b1
;;
458 altos
) gdb_target
=altos
;;
460 case "${target_os}" in
461 bsd
) gdb_target
=hp300bsd
;;
462 hpux
) gdb_target
=hp300hpux
;;
466 case "${target_os}" in
467 sunos3
) gdb_target
=sun3os3
;;
468 sunos4
) gdb_target
=sun3os4
;;
469 *) gdb_target
=sun3
;;
472 wrs
) gdb_target
=vxworks68
;;
473 isi
) gdb_target
=isi
;;
474 sony
) gdb_target
=news
;;
479 case "${target_vendor}" in
481 case "${target_os}" in
482 sunos3
) gdb_target
=sun2os3
;;
483 sunos4
) gdb_target
=sun2os4
;;
484 *) gdb_target
=sun2
;;
490 case "${target_vendor}" in
491 sony
) gdb_target
=news1000
;;
495 none | arm | tahoe | vax | np1 | pn | np1 | pn | pyramid | merlin | m88k
)
496 gdb_target
=${target_cpu} ;;
499 case "${target_os}" in
500 none|aout|coff
) gdb_target
=a29k
;;
501 sym1
) gdb_target
=ultra3
;;
502 kern
) gdb_target
=a29k-kern
;;
507 case "${target_vendor}" in
508 sony
) gdb_target
=bigmips
;;
509 dec
) gdb_target
=dec3100
;;
510 little
) gdb_target
=littlemips
;;
511 sgi
) gdb_target
=irix3
;;
515 c1 | c2
) gdb_target
=convex
;;
518 case "${target_vendor}" in
520 case "${target_os}" in
521 sunos3
) gdb_target
=sun4os3
;;
522 sunos4
) gdb_target
=sun4os4
;;
523 *) gdb_target
=sun4
;;
531 case "${target_vendor}" in
532 sco
) gdb_target
=i386sco
;;
533 sun
) gdb_target
=sun386
;;
534 sequent
) gdb_target
=symmetry
;;
535 coff
) gdb_target
=i386v
;;
536 aout
) gdb_target
=i386v
;;
538 case "${target_os}" in
539 sysv
) gdb_target
=i386v
;;
540 sysv32
) gdb_target
=i386v32
;;
546 case "${target_vendor}" in
547 bout | wrs
) gdb_target
=vxworks960
;;
548 coff | intel
) gdb_target
=nindy960
;;
553 case "${target_vendor}" in
554 utek
) gdb_target
=umax
;;
558 ### unhandled targets
565 if [ ! -f tconfig
/${gdb_target} ]; then
566 echo '***' "Gdb does not support target ${target}" 1>&2
570 if [ -z "${removing}" ] ; then
571 cat xconfig
/${gdb_host} tconfig
/${gdb_target} |
awk '$1 == "#msg" {
575 # We really shouldn't depend on there being a space after TM_FILE= ...
576 targetfile
=`awk '$1 == "TM_FILE=" { print $2 }' <tconfig/${gdb_target}`
578 host_makefile_frag
=xconfig
/${gdb_host}
579 target_makefile_frag
=tconfig
/${gdb_target}
581 # If hostfile (XM_FILE) and/or targetfile (TM_FILE) is not set in the
582 # ?config/* file, we don't make the corresponding links. But we have
583 # to remove the xm.h files and tm.h files anyway, e.g. when switching
584 # from "configure host" to "configure none".
588 if [ "${hostfile}" != "" ]; then
589 files
="${files} ${hostfile}"
590 links
="${links} xm.h"
593 if [ "${targetfile}" != "" ]; then
594 files
="${files} ${targetfile}"
595 links
="${links} tm.h"
598 ## end of per-target part.
600 # Temporarily, we support only direct subdir builds.
601 hostsubdir
=H-
${host_alias}
602 targetsubdir
=T-
${target_alias}
604 if [ -n "${removing}" ] ; then
605 if [ -n "${subdirs}" ] ; then
606 if [ -d "${hostsubdir}" ] ; then
607 rm -rf ${hostsubdir}/${targetsubdir}
609 if [ -z "`(ls ${hostsubdir}) 2>&1 | grep Target- | grep -v Target-independent`" ] ; then
613 echo Warning
: no
`pwd`/${hostsubdir} to remove.
616 rm -f ${Makefile} config.status
${links}
619 if [ -n "${subdirs}" ] ; then
620 # check for existing status before allowing forced subdirs.
621 if [ -f ${Makefile} ] ; then
622 echo '***' "${Makefile} already exists in source directory. `pwd` not configured." 1>&2
626 if [ ! -d ${hostsubdir} ] ; then mkdir
${hostsubdir} ; fi
629 if [ ! -d ${targetsubdir} ] ; then
630 if [ -z "${commontargets}" ] ; then
631 mkdir
${targetsubdir}
633 if [ ! -d Target-independent
] ; then
634 mkdir Target-independent
637 ${symbolic_link} Target-independent
${targetsubdir}
638 fi # if target independent
639 fi # if no target dir yet
645 # if not subdir builds, then make sure none exist.
646 if [ -n "`(ls .) 2>&1 | grep Host-`" ] ; then
647 echo '***' "Configured subdirs exist. `pwd` not configured." 1>&2
652 # Find the source files, if location was not specified.
653 if [ -z "${srcdir}" ] ; then
656 if [ -n "${srctrigger}" -a ! -r ${srctrigger} ] ; then
661 if [ -n "${srctrigger}" -a ! -r ${srcdir}/${srctrigger} ] ; then
662 if [ -z "${srcdirdefaulted}" ] ; then
663 echo '***' "${progname}: Can't find ${srcname} sources in `pwd`/${srcdir}" 1>&2
665 echo '***' "${progname}: Can
't find ${srcname} sources in `pwd`/. or `pwd`/.." 1>&2
668 echo '***' \(At least ${srctrigger} is missing.\) 1>&2
672 # Set up the list of links to be made.
673 # ${links} is the list of link names, and ${files} is the list of names to link to.
676 while [ -n "${files}" ] ; do
677 # set file to car of files, files to cdr of files
678 set ${files}; file=$1; shift; files=$*
679 set ${links}; link=$1; shift; links=$*
681 if [ ! -r ${srcdir}/${file} ] ; then
682 echo '***' "${progname}: cannot create a link \"${link}\"," 1>&2
683 echo '***' "since the file \"${file}\" does not exist." 1>&2
689 # Make a symlink if possible, otherwise try a hard link
690 ${symbolic_link} ${srcdir}/${file} ${link} 2>/dev/null || ${hard_link} ${srcdir}/${file} ${link}
692 if [ ! -r ${link} ] ; then
693 echo '***' "${progname}: unable to link \"${link}\" to \"${srcdir}/${file}\"." 1>&2
697 if [ -n "${verbose}" ] ; then
698 echo "Linked \"${link}\" to \"${srcdir}/${file}\"."
702 # Create a .gdbinit file which runs the one in srcdir
703 # and tells GDB to look there for source files.
709 echo "dir ." > .gdbinit
710 echo "dir ${srcdir}" >> .gdbinit
711 echo "source ${srcdir}/.gdbinit" >> .gdbinit
715 # Install a makefile, and make it set VPATH
716 # if necessary so that the sources are found.
717 # Also change its value of srcdir.
719 # FIXME-someday: This business of always writing to .tem and mv back
720 # is so that I don't screw things up
while developing. Once this
721 # template is stable, these should be optimized. xoxorich.
723 # Define macro CROSS_COMPILE in compilation if this is a cross-compiler.
724 if [ "${host}" != "${target}" ] ; then
725 echo "CROSS=-DCROSS_COMPILE" > ${Makefile}
726 echo "ALL=start.encap" >> ${Makefile}
728 echo "ALL=all.internal" > ${Makefile}
731 # set target, host, VPATH
732 echo "host_alias = ${host_alias}" >> ${Makefile}
733 echo "host_cpu = ${host_cpu}" >> ${Makefile}
734 echo "host_vendor = ${host_vendor}" >> ${Makefile}
735 echo "host_os = ${host_os}" >> ${Makefile}
737 echo "target_alias = ${target_alias}" >> ${Makefile}
738 echo "target_cpu = ${target_cpu}" >> ${Makefile}
739 echo "target_vendor = ${target_vendor}" >> ${Makefile}
740 echo "target_os = ${target_os}" >> ${Makefile}
742 if [ -n "${subdirs}" ] ; then
743 echo "subdir = /${hostsubdir}/${targetsubdir}" >> ${Makefile}
745 echo "subdir
=" >> ${Makefile}
748 # echo "workdir
= `pwd`" >> ${Makefile}
749 echo "VPATH
= ${srcdir}" >> ${Makefile}
751 # add "Makefile.
in" (or whatever it's called)
752 cat ${srcdir}/${Makefile_in} >> ${Makefile}
754 # Conditionalize the makefile for this host.
755 if [ -f ${srcdir}/${host_makefile_frag} ] ; then
756 (echo "host_makefile_frag
= ${srcdir}/${host_makefile_frag}" ;
757 sed -e "/^
####/ r ${srcdir}/${host_makefile_frag}" ${Makefile}) > Makefile.tem
758 mv Makefile.tem
${Makefile}
761 # Conditionalize the makefile for this target.
762 if [ -f ${srcdir}/${target_makefile_frag} ] ; then
763 (echo "target_makefile_frag = ${srcdir}/${target_makefile_frag}" ;
764 sed -e "/^####/ r ${srcdir}/${target_makefile_frag}" ${Makefile}) > Makefile.tem
765 mv Makefile.tem ${Makefile}
769 sed "s@^srcdir
= \.@srcdir
= ${srcdir}@
" ${Makefile} > Makefile.tem
770 mv Makefile.tem ${Makefile}
773 if [ -n "${destdir}" ] ; then
774 sed "s
:^destdir
=.
*$
:destdir
= ${destdir}:" ${Makefile} > Makefile.tem
775 mv Makefile.tem ${Makefile}
779 sed "s
:^SUBDIRS
=.
*$
:SUBDIRS
= ${configdirs}:" ${Makefile} > Makefile.tem
780 mv Makefile.tem ${Makefile}
783 sed "s
:^NONSUBDIRS
=.
*$
:NONSUBDIRS
= ${noconfigdirs}:" ${Makefile} > Makefile.tem
784 mv Makefile.tem ${Makefile}
787 if [ -f ${srcdir}/${host_makefile_frag} ] ; then
788 using=" using
\"${host_makefile_frag}\""
791 # remove any form feeds.
792 sed -e "s
/\f//" ${Makefile} > Makefile.tem
793 mv Makefile.tem ${Makefile}
795 if [ -f ${srcdir}/${target_makefile_frag} ] ; then
796 if [ -z "${using}" ] ; then
797 andusing=" using
\"${target_makefile_frag}\""
799 andusing="${using} and
\"${target_makefile_frag}\""
805 if [ -n "${verbose}" -o -z "${recurring}" ] ; then
806 echo "Created
\"${Makefile}\"" in `pwd`${andusing}.
809 #### configure.in post-target parts come in here.
815 grep -s "source ${srcdir}/.gdbinit
" .gdbinit 2>/dev/null || \
816 echo "source ${srcdir}/.gdbinit
" >> .gdbinit
819 cat ${srcdir}/alldeps.mak ${srcdir}/depend >>Makefile
820 ## end of post-target part.
822 # describe the chosen configuration in config.status.
823 # Make that file a shellscript which will reestablish
824 # the same configuration. Used in Makefiles to rebuild
828 # ${srcname} was configured as follows:
829 ${srcdir}/configure" ${arguments} `if [ -z "${norecursion}" ] ; then echo +norecursion ; else true ; fi` > config.status
830 chmod a+x config.status
836 # If there are subdirectories, then recurse.
837 if [ -z "${norecursion}" -a -n "${configdirs}" ] ; then
838 for configdir in ${configdirs} ; do
839 if [ -n "${verbose}" ] ; then
840 echo Configuring ${configdir}...
843 if [ -d ${configdir} ] ; then
845 ./configure +recurring ${host_alias} +target=${target_alias} \
846 ${verbose} ${subdirs} ${removing} +destdir=${destdir}) \
849 if [ -n "${verbose}" ] ; then
850 echo Warning: directory \"${configdir}\" is missing.
855 done # for each target
857 # Now build a Makefile for this host.
858 if [ -n "${subdirs}" -a ! -n "${removing}" ] ; then
860 cat > GNUmakefile << E!O!F
861 # Makefile generated by configure for host ${host_alias}.
863 ALL := $(shell ls -d Target-*)
866 $(foreach subdir,$(ALL),$(MAKE) -C $(subdir) \$@ &&) true