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