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