ftp.nice.ch/pub/next/text/tex/teTeX/distrib/install.sh

This is install.sh in view mode; [Download] [Up]

#!/bin/sh

################################################################
# Basic IO:
################################################################

################################################################
# read: called with the name of a variable and (optionally) a
#       different message text. Keeps the old value of the
#       variable, if the empty string in entered.
################################################################
gets()
{
    gets_var=$1; gets_text=${2-$gets_var}
    eval old=\$$gets_var
    eval $echon \""New value for $gets_text [$old]: "\"
    read $gets_var
    eval test -z \"\$$gets_var\" && eval $gets_var=\'$old\'
}

################################################################
# getopt: get a menu choice.
#   $1: string with valid characters
#   $2: message for prompting
################################################################
getopt()
{
    chars=$1; msg=$2
    while true; do
        #$echon "$msg ([$chars]): "
        $echon "$msg: " >&2
        read ans
        ans=`echo $ans | tr '[a-z]' '[A-Z]'`
        case "$ans" in
          [$chars])
            echo "$ans"
            return
        esac
    done
}

################################################################
# toolge: given the name of a variable, toogle switches between
#         the values ' ' and X.
################################################################
toggle()
{
    if eval test \"\$$1\" = X; then
        eval $1=\' \'
    else
        eval $1=X
    fi
}

################################################################
# This tricky function displays the value of a variable that can
# contain newline characters. Variables will be expanded, too.
# Arguments:
#       1: the name of the variable
################################################################
textvar_show()
{
    OLDIFS=$IFS; IFS=;
    eval echo \"`eval echo \\$${1}`\"
    IFS=$OLDIFS
}

readln()
{
    $echon 'Press return to continue... '
    read foo
}

help()
{
    var=$1
    cls
    textvar_show $var 2>&1 | eval $PAGER
    echo
    readln
}

################################################################
# Use the yesno functions to ask the user a simple yes/no
# question.
# Arguments:
#   $1: test to display for the question (" (Y/N)? " will
#       automatically be appended).
################################################################
yesno()
{
    while true; do
    $echon "$1 (Y/N)? "
    read ans
    case $ans in
        y|Y)    return 0;;
        n|N)    return 1;;
        esac
    done
}

################################################################
# A set of functions the might do an echo without linefeed in
# the end. Function find_echo sets the variable "echon" to a
# suitable function.
################################################################
echo_a() { echo      -n "$@";   }
echo_b() { echo         "$@\c"; }
echo_c() { echo      -e "$@\c"; }
echo_d() { /bin/echo -n "$@";   }
echo_e() { /bin/echo    "$@\c"; }
echo_f() { /bin/echo -e "$@\c"; }

################################################################
# Test which of the above functions does the trick. We set
# the variable "echon" to the first function that works
# correctly.
################################################################
find_echo()
{
    for i in a b c d e f; do
        test "`echo_$i c``echo_$i a`"  = ca && echon=echo_$i && return
    done
    echon=echo
}


################################################################
# series and packages management:
################################################################

###############################################################################
# The series structure:
#  s_${series}_la:   "list of all packages"
#  s_${series}_lf:   "list of packages we found on the disk"
#  s_${series}_ls:   "list of selected packages"
#  s_${series}_mis:  "list of packages that are missing"
#  s_${series}_nf:   "number of packages we find"
#  s_${series}_ns:   "number of selected packages"
#  s_${series}_nmis: "number of packages that are missing"
#  s_${series}_du:   "disk space usage of all packages found"
#  s_${series}_dus:  "disk space usage of selected packages"
#  s_${series}_h:    "help text"
###############################################################################

###############################################################################
# The package structure:
#  p_${package}_n:  "the name of the package"
#  p_${package}_s:  "is the package selected?"
#  p_${package}_l:  "level: required, recommended or optional"
#  p_${package}_da: "did we find the package?"
#  p_${package}_fn: "the filename of a package the we found"
#  p_${package}_h:  "help text"
###############################################################################

allseries_locate()
{
    for al_series in $S_all_la;
    do
        series_locate $al_series;
    done
}

allseries_locate_check()
{
    notall=false
    hasbin=false
    test "$this_platform" != "" &&
        eval test \"\$p_${this_platform}_da\" = true &&
        hasbin=true
    for alc_series in $S_all_la; do
        test $alc_series = bin && $hasbin && continue
        eval alc_all_packages=\"\$s_${alc_series}_la\"
        for alc_p in $alc_all_packages; do
          if eval test \"\$p_${alc_p}_da\" = false; then
            notall=true
            eval echo \""Warning: package not found: \${p_${alc_p}_d-$alc_p} (series: $alc_series)."\"
          fi
        done
    done
    if test "$notall" = true; then
        echo
        echo "Notice: ignore the warnings, if the packages are missing intentionally."
        echo
        $echon "Press return to continue or Control-C to abort... "
        read foo
    fi
}

series_locate()
{
    sl_series=$1
    eval sl_all_packages=\"\$s_${sl_series}_la\"
    eval dft_dir=\"\$s_${sl_series}_d\"
    lf=; mis=; nmis=0; nf=0
    for sl_p in $sl_all_packages; do
        eval bn=\${p_${sl_p}_d-$sl_p}
        fn=
        test -f $here/$dft_dir/$bn.tar.gz && fn=$here/$dft_dir/$bn.tar.gz
        test -f $here/$bn.tar.gz && fn=$here/$bn.tar.gz
        if test -z "$fn"; then
          eval p_${sl_p}_da=false
          eval p_${sl_p}_fn=

          mis="$mis $sl_p"
          nmis=`expr $nmis + 1`
        else
          eval p_${sl_p}_da=true
          eval p_${sl_p}_fn=$fn

          lf="$lf $sl_p"
          nf=`expr $nf + 1`
        fi
    done
    eval s_${sl_series}_lf=\"$lf\"
    eval s_${sl_series}_mis=\"$mis\"
    eval s_${sl_series}_nmis=$nmis
    eval s_${sl_series}_nf=$nf
    setlength s_${sl_series}_nf 2
}

series_select_all()
{
    ssa_series=$1
    eval all_packages=\"\$s_${ssa_series}_lf\"
    for ssa_p in $all_packages; do
        package_select $ssa_p
    done
    series_stat $ssa_series
}

series_deselect_all()
{
    sda_series=$1
    eval all_packages=\"\$s_${sda_series}_lf\"
    for sda_p in $all_packages; do
        package_deselect $sda_p
    done
    series_stat $sda_series
}

series_stat()
{
    series=$1
    dus=0
    ns=0
    ls=
    eval ss_all_packages=\"\$s_${series}_lf\"
    for ss_p in $ss_all_packages; do
        eval \$p_${ss_p}_s || continue
        eval newdu=\"\$p_${ss_p}_du\"
        if test -z "$newdu"; then
          echo "unknown disk space usage for package: $ss_p"
          newdu=0
        fi
        ls="$ls $ss_p"
        ns=`expr $ns + 1`
        dus=`expr $dus + $newdu`
    done
    eval s_${series}_dus=\$dus
    setlength s_${series}_dus 6
    eval s_${series}_ns=\$ns
    setlength s_${series}_ns 2
    eval s_${series}_ls=\$ls
}

nobin_stat()
{
    dus=0; nf=0; ns=0;
    for ns_series in $S_nobin_la; do
      eval dus=\`expr \$dus + \$s_${ns_series}_dus\`
      eval nf=\` expr \$nf  + \$s_${ns_series}_nf\`
      eval ns=\` expr \$ns  + \$s_${ns_series}_ns\`
    done
    S_nobin_dus=$dus;  setlength S_nobin_dus 6
    S_nobin_nf=$nf;    setlength S_nobin_nf 2
    S_nobin_ns=$ns;    setlength S_nobin_ns 2
    total_stat
}

total_stat()
{
    s_total_dus=`expr $s_bin_dus + $S_nobin_dus`; setlength s_total_dus 6
    s_total_nf=`expr $s_bin_nf + $S_nobin_nf`;    setlength s_total_nf 2
    s_total_ns=`expr $s_bin_ns + $S_nobin_ns`;    setlength s_total_du 2
}

package_select()   { eval p_${1}_s=true;  }
package_deselect() { eval p_${1}_s=false; }

series_list()
{
    sl_series=$1
    cls
    echo "Series \`\`$sl_series'' statistics:"; echo
    echo "                  package name   size selected"
    echo "  --------------------------------------------"
    eval sl_all_p=\"\$s_${sl_series}_lf\"
    for sl_p in $sl_all_p; do
      eval sl_n=\"\$p_${sl_p}_n\"
      eval sl_du=\"\$p_${sl_p}_du\"
      eval sl_s=\"\$p_${sl_p}_s\"
      if $sl_s; then sl_s='[X]'; else sl_s='[ ]'; fi
      setlength sl_n 30
      setlength sl_du 6
      echo "$sl_n ${sl_du}k    $sl_s"
    done
    eval sl_s_dus=\"\$s_${sl_series}_dus\"
    setlength sl_s_dus 6
    echo "  --------------------------------------------"
    echo "                selected size: ${sl_s_dus}k"
    echo
    echo
    readln
}

series_init()
{
    $echon "Locating packages... "; allseries_locate; echo "Done."
    $echon "Initializing series... "
    for si_series in $S_nobin_la; do
        series_select_all $si_series
    done
    echo "Done."
    series_deselect_all bin
    test -z "$this_platform" || {
        this_platform_set "$this_platform"
        package_select "$this_platform"
        series_stat bin
    }
    allseries_locate_check
}

this_platform_set()
{
    this_platform="$1"
    for tps_p in $s_bin_lf; do
        eval p_${tps_p}_l=optional
    done
    series_deselect_all bin
    if test -z "$this_platform"; then
        this_platform_n=
        this_platform_d=
    else
      package_select ${this_platform}
      series_stat bin
      eval this_platform_n=\$p_${this_platform}_n
      eval this_platform_d=\$p_${this_platform}_d
      eval p_${this_platform}_l=required
    fi
    nobin_stat
}

################################################################
#debugging:
################################################################
series_dbg()
{
    series=$1

    eval echo \""all packages: '\$s_${series}_la'"\"
    eval echo \""default dir:  '\$s_${series}_d'"\"
    eval echo \""selected:     '\$s_${series}_ls'"\"
    eval echo \""found:        '\$s_${series}_lf'"\"
    eval echo \""missing:      '\$s_${series}_mis'"\"
    eval echo \""anz found:    '\$s_${series}_nf'"\"
    eval echo \""anz missing:  '\$s_${series}_nmis'"\"
    eval echo \""anz selected: '\$s_${series}_ns'"\"
    eval echo \""du total:     '\$s_${series}_du'"\"
    eval echo \""du selected:  '\$s_${series}_dus'"\"
    echo help:
    textvar_show s_${series}_h
    echo
}

package_dbg()
{
    p=$1
    eval echo \""gefunden: '\$p_${p}_da'"\"
    eval echo \""filename: '\$p_${p}_fn'"\"
    eval echo \""du:       '\$p_${p}_du'"\"
    eval echo \""version:  '\$p_${p}_v'"\"
    eval echo \""selected: '\$p_${p}_s'"\"
    eval echo \""name:     '\$p_${p}_n'"\"
    echo help:
    textvar_show p_${p}_h
    echo
}

################################################################
# utility functions:
################################################################

bad_sh()
{
    /bin/sh -c 'exit 1'
    retval=$?
    if test "$retval" != 1; then
        echo
        echo 'Your /bin/sh is completely broken. A simple program like'
        echo
        echo "                /bin/sh -c 'exit 1'; echo \$?"
        echo
        echo "gives a wrong result."
        echo
        echo 'Your shell is likely to break some scripts of teTeX. Please'
        echo 'update your /bin/sh first and try to install teTeX later.'
        echo 'GNU bash 1.14.5 will do, whereas bash 1.14.3 is known to have'
        echo 'problems.'
        echo
        exit 1
   fi
}

warning()
{
    echo "$@"
}

cls()
{
    test "$debug" = true || clear
}

check_for_binary()
{
    testbin=$1
    case "$testbin" in
      /*) test -x "$testbin" && test -f "$testbin"; return;;
      *)
         OLDIFS=$IFS; IFS=:; eval set $PATH; IFS=$OLDIFS
         for this_dir
         do
             test -x "$this_dir/$testbin" &&
             test -f "$this_dir/$testbin" && return 0
         done
         return 1;;
    esac
}

require_binaries()
{
    for this_bin
    do
        check_for_binary $this_bin ||
          fatal "program '$this_bin' not found in PATH"
    done
}

man_fix_texmf()
{
    file=$TETEXDIR/man/man1/bibtex.1
    test -f "$file" || return
    man_texmf_old=`grep texmf/bibtex/bst $file 2>/dev/null | sed 's@.*:@@; s@/bibtex/bst@@'`
    test -z "$man_texmf_old" && man_texmf_old=$man_texmf_old_fallback
    man_tetexdir_old=`dirname "$man_texmf_old"`
    test -z "$man_tetexdir_old" && man_tetexdir_old=$man_tetexdir_old_fallback

    if test "$opt_savespace_man_rm" = X; then
        rm -f $TETEXDIR/man/man*/*
        rmdir $TETEXDIR/man/man*
    fi 2>/dev/null

    if test "$TEXMF" != "$man_texmf_old" ||
       test "$man_tetexdir_old" != "$TETEXDIR"; then
        $echon "Fixing pathnames in the manualpages... "
        for mpage in $TETEXDIR/man/*/*[0-9]; do
          sed s@$man_texmf_old@$TEXMF@g\;s@$man_tetexdir_old@$TETEXDIR@g \
            $mpage > $TMPDIR/man.tmp.$$
          test -s $TMPDIR/man.tmp.$$ && mv $TMPDIR/man.tmp.$$ $mpage
        done
        echo "Done."
    fi
    test "$opt_savespace_man_gzip" = X && gzip $TETEXDIR/man/cat*/*.[1.9]
    touch $TETEXDIR/man/cat*/* 2>/dev/null
}

maketex_setopt()
{
    mtsite=$TEXMF/$mt_site_loc
    test -w "$mtsite" || return
    test -w "$TETEXDIR/texmf.cnf" || return
    test "$opt_varfonts" = X || return

    ed "$TETEXDIR/texmf.cnf" >$ERRLOG 2>&1 <<eof
/^VARFONTS.*=/
c
VARFONTS	= $opt_varfonts_dir
.
w
q
eof
    show_error

    ed "$mtsite" >$ERRLOG 2>&1 <<'eof'
/^: \${MT_FEATURES=/
s/}/:varfonts}/
w
q
eof
    show_error
}

texmfcnf_fix_texmf()
{
    test "$TETEXDIR/texmf" = "$TEXMF" && return
    test -w "$TETEXDIR/texmf.cnf" || return
    ed "$TETEXDIR/texmf.cnf" >$ERRLOG 2>&1 <<-eof
/^TEXMF.*=/
c
TEXMF		= $TEXMF
.
w
q
eof
    show_error
    rm -f $TETEXDIR/texmf
}

texmfcnf_fix_tetexdir()
{
    test -f $TETEXDIR/texmf.cnf || return
    if test ! -w "$TETEXDIR/texmf.cnf"; then
        warning "Warning: cannot write to file $TETEXDIR/texmf.cnf"
        readln
        return
    fi
    if test $platform_subdir_strip = true; then
        newtexmf='$SELFAUTODIR'
    else
        newtexmf='$SELFAUTOPARENT'
    fi
    ed "$TETEXDIR/texmf.cnf" >$ERRLOG 2>&1 <<-eof
/^TETEXDIR.*=/
c
TETEXDIR           = $newtexmf
.
w
q
eof
    show_error
}

# fill a string with blanks:
setlength()
{
    var=$1
    length=$2
    eval value=\"\$$var\"
    l=`expr "$value" : '.*'`
    test $l -lt $length || return
    d=`expr $length - $l`
    OLDIFS=$IFS; IFS=
    substr=`awk 'END {print substr("                                         ", 1, ANZ)}' ANZ=$d </dev/null`
    eval $var='$substr$value'
    IFS=$OLDIFS
}

# NEW PLATFORM: add a 'case'
platform_guess()
{
  case `(guess | sed 's@-.*-@-@')` in
    alpha-linux)
      echo alpha_linux;;
    alpha-osf3.*)
      echo alpha_osf32;;
    alpha-osf4.*)
      echo alpha_osf40;;
    c1-bsd)
      echo c1_bsd;;
    c*-bsd)
      echo c2_bsd;;
    hppa-nextstep3)
      echo hppa_nextstep3;;
    hppa1.1-hpux10*)
      echo hppa11_hpux10;;
    hppa1.1-hpux9*)
      echo hppa11_hpux9;;
    *86-freebsd2.*)
      echo i386_freebsd215;;
    *86-linux)
      echo i386_linux;;
    *86-linuxaout)
      echo i386_linuxaout;;
    *86-nextstep3)
      echo i386_nextstep3;;
    *86-solaris2.*)
      echo i386_solaris25;;
    m68k-hpux*)
      echo m68k_hpux9;;
    m68k-nextstep3)
      echo m68k_nextstep3;;
    mips-irix5.*)
      echo mips_irix53;;
    mips-irix6.*)
      echo mips_irix62;;
    mips-ultrix4*)
      echo mips_ultrix43;;
    rs6000-aix4.1*)
      echo rs6000_aix414;;
    rs6000-aix4.2*)
      echo rs6000_aix420;;
    sparc-nextstep3)
      echo sparc_nextstep3;;
    sparc-solaris2.4)
      echo sparc_solaris24;;
    sparc-solaris2.[56789])
      echo sparc_solaris25;;
    sparc-sunos4*)
      echo sparc_sunos413;;
   esac
}

unset_vars()
{
    for var in $envvars; do
        unset $var
    done
}

mkdirhier()
{
    case $1 in
        /*) cd /;;
    esac
    OLDIFS=$IFS; IFS=/; eval set $1; IFS=$OLDIFS
    for i
    do
        test -d $i || mkdir $i || break
        cd $i || break
    done
}

# [t]ry again, [r]econfigure, [a] abort
tra()
{
    msg=$1
    cls
    echo "Oops, I am in trouble here! The error was:"
    echo ">> $msg <<"
    echo
    case `getopt TRQ 'What shall we do now: t: try again, r: reconfigure, q: quit'` in
        T) return;;
        R) menu_main;;
        Q) exit 1;;
    esac
}

warn()
{
    msg=$1
    cls
    echo "Oops, I am in trouble here! The problem was:"
    echo ">> $msg <<"
    echo
    case `getopt CQ 'What shall we do now: c: ccontinue, q: quit'` in
        C) return;;
        Q) exit 1;;
    esac
}

fatal()
{
    echo; echo
    echo "ERROR: $@."
    echo "This was a fatal error, my friend. Installation aborted."
    exit 1
}

show_error()
{
    test $? = 0 && return
    cls
    echo 'WARNING: the last command returned an error.'
    if yesno 'Do you want to see the errorlog'; then
        cat $ERRLOG | eval $PAGER
        readln
    fi
    cls
}

nonemptydir()
{
  test -d "$1" && test -n "`ls \"$1\"`"
  return $?
}

# this is a hard job... trying to anticipiate trouble...
sanity_checks()
{
    while nonemptydir $TETEXDIR; do
        tra "non-empty directory TETEXDIR=$TETEXDIR already exists"
    done
    while nonemptydir $TEXMF; do
        tra "non-empty directory TEXMF=$TEXMF already exists"
    done
    while test "$opt_symlink" = X &&
          test ! -z "$opt_symlinks_bin" &&
          test -d "$opt_symlinks_bin" &&
          test ! -w "$opt_symlinks_bin"; do
        tra "cannot write to directory $opt_symlinks_bin"
    done
    while test "$opt_symlink" = X &&
          test ! -z "$opt_symlinks_man" &&
          test -d "$opt_symlinks_man" &&
          test ! -w "$opt_symlinks_man"; do
        tra "cannot write to directory $opt_symlinks_man"
    done
    while test "$opt_symlink" = X &&
          test ! -z "$opt_symlinks_info" &&
          test -d "$opt_symlinks_info" &&
          test ! -w "$opt_symlinks_info"; do
        tra "cannot write to directory $opt_symlinks_info"
    done
    while test ! -z "$opt_varfonts_dir" &&
          test -d "$opt_varfonts_dir" &&
          test ! -w "$opt_varfonts_dir"; do
        tra "cannot write to directory $opt_varfonts_dir"
    done
}

prepare_directories()
{
    alldirs="$TMPDIR $TETEXDIR $TEXMF
             $opt_symlinks_bin $opt_symlinks_info"
    test -z "$opt_symlinks_man" ||
             alldirs="$alldirs $opt_symlinks_man/man1 $opt_symlinks_man/man5 $opt_symlinks_man/cat1 $opt_symlinks_man/cat5"
    test -z "$opt_varfonts_dir" ||
             alldirs="$alldirs $opt_varfonts_dir/pk $opt_varfonts_dir/tfm"
    for dir in $alldirs; do
        while test ! -d $dir || test ! -w $dir; do
          mkdirhier $dir
          test -d $dir || { tra "could not make directory '$dir'"; continue; }
          test -w $dir || { tra "cannot write to directory '$dir'"; continue; }
        done
    done
    chmod 700 $TMPDIR || fatal "command 'chmod 700 $TMPDIR' failed"
    test -z "$opt_varfonts_dir" ||
        chmod 1777 $opt_varfonts_dir/pk $opt_varfonts_dir/tfm ||
        fatal "command 'chmod 1777 $opt_varfonts_dir/pk $opt_varfonts_dir/tfm' failed"
    ln -s $TETEXDIR $TMPDIR/$tetex_prefix
    test -d $TETEXDIR/texmf || ln -s $TEXMF $TETEXDIR/texmf
    platform_subdir_strip=false
    if test $s_bin_ns = 1; then
        cls
        textvar_show screen_6
        echo
        if yesno 'Do you want to omit the extra subdirectory'; then
          platform_subdir_strip=true
          mkdir $TETEXDIR/bin
          for pd_p in $s_bin_lf; do
            if eval \$p_${pd_p}_s; then
              eval platform_subdir_strip_d=\$p_${pd_p}_d
              break
            fi
          done
          ln -s . $TETEXDIR/bin/$platform_subdir_strip_d
        fi
    fi
    mkdirhier $TEXMF/lists
}

opt_do_symlinks()
{
    test "$opt_symlinks" = X || return
    $echon 'Creating symbolic links... '
    if test -d $TETEXDIR/man/man1 && test -w $opt_symlinks_man/man1; then
        cd $opt_symlinks_man/man1
        rm -f `ls $TETEXDIR/man/man1`; ln -s $TETEXDIR/man/man1/* .
    fi
    if test -d $TETEXDIR/man/man5 && test -w $opt_symlinks_man/man5; then
        cd $opt_symlinks_man/man5
        rm -f `ls $TETEXDIR/man/man5`; ln -s $TETEXDIR/man/man5/* .
    fi
    if test -d $TETEXDIR/man/cat1 && test -w $opt_symlinks_man/cat1; then
        cd $opt_symlinks_man/cat1
        rm -f `ls $TETEXDIR/man/cat1`; ln -s $TETEXDIR/man/cat1/* .
    fi
    if test -d $TETEXDIR/man/cat5 && test -w $opt_symlinks_man/cat5; then
        cd $opt_symlinks_man/cat5
        rm -f `ls $TETEXDIR/man/cat5`; ln -s $TETEXDIR/man/cat5/* .
    fi
    if test -d $TETEXDIR/info && test -w "$opt_symlinks_info"; then
        cd $opt_symlinks_info
        rm -f `ls $TETEXDIR/info`; ln -s $TETEXDIR/info/*info* .
    fi
    if test "$opt_symlinks" = X; then
        if test ! -z "$this_platform_bin"; then
          if test -w "$opt_symlinks_bin"; then
            cd $opt_symlinks_bin
            rm -f `ls $this_platform_bin`; ln -s $this_platform_bin/* .
            echo 'Done.'
          fi
        else
          cls
          echo '                              WARNING!                              '
          echo
          echo 'teTeX binaries for this platform are not installed. If you install'
          echo 'them later, you can create symbolic links to $opt_symlinks_bin'
          echo 'with a command like:'
          echo
          echo "  ln -s $TETEXDIR/bin/PLATFORM/* $opt_symlinks_bin"
          echo
          echo 'PLATFORM needs to be replaced by the name of the subdirectory that'
          echo 'contains the binaries for this platform.'
          echo
          readln
        fi
    fi
}

locate_binaties()
{
    this_platform_bin=
    lb_dir=$TETEXDIR/bin/$this_platform_d
    test -x "$lb_dir/initex" && this_platform_bin=$lb_dir
    test -x "$TETEXDIR/bin/initex" && this_platform_bin=$TETEXDIR/bin
    test ! -d $lb_dir && rm -f $lb_dir 2>/dev/null
    test -z "$this_platform_bin" && return
    PATH="${this_platform_bin}:${PATH}"; export PATH
}

untgz()
{
    cd $TMPDIR
    for u_series in $S_all_la; do
        eval selected=\$s_${u_series}_ls
        for u_package in $selected; do
          eval file=\$p_${u_package}_fn
          list=`basename $file| sed 's@.tar.gz$@@'`
          package_showinfo $u_package
          if $checkit; then
            echo
            $echon "Testing integrity of file $file... "
            gzip --test $file
            if test $? = 0; then
              echo "Ok."
            else
              warn "Integrity of file $file is void."
              continue
            fi
          fi
          $echon "Extracting package $p_current_n... "
          gzip -dc < $file | tar xvf - >$ERRLOG 2>&1
          if test $? = 0; then
            echo 'Done.'
            sed /$tetex_prefix/'!d; s@[^/]*'$tetex_prefix'/*@@; s/[,/]*[ 	].*//; /^$/d' $ERRLOG > $TEXMF/lists/$list
            if test -s $TEXMF/lists/$list; then
              chmod 755 $TEXMF/lists/$list
            else
              rm -f $TEXMF/lists/$list
            fi
          else
            show_error
            continue
          fi
        done
    done
    rmdir $TEXMF/lists 2>/dev/null
}

prepare_errorlog()
{
    touch "$ERRLOG"
    test -w "$ERRLOG" || fatal "cannot write to file '$ERRLOG'"
}

locate_binaries()
{
    require_binaries touch sed awk gzip ln rm ls tar tr mkdir cat pwd
}

init()
{
    cd $here
    # for fast installation: set CHECKIT_OVERRIDE to false in your environment.
    checkit=${CHECKIT_OVERRIDE-true}
    bad_sh
    prepare_errorlog
    locate_binaries
    find_echo
    unset_vars
    this_platform=`platform_guess`
    series_init
    nobin_stat    
}

fixperm()
{
    $echon 'Fixing permissions... '
    cd $TEXMF
    files=`find . -perm -2 \( -type d -o -type f \) -print`
    test -z "$files" || chmod go-w $files
    cd $TETEXDIR
    files=`find . -perm -2 \( -type d -o -type f \) -print`
    test -z "$files" || { chmod go-w $files 2>$ERRLOG; show_error; }
    dirs=`find $TEXMF/fonts/tfm $TEXMF/fonts/pk $TEXMF/fonts/source/jknappen/* -type d -print 2>$ERRLOG`
    test -z "$dirs" || { chmod 1777 $dirs 2>$ERRLOG; show_error; }
    test -f $TEXMF/ls-R && { chmod 666 $TEXMF/ls-R 2>$ERRLOG; show_error; }
    echo 'Done.'
}

install_now()
{
    umask 022
    cls; sanity_checks
    cls; prepare_directories
    umask 0
    cls; untgz
    { $platform_subdir_strip && rm -f $TETEXDIR/bin/$platform_subdir_strip_d; } >/dev/null 2>&1
    cls; fixperm
    umask 022
    locate_binaties
    man_fix_texmf
    opt_do_symlinks
    texmfcnf_fix_texmf
    texmfcnf_fix_tetexdir
    update
    init_tetex
    cls
    if test ! -z "$this_platform_bin"; then
        if test -z "$opt_symlinks_bin"; then
          bin=$this_platform_bin
        else
          bin=$opt_symlinks_bin
        fi

        cat <<eof
Welcome to the teTeX TeX system!

Some notes on how to proceed:
  - set up your PATH to include the directory containing the just
    installed binaries in $bin.
    Similarly, MANPATH and INFOPATH to include the relevant newly
    installed subdirectories.
  - run \`\`texconfig confall'' to check your setup
  - call texconfig to set up a few things: hyphenation, paper size for
    printing, printer mode (implies resolution), font generation, etc.
  - you need to run texhash after you install new files in
      $TEXMF
  - There are two mailing list for discussion and announces about the
    teTeX.  See the FAQ (\$TEXMF/doc/tetex/teTeX-FAQ) for more about this.
  - See CTAN sites (systems/unix/teTeX/updates) for updates and corrections
    to the system. For information about CTAN, see \$TEXMF/doc/help/ctan.
eof
    else
	cat <<eof
Welcome to the teTeX TeX system!

Some notes on how to proceed:
  - binaries for this platform are not installed. If you install the
    missing binaries later, make sure to run
      texconfig init
  - run \`\`texconfig confall'' to check your setup
  - call texconfig to set up a few things: hyphenation, paper size for
    printing, printer mode (implies resolution), font generation, etc.
  - you need to run texhash after you install new files in
      $TEXMF
  - There are two mailing list for discussion and announces about the
    teTeX.  See the FAQ (\$TEXMF/doc/tetex/teTeX-FAQ) for more about this.
  - See CTAN sites (systems/unix/teTeX/updates) for updates and corrections
    to the system. For information about CTAN, see \$TEXMF/doc/help/ctan.
eof
    fi

    exit
}

tetex_dump()
{
    $echon "Building filename database... "
    echo '% This is file ls-R. Maintained by texhash and append_db.' > $TEXMF/ls-R
    (cd $TEXMF; \ls -LAR ./ /dev/null | grep -v '^\.*$' | sed 's@\.//@./@' ) 2>$ERRLOG >> $TEXMF/ls-R
    show_error
    chmod 666 $TEXMF/ls-R
    echo 'Done.'

    if test ! -z "$this_platform_bin"; then
        test "$debug" = true && { set; sleep 5; }
        $echon 'Creating base/fmt/mem files... '
        eval TEXMF=$TEXMF $this_platform_bin/texconfig init >$ERRLOG 2>&1
        show_error
        echo 'Done.'
    fi
    $echon "Setting permissions for fonts tree... "
    if test "x$opt_varfonts" = xX; then
      texconfig font ro
    else
      texconfig font rw
    fi >/dev/null 2>&1
    echo Done.
}

init_tetex()
{
    tetex_dump
    maketex_setopt
}

update()
{
    test "$opt_update" = X || return
    echo "locating files for update option... "
    update_get_texmf
    if test -d "$opt_update_oldtexmf"; then
        echo "  old TEXMF: $opt_update_oldtexmf"
    else
        echo "  old TEXMF: not found"
    fi
    update_get_xdvi_ad
    if test -f "$opt_update_xdviad"; then
        echo "  old app-defaults file for xdvi: $opt_update_xdviad"
        rm -f $TEXMF/xdvi/XDvi
        cp "$opt_update_xdviad" $TEXMF/xdvi/XDvi
    else
        echo "  old app-defaults file for xdvi: not found"
    fi
    if test -d "$opt_update_oldtexmf/dvips"; then
        echo "  old dvips config files: $opt_update_oldtexmf/dvips"
        files=`(cd "$opt_update_oldtexmf/dvips"; find . -name config.\* -print)`
        (cd $TEXMF/dvips && rm -f `echo "$files" | sed 's@.*/@@'`)
        (cd "$opt_update_oldtexmf/dvips"; cp $files $TEXMF/dvips)
    else
        echo "  old dvips config files: not found"
    fi
}

update_get_texmf()
{
    opt_update_oldtexmf=`sed -n '/^TEXMF[ 	]*=/!d; s/.*=[ 	]*//; s/[ 	].*//; s@\$TETEXDIR@'$opt_update_olddir'@; p' $opt_update_olddir/texmf.cnf 2>/dev/null`
    test ! -d "$opt_update_oldtexmf" && opt_update_oldtexmf="$opt_update_olddir/texmf"
}

update_get_xdvi_ad()
{
    opt_update_xdviad=`find $opt_update_olddir/xdvi* $opt_update_oldtexmf \( -name XDvi -o -name XDvi.ad \) -print | sed q 2>/dev/null`
    test ! -f "$opt_update_xdviad" && opt_update_xdviad=
}

################################################################
# menus:
################################################################
menu_main()
{
    while true; do
        cls
        opt_savespace_man=X
        test "$opt_savespace_man_rm" = X || test "$opt_savespace_man_gzip" = X ||
          opt_savespace_man=' '
        textvar_show screen_1; echo
        case `getopt SDOIHQ 'Enter command'` in
          S) menu_series;;
          D) menu_directories;;
          O) menu_options;;
          I) install_now;;
          H) help help_1;;
          Q) exit_on_confirm;;
        esac
    done
}

menu_directories()
{
    while true; do
        cls
        textvar_show screen_2; echo
        case `getopt 12RQ 'Enter command'` in
          1) gets TETEXDIR; TETEXDIR=`dirname "$TETEXDIR/x" | sed 's@//*@/@g'`
             TEXMF=`echo $TETEXDIR/texmf | sed 's@//*@/@g'`;;
          2) gets TEXMF; TEXMF=`dirname "$TEXMF/x" | sed 's@//*@/@g'`;;
          R) return;;
          Q) exit_on_confirm;;
        esac
    done
}

menu_options()
{
    while true; do
        cls
        textvar_show screen_3; echo
        case `getopt ASMRQ 'Enter command'` in
          A) toggle opt_varfonts
             if test "$opt_varfonts" = X; then
               cls; textvar_show screen_3; echo
               opt_varfonts_dir=$opt_varfonts_dir_last
               test -z "$opt_varfonts_dir" && opt_varfonts_dir=/var/tmp/texfonts
               gets opt_varfonts_dir 'alternate directory'
             else
               opt_varfonts_dir_last=$opt_varfonts_dir
               opt_varfonts_dir=
             fi
             ;;
          S) toggle opt_symlinks
             if test "$opt_symlinks" = X; then
               cls; textvar_show screen_3; echo
               opt_symlinks_bin=$opt_symlinks_bin_last
               test -z "$opt_symlinks_bin" && opt_symlinks_bin=/usr/local/bin
               gets opt_symlinks_bin 'binary directory'
               opt_symlinks_man=$opt_symlinks_man_last
               test -z "$opt_symlinks_man" && opt_symlinks_man=`dirname $opt_symlinks_bin`/man
               gets opt_symlinks_man 'man directory   '
               opt_symlinks_info=$opt_symlinks_info_last
               test -z "$opt_symlinks_info" && opt_symlinks_info=`dirname $opt_symlinks_bin`/info
               gets opt_symlinks_info 'info directory  '
             else
               opt_symlinks_bin_last=$opt_symlinks_bin
               opt_symlinks_man_last=$opt_symlinks_man
               opt_symlinks_info_last=$opt_symlinks_info
               opt_symlinks_bin=; opt_symlinks_man=; opt_symlinks_info=
             fi
             ;;
          M) cls; textvar_show screen_3; echo
             opt_savespace_man=' '
             opt_savespace_man_rm=' '
             opt_savespace_man_gzip=' '
             yesno 'remove nroff sources' &&
                 { opt_savespace_man_rm=X; opt_savespace_man=X; }
             yesno 'compress preprocessed manpages with gzip' &&
                 { opt_savespace_man_gzip=X; opt_savespace_man=X; }
             ;;
          C) toggle opt_update
             if test "$opt_update" = X; then
               cls; textvar_show screen_3; echo
               opt_update_olddir=$opt_update_olddir_last
               test -z "$opt_update_olddir" && test -f /usr/local/tex/texmf.cnf &&
                 opt_update_olddir=/usr/local/tex
               gets opt_update_olddir 'old TETEXDIR'
               test -f $opt_update_olddir/texmf.cnf && continue
               echo "File $opt_update_olddir/texmf.cnf does not exist."
               readln
               opt_update=' '
               opt_update_olddir=
             else
               opt_update_olddir_last=$opt_update_olddir
               opt_update_olddir=
             fi
             ;;
          R) return;;
          Q) exit_on_confirm;;
        esac
    done
}

menu_series()
{
    while true; do
        cls
        textvar_show screen_4; echo
        menu_series_ans=`getopt PBGFDRQ 'Enter command'`
        case "$menu_series_ans" in
          P) series=bin;;
          B) series=base;;
          G) series=goodies;;
          F) series=fonts;;
          D) series=doc;;
        esac
        case "$menu_series_ans" in
          [PBGFD])
             cls; textvar_show screen_4;
             textvar_show s_${series}_h; echo
             case `getopt ANSLC "install series $series ([A]ll, [N]o, [S]elect, [L]ist, [C]ancel)"` in
               A) series_select_all $series; nobin_stat;;
               N) series_deselect_all $series; nobin_stat;;
               S) series_usersetup $series; nobin_stat;;
               L) series_list $series;;
               C) : ;;
             esac;;
          R) return;;
          Q) exit_on_confirm;;
        esac
    done
}

package_showinfo()
{
    p=$1
    cls
    eval p_current_du=\$p_${p}_du
    eval p_current_n=\$p_${p}_n
    eval p_current_l=\$p_${p}_l
    eval p_current_v=\$p_${p}_v
    echo "Package:          $p_current_n"
    echo "Series:           $series"
    if [ ! -z "$p_current_v" ] ; then
      echo "Version:          $p_current_v"
    fi
    echo "Status:           $p_current_l"
    echo "Disk space:       $p_current_du"
    textvar_show p_${p}_h
}

series_usersetup()
{
    su_series=$1
    eval all_packages=\"\$s_${su_series}_lf\"
    for p in $all_packages; do
        package_showinfo $p
        echo
        p_current_s=false
        yesno "install package $p_current_n" && p_current_s=true
        eval p_${p}_s=$p_current_s
    done
    series_stat $su_series
}

exit_on_confirm()
{
    cls
    yesno 'Really quit' && exit
}

################################################################
# global variables
################################################################
here=`pwd`
VERSION=0.4
# prefix in the archives. DO NOT CHANGE THE FOLLOWING LINE!!
tetex_prefix=teTeX
TETEXDIR=/usr/local/$tetex_prefix
TEXMF=$TETEXDIR/texmf
man_texmf_old_fallback=$TEXMF
man_tetexdir_old_fallback=$TETEXDIR
TMPDIR=${TMP-/tmp}/inst.tmp.$$
trap 'cd /; rm -rf "$TMPDIR"; rm -f "$TEXMF" 2>/dev/null; trap 0; exit 0' 0 1 2 15
while test -d $TMPDIR; do
  tra "temporal directory $TMPDIR already exists"
done
mkdirhier $TMPDIR
ERRLOG=${TMPDIR}/inst.errlog.$$
: ${PAGER=more}
mt_site_loc=maketex/maketex.site

envvars='
BIBINPUTS BSTINPUTS DVIPSHEADERS GFFONTS GLYPHFONTS MFBASES MFINPUTS
MFPOOL PKFONTS TEXCONFIG TEXFONTS TEXFORMATS TEXINPUTS TEXMFCNF TEXPICTS
TEXPKS TEXPOOL TFMFONTS VFFONTS DVIPSFONTS XDVIVFS XDVIFONTS DVILJFONTS
'

opt_varfonts=' '
opt_varfonts_dir=
opt_varfonts_dir_last=
opt_symlinks=' '
opt_symlinks_bin=
opt_symlinks_man=
opt_symlinks_info=
opt_symlinks_bin_last=
opt_symlinks_man_last=
opt_symlinks_info_last=
opt_savespace_man=' '
opt_savespace_man_rm=' '
opt_savespace_man_gzip=' '
opt_update=' '
opt_update_olddir=
opt_update_olddir_last=

this_platform=

S_nobin_la='
  base
  goodies
  fonts
  doc
'  

S_all_la="
  $S_nobin_la
  bin
"

s_base_la='
  tetex_base
  latex_base
'

# NEW PLATFORM: add entry in s_bin_la variable.
s_bin_la='
  alpha_linux
  alpha_osf32
  alpha_osf40
  c1_bsd
  c2_bsd
  hppa_nextstep3
  hppa11_hpux10
  hppa11_hpux9
  i386_freebsd215
  i386_linux
  i386_linuxaout
  i386_nextstep3
  i386_solaris25
  m68k_hpux9
  m68k_nextstep3
  mab_nextstep3
  mips_irix53
  mips_irix62
  mips_ultrix43
  rs6000_aix414
  rs6000_aix420
  sparc_nextstep3
  sparc_solaris24
  sparc_solaris25
  sparc_sunos413
'

s_doc_la='
  ams_doc
  bibtex_doc
  eplain_doc
  fonts_doc
  general_doc
  generic_doc
  latex_doc
  makeindex_doc
  metapost_doc
  programs_doc
'

s_fonts_la='
  ams_fonts
  dc_fonts
  misc_fonts
  postscript_fonts
  sauter_fonts
'

s_goodies_la='
  amstex
  bibtex
  eplain
  latex_extra
  metapost
  pictex
  pstricks
  texdraw
  xypic
'

s_base_n=base
s_bin_n=binaries
s_doc_n=documentation
s_fonts_n=fonts
s_goodies_n=goodies

s_base_d=base
s_bin_d=binaries
s_doc_d=doc
s_fonts_d=fonts
s_goodies_d=goodies

s_base_h='
This series contains the most basic packages that are needed for the
basic functionality of teTeX and a small LaTeX system.
'

s_bin_h='
This series contains the binaries for teTeX. There is one binary package
for each supported platform containing all teTeX binaries for that
platform.
'

s_doc_h='
This series contains a lot of documentation about teTeX and the packages
it contains. The whole series contains over 130 dvi files plus FAQs
and some other documentation.
'

s_fonts_h='
This series contains font packages: DC, oldgerman, sauter, bbold, bbm,
stmary, pandora, wasy, AMS, concrete and support for PostScript fonts
from Bitstream and Adobe.
'

s_goodies_h='
This series contains some additional packages: AMSTeX, BibTeX, eplain,
LaTeX-extra, METAPOST, PiCTeX, PStricks, TeXdraw and XYpic.
'

#############################################################################
# packages:
#############################################################################


p_latex_base_l=required
p_tetex_base_l=required

p_ams_doc_l=recommended
p_bibtex_doc_l=optional
p_eplain_doc_l=optional
p_fonts_doc_l=optional
p_general_doc_l=recommended
p_generic_doc_l=optional
p_latex_doc_l=recommended
p_makeindex_doc_l=optional
p_metapost_doc_l=optional
p_programs_doc_l=recommended

p_ams_fonts_l=recommended
p_dc_fonts_l=recommended
p_misc_fonts_l=optional
p_postscript_fonts_l=optional
p_sauter_fonts_l=optional

p_amstex_l=optional
p_bibtex_l=recommended
p_eplain_l=optional
p_latex_extra_l=recommended
p_metapost_l=optional
p_pictex_l=optional
p_pstricks_l=optional
p_texdraw_l=optional
p_xypic_l=optional

p_latex_base_d=latex-base
p_latex_base_du=1420
p_latex_base_n='LaTeX base'
p_latex_base_v='<1996/06/01>'
p_latex_base_h='
This package contains a minimal set of macros to use the LaTeX format.
'

p_tetex_base_d=tetex-base
p_tetex_base_du=5080
p_tetex_base_n='teTeX base'
p_tetex_base_h='
This package contains the most basic input files for teTeX: runtime
configuration files, hyphenation tables, manpages and the computer
modern fonts.
'

#############################################################################
# The supported binaries. Add new platforms to the s_bin_la list and create
# a p_PLATFORM st structure with the following variables:
#       _d: the directory name below bin for this platform
#      _du: disk usage
#       _n: name of the package
#       -h: help text
#############################################################################

# NEW PLATFORM: add p_*_{l,d,du,n,h} variables.
p_alpha_linux_l='optional'
p_alpha_linux_d=alpha-linux
p_alpha_linux_du=13940
p_alpha_linux_n='DEC Alpha/Linux'
p_alpha_linux_h='
This package contains all binaries for DEC Alpha/Linux platforms.
'

p_alpha_osf32_l='optional'
p_alpha_osf32_d=alpha-osf3.2
p_alpha_osf32_du=6840
p_alpha_osf32_n='DEC Alpha/Digital Unix 3.2'
p_alpha_osf32_h='
This package contains all binaries for DEC Alpha/Digital Unix 3.2 platforms.
'

p_alpha_osf40_l=optional
p_alpha_osf40_d=alpha-osf4.0
p_alpha_osf40_du=6840
p_alpha_osf40_n='DEC Alpha/Digital Unix 4.0'
p_alpha_osf40_h='
This package contains all binaries for DEC Alpha/Digital Unix 4.0 platforms.
'

p_c1_bsd_l='optional'
p_c1_bsd_d=c1-bsd
p_c1_bsd_du=12310
p_c1_bsd_n='Convex C-110'
p_c1_bsd_h='
This package contains all binaries for Convex C-110 platforms.
'

p_c2_bsd_l='optional'
p_c2_bsd_d=c2-bsd
p_c2_bsd_du=12250
p_c2_bsd_n='Convex C-210'
p_c2_bsd_h='
This package contains all binaries for Convex C-210 platforms.
'

p_hppa_nextstep3_l=optional
p_hppa_nextstep3_d=hppa-nextstep3
p_hppa_nextstep3_du=6307
p_hppa_nextstep3_n='HPPA/NEXTSTEP 3'
p_hppa_nextstep3_h='
This package contains all binaries for HPPA/NEXTSTEP 3 platforms.
'

p_hppa11_hpux9_l=optional
p_hppa11_hpux9_d=hppa1.1-hpux9
p_hppa11_hpux9_du=6260
p_hppa11_hpux9_n='HPPA/HP-UX 9.xx'
p_hppa11_hpux9_h='
This package contains all binaries for HPPA/HP-UX 9.xx platforms.
'

p_hppa11_hpux10_l=optional
p_hppa11_hpux10_d=hppa1.1-hpux10
p_hppa11_hpux10_du=6720
p_hppa11_hpux10_n='HPPA/HP-UX 10.xx'
p_hppa11_hpux10_h='
This package contains all binaries for HPPA/HP-UX 10.xx platforms.
'

p_i386_freebsd215_l=optional
p_i386_freebsd215_d=i386-freebsd2.1.5
p_i386_freebsd215_du=3720
p_i386_freebsd215_n='Intel x86/FreeBSD 2.1.5'
p_i386_freebsd215_h='
This package contains all binaries for Intel x86/FreeBSD 2.1.5 platforms.
'

p_i386_linux_l=optional
p_i386_linux_d=i386-linux
p_i386_linux_du=3430
p_i386_linux_n='Intel x86/Linux (ELF)'
p_i386_linux_h='
This package contains all binaries for Linux on Intel x86 machines.
The binaries are in ELF format and need ld.so version 1.7.3 or higher and
libc version 5.0.9 or higher.
'

p_i386_linuxaout_l=optional
p_i386_linuxaout_d=i386-linuxaout
p_i386_linuxaout_du=3520
p_i386_linuxaout_n='Intel x86/Linux (a.out)'
p_i386_linuxaout_h='
This package contains all binaries for Linux on x86 machines.
The binaries are in the old a.out format and need version 4 of the
C library (e.g. libc-4.6.26).
'

p_i386_nextstep3_l=optional
p_i386_nextstep3_d=i386-nextstep3
p_i386_nextstep3_du=4789
p_i386_nextstep3_n='Intel x86/NEXTSTEP 3'
p_i386_nextstep3_h='
This package contains all binaries for Intel x86/NEXTSTEP 3 platforms.
'

p_i386_solaris25_l=optional
p_i386_solaris25_d=i386-solaris2.5
p_i386_solaris25_du=3800
p_i386_solaris25_n='Intel x86/Solaris2.5'
p_i386_solaris25_h='
This package contains all binaries for Intel x86/Solaris2.5 platforms.
'

p_m68k_hpux9_l=optional
p_m68k_hpux9_d=m68k-hpux9
p_m68k_hpux9_du=7810
p_m68k_hpux9_n='HP 400/HP-UX 9.xx'
p_m68k_hpux9_h='
This package contains all binaries for HP 400/HP-UX 9.xx platforms.
'

p_m68k_nextstep3_l=optional
p_m68k_nextstep3_d=m68k-nextstep3
p_m68k_nextstep3_du=4637
p_m68k_nextstep3_n='Motorola 68k/NEXTSTEP 3'
p_m68k_nextstep3_h='
This package contains all binaries for Motorola 68k/NEXTSTEP 3 platforms.
'

p_mab_nextstep3_l=optional
p_mab_nextstep3_d=mab-nextstep3
p_mab_nextstep3_du=21419
p_mab_nextstep3_n='NEXTSTEP mab'
p_mab_nextstep3_h='
This package contains all binaries for NEXTSTEP (NeXT,Intel,HP-PA,SPARC)
platforms.
'

p_mips_irix53_l=optional
p_mips_irix53_d=mips-irix5.3
p_mips_irix53_du=6510
p_mips_irix53_n='SGI Irix 5.3'
p_mips_irix53_h='
This package contains all binaries for SGI Indigo machines running
Irix-5.3.
'

p_mips_irix62_l=optional
p_mips_irix62_d=mips-irix6.2
p_mips_irix62_du=6220
p_mips_irix62_n='SGI Irix 6.2'
p_mips_irix62_h='
This package contains all binaries for SGI Indigo machines running
Irix-6.2.
'

p_mips_ultrix43_l=optional
p_mips_ultrix43_d=mips-ultrix4.3
p_mips_ultrix43_du=9424
p_mips_ultrix43_n='Mips/Ultrix 4.3'
p_mips_ultrix43_h='
This package contains all binaries for Mips/Ultrix 4.3 platforms.
'

p_rs6000_aix414_l=optional
p_rs6000_aix414_d=rs6000-aix4.1.4
p_rs6000_aix414_du=5750
p_rs6000_aix414_n='IBM RS6000 AIX 4.1.4'
p_rs6000_aix414_h='
This package contains all binaries for IBM RS600 machines running
AIX 4.1.4.
'

p_rs6000_aix420_l=optional
p_rs6000_aix420_d=rs6000-aix4.2.0
p_rs6000_aix420_du=5390
p_rs6000_aix420_n='IBM RS6000 AIX 4.2.0'
p_rs6000_aix420_h='
This package contains all binaries for IBM RS600 machines running
AIX 4.2.0.
'

p_sparc_nextstep3_l=optional
p_sparc_nextstep3_d=sparc-nextstep3
p_sparc_nextstep3_du=5726
p_sparc_nextstep3_n='SUN Sparc/NEXTSTEP 3'
p_sparc_nextstep3_h='
This package contains all binaries for SUN Sparcs running NEXTSTEP 3.
'

p_sparc_solaris24_l=optional
p_sparc_solaris24_d=sparc-solaris2.4
p_sparc_solaris24_du=4540
p_sparc_solaris24_n='SUN Sparc Solaris 2.4'
p_sparc_solaris24_h='
This package contains all binaries for SUN Sparcs running Solaris 2.4.
'

p_sparc_solaris25_l=optional
p_sparc_solaris25_d=sparc-solaris2.5
p_sparc_solaris25_du=4510
p_sparc_solaris25_n='SUN Sparc Solaris 2.5'
p_sparc_solaris25_h='
This package contains all binaries for SUN Sparcs running Solaris 2.5.
'

p_sparc_sunos413_l=optional
p_sparc_sunos413_d=sparc-sunos4.1.3
p_sparc_sunos413_du=6080
p_sparc_sunos413_n='SUN Sparc SunOS 4.1.3'
p_sparc_sunos413_h='
This package contains all binaries for SUN Sparcs running SunOS 4.1.3.
'

p_ams_doc_d=ams-doc
p_ams_doc_du=600
p_ams_doc_n='AMS documentation'
p_ams_doc_h='
This package contains documentation for the AMS (= american mathematical
society) fonts, AMSLaTeX and AMSTeX. A good thing, if you need lots of
math in your documents.
'

p_bibtex_doc_d=bibtex-doc
p_bibtex_doc_du=170
p_bibtex_doc_n='BibTeX documentation'
p_bibtex_doc_h='
This package contains documentation for the BibTeX programm. BibTeX is
a tool to make a bibliography for (La)TeX.
'

p_eplain_doc_d=eplain-doc
p_eplain_doc_du=360
p_eplain_doc_n='eplain documentation'
p_eplain_doc_h='
This package contains documentation for the extended plain format (eplain).
'

p_fonts_doc_d=fonts-doc
p_fonts_doc_du=410
p_fonts_doc_n='fonts documentation'
p_fonts_doc_h='
This package contains documentation for some font packages.
'

p_general_doc_d=general-doc
p_general_doc_du=1510
p_general_doc_n='general documentation'
p_general_doc_h='
This package contains some general information about TeX: a list of
ftp servers, a draft for the TeX Directory Standard (TDS), The TeX and
LaTeX Catalogue, TeX FAQs from the German and UK TeX usergroups.
'

p_generic_doc_d=generic-doc
p_generic_doc_du=3840
p_generic_doc_n='generic documentation'
p_generic_doc_h='
This package contains documentation for macro packages that can be
used for several format files: babel, texdraw, pstricks, xypic.
'

p_latex_doc_d=latex-doc
p_latex_doc_du=5470
p_latex_doc_n='LaTeX documentation'
p_latex_doc_h='
This package contains documentation for LaTeX: over 100 dvi files and some
examples.
'

p_makeindex_doc_d=makeindex-doc
p_makeindex_doc_du=110
p_makeindex_doc_n='makeindex documentation'
p_makeindex_doc_h='
This package contains documentation for the Makeindex program.
'

p_metapost_doc_d=metapost-doc
p_metapost_doc_du=1560
p_metapost_doc_n='MetaPost documentation'
p_metapost_doc_h='
This package contains documentation for the MetaPost system.
'

p_programs_doc_d=programs-doc
p_programs_doc_du=1210
p_programs_doc_n='Kpathsea documentation'
p_programs_doc_h='
This package contains documentation about the Kpathsea library and some
programmes (dvipsk, info, makeinfo). The Kpathsea library is used by some
programmes in teTeX to locate files on the disk. Its most important
features are the filename database (ls-R) (speeds up recursive directory
searches), runtime configuration (search paths can be set up in file)
and automatic font generation.
'

p_ams_fonts_d=ams-fonts
p_ams_fonts_du=2270
p_ams_fonts_n='AMS fonts'
p_ams_fonts_h='
This package contains the AMS fonts.
'

p_dc_fonts_d=dc-fonts
p_dc_fonts_du=1110
p_dc_fonts_n='DC fonts'
p_dc_fonts_h='
This package contains the DC fonts. These are full 256 character fonts
containing lots of national characters.
'

p_misc_fonts_d=misc-fonts
p_misc_fonts_du=2100
p_misc_fonts_n='misc. fonts'
p_misc_fonts_h='
This package contains: symbol fonts (wasy), special fonts for math (rsfs,
stmary, bbm, bbold), alternate text fonts (concrete, gothic, pandora).
'

p_postscript_fonts_d=postscript-fonts
p_postscript_fonts_du=3010
p_postscript_fonts_n='PostScript fonts'
p_postscript_fonts_h='
This package contains support files to use some PostScript fonts
from Adobe and Bitstream for TeX.
'

p_sauter_fonts_d=sauter-fonts
p_sauter_fonts_du=410
p_sauter_fonts_n='sauter fonts'
p_sauter_fonts_h='
This package contains the sauter fonts. It allows to use some fonts
at (nearly) arbitrary sizes.
'

p_amstex_du=160
p_amstex_n='AMSTeX'
p_amstex_h='
This package contains the AMSTeX package. AMSTeX is an extension of the
plain TeX format with better support of mathematics and easy access to
the AMS fonts.
'

p_bibtex_du=300
p_bibtex_n='BibTeX'
p_bibtex_h='
This package contains some support files for the BibTeX program.
BibTeX is a tool to make a bibliography for (La)TeX.
'

p_eplain_d=eplain
p_eplain_du=80
p_eplain_n='expanded plain TeX'
p_eplain_h='
This package the expanded plain format (eplain).
'

p_latex_extra_d=latex-extra
p_latex_extra_du=2780
p_latex_extra_n='LaTeX extra'
p_latex_extra_h='
This package contains a lot of extra packages for LaTeX: amslatex, fancyhdr,
koma-script, mflogo, psnfss, seminar, cite and many many more...
'

p_metapost_d=metapost
p_metapost_du=150
p_metapost_n='MetaPost'
p_metapost_h='
This package contains files for the MetaPost program. MetaPost is similar
to Metafont, but it outputs to PostScript format.
'

p_pictex_d=pictex
p_pictex_du=280
p_pictex_n='PiCTeX'
p_pictex_h='
This package contains the PiCTeX macros to draw portable pictures with
TeX and LaTeX.
'

p_pstricks_d=pstricks
p_pstricks_du=220
p_pstricks_n='PS Tricks'
p_pstricks_h='
This package contains a package for PostScript macros for generic TeX.
'

p_texdraw_d=texdraw
p_texdraw_du=40
p_texdraw_n='TeXdraw macros'
p_texdraw_h='
This package contains macros for PostScript drawings for TeX.
'

p_xypic_d=xypic
p_xypic_du=830
p_xypic_n='XY-pic macros'
p_xypic_h='
This package contains macros for typesetting graphs and diagrams in TeX.
'

################################################################
# screens:
################################################################
screen_1='====================> teTeX $VERSION installation procedure <====================

        detected platform: $this_platform_n

    <S> series:
          binaries:           $s_bin_ns out of $s_bin_nf, disk space required: $s_bin_dus kB
          other (summary):    $S_nobin_ns out of $S_nobin_nf, disk space required: $S_nobin_dus kB
                                               total disk space: $s_total_dus kB

    <D> directories:
          TETEXDIR = $TETEXDIR
          TEXMF    = $TEXMF

    <O> options:
          [$opt_varfonts] alternate directory for automatically generated fonts
          [$opt_symlinks] create symlinks in standard directories
          [$opt_savespace_man] save space for manpages

    Other commands:
          <I> start installation,  <H> help,  <Q> quit

'

screen_2='Current directories setup:
==============================================================================

  <1>  TETEXDIR:     $TETEXDIR
  <2>  TEXMF         $TEXMF

Other options:
==============================================================================
  <R>   return to main menu
  <Q>   quit
'

screen_3='Current options setup:
==============================================================================

  <A>  alternate directory for automatically generated fonts: [$opt_varfonts]
         directory name: $opt_varfonts_dir
  <S>  create symlinks in standard directories:               [$opt_symlinks]
            binaries to: $opt_symlinks_bin
            manpages to: $opt_symlinks_man
                info to: $opt_symlinks_info
  <M>  save space for manpages                                [$opt_savespace_man]
          remove nroff sources                          [$opt_savespace_man_rm]
          compress preprocessed manpages with gzip      [$opt_savespace_man_gzip]

Other options:
==============================================================================
  <R>   return to main menu
  <Q>   quit
'

screen_4='Current series setup:
==============================================================================
  <P>   platforms: $s_bin_ns out of $s_bin_nf, disk space required: $s_bin_dus kB
  <B>   base:      $s_base_ns out of $s_base_nf, disk space required: $s_base_dus kB
  <G>   goodies:   $s_goodies_ns out of $s_goodies_nf, disk space required: $s_goodies_dus kB
  <F>   fonts:     $s_fonts_ns out of $s_fonts_nf, disk space required: $s_fonts_dus kB
  <D>   doc:       $s_doc_ns out of $s_doc_nf, disk space required: $s_doc_dus kB
                                    total disk space: $s_total_dus kB

==============================================================================
  <R>   return to main menu
  <Q>   quit
'

screen_6='teTeX can be used on multiple platforms by having a subdirectory for each
installed binary package in $TETEXDIR/bin.

However, if you do not plan to add binaries for other platforms to
your teTeX installation, your binaries can directly be put into the
$TETEXDIR/bin directory.'

help_1='
This is the installation program of the teTeX distribution.

The installation procedure is really simple: just go through the
menus and select "start installation" if all options are set up
all right.

To select a menu item (a letter or a number makred with brackets)
just enter the corresponding letter or number and press return
(the letters are case insensitive).

Right now, the each menu item is explained in detail:

======================================================================
  The detected platform:
======================================================================

From the list of supported platforms, the installation procedure
tries to find out which binaries do run best on your system, if it
is supported. These binaries are then pre-selected. If you plan an
installation for a hetrogenous network, you may need to add binaries
for other platforms via the series menue (see below).


======================================================================
  The series menu (<S>)
======================================================================

The series menu allows you to select and deselect packages. The
packages are grouped in some series:

  binaries: you need one binary package for each platform you use
  base:     this series contains a minimal TeX+LaTeX system

All other series are "add-ons":

  goodies:  useful extra stuff, including much about LaTeX
  fonts:    many extra fonts: amsfonts, PostScript fonts, DC, ...
  doc:      much documentation. But one cannot have enough, right?

======================================================================
  The directories menu (<D>)
======================================================================

The teTeX distribution will be installed in a directory of your choice.
This directory is called TETEXDIR. You may choose any directory you like
since there are no absolute paths compiled into the binaries. Instead, a
extension of the Kpathsea library is used (selfdir extension) and all
paths are relative to the location of the binaries.

The platform independend files are stored in a directory tree called
TEXMF. TEXMF defaults to TETEXDIR/texmf, but you can change this, if you
want (many systems use /ust/lib/texmf or /usr/local/lib/texmf)

======================================================================
  The options menu (<O>)
======================================================================

The options are optional part of the installation, as they are not
always applicable or useful.

"alternate directory":
======================

If you choose an alternate directory for automatically generated fonts,
you can mount your TEXMF tree readonly (as long as you do not want to
perform administrative tasks: change configuration, install new inputs
and the like).

There are two good reasons to do this:
  - TEXMF is in your /usr partition and you want to mount it readonly
    (or in another partition that you mount readonly)
  - TEXMF will be accessable via NFS and you do not want to give
    write permissions to your NFS clients

If the second case applies to you, please note that the filename
database (ls-R) and the automatically generated fonts will be installed
in the alternate directory you choose. If this directory is local to
each client, you need to run texhash on each machine to build the
filename database there. Another disadvantage is that new fonts are not
shared in that case.


"symlinks in standard directories"
==================================

To make your binaries, manpages and infopages available to your system,
there are two common ways:
  1) install them in "standard places" that are searched for these files
  2) change your search paths to include the new directories

If you select the "symlinks" option, symbolic links will be installed in
the directories you choose. Note that if you share the teTeX installation
accross several machines via NFS and if the chosen "standard places" are
not shared, you need to create the symbolic links on each client, too
(or use method 2 on your clients).

If you do not use the "symlinks" option, you propably need to set up
your search paths (PATH, MANPATH, INFOPATH).


"save space for manpages"
=========================

Remove the sources for the manpages, if you do not want to keep them
(the distribution contains preprocessed manpages).

You may compress the preprocessed manpages with gzip, if your system
supports this.


"use configuration from a previous teTeX installation"
======================================================

If you have an old version of teTeX, you may consider using some
configuration files from the old system and thus save the time for
reconfiguring. This option supports the xdvi and dvips configuration
(papertypes, modes, paper offsets for printers,...), but not your
hyphenation tables for (La)TeX.

======================================================================
  Other commands (<I>, <H> and <Q>)
======================================================================

Well, this is easy to explain:
  <I> starts the installation after you are confident with set setup
  <H> displays this help
  <Q> quits the installation program
'


guess()
{
  cat > $TMPDIR/config.guess <<'eof-for-guess'
#! /bin/sh
# Attempt to guess a canonical system name.
#   Copyright (C) 1992, 1993, 1994, 1995 Free Software Foundation, Inc.
#
# This file is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
# As a special exception to the GNU General Public License, if you
# distribute this file as part of a program that contains a
# configuration script generated by Autoconf, you may include it under
# the same distribution terms that you use for the rest of that program.

# Written by Per Bothner <bothner@cygnus.com>.
# The master version of this file is at the FSF in /home/gd/gnu/lib.
#
# This script attempts to guess a canonical system name similar to
# config.sub.  If it succeeds, it prints the system name on stdout, and
# exits with 0.  Otherwise, it exits with 1.
#
# The plan is that this can be called by configure scripts if you
# don't specify an explicit system type (host/target name).
#
# Only a few systems have been added to this list; please add others
# (but try to keep the structure clean).
#

# This is needed to find uname on a Pyramid OSx when run in the BSD universe.
# (ghazi@noc.rutgers.edu 8/24/94.)
if (test -f /.attbin/uname) >/dev/null 2>&1 ; then
	PATH=$PATH:/.attbin ; export PATH
fi

UNAME_MACHINE=`(uname -m) 2>/dev/null` || UNAME_MACHINE=unknown
UNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown
UNAME_SYSTEM=`(uname -s) 2>/dev/null` || UNAME_SYSTEM=unknown
UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown

trap 'rm -f dummy.c dummy.o dummy; exit 1' 1 2 15

# Note: order is significant - the case branches are not exclusive.

case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
    alpha:OSF1:V*:*)
	# After 1.2, OSF1 uses "V1.3" for uname -r.
	echo alpha-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^V//'`
	exit 0 ;;
    alpha:OSF1:*:*)
	# 1.2 uses "1.2" for uname -r.
	echo alpha-dec-osf${UNAME_RELEASE}
        exit 0 ;;
    21064:Windows_NT:50:3)
	echo alpha-dec-winnt3.5
	exit 0 ;;
    amiga:NetBSD:*:*)
      echo m68k-cbm-netbsd${UNAME_RELEASE}
      exit 0 ;;
    arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*)
	echo arm-acorn-riscix${UNAME_RELEASE}
	exit 0;;
    Pyramid*:OSx*:*:*)
	if test "`(/bin/universe) 2>/dev/null`" = att ; then
		echo pyramid-pyramid-sysv3
	else
		echo pyramid-pyramid-bsd
	fi
	exit 0 ;;
    sun4*:SunOS:5.*:*)
	echo sparc-sun-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
	exit 0 ;;
    i86pc:SunOS:5.*:*)
	echo i386-unknown-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
	exit 0 ;;
    sun4*:SunOS:6*:*)
	# According to config.sub, this is the proper way to canonicalize
	# SunOS6.  Hard to guess exactly what SunOS6 will be like, but
	# it's likely to be more like Solaris than SunOS4.
	echo sparc-sun-solaris3`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
	exit 0 ;;
    sun4*:SunOS:*:*)
	case "`/usr/bin/arch -k`" in
	    Series*|S4*)
		UNAME_RELEASE=`uname -v`
		;;
	esac
	# Japanese Language versions have a version number like `4.1.3-JL'.
	echo sparc-sun-sunos`echo ${UNAME_RELEASE}|sed -e 's/-/_/'`
	exit 0 ;;
    sun3*:SunOS:*:*)
	echo m68k-sun-sunos${UNAME_RELEASE}
	exit 0 ;;
    atari*:NetBSD:*:*)
	echo m68k-atari-netbsd${UNAME_RELEASE}
	exit 0 ;;
    sun3*:NetBSD:*:*)
	echo m68k-sun-netbsd${UNAME_RELEASE}
	exit 0 ;;
    mac68k:NetBSD:*:*)
	echo m68k-apple-netbsd${UNAME_RELEASE}
	exit 0 ;;
    RISC*:ULTRIX:*:*)
	echo mips-dec-ultrix${UNAME_RELEASE}
	exit 0 ;;
    VAX*:ULTRIX*:*:*)
	echo vax-dec-ultrix${UNAME_RELEASE}
	exit 0 ;;
    mips:*:4*:UMIPS)
	echo mips-mips-riscos4sysv
	exit 0 ;;
    mips:*:5*:RISCos)
	echo mips-mips-riscos${UNAME_RELEASE}
	exit 0 ;;
    m88k:CX/UX:7*:*)
	echo m88k-harris-cxux7
	exit 0 ;;
    m88k:*:4*:R4*)
	echo m88k-motorola-sysv4
	exit 0 ;;
    m88k:*:3*:R3*)
	echo m88k-motorola-sysv3
	exit 0 ;;
    AViiON:dgux:*:*)
        # DG/UX returns AViiON for all architectures
        UNAME_PROCESSOR=`uname -p`
        if [ $UNAME_PROCESSOR = mc88100 -o $UNAME_PROCESSOR = mc88100 ] ; then
	if [ ${TARGET_BINARY_INTERFACE}x = m88kdguxelfx \
	     -o ${TARGET_BINARY_INTERFACE}x = x ] ; then
		echo m88k-dg-dgux${UNAME_RELEASE}
	else
		echo m88k-dg-dguxbcs${UNAME_RELEASE}
	fi
        else echo i586-dg-dgux${UNAME_RELEASE}
        fi
 	exit 0 ;;
    M88*:DolphinOS:*:*)	# DolphinOS (SVR3)
	echo m88k-dolphin-sysv3
	exit 0 ;;
    M88*:*:R3*:*)
	# Delta 88k system running SVR3
	echo m88k-motorola-sysv3
	exit 0 ;;
    XD88*:*:*:*) # Tektronix XD88 system running UTekV (SVR3)
	echo m88k-tektronix-sysv3
	exit 0 ;;
    Tek43[0-9][0-9]:UTek:*:*) # Tektronix 4300 system running UTek (BSD)
	echo m68k-tektronix-bsd
	exit 0 ;;
    *:IRIX*:*:*)
	echo mips-sgi-irix`echo ${UNAME_RELEASE}|sed -e 's/-/_/g'`
	exit 0 ;;
   ????????:AIX?:[12].1:2)   # AIX 2.2.1 or AIX 2.1.1 is RT/PC AIX.
	echo romp-ibm-aix      # uname -m gives an 8 hex-code CPU id
	exit 0 ;;              # Note that: echo "'`uname -s`'" gives 'AIX '
    i[34]86:AIX:*:*)
	echo i386-ibm-aix
	exit 0 ;;
    *:AIX:2:3)
	if grep bos325 /usr/include/stdio.h >/dev/null 2>&1; then
		sed 's/^		//' << EOF >dummy.c
		#include <sys/systemcfg.h>

		main()
			{
			if (!__power_pc())
				exit(1);
			puts("powerpc-ibm-aix3.2.5");
			exit(0);
			}
EOF
		${CC-cc} dummy.c -o dummy && ./dummy && rm dummy.c dummy && exit 0
		rm -f dummy.c dummy
		echo rs6000-ibm-aix3.2.5
	elif grep bos324 /usr/include/stdio.h >/dev/null 2>&1; then
		echo rs6000-ibm-aix3.2.4
	else
		echo rs6000-ibm-aix3.2
	fi
	exit 0 ;;
    *:AIX:*:4)
	if /usr/sbin/lsattr -EHl proc0 | grep POWER >/dev/null 2>&1; then
		IBM_ARCH=rs6000
	else
		IBM_ARCH=powerpc
	fi
	if [ -x /usr/bin/oslevel ] ; then
		IBM_REV=`/usr/bin/oslevel`
	else
		IBM_REV=4.${UNAME_RELEASE}
	fi
	echo ${IBM_ARCH}-ibm-aix${IBM_REV}
	exit 0 ;;
    *:AIX:*:*)
	echo rs6000-ibm-aix
	exit 0 ;;
    ibmrt:4.4BSD:*|romp-ibm:BSD:*)
	echo romp-ibm-bsd4.4
	exit 0 ;;
    ibmrt:*BSD:*|romp-ibm:BSD:*)            # covers RT/PC NetBSD and
	echo romp-ibm-bsd${UNAME_RELEASE}   # 4.3 with uname added to 
	exit 0 ;;                           # report: romp-ibm BSD 4.3
    *:BOSX:*:*)
	echo rs6000-bull-bosx
	exit 0 ;;
    DPX/2?00:B.O.S.:*:*)
	echo m68k-bull-sysv3
	exit 0 ;;
    9000/[34]??:4.3bsd:1.*:*)
	echo m68k-hp-bsd
	exit 0 ;;
    hp300:4.4BSD:*:* | 9000/[34]??:4.3bsd:2.*:*)
	echo m68k-hp-bsd4.4
	exit 0 ;;
    9000/[3478]??:HP-UX:*:*)
	case "${UNAME_MACHINE}" in
	    9000/31? )            HP_ARCH=m68000 ;;
	    9000/[34]?? )         HP_ARCH=m68k ;;
	    9000/7?? | 9000/8?[679] ) HP_ARCH=hppa1.1 ;;
	    9000/8?? )            HP_ARCH=hppa1.0 ;;
	esac
	HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'`
	echo ${HP_ARCH}-hp-hpux${HPUX_REV}
	exit 0 ;;
    3050*:HI-UX:*:*)
	sed 's/^	//' << EOF >dummy.c
	#include <unistd.h>
	int
	main ()
	{
	  long cpu = sysconf (_SC_CPU_VERSION);
	  /* The order matters, because CPU_IS_HP_MC68K erroneously returns
	     true for CPU_PA_RISC1_0.  CPU_IS_PA_RISC returns correct
	     results, however.  */
	  if (CPU_IS_PA_RISC (cpu))
	    {
	      switch (cpu)
		{
		  case CPU_PA_RISC1_0: puts ("hppa1.0-hitachi-hiuxwe2"); break;
		  case CPU_PA_RISC1_1: puts ("hppa1.1-hitachi-hiuxwe2"); break;
		  case CPU_PA_RISC2_0: puts ("hppa2.0-hitachi-hiuxwe2"); break;
		  default: puts ("hppa-hitachi-hiuxwe2"); break;
		}
	    }
	  else if (CPU_IS_HP_MC68K (cpu))
	    puts ("m68k-hitachi-hiuxwe2");
	  else puts ("unknown-hitachi-hiuxwe2");
	  exit (0);
	}
EOF
	${CC-cc} dummy.c -o dummy && ./dummy && rm dummy.c dummy && exit 0
	rm -f dummy.c dummy
	echo unknown-hitachi-hiuxwe2
	exit 0 ;;
    9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:* )
	echo hppa1.1-hp-bsd
	exit 0 ;;
    9000/8??:4.3bsd:*:*)
	echo hppa1.0-hp-bsd
	exit 0 ;;
    hp7??:OSF1:*:* | hp8?[79]:OSF1:*:* )
	echo hppa1.1-hp-osf
	exit 0 ;;
    hp8??:OSF1:*:*)
	echo hppa1.0-hp-osf
	exit 0 ;;
    parisc*:Lites*:*:*)
	echo hppa1.1-hp-lites
	exit 0 ;;
    C1*:ConvexOS:*:* | convex:ConvexOS:C1*:*)
	echo c1-convex-bsd
        exit 0 ;;
    C2*:ConvexOS:*:* | convex:ConvexOS:C2*:*)
	if getsysinfo -f scalar_acc
	then echo c32-convex-bsd
	else echo c2-convex-bsd
	fi
        exit 0 ;;
    C34*:ConvexOS:*:* | convex:ConvexOS:C34*:*)
	echo c34-convex-bsd
        exit 0 ;;
    C38*:ConvexOS:*:* | convex:ConvexOS:C38*:*)
	echo c38-convex-bsd
        exit 0 ;;
    C4*:ConvexOS:*:* | convex:ConvexOS:C4*:*)
	echo c4-convex-bsd
        exit 0 ;;
    CRAY*X-MP:*:*:*)
	echo xmp-cray-unicos
        exit 0 ;;
    CRAY*Y-MP:*:*:*)
	echo ymp-cray-unicos${UNAME_RELEASE}
	exit 0 ;;
    CRAY*C90:*:*:*)
	echo c90-cray-unicos${UNAME_RELEASE}
	exit 0 ;;
    CRAY-2:*:*:*)
	echo cray2-cray-unicos
        exit 0 ;;
    hp3[0-9][05]:NetBSD:*:*)
	echo m68k-hp-netbsd${UNAME_RELEASE}
	exit 0 ;;
    i[34]86:BSD/386:*:* | *:BSD/OS:*:*)
	echo ${UNAME_MACHINE}-unknown-bsdi${UNAME_RELEASE}
	exit 0 ;;
    *:FreeBSD:*:*)
	echo ${UNAME_MACHINE}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`
	exit 0 ;;
    *:NetBSD:*:*)
	echo ${UNAME_MACHINE}-unknown-netbsd`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'`
	exit 0 ;;
    *:GNU:*:*)
	echo `echo ${UNAME_MACHINE}|sed -e 's,/.*$,,'`-unknown-gnu`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'`
	exit 0 ;;
    *:Linux:*:*)
	# The BFD linker knows what the default object file format is, so
	# first see if it will tell us.
	ld_help_string=`ld --help 2>&1`
	if echo $ld_help_string | grep >/dev/null 2>&1 "supported emulations: elf_i[345]86"; then
	  echo "${UNAME_MACHINE}-unknown-linux" ; exit 0
	elif echo $ld_help_string | grep >/dev/null 2>&1 "supported emulations: i[345]86linux"; then
	  echo "${UNAME_MACHINE}-unknown-linuxaout" ; exit 0
	elif echo $ld_help_string | grep >/dev/null 2>&1 "supported emulations: i[345]86coff"; then
	  echo "${UNAME_MACHINE}-unknown-linuxcoff" ; exit 0
	elif test "${UNAME_MACHINE}" = "alpha" ; then
	  echo alpha-unknown-linux ; exit 0
	else
	  # Either a pre-BFD a.out linker (linuxoldld) or one that does not give us
	  # useful --help.  Gcc wants to distinguish between linuxoldld and linuxaout.
	  test ! -d /usr/lib/ldscripts/. \
	    && echo "${UNAME_MACHINE}-unknown-linuxoldld" && exit 0
	  # Determine whether the default compiler is a.out or elf
	  cat >dummy.c <<EOF
main(argc, argv)
int argc;
char *argv[];
{
#ifdef __ELF__
  printf ("%s-unknown-linux\n", argv[1]);
#else
  printf ("%s-unknown-linuxaout\n", argv[1]);
#endif
  return 0;
}
EOF
	  ${CC-cc} dummy.c -o dummy 2>/dev/null && ./dummy "${UNAME_MACHINE}" && rm dummy.c dummy && exit 0
	  rm -f dummy.c dummy
	fi ;;
# ptx 4.0 does uname -s correctly, with DYNIX/ptx in there.  earlier versions
# are messed up and put the nodename in both sysname and nodename.
    i[34]86:DYNIX/ptx:4*:*)
	echo i386-sequent-sysv4
	exit 0 ;;
    i[34]86:*:4.*:* | i[34]86:SYSTEM_V:4.*:*)
	if grep Novell /usr/include/link.h >/dev/null 2>/dev/null; then
		echo ${UNAME_MACHINE}-univel-sysv${UNAME_RELEASE}
	else
		echo ${UNAME_MACHINE}-unknown-sysv${UNAME_RELEASE}
	fi
	exit 0 ;;
    i[34]86:*:3.2:*)
	if test -f /usr/options/cb.name; then
		UNAME_REL=`sed -n 's/.*Version //p' </usr/options/cb.name`
		echo ${UNAME_MACHINE}-unknown-isc$UNAME_REL
	elif /bin/uname -X 2>/dev/null >/dev/null ; then
		UNAME_REL=`(/bin/uname -X|egrep Release|sed -e 's/.*= //')`
		(/bin/uname -X|egrep i80486 >/dev/null) && UNAME_MACHINE=i486
		(/bin/uname -X|egrep '^Machine.*Pentium' >/dev/null) \
			&& UNAME_MACHINE=i586
		echo ${UNAME_MACHINE}-unknown-sco$UNAME_REL
	else
		echo ${UNAME_MACHINE}-unknown-sysv32
	fi
	exit 0 ;;
    Intel:Mach:3*:*)
	echo i386-unknown-mach3
	exit 0 ;;
    paragon:*:*:*)
	echo i860-intel-osf1
	exit 0 ;;
    i860:*:4.*:*) # i860-SVR4
	if grep Stardent /usr/include/sys/uadmin.h >/dev/null 2>&1 ; then
	  echo i860-stardent-sysv${UNAME_RELEASE} # Stardent Vistra i860-SVR4
	else # Add other i860-SVR4 vendors below as they are discovered.
	  echo i860-unknown-sysv${UNAME_RELEASE}  # Unknown i860-SVR4
	fi
	exit 0 ;;
    mini*:CTIX:SYS*5:*)
	# "miniframe"
	echo m68010-convergent-sysv
	exit 0 ;;
    M680[234]0:*:R3V[567]*:*)
	test -r /sysV68 && echo 'm68k-motorola-sysv' && exit 0 ;;
    3[34]??:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0)
        uname -p 2>/dev/null | grep 86 >/dev/null \
          && echo i486-ncr-sysv4.3 && exit 0 ;;
    3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*)
        uname -p 2>/dev/null | grep 86 >/dev/null \
          && echo i486-ncr-sysv4 && exit 0 ;;
    m680[234]0:LynxOS:2.[23]*:*)
	echo m68k-lynx-lynxos${UNAME_RELEASE}
	exit 0 ;;
    mc68030:UNIX_System_V:4.*:*)
	echo m68k-atari-sysv4
	exit 0 ;;
    i[34]86:LynxOS:2.[23]*:*)
	echo i386-lynx-lynxos${UNAME_RELEASE}
	exit 0 ;;
    TSUNAMI:LynxOS:2.[23]*:*)
	echo sparc-lynx-lynxos${UNAME_RELEASE}
	exit 0 ;;
    rs6000:LynxOS:2.[23]*:*)
	echo rs6000-lynx-lynxos${UNAME_RELEASE}
	exit 0 ;;
    RM*:SINIX-*:*:*)
	echo mips-sni-sysv4
	exit 0 ;;
    *:SINIX-*:*:*)
	if uname -p 2>/dev/null >/dev/null ; then
		UNAME_MACHINE=`(uname -p) 2>/dev/null`
		echo ${UNAME_MACHINE}-sni-sysv4
	else
		echo ns32k-sni-sysv
	fi
	exit 0 ;;
esac

#echo '(No uname command or uname output not recognized.)' 1>&2
#echo "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" 1>&2

cat >dummy.c <<EOF
#ifdef _SEQUENT_
# include <sys/types.h>
# include <sys/utsname.h>
#endif
main ()
{
#if defined (sony)
#if defined (MIPSEB)
  /* BFD wants "bsd" instead of "newsos".  Perhaps BFD should be changed,
     I don't know....  */
  printf ("mips-sony-bsd\n"); exit (0);
#else
#include <sys/param.h>
  printf ("m68k-sony-newsos%s\n",
#ifdef NEWSOS4
          "4"
#else
	  ""
#endif
         ); exit (0);
#endif
#endif

#if defined (__arm) && defined (__acorn) && defined (__unix)
  printf ("arm-acorn-riscix"); exit (0);
#endif

#if defined (hp300) && !defined (hpux)
  printf ("m68k-hp-bsd\n"); exit (0);
#endif

#if defined (NeXT)
#if !defined (__ARCHITECTURE__)
#define __ARCHITECTURE__ "m68k"
#endif
  int version;
  version=`(hostinfo | sed -n 's/.*NeXT Mach \([0-9]*\).*/\1/p') 2>/dev/null`;
  printf ("%s-next-nextstep%s\n", __ARCHITECTURE__,  version==2 ? "2" : "3");
  exit (0);
#endif

#if defined (MULTIMAX) || defined (n16)
#if defined (UMAXV)
  printf ("ns32k-encore-sysv\n"); exit (0);
#else
#if defined (CMU)
  printf ("ns32k-encore-mach\n"); exit (0);
#else
  printf ("ns32k-encore-bsd\n"); exit (0);
#endif
#endif
#endif

#if defined (__386BSD__)
  printf ("i386-unknown-bsd\n"); exit (0);
#endif

#if defined (sequent)
#if defined (i386)
  printf ("i386-sequent-dynix\n"); exit (0);
#endif
#if defined (ns32000)
  printf ("ns32k-sequent-dynix\n"); exit (0);
#endif
#endif

#if defined (_SEQUENT_)
    struct utsname un;

    uname(&un);

    if (strncmp(un.version, "V2", 2) == 0) {
	printf ("i386-sequent-ptx2\n"); exit (0);
    }
    if (strncmp(un.version, "V1", 2) == 0) { /* XXX is V1 correct? */
	printf ("i386-sequent-ptx1\n"); exit (0);
    }
    printf ("i386-sequent-ptx\n"); exit (0);

#endif

#if defined (vax)
#if !defined (ultrix)
  printf ("vax-dec-bsd\n"); exit (0);
#else
  printf ("vax-dec-ultrix\n"); exit (0);
#endif
#endif

#if defined (alliant) && defined (i860)
  printf ("i860-alliant-bsd\n"); exit (0);
#endif

  exit (1);
}
EOF

${CC-cc} dummy.c -o dummy 2>/dev/null && ./dummy && rm dummy.c dummy && exit 0
rm -f dummy.c dummy

# Apollos put the system type in the environment.

test -d /usr/apollo && { echo ${ISP}-apollo-${SYSTYPE}; exit 0; }

# Convex versions that predate uname can use getsysinfo(1)

if [ -x /usr/convex/getsysinfo ]
then
    case `getsysinfo -f cpu_type` in
    c1*)
	echo c1-convex-bsd
	exit 0 ;;
    c2*)
	if getsysinfo -f scalar_acc
	then echo c32-convex-bsd
	else echo c2-convex-bsd
	fi
	exit 0 ;;
    c34*)
	echo c34-convex-bsd
	exit 0 ;;
    c38*)
	echo c38-convex-bsd
	exit 0 ;;
    c4*)
	echo c4-convex-bsd
	exit 0 ;;
    esac
fi

#echo '(Unable to guess system type)' 1>&2

exit 1
eof-for-guess
  cd $TMPDIR;
  sh $TMPDIR/config.guess
}

#debug=true
debug=

################################################################
# main()
################################################################
init
menu_main

These are the contents of the former NiCE NeXT User Group NeXTSTEP/OpenStep software archive, currently hosted by Netfuture.ch.