#!/bin/sh

help=no
quiet=no

if [ -z "$PROJECT_NAME" ];      then PROJECT_NAME=$DEFAULT_PROJECT_NAME;            fi
if [ -z "$PROJECT_FULLNAME" ];  then PROJECT_FULLNAME=$DEFAULT_PROJECT_FULLNAME;    fi
if [ -z "$PROJECT_COPYRIGHT" ]; then PROJECT_COPYRIGHT=$DEFAULT_PROJECT_COPYRIGHT;  fi
if [ -z "$PROJECT_VERSION" ];   then PROJECT_VERSION=$DEFAULT_PROJECT_VERSION;      fi
if [ -z "$PROJECT_PAGE" ];      then PROJECT_PAGE=$DEFAULT_PROJECT_PAGE;            fi
if [ -z "$PROJECT_MAIL" ];      then PROJECT_MAIL=$DEFAULT_PROJECT_MAIL;            fi

if [ -z "$INSTALL" ];           then INSTALL=$DEFAULT_INSTALL;                      fi
if [ -z "$SHELL" ];             then SHELL=$DEFAULT_SHELL;                          fi
if [ -z "$CC" ];                then CC=$DEFAULT_CC;                                fi
if [ -z "$BISON" ];             then BISON=$DEFAULT_BISON;                          fi
if [ -z "$FLEX" ];              then FLEX=$DEFAULT_FLEX;                            fi
if [ -z "$RM" ];                then RM=$DEFAULT_RM;                                fi
if [ -z "$RMDIR" ];             then RMDIR=$DEFAULT_RMDIR;                          fi
if [ -z "$TEST" ];              then TEST=$DEFAULT_TEST;                            fi
if [ -z "$MAKE" ];              then MAKE=$DEFAULT_MAKE;                            fi
if [ -z "$GREP" ];              then GREP=$DEFAULT_GREP;                            fi
if [ -z "$CUT" ];               then CUT=$DEFAULT_CUT;                              fi
if [ -z "$SORT" ];              then SORT=$DEFAULT_SORT;                            fi
if [ -z "$PR" ];                then PR=$DEFAULT_PR;                                fi
if [ -z "$CP" ];                then CP=$DEFAULT_CP;                                fi
if [ -z "$CHMOD" ];             then CHMOD=$DEFAULT_CHMOD;                          fi
if [ -z "$MAKEINFO" ];          then MAKEINFO=$DEFAULT_MAKEINFO;                    fi
if [ -z "$TEXI2DVI" ];          then TEXI2DVI=$DEFAULT_TEXI2DVI;                    fi
if [ -z "$TEXI2PDF" ];          then TEXI2PDF=$DEFAULT_TEXI2PDF;                    fi
if [ -z "$DVIPS" ];             then DVIPS=$DEFAULT_DVIPS;                          fi

if [ -z "$CFLAGS" ];            then CFLAGS=$DEFAULT_CFLAGS;                        fi
if [ -z "$LDFLAGS" ];           then LDFLAGS=$DEFAULT_LDFLAGS;                      fi
if [ -z "$LDLIBS" ];            then LDLIBS=$DEFAULT_LDLIBS;                        fi
if [ -z "$BFLAGS" ];            then BFLAGS=$DEFAULT_BFLAGS;                        fi
if [ -z "$FFLAGS" ];            then FFLAGS=$DEFAULT_FFLAGS;                        fi

if [ -z "$DESTDIR" ];           then DESTDIR=$DEFAULT_DESTDIR;                      fi

if [ -z "$prefix" ];            then prefix=$DEFAULT_prefix;                        fi
if [ -z "$exec_prefix" ];       then exec_prefix=$DEFAULT_exec_prefix;              fi
if [ -z "$bindir" ];            then bindir=$DEFAULT_bindir;                        fi
if [ -z "$sbindir" ];           then sbindir=$DEFAULT_sbindir;                      fi
if [ -z "$libexecdir" ];        then libexecdir=$DEFAULT_libexecdir;                fi
if [ -z "$datarootdir" ];       then datarootdir=$DEFAULT_datarootdir;              fi
if [ -z "$datadir" ];           then datadir=$DEFAULT_datadir;                      fi
if [ -z "$sysconfdir" ];        then sysconfdir=$DEFAULT_sysconfdir;                fi
if [ -z "$sharedstatedir" ];    then sharedstatedir=$DEFAULT_sharedstatedir;        fi
if [ -z "$localstatedir" ];     then localstatedir=$DEFAULT_localstatedir;          fi
if [ -z "$docdir" ];            then docdir=$DEFAULT_docdir;                        fi
if [ -z "$infodir" ];           then infodir=$DEFAULT_infodir;                      fi
if [ -z "$htmldir" ];           then htmldir=$DEFAULT_htmldir;                      fi
if [ -z "$dvidir" ];            then dvidir=$DEFAULT_dvidir;                        fi
if [ -z "$pdfdir" ];            then pdfdir=$DEFAULT_pdfdir;                        fi
if [ -z "$psdir" ];             then psdir=$DEFAULT_psdir;                          fi
if [ -z "$libdir" ];            then libdir=$DEFAULT_libdir;                        fi
if [ -z "$localedir" ];         then localedir=$DEFAULT_localedir;                  fi
if [ -z "$mandir" ];            then mandir=$DEFAULT_mandir;                        fi
if [ -z "$man1dir" ];           then man1dir=$DEFAULT_man1dir;                      fi
if [ -z "$man2dir" ];           then man2dir=$DEFAULT_man2dir;                      fi
if [ -z "$man3dir" ];           then man3dir=$DEFAULT_man3dir;                      fi
if [ -z "$man4dir" ];           then man4dir=$DEFAULT_man4dir;                      fi
if [ -z "$man5dir" ];           then man5dir=$DEFAULT_man5dir;                      fi
if [ -z "$man6dir" ];           then man6dir=$DEFAULT_man6dir;                      fi
if [ -z "$man7dir" ];           then man7dir=$DEFAULT_man7dir;                      fi
if [ -z "$man8dir" ];           then man8dir=$DEFAULT_man8dir;                      fi
if [ -z "$man9dir" ];           then man9dir=$DEFAULT_man9dir;                      fi
if [ -z "$manext" ];            then manext=$DEFAULT_manext;                        fi
if [ -z "$man1ext" ];           then man1ext=$DEFAULT_man1ext;                      fi
if [ -z "$man2ext" ];           then man2ext=$DEFAULT_man2ext;                      fi
if [ -z "$man3ext" ];           then man3ext=$DEFAULT_man3ext;                      fi
if [ -z "$man4ext" ];           then man4ext=$DEFAULT_man4ext;                      fi
if [ -z "$man5ext" ];           then man5ext=$DEFAULT_man5ext;                      fi
if [ -z "$man6ext" ];           then man6ext=$DEFAULT_man6ext;                      fi
if [ -z "$man7ext" ];           then man7ext=$DEFAULT_man7ext;                      fi
if [ -z "$man8ext" ];           then man8ext=$DEFAULT_man8ext;                      fi
if [ -z "$man9ext" ];           then man9ext=$DEFAULT_man9ext;                      fi


for option
do
  case "$option" in
    -*=*) value=$(echo "$option" | sed -e 's/[-_a-zA-Z0-9]*=//')  ;;
    *=*)  value=$(echo "$option" | sed -e 's/[_A-Z0-9]*=//')      ;;
    *)    value=""                                                ;;
  esac

  case "$option" in
    --help)             help=yes                                  ;;
    --quiet)            quiet=yes                                 ;;

    DESTDIR=*)          DESTDIR="$value"                          ;;
    --prefix=*)         prefix="$value"                           ;;
    --exec-prefix=*)    exec_prefix="$value"                      ;;
    --bindir=*)         bindir="$value"                           ;;
    --sbindir=*)        sbindir="$value"                          ;;
    --libexecdir=*)     libexecdir="$value"                       ;;
    --datarootdir=*)    datarootdir="$value"                      ;;
    --datadir=*)        datadir="$value"                          ;;
    --sysconfdir=*)     sysconfdir="$value"                       ;;
    --sharedstatedir=*) sharedstatedir="$value"                   ;;
    --localstatedir=*)  localstatedir="$value"                    ;;
    --docdir=*)         docdir="$value"                           ;;
    --infodir=*)        infodir="$value"                          ;;
    --htmldir=*)        htmldir="$value"                          ;;
    --dvidir=*)         dvidir="$value"                           ;;
    --pdfdir=*)         pdfdir="$value"                           ;;
    --psdir=*)          psdir="$value"                            ;;
    --libdir=*)         libdir="$value"                           ;;
    --localedir=*)      localedir="$value"                        ;;
    --mandir=*)         mandir="$value"                           ;;
    --man1dir=*)        man1dir="$value"                          ;;
    --man2dir=*)        man2dir="$value"                          ;;
    --man3dir=*)        man3dir="$value"                          ;;
    --man4dir=*)        man4dir="$value"                          ;;
    --man5dir=*)        man5dir="$value"                          ;;
    --man6dir=*)        man6dir="$value"                          ;;
    --man7dir=*)        man7dir="$value"                          ;;
    --man8dir=*)        man8dir="$value"                          ;;
    --man9dir=*)        man9dir="$value"                          ;;
    --manext=*)         manext="$value"                           ;;
    --man1ext=*)        man1ext="$value"                          ;;
    --man2ext=*)        man2ext="$value"                          ;;
    --man3ext=*)        man3ext="$value"                          ;;
    --man4ext=*)        man4ext="$value"                          ;;
    --man5ext=*)        man5ext="$value"                          ;;
    --man6ext=*)        man6ext="$value"                          ;;
    --man7ext=*)        man7ext="$value"                          ;;
    --man8ext=*)        man8ext="$value"                          ;;
    --man9ext=*)        man9ext="$value"                          ;;

    INSTALL=*)          INSTALL="$value"                          ;;
    SHELL=*)            SHELL="$value"                            ;;
    CC=*)               CC="$value"                               ;;
    BISON=*)            BISON="$value"                            ;;
    FLEX=*)             FLEX="$value"                             ;;
    RM=*)               RM="$value"                               ;;
    RMDIR=*)            RMDIR="$value"                            ;;
    TEST=*)             TEST="$value"                             ;;
    MAKE=*)             MAKE="$value"                             ;;
    GREP=*)             GREP="$value"                             ;;
    CUT=*)              CUT="$value"                              ;;
    SORT=*)             SORT="$value"                             ;;
    PR=*)               PR="$value"                               ;;
    CP=*)               CP="$value"                               ;;
    CHMOD=*)            CHMOD="$value"                            ;;
    MAKEINFO=*)         MAKEINFO="$value"                         ;;
    TEXI2DVI=*)         TEXI2DVI="$value"                         ;;
    TEXI2PDF=*)         TEXI2PDF="$value"                         ;;
    DVIPS=*)            DVIPS="$value"                            ;;

    CFLAGS=*)           CFLAGS="$value"                           ;;
    LDFLAGS=*)          LDFLAGS="$value"                          ;;
    LDLIBS=*)           LDLIBS="$value"                           ;;
    BFLAGS=*)           BFLAGS="$value"                           ;;
    FFLAGS=*)           FFLAGS="$value"                           ;;
  esac
done

if [ "$help" = "yes" ]; then

cat << HELP_END

Configure script for $PROJECT_NAME $PROJECT_VERSION to adapt to many kinds of systems.

Usage:

  ./configure [OPTION]... [VAR=VALUE]...

To assign environment variables (e.g., CC, CFLAGS...), specify them as
VAR=VALUE.  See below for descriptions of some of the useful variables.

Options:

  --help                display this help and exit

Installation directories:

  --prefix=PATH         install architecture-independent files in PATH
  --exec-prefix=PATH    install architecture-dependent files in PATH

Fine tuning of the installation directories:

  --bindir=PATH         user executables
  --sbindir=PATH        system admin executables
  --libexecdir=PATH     program executables
  --datarootdir=PATH    read-only arch.-independent data root
  --datadir=PATH        read-only architecture-independent data
  --sysconfdir=PATH     read-only single-machine data
  --sharedstatedir=PATH modifiable architecture-independent data
  --localstatedir=PATH  modifiable single-machine data
  --docdir=DIR          documentation root
  --infodir=DIR         info documentation
  --htmldir=DIR         html documentation
  --dvidir=DIR          dvi documentation
  --pdfdir=DIR          pdf documentation
  --psdir=DIR           ps documentation
  --libdir=DIR          object code libraries
  --localedir=DIR       locale-dependent data
  --mandir=DIR          man documentation
  --man1dir=DIR         section 1 man documentation
  --man2dir=DIR         section 2 man documentation
  --man3dir=DIR         section 3 man documentation
  --man4dir=DIR         section 4 man documentation
  --man5dir=DIR         section 5 man documentation
  --man6dir=DIR         section 6 man documentation
  --man7dir=DIR         section 7 man documentation
  --man8dir=DIR         section 8 man documentation
  --man9dir=DIR         section 9 man documentation
  --manext=EXT          man extension
  --man1ext=EXT         section 1 man extension
  --man2ext=EXT         section 2 man extension
  --man3ext=EXT         section 3 man extension
  --man4ext=EXT         section 4 man extension
  --man5ext=EXT         section 5 man extension
  --man6ext=EXT         section 6 man extension
  --man7ext=EXT         section 7 man extension
  --man8ext=EXT         section 8 man extension
  --man9ext=EXT         section 9 man extension

Some influential environment variables:

  INSTALL               install command
  SHELL                 shell command
  CC                    C compiler command
  BISON                 Bison compiler command
  RM                    rm command
  RMDIR                 rmdir command
  TEST                  test command
  MAKE                  make command
  GREP                  grep command
  CUT                   cut command
  SORT                  sort command
  PR                    pr command
  CP                    cp command
  CHMOD                 chmod command
  MAKEINFO              makeinfo command
  TEXI2DVI              texi2dvi command
  TEXI2PDF              texi2pdf command
  DVIPS                 dvips command


  CFLAGS                C compiler flags
  LDFLAGS               linker flags, e.g. -L<lib dir> if you have
                        libraries in a nonstandard directory <lib dir>
  LDLIBS                libraries to pass to the linker, e.g. -l<library>
  BFLAGS                Bison compiler flags
  FFLAGS                Flex compiler flags

Use these variables to override default values.

Report bugs to <$PROJECT_MAIL>.
More details at $PROJECT_PAGE.

HELP_END

  exit 1
fi

