#!/bin/sh
# N.B. make sure this really is a true Bourne-compatible shell.

###############################################################
# wxinstal -- wxWindows installation script.                  #
# Julian Smart, April 1994                                    #
# Usage: wxinstal [optional wxWindows target directory]       #
###############################################################

########### Edit these variables for your system. #############
########### ALSO edit wx/src/make.env once unarchived #########

# Editor
MYEDITOR=$EDITOR
if [ "$MYEDITOR" = "" ]
then
  MYEDITOR=emacs
fi

# Pager
MYPAGER=$PAGER
if [ "$MYPAGER" = "" ]
then
  MYPAGER=more
fi

# wxWindows directory to install to
WXDIR=`pwd`
if [ ! "$1" = "" ]
then
  WXDIR=$1
fi

# Target (motif, xview, hp)
GUITARGET=xview

# Archive prefix, dependent on version number
ARCHIVE=wx160

# Current directory
CURRENTDIR=`pwd`

# PostScript viewer, if any
POSTSCRIPTVIEWER=ghostview

# Program to convert to DOS file format
TODOSPROGRAM=todos

# Program to convert from DOS file format
FROMDOSPROGRAM=fromdos

# Don't change this
GUISUFFIX=_motif

if [ "$GUITARGET" = "motif" ]
then
  GUISUFFIX=_motif
fi

if [ "$GUITARGET" = "xview" ]
then
  GUISUFFIX=_ol
fi

if [ "$GUITARGET" = "hp" ]
then
  GUISUFFIX=_hp
fi

install_from_tar()
{
  if [ -f $CURRENTDIR/$ARCHIVE".tar" ]
  then
    if [ ! -d $WXDIR ]
    then
      echo Making directory $WXDIR
      mkdir $WXDIR
    fi
    if [ ! -d $WXDIR ]
    then
      echo $WXDIR" cannot be created!"
    else
      echo Untarring $CURRENTDIR/$ARCHIVE".tar."
      echo Please be patient...
      cd $WXDIR
      tar xf $CURRENTDIR/$ARCHIVE".tar"
      echo If you saw no errors, untarring was successful.
    fi
  else
    echo $CURRENTDIR/$ARCHIVE".tar" not found.
  fi
  cd $CURRENTDIR
}

install_from_z()
{
  if [ -f $CURRENTDIR/$ARCHIVE".tar.Z" ]
  then
    echo Uncompressing $CURRENTDIR/$ARCHIVE".tar.Z"
    uncompress $CURRENTDIR/$ARCHIVE".tar.Z"
    install_from_tar
  else
    echo $CURRENTDIR/$ARCHIVE".tar.Z" not found. Please place in the current directory.
  fi
  cd $CURRENTDIR
}

install_from_gzip()
{
  if [ -f $CURRENTDIR/$ARCHIVE".tgz" ]
  then
    echo Uncompressing $CURRENTDIR/$ARCHIVE".tgz"
    gzip -d $CURRENTDIR/$ARCHIVE".tgz"
    install_from_tar
  else
    echo $CURRENTDIR/$ARCHIVE".tgz" not found. Please place in the current directory.
  fi
  cd $CURRENTDIR
}

install_from_zip()
{
  if [ ! -d $WXDIR ]
  then
    echo Making directory $WXDIR
    mkdir $WXDIR
  fi
  if [ ! -d $WXDIR ]
  then
    echo $WXDIR" cannot be created!"
  else
    if [ -f $CURRENTDIR/$ARCHIVE"_1.zip" -a -f $CURRENTDIR/$ARCHIVE"_2.zip" -a -f $CURRENTDIR/$ARCHIVE"_3.zip" ]
    then
      cd $WXDIR
      echo Unzipping $ARCHIVE"_1.zip, " $ARCHIVE"_2.zip," $ARCHIVE"_3.zip"
      unzip -d $CURRENTDIR/$ARCHIVE"_1.zip"
      unzip -d $CURRENTDIR/$ARCHIVE"_2.zip"
      unzip -d $CURRENTDIR/$ARCHIVE"_3.zip"
    else
      echo $CURRENTDIR/$ARCHIVE"_*.zip" not found. Please place in the current directory.
    fi
  fi
  cd $CURRENTDIR
}

install_from_archive()
{
  echo
  echo "Install from Archive"
  echo "--------------------"
  echo "1) Install from " $ARCHIVE".tar.Z"
  echo "2) Install from " $ARCHIVE".tgz"
  echo "3) Install from " $ARCHIVE"_1.zip, " $ARCHIVE"_2.zip, "$ARCHIVE"_3.zip"
  echo "4) Install from " $ARCHIVE".tar"
  echo "0) Possibly edit make.env and Quit."
  echo
  read archans

  if [ "$archans" = "1" ]
  then
    install_from_z
  fi
  if [ "$archans" = "2" ]
  then
    install_from_gzip
  fi
  if [ "$archans" = "3" ]
  then
    install_from_zip
  fi
  if [ "$archans" = "4" ]
  then
    install_from_tar
  fi
  cd $CURRENTDIR

  if [ -f $WXDIR/src/make.env ]
  then
    echo ""
    echo "If the files are unarchived ok, you should edit the file"
    echo $WXDIR"/src/make.env"
    echo "since this sets many options for your wxWindows"
    echo "compilation environment."
    echo ""
    echo "Would you like to edit the file now? (y/n)"
    echo
    read ans
    if [ "$ans" = "y" ]
    then
      $MYEDITOR $WXDIR/src/make.env
      echo ""
      echo Ok, if you get compilation or link errors in the installation,
      echo $WXDIR"/src/make.env is the first place to look."
      echo ""
      echo "Press return to continue."
      read ans
    fi
  else
    echo ""
    echo "Uh-oh, cannot find "$WXDIR"/src/make.env; probably you have not unarchived"
    echo "properly yet."
    echo ""
    echo "Press return to continue."
    read ans
  fi
}

make_main_library()
{
  if [ ! -d $WXDIR/src ]
  then
    echo "Source directory not found: please unarchive first."
    echo Press return to continue.
    read ans
  else
    echo
    echo Making the wxWindows main library. It will go in
    echo $WXDIR/lib.
    echo
    echo Please press RETURN to continue, and then make yourself a coffee.
    echo 
    read ans
    if [ ! -d $WXDIR/lib ]
    then
      mkdir $WXDIR/lib
    fi

    cd $WXDIR/src/x
    make -f makefile.unx $GUITARGET | tee $CURRENTDIR/make.log
    cd $CURRENTDIR

    if [ -f $WXDIR/lib/libwx$GUISUFFIX".a" ]
    then  
      echo
      echo "If you saw no errors, wxWindows was compiled. See the file make.log"
      echo "for errors and warnings."
    else
      echo
      echo $WXDIR/lib/libwx$GUISUFFIX".a was not built."
      echo "Please check make.env, and read install.txt and faq.txt/ps."
      echo
      echo "Press return to continue."
      echo
      read ans
    fi
  fi
}

###############################################################
# Make peripheral components                                  #
###############################################################

make_toolbar()
{
  if [ ! -d $WXDIR/utils/toolbar ]
  then
    echo wxToolBar directory does not exist.
    echo Press return to continue.
    read ans
  else
    echo
    echo Making the wxToolBar library. It will go in
    echo $WXDIR/utils/toolbar/lib.
    echo
    cd $WXDIR/utils/toolbar/src
    make -e -f makefile.unx $GUITARGET | tee $CURRENTDIR/make.log
    cd $CURRENTDIR
    echo
    echo "If you saw no errors, the toolbar library was compiled. See the file make.log"
    echo "for errors and warnings."
    echo ""
    echo "Would you like to make and run the demo for this library? (y/n)"
    echo
    read ans
    if [ "$ans" = "y" ]
    then
      cd $WXDIR/utils/toolbar/src
      make -e -f makefile.unx demo$GUISUFFIX | tee $CURRENTDIR/make.log
      echo ""
      if [ -f $WXDIR/utils/toolbar/src/test$GUISUFFIX ]
      then
        echo "Run the wxToolBar demo? (y/n)"
        echo ""
        read ans1
        if [ "$ans1" = "y" ]
        then
          $WXDIR/utils/toolbar/src/test$GUISUFFIX
        fi
      fi
      cd $CURRENTDIR
    fi
  fi
}

make_prologio()
{
  if [ ! -d $WXDIR/utils/prologio ]
  then
    echo PROLOGIO directory does not exist.
    echo Press return to continue.
    read ans
  else
    echo
    echo "Warning: if FLEX fails, it may be because lexer.l is"
    echo "in DOS file format. In which case, use EMACS to remove"
    echo "^M characters in lexer.l with:"
    echo "  (Meta-X replace-string RETURN Ctl-Q RETURN RETURN RETURN),"
    echo "or use tounix or other DOS->UNIX file conversion program."
    echo
    echo "Press return to continue."
    read ans
    echo
    echo Making the PROLOGIO library. It will go in
    echo $WXDIR/utils/prologio/lib.
    echo
    cd $WXDIR/utils/prologio/src
    make -e -f makefile.unx $GUITARGET | tee $CURRENTDIR/make.log
    cd $CURRENTDIR
    echo
    echo "If you saw no errors, the PROLOGIO library was compiled. See the file make.log"
    echo "for errors and warnings."
    echo ""
    echo "Would you like to make and run the demo for this library? (y/n)"
    echo
    read ans
    if [ "$ans" = "y" ]
    then
      cd $WXDIR/utils/prologio/src
      make -e -f makefile.unx demo$GUISUFFIX | tee $CURRENTDIR/make.log
      echo ""
      if [ -f $WXDIR/utils/prologio/src/test$GUISUFFIX ]
      then
        echo "Run the PROLOGIO demo? (y/n)"
        echo ""
        read ans1
        if [ "$ans1" = "y" ]
        then
          echo "Try opening the file "$WXDIR/utils/prologio/docs/badcase.txt"."
          echo "This is a fairly big PROLOGIO file; if an error occurs during"
          echo "reading, there is a problem (or the file is not a PROLOGIO file,"
          echo "or is in DOS format)."
          echo ""
          echo "If the test program exits with the message:"
          echo ""
          echo "  Input string too long, limit 200"
          echo ""
          echo "then you'll need to change YYLMAX in lex_yy.c to a large number,"
          echo "such as 5000".
          echo "" 
          echo "You can double-check PROLOGIO by saving as a different file, and checking"
          echo "that the contents are the same as the original."
          echo ""
          echo "Press return to continue."
          read ans1
          $WXDIR/utils/prologio/src/test$GUISUFFIX
        fi
      fi
      cd $CURRENTDIR
    fi
  fi
}

make_hytext()
{
  if [ ! -d $WXDIR/utils/hytext ]
  then
    echo hyText directory does not exist.
    echo Press return to continue.
    read ans
  else
    echo
    echo Making the hyText library. It will go in
    echo $WXDIR/utils/hytext/lib.
    echo
    cd $WXDIR/utils/hytext/src
    make -e -f makefile.unx $GUITARGET | tee $CURRENTDIR/make.log
    cd $CURRENTDIR
    echo
    echo "If you saw no errors, the hyText library was compiled. See the file make.log"
    echo "for errors and warnings."
  fi
}

make_wxtree()
{
  if [ ! -d $WXDIR/utils/wxtree ]
  then
    echo wxTree directory does not exist.
    echo Press return to continue.
    read ans
  else
    echo
    echo Making the wxTree library. It will go in
    echo $WXDIR/utils/wxtree/lib.
    echo
    cd $WXDIR/utils/wxtree/src
    make -e -f makefile.unx $GUITARGET | tee $CURRENTDIR/make.log
    cd $CURRENTDIR
    echo
    echo "If you saw no errors, the wxTree library was compiled. See the file make.log"
    echo "for errors and warnings."
  fi
}

make_wxgraph()
{
  if [ ! -d $WXDIR/utils/wxgraph ]
  then
    echo wxGraph directory does not exist.
    echo Press return to continue.
    read ans
  else
    echo
    echo Making the wxGraph library. It will go in
    echo $WXDIR/utils/wxgraph/lib.
    echo
    cd $WXDIR/utils/wxgraph/src
    make -e -f makefile.unx $GUITARGET | tee $CURRENTDIR/make.log
    cd $CURRENTDIR
    echo
    echo "If you saw no errors, the wxGraph library was compiled. See the file make.log"
    echo "for errors and warnings."
  fi
}

make_wximage()
{
  if [ ! -d $WXDIR/utils/image ]
  then
    echo #WXDIR/utils/image directory does not exist.
    echo Press return to continue.
    read ans
  else
    echo
    echo Making the wxImage library. It will go in
    echo $WXDIR/utils/image/lib.
    echo
    cd $WXDIR/utils/image/src
    make -e -f makefile.unx $GUITARGET | tee $CURRENTDIR/make.log
    cd $CURRENTDIR
    echo
    echo "If you saw no errors, the wxImage library was compiled. See the file make.log"
    echo "for errors and warnings."
    echo ""
    echo "Would you like to make and run the demo for this library? (y/n)"
    echo
    read ans
    if [ "$ans" = "y" ]
    then
      cd $WXDIR/utils/image/src
      make -e -f makefile.unx demo$GUISUFFIX | tee $CURRENTDIR/make.log
      echo ""
      if [ -f $WXDIR/utils/image/src/test$GUISUFFIX ]
      then
        echo "Run the wxImage demo? (y/n)"
        echo ""
        read ans1
        if [ "$ans1" = "y" ]
        then
          $WXDIR/utils/image/src/test$GUISUFFIX
        fi
      fi
      cd $CURRENTDIR
    fi
  fi
}

make_colour()
{
  if [ ! -d $WXDIR/utils/colours ]
  then
    echo $WXDIR/utils/colours directory does not exist.
    echo Press return to continue.
    read ans
  else
    echo
    echo Making the Colour sampler. It will go in
    echo $WXDIR/utils/colours
    echo
    cd $WXDIR/utils/colours
    make -e -f makefile.unx $GUITARGET | tee $CURRENTDIR/make.log
    cd $CURRENTDIR
    echo
    echo "If you saw no errors, the Colour sampler was compiled. See the file make.log"
    echo "for errors and warnings."
    echo ""
    if [ -f $WXDIR/utils/colours/colours$GUISUFFIX ]
    then
      echo "Run the Colour sampler? (y/n)"
      echo ""
      read ans1
      if [ "$ans1" = "y" ]
      then
        $WXDIR/utils/colours/colours$GUISUFFIX
      fi
    fi
  fi
}

make_wxhelp()
{
  if [ ! -d $WXDIR/utils/wxhelp ]
  then
    echo wxHelp directory does not exist.
    echo Press return to continue.
    read ans
  else
    echo
    echo Making the wxHelp program. It will go in
    echo $WXDIR/utils/wxhelp/src.
    echo
    cd $WXDIR/utils/wxhelp/src
    make -e -f makefile.unx $GUITARGET | tee $CURRENTDIR/make.log
    cd $CURRENTDIR
    echo
    echo "If you saw no errors, the wxHelp program was compiled. See the file make.log"
    echo "for errors and warnings."
  fi
}

make_wxbuild1()
{
  echo
  echo Making the wxBuilder program. It will go in
  echo $WXDIR/utils/wxbuild/src.
  echo
  cd $WXDIR/utils/wxbuild/src
  make -e -f makefile.unx $GUITARGET | tee $CURRENTDIR/make.log
  cd $CURRENTDIR
  echo
  echo "If you saw no errors, the wxBuilder program was compiled. See the file make.log"
  echo "for errors and warnings."
}

make_wxbuild()
{
  if [ ! -d $WXDIR/utils/wxbuild ]
  then
    echo wxBuilder directory does not exist.
    echo Press return to continue.
    read ans
  else
    if [ "$GUITARGET" = "xview" ]
    then
      echo "The XView version of wxBuilder isn't fully functional"
      echo "at the moment: it's waiting for some modal dialogs to be removed"
      echo "since more than one level of modal dialog gives XView the"
      echo "heebee-jeebees. Make wxBuilder? (y/n)"
      echo
      read ans
      if [ "$ans" = "y" ]
      then
        make_wxbuild1
      fi
    else
      make_wxbuild1
    fi
  fi
}

make_tex2rtf()
{
  if [ ! -d $WXDIR/utils/tex2rtf ]
  then
    echo Tex2RTF directory does not exist.
    echo Press return to continue.
    read ans
  else
    echo
    echo Making the Tex2RTF utility. It will go in
    echo $WXDIR/utils/tex2rtf/src.
    echo
    cd $WXDIR/utils/tex2rtf/src
    make -e -f makefile.unx $GUITARGET | tee $CURRENTDIR/make.log
    cd $CURRENTDIR
    echo
    echo "If you saw no errors, the Tex2RTF program was compiled. See the file make.log"
    echo "for errors and warnings."
  fi
}

###############################################################
# Make demos                                                  #
###############################################################

make_hello()
{
  echo
  echo Making the Hello demo. It will be made as
  echo $WXDIR/samples/hello/hello$GUISUFFIX
  echo
  cd $WXDIR/samples/hello
  make -e -f makefile.unx $GUITARGET 2>&1 | tee $CURRENTDIR/make.log
  cd $CURRENTDIR
  echo
  echo "If you saw no errors, the Hello demo was compiled. See the file make.log"
  echo "for errors and warnings."
}

make_minimal()
{
  echo
  echo Making the Minimal demo. It will be made as
  echo $WXDIR/samples/minimal/minimal$GUISUFFIX
  echo
  cd $WXDIR/samples/minimal
  make -e -f makefile.unx $GUITARGET 2>&1 | tee $CURRENTDIR/make.log
  cd $CURRENTDIR
  echo
  echo "If you saw no errors, the Minimal demo was compiled. See the file make.log"
  echo "for errors and warnings."
}

make_mdi()
{
  echo
  echo Making the Mdi demo. It will be made as
  echo $WXDIR/samples/mdi/mdi$GUISUFFIX
  echo
  cd $WXDIR/samples/mdi
  make -e -f makefile.unx $GUITARGET 2>&1 | tee $CURRENTDIR/make.log
  cd $CURRENTDIR
  echo
  echo "If you saw no errors, the MDI demo was compiled. See the file make.log"
  echo "for errors and warnings."
}

make_animate()
{
  echo
  echo Making the Animate demo. It will be made as
  echo $WXDIR/samples/animate/anim$GUISUFFIX
  echo
  cd $WXDIR/samples/animate
  make -e -f makefile.unx $GUITARGET 2>&1 | tee $CURRENTDIR/make.log
  cd $CURRENTDIR
  echo
  echo "If you saw no errors, the Animate demo was compiled. See the file make.log"
  echo "for errors and warnings."
}

make_fractal()
{
  echo
  echo Making the Fractal demo. It will be made as
  echo $WXDIR/samples/fractal/fractal$GUISUFFIX
  echo
  cd $WXDIR/samples/fractal
  make -e -f makefile.unx $GUITARGET 2>&1 | tee $CURRENTDIR/make.log
  cd $CURRENTDIR
  echo
  echo "If you saw no errors, the Fractal demo was compiled. See the file make.log"
  echo "for errors and warnings."
}

make_form()
{
  echo
  echo Making the Form demo. It will be made as
  echo $WXDIR/samples/form/form$GUISUFFIX
  echo
  cd $WXDIR/samples/form
  make -e -f makefile.unx $GUITARGET 2>&1 | tee $CURRENTDIR/make.log
  cd $CURRENTDIR
  echo
  echo "If you saw no errors, the Form demo was compiled. See the file make.log"
  echo "for errors and warnings."
}

make_ipc()
{
  echo
  echo Making the IPC demo. It will be made as
  echo $WXDIR/samples/ipc/server$GUISUFFIX
  echo $WXDIR/samples/ipc/client$GUISUFFIX
  echo
  cd $WXDIR/samples/ipc
  make -e -f makefile.unx $GUITARGET 2>&1 | tee $CURRENTDIR/make.log
  cd $CURRENTDIR
  echo
  echo "If you saw no errors, the IPC demo was compiled. See the file make.log"
  echo "for errors and warnings."
}

make_all_periph_components()
{
  make_toolbar
  make_prologio
  make_wxtree
  make_wxgraph
  make_hytext
  make_wxhelp
  make_tex2rtf
  make_colour
  make_wximage
  make_wxbuild
}

about_periph_components()
{
  clear
  echo "About the Peripheral Components"
  echo "-------------------------------"
  echo
  echo "These are libraries and programs that are considered useful"
  echo "enough to put in the main wxWindows distribution."
  echo
  echo wxToolBar
  echo ---------
  echo    A library for constructing arrays of bitmaps, which can be
  echo    clicked or toggled.
  echo
  echo PROLOGIO
  echo --------
  echo    A library of routines for making it easy to read and write
  echo    files of objects with attributes and values, such as:
  echo
  echo "     thing(id = 1, name = fred)."
  echo
  echo    These files can be very robust to changes in your application,
  echo    they can be edited by hand, and they are very easy to manipulate.
  echo
  echo wxTree A tree-drawing library, with demo
  echo ------
  echo    
  echo wxGraph A node and arc graph-drawing library, with demo
  echo -------
  echo    
  echo "Press return to continue"
  read ans
  clear
  echo hyText A simple hypertext library
  echo ------
  echo    
  echo wxHelp The wxWindows on-line help program
  echo ------
  echo
  echo wxImage A library for reading/displaying bitmaps under X,
  echo ------- with demo
  echo
  echo Colours A colour sampler displaying colours and their names
  echo -------
  echo
  echo "Tex2RTF LaTeX->RTF, HTML, XLP converter"
  echo -------
  echo
  echo wxBuilder A simple screen painter/C++ code generator
  echo ---------
  echo
  echo "Press return to continue"
  read ans
  clear
  echo   Also available separately from skye.aiai.ed.ac.uk:
  echo
  echo   wxCLIPS, an Open Look/Motif/Windows version of the
  echo   rule-based shell CLIPS, with binaries.
  echo   "May be ftp'ed from /pub/wxclips."
  echo
  echo   Tex2RTF sources and binaries for Open Look/Motif/Windows.
  echo   "May be ftp'ed from /pub/tex2rtf."
  echo
  echo   ClockWorks, an Open Look/Motif/Windows configurable analog
  echo   clock, with source.
  echo   "May be ftp'ed from /pub/wxwin/clockworks."
  echo   
  echo "Press return to continue"
  read ans
}

make_peripheral_components()
{
  compoption='none'
  while [ "$compoption" != "0" ]
  do
    echo
    echo "Peripheral Component Options"
    echo "----------------------------"
    echo " 1) Make wxToolBar library"
    echo " 2) Make PROLOGIO library"
    echo " 3) Make wxTree layout library"
    echo " 4) Make wxGraph layout library"
    echo " 5) Make hyText library"
    echo " 6) Make wxImage GIF/BMP loading library"
    echo " 7) Make wxHelp system"
    echo " 8) Make Colour sampler"
    echo " 9) Make Tex2RTF RTF/HTML/wxHelp/WinHelp converter"
    echo "10) Make wxBuilder (Motif only)"
    echo "11) Make all the above"
    echo "----------------------------"
    echo " ?) About these components"
    echo "----------------------------"
    echo " 0) Quit."
    echo
    read compoption

    if [ "$compoption" = "1" ]
    then
      make_toolbar
    fi
    if [ "$compoption" = "2" ]
    then
      make_prologio
    fi
    if [ "$compoption" = "3" ]
    then
      make_wxtree
    fi
    if [ "$compoption" = "4" ]
    then
      make_wxgraph
    fi
    if [ "$compoption" = "5" ]
    then
      make_hytext
    fi
    if [ "$compoption" = "6" ]
    then
      make_wximage
    fi
    if [ "$compoption" = "7" ]
    then
      make_wxhelp
    fi
    if [ "$compoption" = "8" ]
    then
      make_colour
    fi
    if [ "$compoption" = "9" ]
    then
      make_tex2rtf
    fi
    if [ "$compoption" = "10" ]
    then
      make_wxbuild
    fi
    if [ "$compoption" = "11" ]
    then
      make_all_periph_components
    fi
    if [ "$compoption" = "?" ]
    then
      about_periph_components
    fi
  done
}

make_all_demos()
{
  make_hello
  make_minimal
  make_mdi
  make_ipc
  make_form
  make_animate
  make_fractal
}

make_demos()
{
  compoption='none'
  while [ "$compoption" != "0" ]
  do
    echo
    echo "Demo compilation options"
    echo "------------------------"
    echo "1) Make Hello demo (the main wxWindows demo)"
    echo "2) Make Minimal demo"
    echo "3) Make MDI (Multiple document interface) demo"
    echo "4) Make IPC demo"
    echo "5) Make wxForm demo"
    echo "6) Make 3D Animate demo"
    echo "7) Make Fractal demo"
    echo "8) Make all the above"
    echo "9) Run a demo"
    echo "------------------------"
    echo "0) Quit."
    echo
    read compoption

    if [ "$compoption" = "1" ]
    then
      make_hello
    fi
    if [ "$compoption" = "2" ]
    then
      make_minimal
    fi
    if [ "$compoption" = "3" ]
    then
      make_mdi
    fi
    if [ "$compoption" = "4" ]
    then
      make_ipc
    fi
    if [ "$compoption" = "5" ]
    then
      make_form
    fi
    if [ "$compoption" = "6" ]
    then
      make_animate
    fi
    if [ "$compoption" = "7" ]
    then
      make_fractal
    fi
    if [ "$compoption" = "8" ]
    then
      make_all_demos
    fi
    if [ "$compoption" = "9" ]
    then
      run_demos
    fi
  done
}

###############################################################
# Run demos                                                   #
###############################################################

run_hello()
{
  if [ ! -f $WXDIR"/samples/hello/hello"$GUISUFFIX ]
  then
    echo The Hello sample has not been compiled yet.
  else
    echo
    echo "Running "$WXDIR"/samples/hello/hello"$GUISUFFIX
    echo
    cd $WXDIR"/samples/hello"
    "hello"$GUISUFFIX
    cd $CURRENTDIR
  fi
}

run_minimal()
{
  if [ ! -f $WXDIR"/samples/minimal/minimal"$GUISUFFIX ]
  then
    echo The Minimal sample has not been compiled yet.
  else
    echo
    echo "Running "$WXDIR"/samples/minimal/minimal"$GUISUFFIX
    echo
    cd $WXDIR"/samples/minimal"
    "minimal"$GUISUFFIX
    cd $CURRENTDIR
  fi
}

run_mdi()
{
  if [ ! -f $WXDIR"/samples/mdi/mdi"$GUISUFFIX ]
  then
    echo The MDI sample has not been compiled yet.
  else
    echo
    echo "Running "$WXDIR"/samples/mdi/mdi"$GUISUFFIX
    echo
    cd $WXDIR"/samples/mdi"
    "mdi"$GUISUFFIX
    cd $CURRENTDIR
  fi
}

run_form()
{
  if [ ! -f $WXDIR"/samples/form/form"$GUISUFFIX ]
  then
    echo The Form sample has not been compiled yet.
  else
    echo
    echo "Running "$WXDIR"/samples/form/form"$GUISUFFIX
    echo
    cd $WXDIR"/samples/form"
    "form"$GUISUFFIX
    cd $CURRENTDIR
  fi
}

run_animate()
{
  if [ ! -f $WXDIR"/samples/animate/anim"$GUISUFFIX ]
  then
    echo The Animate sample has not been compiled yet.
  else
    echo
    echo "Running "$WXDIR"/samples/animate/anim"$GUISUFFIX
    echo
    cd $WXDIR"/samples/animate"
    "anim"$GUISUFFIX
    cd $CURRENTDIR
  fi
}

run_fractal()
{
  if [ ! -f $WXDIR"/samples/fractal/fractal"$GUISUFFIX ]
  then
    echo The Fractal sample has not been compiled yet.
  else
    echo
    echo "Running "$WXDIR"/samples/fractal/fractal"$GUISUFFIX
    echo
    cd $WXDIR"/samples/fractal"
    "fractal"$GUISUFFIX
    cd $CURRENTDIR
  fi
}

run_ipc()
{
  if [ ! -f $WXDIR"/samples/ipc/client"$GUISUFFIX ]
  then
    echo The IPC samples have not been compiled yet.
  else
    echo
    echo "Running "$WXDIR"/samples/ipc/client"$GUISUFFIX,
    echo "        "$WXDIR"/samples/ipc/server"$GUISUFFIX
    echo
    cd $WXDIR"/samples/ipc"
    echo "Starting server..."
    "server"$GUISUFFIX &
    echo "Waiting 15 seconds..."
    sleep 15
    echo "Starting client..."
    "client"$GUISUFFIX
    cd $CURRENTDIR
  fi
}

run_demos()
{
  runoption='none'
  while [ "$runoption" != "0" ]
  do
    echo
    echo "Run a wxWindows demo"
    echo "--------------------"
    echo "1) Run Hello demo (the main wxWindows demo)"
    echo "2) Run Minimal demo"
    echo "3) Run MDI (Multiple document interface) demo"
    echo "4) Run IPC demo"
    echo "5) Run wxForm demo"
    echo "6) Run 3D Animate demo"
    echo "7) Run Fractal demo"
    echo "--------------------"
    echo "0) Quit."
    echo
    read runoption

    if [ "$runoption" = "1" ]
    then
      run_hello
    fi
    if [ "$runoption" = "2" ]
    then
      run_minimal
    fi
    if [ "$runoption" = "3" ]
    then
      run_mdi
    fi
    if [ "$runoption" = "4" ]
    then
      run_ipc
    fi
    if [ "$runoption" = "5" ]
    then
      run_form
    fi
    if [ "$runoption" = "6" ]
    then
      run_animate
    fi
    if [ "$runoption" = "7" ]
    then
      run_fractal
    fi
  done
}

make_all()
{
  make_main_library
  make_all_periph_components
  make_all_demos
}

remove_component()
{
  if [ -d $COMPONENT ]
  then
    echo "Remove "$COMPONENT": are you sure? (y/n) "
    echo
    read ans
    if [ "$ans" = "y" ]
    then
      rm -f -r $COMPONENT
    fi
  fi
}

remove_components()
{
  compoption='none'
  while [ "$compoption" != "0" ]
  do
    if [ -f $WXDIR/docs/manual.ps ]
    then
      PSMANUALSOK="*"
    else
      PSMANUALSOK=" "
    fi
  
    if [ -f $WXDIR/docs/wx.hlp ]
    then
      HLPMANUALSOK="*"
    else
      HLPMANUALSOK=" "
    fi
  
    if [ -d $WXDIR/utils/prologio ]
    then
      PROLOGIOOK="*"
    else
      PROLOGIOOK=" "
    fi
  
    if [ -d $WXDIR/utils/toolbar ]
    then
      TOOLBAROK="*"
    else
      TOOLBAR=" "
    fi
  
    if [ -d $WXDIR/utils/wxtree ]
    then
      WXTREEOK="*"
    else
      WXTREEOK=" "
    fi
  
    if [ -d $WXDIR/utils/wxgraph ]
    then
      WXGRAPHOK="*"
    else
      WXGRAPHOK=" "
    fi

    if [ -d $WXDIR/utils/wxhelp ]
    then
      WXHELPOK="*"
    else
      WXHELPOK=" "
    fi

    if [ -d $WXDIR/utils/tex2rtf ]
    then
      TEX2RTFOK="*"
    else
      TEX2RTFOK=" "
    fi

    if [ -d $WXDIR/utils/hytext ]
    then
      HYTEXTOK="*"
    else
      HYTEXTOK=" "
    fi

    if [ -d $WXDIR/utils/colours ]
    then
      COLOURSOK="*"
    else
      COLOURSOK=" "
    fi

    if [ -d $WXDIR/utils/image ]
    then
      IMAGEOK="*"
    else
      IMAGEOK=" "
    fi

    if [ -d $WXDIR/utils/wxbuild ]
    then
      WXBUILDOK="*"
    else
      WXBUILDOK=" "
    fi

    echo
    echo "Remove a wxWindows component (* means it's installed)"
    echo "-----------------------------------------------------"
    echo "wxWindows currently takes up this many KB:"
    du -s $WXDIR
    echo "-----------------------------------------------------"
    echo " 1) "$PSMANUALSOK"Remove PostScript manuals"
    echo " 2) "$HLPMANUALSOK"Remove Windows Help manuals"
    echo " 3) "$PROLOGIOOK"Remove PROLOGIO library"
    echo " 4) "$HYTEXTOK"Remove hyText library"
    echo " 5) "$TOOLBAROK"Remove wxToolBar library"
    echo " 6) "$WXTREEOK"Remove wxTree library"
    echo " 7) "$WXGRAPHOK"Remove wxGraph library"
    echo " 8) "$WXHELPOK"Remove wxHelp system"
    echo " 9) "$TEX2RTFOK"Remove Tex2RTF/HTML/WinHelp/wxHelp converter"
    echo "10) "$COLOURSOK"Remove Colour sampler"
    echo "11) "$IMAGEOK"Remove wxImage GIF/BMP loader library"
    echo "12) "$WXBUILDOK"Remove wxBuilder"
    echo "------------------------------------------------------"
    echo " 0) Quit."
    echo
    read compoption

    if [ "$compoption" = "1" ]
    then
      rm -f $WXDIR/docs/*.ps
      rm -f $WXDIR/utils/*/docs/*.ps
    fi
    if [ "$compoption" = "2" ]
    then
      rm -f $WXDIR/docs/*.hlp
      rm -f $WXDIR/utils/*/docs/*.hlp
    fi
    if [ "$compoption" = "3" ]
    then
      COMPONENT=$WXDIR/utils/prologio
      remove_component
    fi
    if [ "$compoption" = "4" ]
    then
      COMPONENT=$WXDIR/utils/hytext
      remove_component
    fi
    if [ "$compoption" = "5" ]
    then
      COMPONENT=$WXDIR/utils/toolbar
      remove_component
    fi
    if [ "$compoption" = "6" ]
    then
      COMPONENT=$WXDIR/utils/wxtree
      remove_component
    fi
    if [ "$compoption" = "7" ]
    then
      COMPONENT=$WXDIR/utils/wxgraph
      remove_component
    fi
    if [ "$compoption" = "8" ]
    then
      COMPONENT=$WXDIR/utils/wxhelp
      remove_component
    fi
    if [ "$compoption" = "9" ]
    then
      COMPONENT=$WXDIR/utils/tex2rtf
      remove_component
    fi
    if [ "$compoption" = "10" ]
    then
      COMPONENT=$WXDIR/utils/colours
      remove_component
    fi
    if [ "$compoption" = "11" ]
    then
      COMPONENT=$WXDIR/utils/image
      remove_component
    fi
    if [ "$compoption" = "12" ]
    then
      COMPONENT=$WXDIR/utils/wxbuild
      remove_component
    fi
  done
}

clean_component()
{
  if [ -d $COMPONENT ]
  then
    cd $COMPONENT
    make -f makefile.unx clean$GUISUFFIX
    cd $CURRENTDIR
  fi
}

clean_samples()
{
  cd $WXDIR/samples/hello
  make -f makefile.unx clean$GUISUFFIX
  cd $WXDIR/samples/form
  make -f makefile.unx clean$GUISUFFIX
  cd $WXDIR/samples/fractal
  make -f makefile.unx clean$GUISUFFIX
  cd $WXDIR/samples/animate
  make -f makefile.unx clean$GUISUFFIX
  cd $WXDIR/samples/mdi
  make -f makefile.unx clean$GUISUFFIX
  cd $WXDIR/samples/ipc
  make -f makefile.unx clean$GUISUFFIX
  cd $WXDIR/samples/minimal
  make -f makefile.unx clean$GUISUFFIX
  cd $CURRENTDIR
}

clean_components()
{
  compoption='none'
  olddu=""
  while [ "$compoption" != "0" ]
  do
    if [ -f $WXDIR/samples/hello/hello$GUISUFFIX -o \
         -f $WXDIR/samples/form/form$GUISUFFIX -o \
         -f $WXDIR/samples/mdi/mdi$GUISUFFIX -o \
         -f $WXDIR/samples/fractal/fractal$GUISUFFIX -o \
         -f $WXDIR/samples/animate/anim$GUISUFFIX -o \
         -f $WXDIR/samples/ipc/server$GUISUFFIX -o \
         -f $WXDIR/samples/minimal/minimal$GUISUFFIX ]
    then
      SAMPLESOK="*"
    else
      SAMPLESOK=" "
    fi

    if [ -f $WXDIR/lib/libwx$GUISUFFIX".a" ]
    then
      WXOK="*"
    else
      WXOK=" "
    fi

    if [ -f $WXDIR/utils/prologio/lib/libproio$GUISUFFIX".a" ]
    then
      PROLOGIOOK="*"
    else
      PROLOGIOOK=" "
    fi
  
    if [ -f $WXDIR/utils/toolbar/lib/libtbar$GUISUFFIX".a" ]
    then
      TOOLBAROK="*"
    else
      TOOLBAROK=" "
    fi
  
    if [ -f $WXDIR/utils/wxtree/lib/libwxgraph$GUISUFFIX".a" ]
    then
      WXTREEOK="*"
    else
      WXTREEOK=" "
    fi
  
    if [ -f $WXDIR/utils/wxgraph/lib/libwxtree$GUISUFFIX".a" ]
    then
      WXGRAPHOK="*"
    else
      WXGRAPHOK=" "
    fi

    if [ -f $WXDIR/utils/wxhelp/src/objects$GUISUFFIX/wxhelp.o ]
    then
      WXHELPOK="*"
    else
      WXHELPOK=" "
    fi

    if [ -f $WXDIR/utils/tex2rtf/src/objects$GUISUFFIX/tex2rtf.o ]
    then
      TEX2RTFOK="*"
    else
      TEX2RTFOK=" "
    fi

    if [ -f $WXDIR/utils/hytext/lib/libhytext$GUISUFFIX".a" ]
    then
      HYTEXTOK="*"
    else
      HYTEXTOK=" "
    fi

    if [ -f $WXDIR/utils/colours/colours$GUISUFFIX ]
    then
      COLOURSOK="*"
    else
      COLOURSOK=" "
    fi

    if [ -f $WXDIR/utils/image/lib/libimage$GUISUFFIX".a" ]
    then
      IMAGEOK="*"
    else
      IMAGEOK=" "
    fi

    if [ -f $WXDIR/utils/wxbuild/src/wxbuild$GUISUFFIX ]
    then
      WXBUILDOK="*"
    else
      WXBUILDOK=" "
    fi

    echo
    echo "Cleanup a wxWindows component (* means objects/binaries exist)"
    echo "-----------------------------------------------------"
    echo "wxWindows currently takes up this many KB:"
    newdu=`du -s $WXDIR`
    if [ "$olddu" = "" ]
    then
      theline=$newdu
    else
      theline=$newdu" (previous usage was "$olddu")"
    fi
    echo $theline
    olddu=$newdu
    echo "-----------------------------------------------------"
    echo " 1) "$WXOK"Clean wxWindows library"
    echo " 2) "$SAMPLESOK"Clean all wxWindows samples"
    echo " 3) "$PROLOGIOOK"Clean PROLOGIO library"
    echo " 4) "$HYTEXTOK"Clean hyText library"
    echo " 5) "$TOOLBAROK"Clean wxToolBar library"
    echo " 6) "$WXTREEOK"Clean wxTree library"
    echo " 7) "$WXGRAPHOK"Clean wxGraph library"
    echo " 8) "$WXHELPOK"Clean wxHelp system"
    echo " 9) "$TEX2RTFOK"Clean Tex2RTF/HTML/WinHelp/wxHelp converter"
    echo "10) "$COLOURSOK"Clean Colour sampler"
    echo "11) "$IMAGEOK"Clean wxImage GIF/BMP loader library"
    echo "12) "$WXBUILDOK"Clean wxBuilder tool"
    echo "------------------------------------------------------"
    echo " 0) Quit."
    echo
    read compoption

    if [ "$compoption" = "1" ]
    then
      COMPONENT=$WXDIR/src/x
      clean_component
    fi
    if [ "$compoption" = "2" ]
    then
      clean_samples
    fi
    if [ "$compoption" = "3" ]
    then
      COMPONENT=$WXDIR/utils/prologio/src
      clean_component
    fi
    if [ "$compoption" = "4" ]
    then
      COMPONENT=$WXDIR/utils/hytext/src
      clean_component
    fi
    if [ "$compoption" = "5" ]
    then
      COMPONENT=$WXDIR/utils/toolbar/src
      clean_component
    fi
    if [ "$compoption" = "6" ]
    then
      COMPONENT=$WXDIR/utils/wxtree/src
      clean_component
    fi
    if [ "$compoption" = "7" ]
    then
      COMPONENT=$WXDIR/utils/wxgraph/src
      clean_component
    fi
    if [ "$compoption" = "8" ]
    then
      COMPONENT=$WXDIR/utils/wxhelp/src
      clean_component
    fi
    if [ "$compoption" = "9" ]
    then
      COMPONENT=$WXDIR/utils/tex2rtf/src
      clean_component
    fi
    if [ "$compoption" = "10" ]
    then
      COMPONENT=$WXDIR/utils/colours
      clean_component
    fi
    if [ "$compoption" = "11" ]
    then
      COMPONENT=$WXDIR/utils/image/src
      clean_component
    fi
    if [ "$compoption" = "12" ]
    then
      COMPONENT=$WXDIR/utils/wxbuild/src
      clean_component
    fi
  done
}

### View manual ###

view_manual()
{
  if [ ! -d $WXDIR ]
  then
    echo "Sorry -- you must unarchive the distribution before you can"
    echo "look at the manual."
  else
    manoption='none'
    while [ "$manoption" != "0" ]
    do
      echo
      echo "View wxWindows documentation"
      echo "----------------------------"
      echo "1) The installation instructions, using "$MYPAGER
      echo "2) readme.txt, using "$MYPAGER
      echo "3) The change log, using "$MYPAGER
      echo "4) The PostScript User Manual, using "$POSTSCRIPTVIEWER
      echo "5) The PostScript Reference Manual, using "$POSTSCRIPTVIEWER
      echo "6) The .XLP User Manual and Reference, using wxHelp"
      echo "--------------------"
      echo "0) Quit."
      echo
      read manoption

      if [ "$manoption" = "1" ]
      then
        if [ -f $WXDIR"/install/install.txt" ]
        then
          $MYPAGER $WXDIR/install/install.txt
        else
          if [ -f "install.txt" ]
          then
            $MYPAGER "install.txt"
          else
            if [ -f $WXDIR/"install.txt" ]
            then
              $MYPAGER $WXDIR/"install.txt"
            else
              echo
              echo "Sorry, cannot find install.txt. Perhaps you did not ftp"
              echo "it along with the archives, and/or you haven't unarchived"
              echo "the sources yet. Please press return to continue."
              echo
              read ans
            fi
          fi
        fi
      fi
      if [ "$manoption" = "2" ]
      then
        if [ -f $WXDIR"/docs/readme.txt" ]
        then
          $MYPAGER $WXDIR/docs/readme.txt
        else
          if [ -f "readme.txt" ]
          then
            $MYPAGER "readme.txt"
          else
            if [ -f $WXDIR/"readme.txt" ]
            then
              $MYPAGER $WXDIR/"readme.txt"
            else
              echo
              echo "Sorry, cannot find readme.txt. Perhaps you did not ftp"
              echo "it along with the archives, and/or you haven't unarchived"
              echo "the sources yet. Please press return to continue."
              echo
              read ans
            fi
          fi
        fi
      fi
      if [ "$manoption" = "3" ]
      then
        if [ -f $WXDIR"/docs/changes.txt" ]
        then
          $MYPAGER $WXDIR/docs/changes.txt
        else
          if [ -f "changes.txt" ]
          then
            $MYPAGER "changes.txt"
          else
            if [ -f $WXDIR/"changes.txt" ]
            then
              $MYPAGER $WXDIR/"changes.txt"
            else
              echo
              echo "Sorry, cannot find changes.txt. Perhaps you did not ftp"
              echo "it along with the archives, and/or you haven't unarchived"
              echo "the sources yet. Please press return to continue."
              echo
              read ans
            fi
          fi
        fi
      fi
      if [ "$manoption" = "4" ]
      then
        $POSTSCRIPTVIEWER $WXDIR/docs/manual.ps
      fi
      if [ "$manoption" = "5" ]
      then
        $POSTSCRIPTVIEWER $WXDIR/docs/referenc.ps
      fi
      if [ "$manoption" = "6" ]
      then
        if [ ! -f $WXDIR"/utils/wxhelp/src/wxhelp"$GUISUFFIX ]
        then
          echo "Please compile wxHelp first, or place wxhelp"$GUISUFFIX" in"
          echo $WXDIR"/utils/wxhelp/src."
          echo "Make it now? (y/n)"
          echo
          read ans
          if [ "$ans" = "y" ]
          then
            make_wxhelp
          fi
        fi
        if [ -f $WXDIR"/utils/wxhelp/src/wxhelp"$GUISUFFIX ]
        then
          $WXDIR"/utils/wxhelp/src/wxhelp"$GUISUFFIX -f $WXDIR"/docs/wx.xlp"
        fi
      fi
    done
  fi
}


#### Convert to either DOS or UNIX format ######

convert_all_ascii_files()
{
  PROG=$WXDIR/install/$arg1

  # Main source
  $PROG $WXDIR/include/base/*.h
  $PROG $WXDIR/include/x/*.h $WXDIR/include/x/*.xbm
  $PROG $WXDIR/include/msw/*.h
  $PROG $WXDIR/src/base/*.cc $WXDIR/src/base/make*.*
  $PROG $WXDIR/src/x/*.cc $WXDIR/src/x/*.c $WXDIR/src/x/make*.*
  $PROG $WXDIR/src/msw/*.cc $WXDIR/src/msw/*.c $WXDIR/src/msw/make*.*

  # Documentation
  $PROG $WXDIR/docs/*[.tex,.txt,.ini,.bib,.ps]

  # Contributions
  $PROG $WXDIR/contrib/*/[.txt,.c,.cc,.cpp,.h]

  # Samples
  $PROG $WXDIR/samples/*/*.cc $WXDIR/samples/*/*.h $WXDIR/samples/*/*.xbm $WXDIR/samples/*/make*.* $WXDIR/samples/*/*.txt $WXDIR/samples/*/*.def

  # Install directory
  $PROG $WXDIR/utils/install/*.txt

  # Utilities
  # Utilities with no separate src directory
  $PROG $WXDIR/utils/*/*[.cc,.h,.xbm,.txt,.def,.rc] $WXDIR/utils/*/make*.*

  # Utilities with separate src and docs directories
  $PROG $WXDIR/utils/*/src/*[.cc,.h,.xbm,.txt,.def,.rc] $WXDIR/*/*/src/make*.*
  $PROG $WXDIR/utils/*/docs/*[.tex,.hpj,.ps,.xlp,.txt]

  # PROLOGIO special files
  $PROG $WXDIR/utils/prologio/src/*[.l,.y,.c]

  # Tex2RTF non-GUI files
  $PROG $WXDIR/utils/tex2rtf/src/wxwin/*[.cc,.h] $WXDIR/utils/tex2rtf/src/wxwin/make*.*

  # wxBuilder bitmap directory
  $PROG $WXDIR/utils/wxbuild/src/bitmaps/*[.xbm,.txt]
}


####### Convert to DOS format ###########

convert_to_dos()
{
  clear
  if [ ! -d $WXDIR/src ]
  then
    echo "Archive not unpacked yet."
  else
    echo "Convert to DOS"
    echo "--------------"
    echo
    echo "You might wish to convert all files to DOS format"
    echo "if transferring wxWindows to a DOS system."
    echo
    echo "This procedure relies on the file wxtodos being"
    echo "in the install directory, with execution permission."
    echo "The wxtodos script calls the todos filter by default,"
    echo "so edit wxtodos if your local UNIX to DOS filter is"
    echo "called something else."
    echo
    echo "Convert all wxWindows ASCII files to DOS? (y/n)"
    read ans
    if [ "$ans" = "y" ]
    then
      if [ -f $WXDIR/install/wxtodos ]
      then
        chmod a+x $WXDIR/install/wxtodos
        arg1=wxtodos
        convert_all_ascii_files
      else
        echo "Cannot find "$WXDIR/install/wxtodos"."
      fi
    fi
  fi
}

####### Convert from DOS format ###########

convert_to_unix()
{
  clear
  if [ ! -d $WXDIR/src ]
  then
    echo "Archive not unpacked yet."
  else
    echo "Convert to UNIX"
    echo "---------------"
    echo
    echo "You might wish to convert all files to UNIX format"
    echo "if transferring wxWindows from a DOS system,"
    echo "or if the UNIX distribution has accidentally left"
    echo "DOS format files in (it happens!)"
    echo
    echo "This procedure relies on the file wxfrmdos being"
    echo "in the install directory, with execution permission."
    echo "The wxfrmdos script calls the fromdos filter by default,"
    echo "so edit wxfrmdos if your local UNIX to DOS filter is"
    echo "called something else."
    echo
    echo "Convert all wxWindows ASCII files to UNIX? (y/n)"
    read ans
    if [ "$ans" = "y" ]
    then
      if [ -f $WXDIR/install/wxfrmdos ]
      then
        chmod a+x $WXDIR/install/wxfrmdos
        arg1=wxfrmdos
        convert_all_ascii_files
      else
        echo "Cannot find "$WXDIR/install/wxfrmdos"."
      fi
    fi
  fi
}

preliminary_notes()
{
  clear
  echo
  echo The GUI target is GUITARGET=$GUITARGET "(out of motif, xview, hp)."
  echo
  echo The directory to install to is WXDIR=$WXDIR
  echo
  echo "The archives comprise one of:"
  echo "  "$ARCHIVE".tgz"
  echo "  "$ARCHIVE".tar.Z"
  echo "  "$ARCHIVE"_1.zip/"$ARCHIVE"_2.zip/"$ARCHIVE"_3.zip"
  echo
  echo "Please check these settings carefully."
  echo "Are they correct for your system? (y/n)"
  echo

  read ans

  if [ "$ans" != "y" ]
  then 
    echo Please edit this file, wxinstal, for WXDIR, GUITARGET and ARCHIVE.
    echo Then rerun this installation script.
    exit
  else
    clear
    echo ""
    echo "Configuring wxWindows"
    echo "---------------------"
    echo ""
    echo "Most makefile settings to do with compilers, platforms and"
    echo "directories are kept in "$WXDIR"/src/make.env."
    echo ""
    echo "If you get a compiler error or warning, please strongly"
    echo "suspect this file, and if necessary edit it from the first"
    echo "option on the Main Menu."
    echo ""
    echo "Some suggestions for settings are contained in make.env,"
    echo "and further information is in "$WXDIR"/install/install.txt"
    echo "and the Frequently Asked Questions list,"
    echo $WXDIR"/docs/faq.txt or faq.ps."
    echo
    echo wxWindows itself can be tailored to remove certain features
    echo "(such as PostScript support), or select library preferences, by"
    echo "editing the file "$WXDIR"/include/base/wx_setup.h."
    echo
    echo The wx_setup.h defaults are probably ok for now though.
    echo
    echo "Please press return to continue."
    read ans
    echo
    clear
    echo ""
    echo "Configuring wxWindows (cont'd)"
    echo "--------------------- --------"
    echo ""
    echo "By default (at least for GNU compiler use), debugging information"
    echo "is included. This will make the libraries and binaries"
    echo "a lot bigger than if you left debugging information out."
    echo
    echo "So you might want to set DEBUG to nothing in make.env"
    echo "to disable debugging information, at least for a first look at wxWindows."
    echo
    echo "Please press return to continue."
    read ans
    echo
    clear
    echo
    echo "You may wish to choose 'View documentation' now..."
  fi
}

  ############# MAIN BIT OF THE SCRIPT #################
  clear
  echo
  echo "-------------------------------------------"
  echo "Welcome to the wxWindows 1.60 installation."
  echo "-------------------------------------------"
  echo
  echo "If running this for the first time, you should"
  echo "view the preliminary notes."
  echo
  echo "Do you wish to see these? (y/n)"
  echo
  read ans
  if [ "$ans" = "y" ]
  then
    preliminary_notes
  fi

  useroption='none'
  while [ "$useroption" != "0" ]
  do
    echo
    echo "wxWindows Installation Main Menu"
    echo "--------------------------------"
    echo
    echo " 1) Install from archive and/or edit makefile variables."
    echo " 2) Make main wxWindows library."
    echo " 3) Make a peripheral component."
    echo " 4) Make a demo."
    echo " 5) Make absolutely everything."
    echo " 6) Run a demo."
    echo " 7) View documentation."
    echo " 8) Clean objects/binaries, saving space."
    echo " 9) Remove wxWindows components from disk."
    echo "10) Convert all ASCII files to DOS format."
    echo "11) Convert all ASCII files to UNIX format."
    echo "-----------------------------------"
    echo " 0) Exit from installation."
    echo
    read useroption

    if [ "$useroption" = "1" ]
    then
      install_from_archive
    fi
    if [ "$useroption" = "2" ]
    then
      make_main_library
    fi
    if [ "$useroption" = "3" ]
    then
      make_peripheral_components
    fi
    if [ "$useroption" = "4" ]
    then
      make_demos
    fi
    if [ "$useroption" = "5" ]
    then
      make_all
    fi
    if [ "$useroption" = "6" ]
    then
      run_demos
    fi
    if [ "$useroption" = "7" ]
    then
      view_manual
    fi
    if [ "$useroption" = "8" ]
    then
      clean_components
    fi
    if [ "$useroption" = "9" ]
    then
      remove_components
    fi
    if [ "$useroption" = "10" ]
    then
      convert_to_dos
    fi
    if [ "$useroption" = "11" ]
    then
      convert_to_unix
    fi
  done
  clear
  echo ""
  echo "Goodbye! I hope your wxWindows installation was successful."
  echo "If not, please contact me, Julian Smart, at:"
  echo ""
  echo "J.Smart@ed.ac.uk"
  echo ""
  echo "I can subscribe you to the mailing list wxwin-users"
  echo "for further assistance from experienced users."
  echo ""
  echo "Information is also available via the World Wide Web at:"
  echo ""
  echo "http://www.aiai.ed.ac.uk/~jacs/wxwin.html"
  echo ""
  echo "If you have any suggestions, bug reports or patches,"
  echo "please email me at the above address."
  echo ""


