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 export PATH || (echo "OOPS, this isn't sh. Desperation time. I will feed myself to sh."; sh $0 $argv; kill $$)
47 #symbolic_link="echo ln -s"
49 # clear some things potentially inherited from environment.
52 Makefile_in=Makefile.in
81 -destdir=* | +destdir=* | +destdi=* | +destd=* | +dest=* | +des=* | +de=* | +d=*)
82 destdir=`echo ${arg} | sed 's/[+-]d[a-z]*=//'`
84 -languages=* | +languages=* | +language=* | +languag=* \
85 | +langua=* | +langu=* | +lang=* | +lan=* | +la=* \
87 languages="${languages} `echo ${arg} | sed 's/[+-]l[a-z]*=//'`"
101 -objdir=* | +objdir=* | +objdi=* | +objd=* | +obj=* | +ob=* | +o=*)
103 objdir=`echo ${arg} | sed 's/[+-]o[a-z]*=//'`
105 -recurring | +recurring | +recurrin | +recurri | +recurr | +recur | +recu | +rec | +re)
111 -site=* | +site=* | +sit=* | +si=*)
112 site=`echo ${arg} | sed 's/[+-]s[a-z]*=//'`
114 # -srcdir=* | +srcdir=* | +srcdi=* | +srcd=* | +src=* | +sr=*)
115 # srcdir=`echo ${arg} | sed 's/[+-]s[a-z]*=//'`
120 -target=* | +target=* | +targe=* | +targ=* | +tar=* | +ta=*)
121 if [ -n "${targets}" ] ; then
125 newtargets="${targets} `echo ${arg} | sed 's/[+-]t[a-z]*=//'`"
126 targets="${newtargets}"
128 -tmpdir=* | +tmpdir=* | +tmpdi=* | +tmpd=* | +tmp=* | +tm=*)
130 TMPDIR=`echo ${arg} | sed 's/[+-]t[a-z]*=//'`
137 echo "Unrecognized option: \"${arg}\"". ;
142 if [ -n "${hosts}" ] ; then
146 newhosts="${hosts} ${arg}"
152 if [ -n "${verbose}" ] ; then
156 ## this is a little touchy and won't always work, but...
158 ## if the argv[0] starts with a slash then it is an absolute name that can be
161 ## otherwise, if argv[0] has no slash in it, we can assume that it is on the
162 ## path. Since PATH might include "." we also add `pwd` to the end of PATH.
164 ## otherwise we prepend `pwd` to $0 and hope that will give us an absolute
168 if (echo $0 | grep '^/' > /dev/null) ; then
171 if (echo $0 | grep '/' > /dev/null) ; then
175 PATH=$PATH:`pwd` ; export PATH
179 configsub=`echo ${progname} | sed 's/configure$/config.sub/'`
181 if ${configsub} none >/dev/null 2>&1 ; then
184 echo '***' cannot find config.sub.
188 # process host and target only if not removing.
189 if [ -z "${removing}" -a -z "${fatal}" ] ; then
190 # Complain if an arg is missing
191 if [ -z "${hosts}" ] ; then
193 echo "configure: No HOST specified." ;
199 if [ -n "${fatal}" -o "${hosts}" = "help" ] ; then
200 (echo "Usage: configure HOST" ;
202 echo "Options: [defaults in brackets]" ;
203 echo " +ansi configure w/ANSI library. [no ansi lib]" ;
204 echo " +destdir=MYDIR configure for installation into MYDIR. [\"/usr/local\"]" ;
205 echo " +gas configure the compilers for use with gas. [native as]" ;
206 echo " +help print this message. [normal config]" ;
207 echo " +lang=LANG configure to build LANG. [gcc]" ;
208 echo " +nfp configure the compilers default to soft floating point. [hard float]" ;
209 echo " +norecursion configure this directory only. [recurse]" ;
210 echo " +objdir=ODIR configure in a parallel tree rooted in ODIR. [rooted in \".\"]" ;
211 echo " +rm remove this configuration. [build a configuration]" ;
212 echo " +site configure with site specific makefile" ;
213 # This is correctly aligned in the output, even though it isn't here.
214 echo " +subdirs configure in subdirectories. [in source directories]" ;
215 echo " +target=TARGET configure for TARGET. [TARGET = HOST]" ;
216 echo " +tmpdir=TMPDIR create temporary files in TMPDIR. [ TMPDIR = \"/tmp\" ]" ;
218 echo "Where HOST and TARGET are something like \"vax\", \"sun3\", \"encore\", etc." ;
219 echo "Asking for more than one \"+target\" implies \"+subdirs\". Any other" ;
220 echo "options given will apply to all targets.") 1>&2
222 if [ -r config.status ] ; then
229 ### break up configure.in.
230 if [ -r configure.in ] ; then
231 if [ -z "`grep '^# per\-host:' configure.in`" ] ; then
232 echo '***' `pwd`/configure.in has no "per-host:" line. 1>&2
236 if [ -z "`grep '^# per\-target:' configure.in`" ] ; then
237 echo '***' `pwd`/configure.in has no "per-target:" line. 1>&2
241 if [ -z "${TMPDIR}" ] ; then
242 TMPDIR=/tmp ; export TMPDIR
245 # keep this filename short for &%*%$*# 14 char file names
246 tmpfile=${TMPDIR}/cONf$$
248 # split configure.in into common, per-host, per-target,
249 # and post-target parts. Post-target is optional.
250 sed -e '/^# per\-host:/,$d' configure.in > ${tmpfile}.com
251 sed -e '1,/^# per\-host:/d' -e '/^# per\-target:/,$d' configure.in > ${tmpfile}.hst
252 if grep '^# post-target:' configure.in >/dev/null ; then
253 sed -e '1,/^# per\-target:/d' -e '/^# post\-target:/,$d' configure.in > ${tmpfile}.tgt
254 sed -e '1,/^# post\-target:/d' configure.in > ${tmpfile}.pos
256 sed -e '1,/^# per\-target:/d' configure.in > ${tmpfile}.tgt
261 echo '***' No configure.in in `pwd`
265 ### do common part of configure.in
269 # some sanity checks on configure.in
270 if [ -z "${srctrigger}" ] ; then
271 echo '***' srctrigger not set in `pwd`/configure.in.
275 for host in ${hosts} ; do
277 if [ -z "${targets}" -o -n "${defaulttargets}" ] ; then
284 result=`${configsub} ${host}`
285 host_cpu=`echo $result | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\1/'`
286 host_vendor=`echo $result | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\2/'`
287 host_os=`echo $result | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\3/'`
288 host=${host_cpu}-${host_vendor}-${host_os}
289 host_makefile_frag=config/hmake-${host}
290 if [ ! -f ${host_makefile_frag} ]
292 host_makefile_frag=config/hmake-${host_alias}
297 for target in ${targets} ; do
299 target_alias=${target}
300 result=`${configsub} ${target}`
301 target_cpu=`echo $result | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\1/'`
302 target_vendor=`echo $result | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\2/'`
303 target_os=`echo $result | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\3/'`
304 target=${target_cpu}-${target_vendor}-${target_os}
305 target_makefile_frag=config/tmake-${target}
306 if [ ! -f ${target_makefile_frag} ]
308 target_makefile_frag=config/tmake-${target_alias}
313 # Temporarily, we support only direct subdir builds.
314 hostsubdir=H-${host_alias}
315 targetsubdir=T-${target_alias}
317 if [ -n "${removing}" ] ; then
318 if [ -n "${objdir}" ] ; then
319 echo '***' +rm not supported for +objdir. Just \"rm -rf ${objdir}\" by hand.
323 if [ -n "${subdirs}" ] ; then
324 if [ -d "${hostsubdir}" ] ; then
325 rm -rf ${hostsubdir}/${targetsubdir}
327 if [ -z "`(ls ${hostsubdir}) 2>&1 | grep T- | grep -v T-independent`" ] ; then
331 echo Warning: no `pwd`/${hostsubdir} to remove.
334 rm -f ${Makefile} config.status ${links}
337 if [ -n "${objdir}" ]; then
342 if [ -n "${subdirs}" ] ; then
343 # check for existing status before allowing forced subdirs.
344 if [ -f ${Makefile} ] ; then
345 echo '***' "${Makefile} already exists in source directory. `pwd` not configured." 1>&2
349 if [ ! -d ${hostsubdir} ] ; then mkdir ${hostsubdir} ; fi
352 if [ ! -d ${targetsubdir} ] ; then
353 if [ -z "${commontargets}" ] ; then
354 mkdir ${targetsubdir}
356 if [ ! -d T-independent ] ; then
360 ${symbolic_link} T-independent ${targetsubdir}
361 fi # if target independent
362 fi # if no target dir yet
366 if [ -z "${srcdir}" ] ; then
370 # if not subdir builds, then make sure none exist.
371 if [ -n "`(ls .) 2>&1 | (grep H- ; true)`" ] ; then
372 echo '***' "Configured subdirs exist. `pwd` not configured." 1>&2
379 # Find the source files, if location was not specified.
380 if [ -z "${srcdir}" ] ; then
383 if [ -n "${srctrigger}" -a ! -r ${srctrigger} ] ; then
388 if [ -n "${srctrigger}" -a ! -r ${srcdir}/${srctrigger} ] ; then
389 if [ -z "${srcdirdefaulted}" ] ; then
390 echo '***' "${progname}: Can't find ${srcname} sources in `pwd`/${srcdir}" 1>&2
392 echo '***' "${progname}: Can't find ${srcname} sources in `pwd`/. or `pwd`/.." 1>&2
395 echo '***' \(At least ${srctrigger} is missing.\) 1>&2
399 # Set up the list of links to be made.
400 # ${links} is the list of link names, and ${files} is the list of names to link to.
403 while [ -n "${files}" ] ; do
404 # set file to car of files, files to cdr of files
405 set ${files}; file=$1; shift; files=$*
406 set ${links}; link=$1; shift; links=$*
408 if [ ! -r ${srcdir}/${file} ] ; then
409 echo '***' "${progname}: cannot create a link \"${link}\"," 1>&2
410 echo '***' "since the file \"${file}\" does not exist." 1>&2
416 # Make a symlink if possible, otherwise try a hard link
417 ${symbolic_link} ${srcdir}/${file} ${link} 2>/dev/null || ${hard_link} ${srcdir}/${file} ${link}
419 if [ ! -r ${link} ] ; then
420 echo '***' "${progname}: unable to link \"${link}\" to \"${srcdir}/${file}\"." 1>&2
424 if [ -n "${verbose}" ] ; then
425 echo "Linked \"${link}\" to \"${srcdir}/${file}\"."
429 # Create a .gdbinit file which runs the one in srcdir
430 # and tells GDB to look there for source files.
436 echo "dir ." > .gdbinit
437 echo "dir ${srcdir}" >> .gdbinit
438 echo "source ${srcdir}/.gdbinit" >> .gdbinit
442 # Install a makefile, and make it set VPATH
443 # if necessary so that the sources are found.
444 # Also change its value of srcdir.
446 # FIXME-someday: This business of always writing to .tem and mv back
447 # is so that I don't screw things up while developing. Once this
448 # template is stable, these should be optimized. xoxorich.
450 # Define macro CROSS_COMPILE in compilation if this is a cross-compiler.
451 if [ "${host}" != "${target}" ] ; then
452 echo "CROSS=-DCROSS_COMPILE" > ${Makefile}
453 echo "ALL=start.encap" >> ${Makefile}
455 echo "ALL=all.internal" > ${Makefile}
458 # set target, host, VPATH
459 echo "host_alias = ${host_alias}" >> ${Makefile}
460 echo "host_cpu = ${host_cpu}" >> ${Makefile}
461 echo "host_vendor = ${host_vendor}" >> ${Makefile}
462 echo "host_os = ${host_os}" >> ${Makefile}
464 echo "target_alias = ${target_alias}" >> ${Makefile}
465 echo "target_cpu = ${target_cpu}" >> ${Makefile}
466 echo "target_vendor = ${target_vendor}" >> ${Makefile}
467 echo "target_os = ${target_os}" >> ${Makefile}
469 if [ -n "${subdirs}" ] ; then
470 (echo "subdir = /${hostsubdir}/${targetsubdir}" ;
471 echo "unsubdir = ../..") >> ${Makefile}
474 echo "unsubdir = .") >> ${Makefile}
477 # echo "workdir = `pwd`" >> ${Makefile}
478 echo "VPATH = ${srcdir}" >> ${Makefile}
480 # add "Makefile.in" (or whatever it's called)
481 cat ${srcdir}/${Makefile_in} >> ${Makefile}
483 # Conditionalize the makefile for this host.
484 (echo "host_makefile_frag = ${srcdir}/${host_makefile_frag}" ;
485 sed -e "/^####/ r ${srcdir}/${host_makefile_frag}" ${Makefile}) > Makefile.tem
486 mv Makefile.tem ${Makefile}
488 # Conditionalize the makefile for this target.
489 (echo "target_makefile_frag = ${srcdir}/${target_makefile_frag}" ;
490 sed -e "/^####/ r ${srcdir}/${target_makefile_frag}" ${Makefile}) > Makefile.tem
491 mv Makefile.tem ${Makefile}
493 # Conditionalize the makefile for this site.
494 if [ -n "${site}" ] ; then
495 site_makefile_frag=config/smake-${site}
497 (echo "site_makefile_frag = ${srcdir}/${site_makefile_frag}" ;
498 sed -e "/^####/ r ${srcdir}/${site_makefile_frag}" ${Makefile}) > Makefile.tem
499 mv Makefile.tem ${Makefile}
503 sed "s@^srcdir = \.@srcdir = ${srcdir}@" ${Makefile} > Makefile.tem
504 mv Makefile.tem ${Makefile}
507 if [ -n "${destdir}" ] ; then
508 sed "s:^destdir =.*$:destdir = ${destdir}:" ${Makefile} > Makefile.tem
509 mv Makefile.tem ${Makefile}
513 sed "s:^SUBDIRS =.*$:SUBDIRS = ${configdirs}:" ${Makefile} > Makefile.tem
514 mv Makefile.tem ${Makefile}
517 sed "s:^NONSUBDIRS =.*$:NONSUBDIRS = ${noconfigdirs}:" ${Makefile} > Makefile.tem
518 mv Makefile.tem ${Makefile}
520 # remove any form feeds.
521 sed -e "s/
\f//" ${Makefile} > Makefile.tem
522 mv Makefile.tem ${Makefile}
525 if [ -f ${srcdir}/${host_makefile_frag} ] ; then
526 using="${using} and \"${host_makefile_frag}\""
528 if [ -f ${srcdir}/${target_makefile_frag} ] ; then
529 using="${using} and \"${target_makefile_frag}\""
531 if [ -n "${site}" -a \
532 -f ${srcdir}/${site_makefile_frag} ] ; then
533 using="${using} and \"${site_makefile_frag}\""
535 using=`echo "${using}" | sed 's/and/using/'`
536 using="Created \"${Makefile}\" in `pwd`${using}."
538 if [ -n "${verbose}" -o -z "${recurring}" ] ; then
544 # describe the chosen configuration in config.status.
545 # Make that file a shellscript which will reestablish
546 # the same configuration. Used in Makefiles to rebuild
550 # `pwd` was configured as follows:
551 (cd ${srcdir} ; ${progname}" ${arguments} `if [ -z "${norecursion}" ] ; then echo +norecursion ; else true ; fi` ")
552 # ${using}" > config.status
553 chmod a+x config.status
559 # If there are subdirectories, then recurse.
560 if [ -z "${norecursion}" -a -n "${configdirs}" ] ; then
561 for configdir in ${configdirs} ; do
562 if [ -n "${verbose}" ] ; then
563 echo Configuring ${configdir}...
566 if [ -d ${configdir} ] ; then
567 if [ -n "${objdir}" ] ; then
568 if [ ! -d ${objdir}/${configdir} ] ; then
569 mkdir ${objdir}/${configdir}
576 if (${progname} +recurring ${host_alias} +target=${target_alias} \
577 ${verbose} ${subdirs} ${removing} +destdir=${destdir} \
578 `if [ -n "${objdir}" ] ; then echo +objdir=${objdir}/${configdir} ; fi` \
579 ${tmpdiroption}) ; then
588 # if (${progname} +recurring ${host_alias} +target=${target_alias} \
589 # ${verbose} ${subdirs} ${removing} +destdir=${destdir} \
590 # `if [ -n "${objdir}" ] ; then echo +objdir=${objdir}/${configdir} ; fi` \
591 # ${tmpdiroption}) ; then true ; else exit 1 ; fi) \
594 if [ -n "${verbose}" ] ; then
595 echo Warning: directory \"${configdir}\" is missing.
600 done # for each target
602 # Now build a Makefile for this host.
603 if [ -n "${subdirs}" -a ! -n "${removing}" ] ; then
606 if [ -n "${objdir}" ] ; then
611 cat > GNUmakefile << 'E!O!F'
612 # Makefile generated by configure for host ${host_alias}.
614 ALL := $(shell ls -d T-*)
617 $(foreach subdir,$(ALL),$(MAKE) -C $(subdir) \$@ &&) true
627 rm -f ${tmpfile}.com ${tmpfile}.tgt ${tmpfile}.hst ${tmpfile}.pos
634 # Revision 1.61 1991/10/24 00:23:59 hgs
635 # Allow for using tmake-sun4
637 # Revision 1.60 1991/10/23 21:48:28 rich
638 # Makefiles should include the makefile frag names even if the makefile
639 # frag doesn't exist in *this* directory. Otherwise we inherit the
640 # variable setting from our parent Makefile.
642 # Revision 1.59 1991/10/16 19:53:31 gnu
643 # Update for SCO problems.
645 # * Fix "Larry Wall kludge" line so it works. If this script is run by csh,
646 # it will complain, feed itself to sh, and complain some more. But will work.
648 # * Use <14 char file names in /tmp.
650 # Revision 1.58 1991/10/16 06:12:52 rich
651 # Two small bugs. First, single quoted sed line doesn't need to quote
652 # '$'. Second, use quotes around the hereis document trigger in order
653 # to quote the entire contents of the hereis document.
655 # Revision 1.57 1991/10/11 05:31:05 gnu
656 # Simplify "Using" message code. Put the message that configure prints
657 # (or suppresses) into the config.status file as a comment.
659 # Revision 1.56 1991/10/10 05:01:47 rich
660 # Remove the set -e but protect the recusion call.
662 # Revision 1.55 1991/10/10 04:57:23 rich
663 # * Die when sub-configure's do.
664 # * get the makefile building message line correct.
667 # Revision 1.54 1991/10/10 01:04:42 rich
668 # Backed out the "/bin/sh config.sub" change. Fails when config.sub was
671 # Revision 1.53 1991/10/10 00:38:08 rich
672 # Call config.sub as "/bin/sh config.sub" instead of directly. This
673 # protects us from the case where config.sub isn't executable.
675 # Revision 1.52 1991/10/09 00:48:26 rich
676 # Another patch from jim.
678 # Revision 1.51 1991/10/08 06:07:58 wilson
679 # Fix bug in smake- file code.
681 # Revision 1.50 1991/10/04 23:49:37 rich
682 # Per's patch for my config.sub botch.
684 # Revision 1.49 1991/10/04 22:52:09 rich
685 # Use john's heuristic for finding ourselves. kinda like hare krishna.
687 # Revision 1.48 1991/10/02 13:17:28 rich
688 # take out the set -e for now
690 # Revision 1.47 1991/10/02 10:02:23 rich
691 # * temporary files in TMPDIR
694 # Revision 1.46 1991/10/02 06:29:53 rich
695 # Added +site=foo option for naming site specific Makefile fragments.
697 # Revision 1.45 1991/10/02 06:15:13 rich
698 # Removed +f option. Used to stand for +forcesubdirs which is now
701 # Revision 1.44 1991/10/02 06:02:35 rich
702 # Added rcs log line.