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