home *** CD-ROM | disk | FTP | other *** search
/ Fresh Fish 8 / FreshFishVol8-CD1.bin / gnu / src / amiga / binutils-2.5.2-src.lha / binutils-2.5.2 / configure < prev    next >
Encoding:
Text File  |  1994-11-21  |  32.8 KB  |  1,027 lines

  1. #!/bin/sh
  2.  
  3. ### WARNING: this file contains embedded tabs.  Do not run untabify on this file.
  4.  
  5. # Configuration script
  6. # Copyright (C) 1988, 90, 91, 92, 93, 94 Free Software Foundation, Inc.
  7.  
  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.
  12. # This program is distributed in the hope that it will be useful,
  13. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  15. # 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.
  19.  
  20. # Please report any problems running this configure script to
  21. # configure@cygnus.com
  22. # Please do not send reports about other problems to this address.  See
  23. # gdb/README, gas/README, etc., for info on where and how to report
  24. # problems about particular tools.
  25.  
  26. # This file was written by K. Richard Pixley.
  27.  
  28. #
  29. # Shell script to create proper links to machine-dependent files in
  30. # preparation for compilation.
  31. #
  32. # If configure succeeds, it leaves its status in config.status.
  33. # If configure fails after disturbing the status quo, 
  34. #       config.status is removed.
  35. #
  36.  
  37. # In places where the argument to echo may start with a '-', use /bin/echo
  38. # since the AmigaDOS pdksh builtin echo botches this case.
  39.  
  40. export PATH || (echo "OOPS, this isn't sh.  Desperation time.  I will feed myself to sh."; sh $0 $argv; kill $$)
  41.  
  42. remove=rm
  43. hard_link=cp
  44. symbolic_link=cp
  45.  
  46. #for Test
  47. #remove="echo rm"
  48. #hard_link="echo ln"
  49. #symbolic_link="echo ln -s"
  50.  
  51. # clear some things potentially inherited from environment.
  52.  
  53. Makefile=Makefile
  54. Makefile_in=Makefile.in
  55. arguments=$*
  56. build_alias=
  57. configdirs=
  58. exec_prefix=
  59. exec_prefixoption=
  60. fatal=
  61. floating_point=default
  62. gas=default
  63. host_alias=NOHOST
  64. host_makefile_frag=
  65. moveifchange=
  66. norecursion=
  67. other_options=
  68. package_makefile_frag=
  69. # This is a hack so we don't have to remember to always configure using
  70. # the "--prefix=/gnu" option.  Personally I feel this should be settable
  71. # in a config file.  -fnf
  72. prefix=/gnu
  73. progname=
  74. program_prefix=
  75. program_prefixoption=
  76. program_suffix=
  77. program_suffixoption=
  78. program_transform_name=
  79. program_transform_nameoption=
  80. redirect=">/dev/null"
  81. removing=
  82. site=
  83. site_makefile_frag=
  84. site_option=
  85. srcdir=
  86. srctrigger=
  87. subdirs=
  88. target_alias=NOTARGET
  89. target_makefile_frag=
  90. undefs=NOUNDEFS
  91. version="$Revision: 1.197.2.2 $"
  92. x11=default
  93.  
  94. ### we might need to use some other shell than /bin/sh for running subshells
  95. #
  96. config_shell=${CONFIG_SHELL-/bin/sh}
  97.  
  98. NO_EDIT="This file was generated automatically by configure.  Do not edit."
  99.  
  100. ## this is a little touchy and won't always work, but...
  101. ##
  102. ## if the argv[0] starts with a slash then it is an absolute name that can (and
  103. ## must) be used as is.
  104. ##
  105. ## otherwise, if argv[0] has no slash in it, we can assume that it is on the
  106. ## path.  Since PATH might include "." we also add `pwd` to the end of PATH.
  107. ##
  108.  
  109. # For some reason, the value of $0 in AmigaDOS pdksh ends up with a
  110. # trailing '/' that needs to be stripped.
  111. progname=`/bin/echo $0 | sed 's:/$::'`
  112. # if PWD already has a value, it is probably wrong.
  113. # The AmigaDOS pksh can't change the value of PWD, it's readonly.
  114. #if [ -n "$PWD" ]; then PWD=`pwd`; fi
  115. # if PWD already has a value, it is probably wrong.
  116.  
  117. case "${progname}" in
  118. /*) ;;
  119. */*) ;;
  120. *)
  121.         PATH=$PATH:${PWD=`pwd`} ; export PATH
  122.         ;;
  123. esac
  124.  
  125. # Loop over all args
  126.  
  127. while :
  128. do
  129.  
  130. # Break out if there are no more args
  131.     case $# in
  132.     0)
  133.         break
  134.         ;;
  135.     esac
  136.  
  137. # Get the first arg, and shuffle
  138.     option=$1
  139.     shift
  140.  
  141. # Make all options have two hyphens
  142.     orig_option=$option    # Save original for error messages
  143.     case $option in
  144.     --*) ;;
  145.     -*) option=-$option ;;
  146.     esac
  147.         
  148. # Split out the argument for options that take them
  149.     case $option in
  150.     --*=*)
  151.         optarg=`/bin/echo $option | sed -e 's/^[^=]*=//'`
  152.         ;;
  153. # These options have mandatory values.  Since we didn't find an = sign,
  154. # the value must be in the next argument
  155.     --b* | --cache* | --ex* | --ho* | --pre* | --program-p* | --program-s* | --program-t* | --si* | --sr* | --ta* | --tm* | --x-*)
  156.         optarg=$1
  157.         shift
  158.         ;;
  159.     esac
  160.  
  161. # Now, process the options
  162.     case $option in
  163.  
  164.     --build* | --b*)
  165.         case "$build_alias" in
  166.         "") build_alias=$optarg ;;
  167.         *) echo '***' Can only configure for one build machine at a time.  1>&2
  168.            fatal=yes
  169.            ;;
  170.         esac
  171.         ;;
  172. # Accepted for compatibility with new autoconf; ignored.
  173.     --cache*)
  174.         ;;
  175.     --disable-*)
  176.         enableopt=`/bin/echo ${option} | sed 's:^--disable-:enable_:;s:-:_:g'`
  177.         eval $enableopt=no
  178.         disableoptions="$disableoptions $option"
  179.         ;;
  180.     --enable-*)
  181.         case "$option" in
  182.         *=*)    ;;
  183.         *)    optarg=yes ;;
  184.         esac
  185.  
  186.         enableopt=`/bin/echo ${option} | sed 's:^--::;s:=.*$::;s:-:_:g'`
  187.         eval $enableopt="$optarg"
  188.         enableoptions="$enableoptions $option"
  189.         ;;
  190.     --exec-prefix* | --ex*)
  191.         exec_prefix=$optarg
  192.         exec_prefixoption="--exec-prefix=$optarg"
  193.         ;;
  194.     --gas | --g*)
  195.         gas=yes
  196.         ;;
  197.     --help | --he*)
  198.         fatal=yes
  199.         ;;
  200.     --host* | --ho*)
  201.         case $host_alias in
  202.         NOHOST) host_alias=$optarg ;;
  203.         *) echo '***' Can only configure for one host at a time.  1>&2
  204.            fatal=yes
  205.            ;;
  206.         esac
  207.         ;;
  208.     --nfp | --nf*)
  209.         floating_point=no
  210.         ;;
  211.     --norecursion | --no*)
  212.         norecursion=yes
  213.         ;;
  214.     --prefix* | --pre*)
  215.         prefix=$optarg
  216.         prefixoption="--prefix=$optarg"
  217.         ;;
  218.     --program-prefix* | --program-p*)
  219.         program_prefix=$optarg
  220.         program_prefixoption="--program-prefix=$optarg"
  221.         ;;
  222.     --program-suffix* | --program-s*)
  223.         program_suffix=$optarg
  224.         program_suffixoption="--program-suffix=$optarg"
  225.         ;;
  226.     --program-transform-name* | --program-t*)
  227.         # Double any backslashes or dollar signs in the argument
  228.         program_transform_name="${program_transform_name} -e `/bin/echo ${optarg} | sed -e 's/\\\\/\\\\\\\\/g' -e 's/\\\$/$$/g'`"
  229.         program_transform_nameoption="${program_transform_nameoption} --program-transform-name='$optarg'"
  230.         ;;
  231.     --rm)
  232.         removing=--rm
  233.         ;;
  234.     --silent | --sil* | --quiet | --q*)
  235.         redirect=">/dev/null"
  236.         verbose=--silent
  237.         ;;
  238.     --site* | --sit*)
  239.         site=$optarg
  240.         site_option="--site=$optarg"
  241.         ;;
  242.     --srcdir*/ | --sr*/)
  243.                 # Remove trailing slashes.  Otherwise, when the file name gets
  244.                 # bolted into an object file as debug info, it has two slashes
  245.                 # in it.  Ordinarily this is ok, but emacs takes double slash
  246.                 # to mean "forget the first part".
  247.         srcdir=`/bin/echo $optarg | sed -e 's:/$::'`
  248.         ;;
  249.     --srcdir* | --sr*)
  250.         srcdir=$optarg
  251.         ;;
  252.     --target* | --ta*)
  253.         case $target_alias in
  254.         NOTARGET) target_alias=$optarg ;;
  255.         *) echo '***' Can only configure for one target at a time.  1>&2
  256.            fatal=yes
  257.            ;;
  258.         esac
  259.         ;;
  260.     --tmpdir* | --tm*)
  261.         TMPDIR=$optarg
  262.         tmpdiroption="--tmpdir=$optarg"
  263.         ;;
  264.     --verbose | --v | --verb*)
  265.         redirect=
  266.         verbose=--verbose
  267.         ;;
  268.     --version | --V | --vers*)
  269.         echo "This is Cygnus Configure version" `/bin/echo ${version} | sed 's/[ $:]//g'`
  270.         exit 0
  271.         ;;
  272.     --with-*)
  273.         case "$option" in
  274.         *=*)    ;;
  275.         *)    optarg=yes ;;
  276.         esac
  277.  
  278.         withopt=`/bin/echo ${option} | sed 's:^--::;s:=.*$::;s:-:_:g'`
  279.         eval $withopt="$optarg"
  280.         withoptions="$withoptions $option"
  281.         ;;
  282.     --without-*)
  283.         withopt=`/bin/echo ${option} | sed 's:^--::;s:out::;s:-:_:g'`
  284.         eval $withopt=no
  285.         withoutoptions="$withoutoptions $option"
  286.         ;;
  287.     --x)    with_x=yes
  288.         withoptions="$withoptions --with-x"
  289.         ;;
  290.     --x-i* | --x-l*) other_options="$other_options $orig_option"
  291.         ;;
  292.     --*)
  293.         echo "configure: Unrecognized option: \"$orig_option\"; use --help for usage." >&2
  294.         exit 1
  295.         ;;
  296.     *)
  297.         case $undefs in
  298.         NOUNDEFS) undefs=$option ;;
  299.         *) echo '***' Can only configure for one host and one target at a time.  1>&2
  300.            fatal=yes
  301.            ;;
  302.         esac
  303.         ;;
  304.     esac
  305. done
  306.  
  307. # process host and target
  308.  
  309. # Do some error checking and defaulting for the host and target type.
  310. # The inputs are:
  311. #    configure --host=HOST --target=TARGET UNDEFS
  312. #
  313. # The rules are:
  314. # 1. You aren't allowed to specify --host, --target, and undefs at the
  315. #    same time.
  316. # 2. Host defaults to undefs.
  317. # 3. If undefs is not specified, then host defaults to the current host,
  318. #    as determined by config.guess.
  319. # 4. Target defaults to undefs.
  320. # 5. If undefs is not specified, then target defaults to host.
  321.  
  322. case "${fatal}" in
  323. "")
  324.     # Make sure that host, target & undefs aren't all specified at the
  325.     # same time.
  326.     case $host_alias---$target_alias---$undefs in
  327.     NOHOST---*---* | *---NOTARGET---* | *---*---NOUNDEFS)
  328.         ;;
  329.     *) echo '***' Can only configure for one host and one target at a time.  1>&2
  330.        fatal=yes
  331.        break 2
  332.         ;;
  333.     esac
  334.  
  335.     # Now, do defaulting for host.
  336.     case $host_alias in
  337.     NOHOST)
  338.         case $undefs in
  339.         NOUNDEFS)
  340.             # Neither --host option nor undefs were present.
  341.             # Call config.guess.
  342.             guesssys=`/bin/echo ${progname} | sed 's/configure$/config.guess/'`
  343.             if host_alias=`${guesssys}`
  344.             then
  345.                 # If the string we are going to use for
  346.                 # the target is a prefix of the string
  347.                 # we just guessed for the host, then
  348.                 # assume we are running native, and force
  349.                 # the same string for both target and host.
  350.                 case $target_alias in
  351.                 NOTARGET) ;;
  352.                 *)
  353.                     if expr $host_alias : $target_alias >/dev/null
  354.                     then
  355.                         host_alias=$target_alias
  356.                     fi
  357.                     ;;
  358.                 esac
  359.                 echo "Configuring for a ${host_alias} host." 1>&2
  360.                 arguments="--host=$host_alias $arguments"
  361.             else
  362.                 echo 'Config.guess failed to determine the host type.  You need to specify one.' 1>&2
  363.                 fatal=yes
  364.             fi
  365.             ;;
  366.         *)
  367.             host_alias=$undefs
  368.             ;;
  369.         esac
  370.     esac
  371.  
  372.     # Do defaulting for target.  If --target option isn't present, default
  373.     # to undefs.  If undefs isn't present, default to host.
  374.     case $target_alias in
  375.     NOTARGET)
  376.         case $undefs in
  377.         NOUNDEFS)
  378.             target_alias=$host_alias
  379.             ;;
  380.         *)
  381.             target_alias=$undefs
  382.             ;;
  383.         esac
  384.     esac
  385.     ;;
  386. *) ;;
  387. esac
  388.  
  389. if [ -n "${fatal}" -o "${host_alias}" = "help" ] ; then
  390.     exec 1>&2
  391.     echo Usage: configure [OPTIONS] [HOST]
  392.     echo
  393.     echo Options: [defaults in brackets]
  394.     echo ' --prefix=MYDIR         install into MYDIR [/usr/local]'
  395.     echo ' --exec-prefix=MYDIR     install host-dependent files into MYDIR [/usr/local]'
  396.     echo ' --help             print this message [normal config]'
  397.     echo ' --build=BUILD         configure for building on BUILD [BUILD=HOST]'
  398.     echo ' --host=HOST         configure for HOST [determined via config.guess]'
  399.     echo ' --norecursion         configure this directory only [recurse]'
  400.     echo ' --program-prefix=FOO     prepend FOO to installed program names [""]'
  401.     echo ' --program-suffix=FOO     append FOO to installed program names [""]'
  402.     echo ' --program-transform-name=P transform installed names by sed pattern P [""]'
  403.     echo ' --site=SITE         configure with site-specific makefile for SITE'
  404.     echo ' --srcdir=DIR         find the sources in DIR [. or ..]'
  405.     echo ' --target=TARGET     configure for TARGET [TARGET=HOST]'
  406.     echo ' --tmpdir=TMPDIR     create temporary files in TMPDIR [/tmp]'
  407.     echo ' --nfp             configure for software floating point [hard float]'
  408.     echo ' --with-FOO, --with-FOO=BAR package FOO is available (parameter BAR)'
  409.     echo ' --without-FOO         package FOO is NOT available'
  410.     echo ' --enable-FOO, --enable-FOO=BAR include feature FOO (parameter BAR)'
  411.     echo ' --disable-FOO         do not include feature FOO'
  412.     echo
  413.     echo 'Where HOST and TARGET are something like "sparc-sunos", "mips-sgi-irix5", etc.'
  414.     echo
  415.     if [ -r config.status ] ; then
  416.         cat config.status
  417.     fi
  418.  
  419.     exit 1
  420. fi
  421.  
  422. configsub=`/bin/echo ${progname} | sed 's/configure$/config.sub/'`
  423. moveifchange=`/bin/echo ${progname} | sed 's/configure$/move-if-change/'`
  424.  
  425. # this is a hack.  sun4 must always be a valid host alias or this will fail.
  426. if ${configsub} sun4 >/dev/null 2>&1 ; then
  427.         true
  428. else
  429.         echo '***' cannot find config.sub.  1>&2
  430.         exit 1
  431. fi
  432.  
  433. touch config.junk
  434. if ${moveifchange} config.junk config.trash ; then
  435.         true
  436. else
  437.         echo '***' cannot find move-if-change.  1>&2
  438.         exit 1
  439. fi
  440. rm -f config.junk config.trash
  441.  
  442. case "${srcdir}" in
  443. "")
  444.         if [ -r configure.in ] ; then
  445.                 srcdir=.
  446.         else
  447.                 if [ -r ${progname}.in ] ; then
  448.                         srcdir=`/bin/echo ${progname} | sed 's:/configure$::'`
  449.                 else
  450.                         echo '***' "Can't find configure.in.  Try using --srcdir=some_dir"  1>&2
  451.                         exit 1
  452.                 fi
  453.         fi
  454.         ;;
  455. *) ;;
  456. esac
  457.  
  458. ### warn about some conflicting configurations.
  459.  
  460. case "${srcdir}" in
  461. ".") ;;
  462. *)
  463.         if [ -f ${srcdir}/config.status ] ; then
  464.                 echo '***' Cannot configure here in \"${PWD=`pwd`}\" when \"${srcdir}\" is currently configured. 1>&2
  465.                 exit 1
  466.         fi
  467. esac
  468.  
  469. # default exec_prefix
  470. case "${exec_prefixoption}" in
  471. "") exec_prefix="\$(prefix)" ;;
  472. *) ;;
  473. esac
  474.  
  475. ### break up ${srcdir}/configure.in.
  476. case "`grep '^# per\-host:' ${srcdir}/configure.in`" in
  477. "")
  478.         echo '***' ${srcdir}/configure.in has no \"per-host:\" line. 1>&2
  479.         exit 1
  480.         ;;
  481. *) ;;
  482. esac
  483.  
  484. case "`grep '^# per\-target:' ${srcdir}/configure.in`" in
  485. "")
  486.         echo '***' ${srcdir}/configure.in has no \"per-target:\" line. 1>&2
  487.         exit 1
  488.         ;;
  489. *) ;;
  490. esac
  491.  
  492. case "${TMPDIR}" in
  493. "") TMPDIR=/tmp ; export TMPDIR ;;
  494. *) ;;
  495. esac
  496.  
  497. # keep this filename short for &%*%$*# 14 char file names
  498. tmpfile=${TMPDIR}/cONf$$
  499. # Note that a trap handler for 0 will *override* any exit status you explicitly
  500. # specify!  At this point, the only non-error exit is at the end of the script;
  501. # these actions are duplicated there, minus the "exit 1".
  502. trap "rm -f ${tmpfile}.com ${tmpfile}.tgt ${tmpfile}.hst ${tmpfile}.pos; exit 1" 0 1 2 15
  503.  
  504. # split ${srcdir}/configure.in into common, per-host, per-target,
  505. # and post-target parts.  Post-target is optional.
  506. sed -e '/^# per\-host:/,$d' ${srcdir}/configure.in > ${tmpfile}.com
  507. sed -e '1,/^# per\-host:/d' -e '/^# per\-target:/,$d' ${srcdir}/configure.in > ${tmpfile}.hst
  508. if grep '^# post-target:' ${srcdir}/configure.in >/dev/null ; then
  509.   sed -e '1,/^# per\-target:/d' -e '/^# post\-target:/,$d' ${srcdir}/configure.in > ${tmpfile}.tgt
  510.   sed -e '1,/^# post\-target:/d' ${srcdir}/configure.in > ${tmpfile}.pos
  511. else
  512.   sed -e '1,/^# per\-target:/d' ${srcdir}/configure.in > ${tmpfile}.tgt
  513.   echo >${tmpfile}.pos
  514. fi
  515.  
  516. ### do common part of configure.in
  517.  
  518. . ${tmpfile}.com
  519.  
  520. # some sanity checks on configure.in
  521. case "${srctrigger}" in
  522. "")
  523.         echo '***' srctrigger not set in ${PWD=`pwd`}/configure.in.  1>&2
  524.         exit 1
  525.         ;;
  526. *) ;;
  527. esac
  528.  
  529. case "${build_alias}" in
  530. "")    ;;
  531. *)
  532.     if result=`${config_shell} ${configsub} ${build_alias}` ; then
  533.         buildopt="--build=${build_alias}"
  534.         build_cpu=`/bin/echo $result | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\1/'`
  535.         build_vendor=`/bin/echo $result | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\2/'`
  536.         build_os=`/bin/echo $result | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\3/'`
  537.         build=${build_cpu}-${build_vendor}-${build_os}
  538.     else
  539.         echo "Unrecognized build system name ${build_alias}." 1>&2
  540.         exit 1
  541.     fi
  542.     ;;
  543. esac
  544.  
  545. if result=`${config_shell} ${configsub} ${host_alias}` ; then
  546.     true
  547. else
  548.     echo "Unrecognized host system name ${host_alias}." 1>&2
  549.     exit 1
  550. fi
  551. host_cpu=`/bin/echo $result | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\1/'`
  552. host_vendor=`/bin/echo $result | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\2/'`
  553. host_os=`/bin/echo $result | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\3/'`
  554. host=${host_cpu}-${host_vendor}-${host_os}
  555.  
  556. . ${tmpfile}.hst
  557.  
  558. if result=`${config_shell} ${configsub} ${target_alias}` ; then
  559.     true
  560. else
  561.     echo "Unrecognized target system name ${target_alias}." 1>&2
  562.     exit 1
  563. fi
  564. target_cpu=`/bin/echo $result | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\1/'`
  565. target_vendor=`/bin/echo $result | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\2/'`
  566. target_os=`/bin/echo $result | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\3/'`
  567. target=${target_cpu}-${target_vendor}-${target_os}
  568.  
  569. . ${tmpfile}.tgt
  570.  
  571. # Find the source files, if location was not specified.
  572. case "${srcdir}" in
  573. "")
  574.         srcdirdefaulted=1
  575.         srcdir=.
  576.         if [ ! -r ${srctrigger} ] ; then
  577.                 srcdir=..
  578.         fi
  579.         ;;
  580. *) ;;
  581. esac
  582.  
  583. if [ ! -r ${srcdir}/${srctrigger} ] ; then
  584.         case "${srcdirdefaulted}" in
  585.         "") echo '***' "${progname}: Can't find ${srcname} sources in ${PWD=`pwd`}/${srcdir}" 1>&2 ;;
  586.         *)  echo '***' "${progname}: Can't find ${srcname} sources in ${PWD=`pwd`}/. or ${PWD=`pwd`}/.." 1>&2 ;;
  587.         esac
  588.  
  589.         echo '***' \(At least ${srctrigger} is missing.\) 1>&2
  590.         exit 1
  591. fi
  592.  
  593. # Some systems (e.g., one of the i386-aix systems the gas testers are
  594. # using) don't handle "\$" correctly, so don't use it here.
  595. tooldir='$(exec_prefix)'/${target_alias}
  596.  
  597. if [ "${host_alias}" != "${target_alias}" ] ; then
  598.     if [ "${program_prefixoption}" = "" ] ; then
  599.         if [ "${program_suffixoption}" = "" ] ; then 
  600.             if [ "${program_transform_nameoption}" = "" ] ; then
  601.                 program_prefix=${target_alias}- ;
  602.             fi
  603.         fi
  604.     fi
  605. fi
  606.  
  607. # Merge program_prefix and program_suffix onto program_transform_name
  608. # Use a double $ so that make ignores it
  609. if [ "${program_suffix}" != "" ] ; then
  610.     program_transform_name="-e s,\$\$,${program_suffix}, ${program_transform_name}"
  611. fi
  612.  
  613. if [ "${program_prefix}" != "" ] ; then
  614.     program_transform_name="-e s,^,${program_prefix}, ${program_transform_name}"
  615. fi
  616.  
  617. for subdir in . ${subdirs} ; do
  618.  
  619.     # ${subdir} is relative path from . to the directory we're currently
  620.     # configuring.
  621.     # ${invsubdir} is inverse of ${subdir), *with* trailing /, if needed.
  622.     invsubdir=`/bin/echo ${subdir}/ | sed -e 's|\./||g' -e 's|[^/]*/|../|g'`
  623.  
  624.     ### figure out what to do with srcdir
  625.     case "${srcdir}" in
  626.         ".")  # no -srcdir option.  We're building in place.
  627.                 makesrcdir=. ;;
  628.         /*) # absolute path
  629.                 makesrcdir=`/bin/echo ${srcdir}/${subdir} | sed -e 's|/\.$||'`
  630.                 ;;
  631.         *) # otherwise relative
  632.                 case "${subdir}" in
  633.                 .) makesrcdir=${srcdir} ;;
  634.                 *) makesrcdir=${invsubdir}${srcdir}/${subdir} ;;
  635.                 esac
  636.                 ;;
  637.     esac
  638.  
  639.     if [ "${subdir}/" != "./" ] ; then
  640.         Makefile=${subdir}/Makefile
  641.     fi
  642.  
  643.     if [ ! -d ${subdir} ] ; then
  644.         if mkdir ${subdir} ; then
  645.                 true
  646.         else
  647.                 echo '***' "${progname}: could not make ${PWD=`pwd`}/${subdir}" 1>&2
  648.                 exit 1
  649.         fi
  650.     fi
  651.  
  652.     case "${removing}" in
  653.     "")
  654.         case "${subdir}" in
  655.         .) ;;
  656.         *) eval echo Building in ${subdir} ${redirect} ;;
  657.         esac
  658.  
  659.         # FIXME Should this be done recursively ??? (Useful for e.g. gdbtest)
  660.         # Set up the list of links to be made.
  661.         # ${links} is the list of link names, and ${files} is the list of names to link to.
  662.  
  663.         # Make the links.
  664.         configlinks="${links}"
  665.         if [ -r ${subdir}/config.status ] ; then
  666.                 mv -f ${subdir}/config.status ${subdir}/config.back
  667.         fi
  668.         while [ -n "${files}" ] ; do
  669.                 # set file to car of files, files to cdr of files
  670.                 set ${files}; file=$1; shift; files=$*
  671.                 set ${links}; link=$1; shift; links=$*
  672.  
  673.                 if [ ! -r ${srcdir}/${file} ] ; then
  674.                         echo '***' "${progname}: cannot create a link \"${link}\"," 1>&2
  675.                         echo '***' "since the file \"${srcdir}/${file}\" does not exist." 1>&2
  676.                         exit 1
  677.                 fi
  678.  
  679.                 ${remove} -f ${link}
  680.         # Make a symlink if possible, otherwise try a hard link
  681.         if ${symbolic_link} ${srcdir}/${file} ${link} >/dev/null 2>&1 ; then
  682.             true
  683.         else
  684.             # We need to re-remove the file because Lynx leaves a 
  685.             # very strange directory there when it fails an NFS symlink.
  686.             ${remove} -r -f ${link}
  687.             ${hard_link} ${srcdir}/${file} ${link}
  688.         fi
  689.                 if [ ! -r ${link} ] ; then
  690.                         echo '***' "${progname}: unable to link \"${link}\" to \"${srcdir}/${file}\"." 1>&2
  691.                         exit 1
  692.                 fi
  693.  
  694.                 echo "Linked \"${link}\" to \"${srcdir}/${file}\"."
  695.         done
  696.  
  697.         # Create a .gdbinit file which runs the one in srcdir
  698.         # and tells GDB to look there for source files.
  699.  
  700.         if [ -r ${srcdir}/${subdir}/.gdbinit ] ; then
  701.                 case ${srcdir} in
  702.                 .) ;;
  703.                 *) cat > ${subdir}/.gdbinit <<EOF
  704. # ${NO_EDIT}
  705. dir ${makesrcdir}
  706. dir .
  707. source ${makesrcdir}/.gdbinit
  708. EOF
  709.                         ;;
  710.                 esac
  711.         fi
  712.  
  713.         # Install a makefile, and make it set VPATH
  714.         # if necessary so that the sources are found.
  715.         # Also change its value of srcdir.
  716.         # NOTE: Makefile generation constitutes the majority of the time in configure.  Hence, this section has
  717.         # been somewhat optimized and is perhaps a bit twisty.
  718.  
  719.         # code is order so as to try to sed the smallest input files we know.
  720.  
  721.         # the four makefile fragments MUST end up in the resulting Makefile in this order: 
  722.         # package, target, host, and site.  so do these separately because I don't trust the
  723.         #  order of sed -e expressions.
  724.  
  725.         if [ -f ${srcdir}/${subdir}/${Makefile_in} ] ; then
  726.  
  727.             # Conditionalize for this site from "Makefile.in" (or whatever it's called) into Makefile.tem
  728.             rm -f ${subdir}/Makefile.tem
  729.               case "${site}" in
  730.               "") cp ${srcdir}/${subdir}/${Makefile_in} ${subdir}/Makefile.tem ;;
  731.               *)
  732.                       site_makefile_frag=${srcdir}/config/ms-${site}
  733.  
  734.                       if [ -f ${site_makefile_frag} ] ; then
  735.                               sed -e "/^####/  r ${site_makefile_frag}" ${srcdir}/${subdir}/${Makefile_in} \
  736.                                       > ${subdir}/Makefile.tem
  737.                       else
  738.                               cp ${srcdir}/${subdir}/${Makefile_in} ${subdir}/Makefile.tem
  739.                               site_makefile_frag=
  740.                       fi
  741.                       ;;
  742.             esac
  743.             # working copy now in ${subdir}/Makefile.tem
  744.  
  745.             # Conditionalize the makefile for this host.
  746.             rm -f ${Makefile}
  747.             case "${host_makefile_frag}" in
  748.               "") mv ${subdir}/Makefile.tem ${Makefile} ;;
  749.               *)
  750.                       if [ ! -f ${host_makefile_frag} ] ; then
  751.                               host_makefile_frag=${srcdir}/${host_makefile_frag}
  752.                       fi
  753.                       if [ -f ${host_makefile_frag} ] ; then
  754.                               sed -e "/^####/  r ${host_makefile_frag}" ${subdir}/Makefile.tem > ${Makefile}
  755.                       else
  756.                               echo '***' Expected host makefile fragment \"${host_makefile_frag}\" 1>&2
  757.                               echo '***' is missing in ${PWD=`pwd`}. 1>&2
  758.                               mv ${subdir}/Makefile.tem ${Makefile}
  759.                       fi
  760.             esac
  761.             # working copy now in ${Makefile}
  762.  
  763.             # Conditionalize the makefile for this target.
  764.             rm -f ${subdir}/Makefile.tem
  765.             case "${target_makefile_frag}" in
  766.               "") mv ${Makefile} ${subdir}/Makefile.tem ;;
  767.               *)
  768.                       if [ ! -f ${target_makefile_frag} ] ; then
  769.                               target_makefile_frag=${srcdir}/${target_makefile_frag}
  770.                       fi
  771.                       if [ -f ${target_makefile_frag} ] ; then
  772.                               sed -e "/^####/  r ${target_makefile_frag}" ${Makefile} > ${subdir}/Makefile.tem
  773.                       else
  774.                               mv ${Makefile} ${subdir}/Makefile.tem
  775.                               target_makefile_frag=
  776.                       fi
  777.                       ;;
  778.             esac
  779.             # real copy now in ${subdir}/Makefile.tem
  780.  
  781.             # Conditionalize the makefile for this package.
  782.             rm -f ${Makefile}
  783.             case "${package_makefile_frag}" in
  784.               "") mv ${subdir}/Makefile.tem ${Makefile} ;;
  785.               *)
  786.                       if [ ! -f ${package_makefile_frag} ] ; then
  787.                               package_makefile_frag=${srcdir}/${package_makefile_frag}
  788.                       fi
  789.                       if [ -f ${package_makefile_frag} ] ; then
  790.                               sed -e "/^####/  r ${package_makefile_frag}" ${subdir}/Makefile.tem > ${Makefile}
  791.                   rm -f ${subdir}/Makefile.tem
  792.                       else
  793.                               echo '***' Expected package makefile fragment \"${package_makefile_frag}\" 1>&2
  794.                               echo '***' is missing in ${PWD=`pwd`}. 1>&2
  795.                               mv ${subdir}/Makefile.tem ${Makefile}
  796.                       fi
  797.             esac
  798.             # working copy now in ${Makefile}
  799.  
  800.             mv ${Makefile} ${subdir}/Makefile.tem
  801.  
  802.             # real copy now in ${subdir}/Makefile.tem
  803.  
  804.             # prepend warning about editting, and a bunch of variables.
  805.             rm -f ${Makefile}
  806.             cat > ${Makefile} <<EOF
  807. # ${NO_EDIT}
  808. VPATH = ${makesrcdir}
  809. links = ${configlinks}
  810. host_alias = ${host_alias}
  811. host_cpu = ${host_cpu}
  812. host_vendor = ${host_vendor}
  813. host_os = ${host_os}
  814. host_canonical = ${host_cpu}-${host_vendor}-${host_os}
  815. target_alias = ${target_alias}
  816. target_cpu = ${target_cpu}
  817. target_vendor = ${target_vendor}
  818. target_os = ${target_os}
  819. target_canonical = ${target_cpu}-${target_vendor}-${target_os}
  820. EOF
  821.         case "${build}" in
  822.           "") ;;
  823.           *)  cat >> ${Makefile} << EOF
  824. build_alias = ${build_alias}
  825. build_cpu = ${build_cpu}
  826. build_vendor = ${build_vendor}
  827. build_os = ${build_os}
  828. build_canonical = ${build_cpu}-${build_vendor}-${build_os}
  829. EOF
  830.         esac
  831.  
  832.             case "${package_makefile_frag}" in
  833.               "") ;;
  834.               /*) echo package_makefile_frag = ${package_makefile_frag} >>${Makefile} ;;
  835.               *)  echo package_makefile_frag = ${invsubdir}${package_makefile_frag} >>${Makefile} ;;
  836.             esac
  837.  
  838.             case "${target_makefile_frag}" in
  839.               "") ;;
  840.               /*) echo target_makefile_frag = ${target_makefile_frag} >>${Makefile} ;;
  841.               *)  echo target_makefile_frag = ${invsubdir}${target_makefile_frag} >>${Makefile} ;;
  842.             esac
  843.  
  844.             case "${host_makefile_frag}" in
  845.               "") ;;
  846.               /*) echo host_makefile_frag = ${host_makefile_frag} >>${Makefile} ;;
  847.               *)  echo host_makefile_frag = ${invsubdir}${host_makefile_frag} >>${Makefile} ;;
  848.             esac
  849.  
  850.             if [ "${site_makefile_frag}" != "" ] ; then
  851.                 echo site_makefile_frag = ${invsubdir}${site_makefile_frag} >>${Makefile}
  852.             fi 
  853.  
  854.         # make sure that some sort of reasonable default exists for these 
  855.         # two variables
  856.         CXX=${CXX-"g++ -O"}
  857.         CC=${CC-gcc}
  858.  
  859.             # reset prefix, exec_prefix, srcdir, SUBDIRS, NONSUBDIRS,
  860.             # remove any form feeds.
  861.             if [ -z "${subdirs}" ]; then
  862.                 rm -f ${subdir}/Makefile.tem2
  863.                 sed -e "s:^SUBDIRS[     ]*=.*$:SUBDIRS = ${configdirs}:" \
  864.                     -e "s:^NONSUBDIRS[     ]*=.*$:NONSUBDIRS = ${noconfigdirs}:" \
  865.                     ${subdir}/Makefile.tem > ${subdir}/Makefile.tem2
  866.                 rm -f ${subdir}/Makefile.tem
  867.                 mv ${subdir}/Makefile.tem2 ${subdir}/Makefile.tem
  868.             fi
  869.             sed -e "s:^prefix[     ]*=.*$:prefix = ${prefix}:" \
  870.                     -e "s:^exec_prefix[     ]*=.*$:exec_prefix = ${exec_prefix}:" \
  871.             -e "s:^SHELL[     ]*=.*$:SHELL = ${config_shell}:" \
  872.                     -e "s:^srcdir[     ]*=.*$:srcdir = ${makesrcdir}:" \
  873.                     -e "s/ //" \
  874.                     -e "s:^program_prefix[     ]*=.*$:program_prefix = ${program_prefix}:" \
  875.                     -e "s:^program_suffix[     ]*=.*$:program_suffix = ${program_suffix}:" \
  876.                     -e "s:^program_transform_name[     ]*=.*$:program_transform_name = ${program_transform_name}:" \
  877.                     -e "s:^tooldir[     ]*=.*$:tooldir = ${tooldir}:" \
  878.                     ${subdir}/Makefile.tem >> ${Makefile}
  879.             # final copy now in ${Makefile}
  880.  
  881.         else
  882.            echo "No Makefile.in found in ${srcdir}/${subdir}, unable to configure" 1>&2
  883.         fi
  884.  
  885.         rm -f ${subdir}/Makefile.tem
  886.  
  887.         case "${host_makefile_frag}" in
  888.         "") using= ;;
  889.         *) using="and \"${host_makefile_frag}\"" ;;
  890.         esac
  891.  
  892.         case "${target_makefile_frag}" in
  893.         "") ;;
  894.         *) using="${using} and \"${target_makefile_frag}\"" ;;
  895.         esac
  896.  
  897.         case "${site_makefile_frag}" in
  898.         "") ;;
  899.         *) using="${using} and \"${site_makefile_frag}\"" ;;
  900.         esac
  901.  
  902.         newusing=`/bin/echo "${using}" | sed 's/and/using/'`
  903.         using=${newusing}
  904.         echo "Created \"${Makefile}\" in" ${PWD=`pwd`} ${using}
  905.  
  906.         . ${tmpfile}.pos
  907.  
  908.         # describe the chosen configuration in config.status.
  909.         # Make that file a shellscript which will reestablish
  910.         # the same configuration.  Used in Makefiles to rebuild
  911.         # Makefiles.
  912.  
  913.         case "${norecursion}" in
  914.         "") arguments="${arguments} --norecursion" ;;
  915.         *) ;;
  916.         esac
  917.  
  918.         if [ ${subdir} = . ] ; then
  919.             echo "#!/bin/sh
  920. # ${NO_EDIT}
  921. # This directory was configured as follows:
  922. ${progname}" ${arguments}  "
  923. # ${using}" > ${subdir}/config.new
  924.         else
  925.             echo "#!/bin/sh
  926. # ${NO_EDIT}
  927. # This directory was configured as follows:
  928. cd ${invsubdir}
  929. ${progname}" ${arguments}  "
  930. # ${using}" > ${subdir}/config.new
  931.         fi
  932.         chmod a+x ${subdir}/config.new
  933.         if [ -r ${subdir}/config.back ] ; then
  934.                 mv -f ${subdir}/config.back ${subdir}/config.status
  935.         fi
  936.         ${moveifchange} ${subdir}/config.new ${subdir}/config.status
  937.         ;;
  938.  
  939.     *)  rm -f ${Makefile} ${subdir}/config.status ${links} ;;
  940.     esac
  941. done
  942.  
  943. # If there are subdirectories, then recur. 
  944. if [ -z "${norecursion}" -a -n "${configdirs}" ] ; then 
  945.         for configdir in ${configdirs} ; do
  946.  
  947.                 if [ -d ${srcdir}/${configdir} ] ; then
  948.                         eval echo Configuring ${configdir}... ${redirect}
  949.                         case "${srcdir}" in
  950.                         ".") ;;
  951.                         *)
  952.                                 if [ ! -d ./${configdir} ] ; then
  953.                                         if mkdir ./${configdir} ; then
  954.                                                 true
  955.                                         else
  956.                                                 echo '***' "${progname}: could not make ${PWD=`pwd`}/${configdir}" 1>&2
  957.                                                 exit 1
  958.                                         fi
  959.                                 fi
  960.                                 ;;
  961.                         esac
  962.  
  963.                         POPDIR=${PWD=`pwd`}
  964.                         cd ${configdir} 
  965.  
  966. ### figure out what to do with srcdir
  967.                         case "${srcdir}" in
  968.                         ".") newsrcdir=${srcdir} ;; # no -srcdir option.  We're building in place.
  969.                         /*) # absolute path
  970.                                 newsrcdir=${srcdir}/${configdir}
  971.                                 srcdiroption="--srcdir=${newsrcdir}"
  972.                                 ;;
  973.                         *) # otherwise relative
  974.                                 newsrcdir=../${srcdir}/${configdir}
  975.                                 srcdiroption="--srcdir=${newsrcdir}"
  976.                                 ;;
  977.                         esac
  978.  
  979. ### check for guested configure, otherwise fix possibly relative progname
  980.                         if [ -f ${newsrcdir}/configure ] ; then
  981.                                 recprog=${newsrcdir}/configure
  982.                         elif [ -f ${newsrcdir}/configure.in ] ; then
  983.                                 case "${progname}" in
  984.                                 /*)     recprog=${progname} ;;
  985.                                 *)      recprog=../${progname} ;;
  986.                                 esac
  987.             else
  988.                 eval echo No configuration information in ${configdir} ${redirect}
  989.                 recprog=
  990.                         fi
  991.  
  992. ### The recursion line is here.
  993.             if [ ! -z "${recprog}" ] ; then
  994.                                 echo ${config_shell} ${recprog} ${verbose} ${buildopt} --host=${host_alias} --target=${target_alias} ${prefixoption} ${tmpdiroption} ${exec_prefixoption} ${srcdiroption} ${program_prefixoption} ${program_suffixoption} \
  995.                     ${program_transform_nameoption} ${site_option} ${withoptions} ${withoutoptions} ${enableoptions} ${disableoptions} ${removing} ${other_options} ${redirect}
  996.                     if eval ${config_shell} ${recprog} ${verbose} ${buildopt} --host=${host_alias} --target=${target_alias} \
  997.                                     ${prefixoption} ${tmpdiroption} ${exec_prefixoption} \
  998.                                     ${srcdiroption} ${program_prefixoption} ${program_suffixoption} ${program_transform_nameoption} ${site_option} ${withoptions} ${withoutoptions} ${enableoptions} ${disableoptions} ${removing} ${other_options} ${redirect} ; then
  999.                                     true
  1000.                             else
  1001.                     echo Configure in `pwd` failed, exiting. 1>&2
  1002.                                     exit 1
  1003.                             fi
  1004.             fi
  1005.  
  1006.                         cd ${POPDIR}
  1007.                 fi
  1008.         done
  1009. fi
  1010.  
  1011. # Perform cleanup from trap handler, and reset it, so we can give a zero
  1012. # exit status.
  1013. rm -f ${tmpfile}.com ${tmpfile}.tgt ${tmpfile}.hst ${tmpfile}.pos
  1014. trap 0
  1015.  
  1016. exit 0
  1017.  
  1018. #
  1019. # Local Variables:
  1020. # fill-column: 131
  1021. # End:
  1022. #
  1023.  
  1024. # end of configure
  1025.