[BACK]Return to Configure CVS log [TXT][DIR] Up to [local] / OpenXM_contrib / pari-2.2

File: [local] / OpenXM_contrib / pari-2.2 / Attic / Configure (download)

Revision 1.1.1.1 (vendor branch), Tue Oct 2 11:16:55 2001 UTC (22 years, 7 months ago) by noro
Branch: NORO
CVS Tags: RELEASE_1_2_1, PARI_2_2
Changes since 1.1: +0 -0 lines

Imported pari-2.2.1(alpha).

#! /bin/sh
#
# This file is part of the PARI/GP package.
#  
# PARI/GP 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. It is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY WHATSOEVER.
# 
# Check the License for details. You should have received a copy of it, along
# with the package; see the file 'COPYING'. If not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.

#   Configuration file for GP/PARI. (K.B & Ptitboul).
#
#   Run Configure -help for Usage.
#
# The Configure included in Perl distribution (written by Larry Wall), as
# well as GNU autoconfig package were of much help in writing these config
# files.

TOP=`pwd`
dflt_conf_file=dft.Config.in

# Directories
config_dir=config
data_dir=data
doc_dir=doc
emacs_dir=emacs
examples_dir=examples
misc_dir=misc
src_dir=src

extract_dir_list="$doc_dir $emacs_dir $misc_dir"

# Version number and patch level.
. $config_dir/version
version=$VersionMajor.$VersionMinor
if test `expr $VersionMinor % 2` = 1; then
  echo "Configuring pari-$version.$patch (STABLE)"
  libpari_base=pari
else
  echo "Configuring pari-$version.$patch (DEVELOPMENT VERSION)"
  libpari_base=pari-$version
fi

cd $config_dir

####################### CONFIGURE - OPTIONS #################################
#
# Processing Options
#
fastread=yes
config_file=
optimization=full
prefix=/usr/local
share_prefix=
target_host=
which_graphic_lib=none
test -n "$GP_INSTALL_PREFIX" && prefix=$GP_INSTALL_PREFIX
while test $# -gt 0; do
  case "$1" in
  -l|-load) shift; initfile=$1;
     cd $TOP
     PATH=.:$PATH; export PATH
     if test -z "$1";then
       tmp_host=`$config_dir/arch-osname`
       arch=`echo "$tmp_host" | sed -e 's/\(.*\)-.*/\1/'`
       osname=`echo "$tmp_host" | sed -e 's/.*-\(.*\)/\1/'`
       objdir=O$osname-$arch;
       initfile=$objdir/$dflt_conf_file;
     fi
     if test -r "$initfile"; then
       . $initfile
       if test ! -d $objdir; then mkdir $objdir; fi
       . $config_dir/extract_files
       exit 0
     else
       echo "Cannot read config file \"$initfile\"." >&2
       exit 1
     fi;;
  -p|-prefix)   shift; prefix=$1;;
  --prefix=*|--prefi=*|--pref=*|--pre=*|--pr=*|--p=*)
               prefix=`echo "$1" | sed -e 's/[-a-z]*=//'`;;
  --share-prefix=*)
               share_prefix=`echo "$1" | sed -e 's/[-a-z]*=//'`;;
  --bindir=*) dfltbindir=`echo "$1" | sed -e 's/[-a-z]*=//'`;;
  --libdir=*) dfltlibdir=`echo "$1" | sed -e 's/[-a-z]*=//'`;;
  --mandir=*) dfltmandir=`echo "$1" | sed -e 's/[-a-z]*=//'`;;
  --miscdir=*) dfltmiscdir=`echo "$1" | sed -e 's/[-a-z]*=//'`;;
  --datadir=*) dfltdatadir=`echo "$1" | sed -e 's/[-a-z]*=//'`;;
  --includedir=*) dfltincludedir=`echo "$1" | sed -e 's/[-a-z]*=//'`;;
  --host=*)
               target_host=`echo "$1" | sed -e 's/[-a-z]*=//'`;;
  --disable-kernel) kernel=no;;
  -a|-ask|--ask)     fastread=no;;
  -g)          optimization=debugging;;
  -pg)         optimization=profiling;;
  -rdll)       DYNRELOC=yes;;
  -h|-help|--help|-\?)error=true;;
  -v|-verbhelp|--verbhelp)error=verb;;
  -s|--static) static=y;;
  -graphic|--graphic) shift; which_graphic_lib=$1; graph_cmd=yes ;;
  --graphic=*|--graphi=*|--graph=*|--grap=*|--gra=*|--gr=*|--g=*)
	       graph_cmd=yes
	       which_graphic_lib=`echo "$1" | sed -e 's/[-a-z]*=//'`;;
  *) echo "*** Unrecognized option $1." >&2; error=true;;
  esac
  shift
done

case "$error" in
true) cat >&2 <<EOT
Usage: Configure [-ask|-help|-g|-pg] [ -load <filename> ] [ --prefix=<dir> ]

Options: some names can be abbreviated to one character (e.g -h = -help)
-a, --ask        interactive configuration
-h, --help       this message
-l, --load       skip Configure and specify a default config file
-s, --static     build static GP binary only
-v, --verbhelp   a longer help message
Build Options:
  --host=<arch-osname>  target achitecture
  --graphic=<gr>        graphic library used (default X11) (none X11 gnuplot)
Additional developer options:
  -g              creates debugging version (in Oxxx.dbg)
  -pg             creates profiling version (in Oxxx.prf)
  -rdll           creates relocatable DLL (Cygwin32 only)

Installation directories:
  --prefix=<dir>        install files in <dir> (default $prefix)
  --share-prefix=<dir>  as 'prefix', for architecture independant files
  --bindir=<dir>        for binaries
  --libdir=<dir>        for libraries
  --mandir=<dir>        for manual pages
  --miscdir=<dir>       for documentation, examples and emacs macros
  --datadir=<dir>       for precomputed data (Galois resolvents for polgalois)
  --includedir=<dir>    for C header files
EOT
exit 1
;;
verb) cat >&2 <<EOT
Architecture, operating system and asm kernel.
  Configure tries to detect what is the architecture of the machine (CPU type)
  and what operating system it is running. Then, it decides whether an asm
  kernel exists and should be used. You can override this with Configure -ask.
Which compiler will be used ?
  Depending on the machine (architecture and operating system) and on what is
  found in the path, a compiler is automatically chosen. If you set the
  environment variable CC before typing Configure, it will be used instead.
  Typeset the installation help ('tex INSTALL.tex') for more details.
EOT
exit 1
;;
esac

test "$fastread" = yes || cat <<EOT
==========================================================================
             Beginning configuration questions for GP/PARI.

You will be asked some questions about your system. Most of the time, a list
of acceptable answers will be supplied as well as a default between brackets.
Type a carriage return ('Enter') to accept these defaults.

Though the present script strives to prevent any fatal mistake on your part,
there is currently no easy way out if you make one. Your best bet is to press
Ctrl-C, then start again.  Another possibility is to wait till the questions
end, edit the file "Oxxx/$dflt_conf_file", then run

      Configure -load Oxxx/$dflt_conf_file

(which can be abbreviated to simply "Configure -l", provided your architecture
is correctly detected)
==========================================================================
EOT

####################### CONFIGURE - SHELL ###################################
if test -z "$OS2_SHELL"; then dir_sep=':' ; else dir_sep=';' ; fi

#
# Proper PATH setting
#
pth="\
  /bin\
  /usr/bin\
  /usr/locateal/bin\
  /usr/ucb\
  /usr/locateal\
  /usr/lbin\
  /usr/5bin\
  /etc\
  /usr/etc\
  /usr/gnu/bin\
  /usr/new\
  /usr/new/bin\
  /usr/nbin\
  /sys5.3/bin\
  /sys5.3/usr/bin\
  /bsd4.3/bin\
  /bsd4.3/usr/ucb\
  /bsd4.3/usr/bin\
  /usr/bsd\
  /bsd43/bin\
  /opt/ansic/bin\
  /usr/ccs/bin\
  /usr/lib\
  /usr/ucblib\
  /lib\
  /usr/ccs/lib\
  /sbin\
  /usr/sbin\
  /usr/libexec\
  /usr/openwin/bin\
  /usr/local/bin\
"
# /usr/openwin/bin added for xmkmf

for p in $pth
do
  case "$dir_sep$PATH$dir_sep" in
    *$dir_sep$p$dir_sep*) ;;
    *) test -d $p && PATH=$PATH$dir_sep$p ;;
  esac
done
PATH=.$dir_sep$PATH; export PATH

echo "Checking echo to see how to suppress newlines..."

if (echo "hi\c"; echo " ") | grep c >/dev/null 2>&1 ; then
  echo "...using -n."; n=-n; c=
else
  cat <<EOM
...using \c
EOM
  n=; c='\c'
fi
if test "$fastread" != yes; then
  echo $n ..."The star should be here-->$c"; echo '*'
fi

#
#  We might need the following :
#
echo Looking for some tools first ...
list='ld zcat gzip ranlib perl emacs'
pathspace=`echo $PATH | sed -e "s/$dir_sep/ /g" | sed -e 's,\\\\,/,g'`

for file in $list; do
  x=`./locate $file '' $pathspace`
  eval $file=$x
  case $x in
# support also DOS filesystems (hard drive prepended)
   ?:/*|/*) echo ..."$file is $x";;
      *) echo ..."I could not find $file." >&2;;
  esac
done
if test -z "$zcat" -a -n "$gzip"; then zcat="$gzip -dc"; fi

####################### CONFIGURE - ARCHITECTURE ############################
#
# Testing Architectures. Try uname to provide a default, then ask user.
#
if test -z "$target_host"; then 
	target_host=`./arch-osname`
fi
arch=`echo "$target_host" | sed -e 's/\(.*\)-.*/\1/'`
osname=`echo "$target_host" | sed -e 's/.*-\(.*\)/\1/'`

if test "$fastread" != yes; then
  cat << EOM
==========================================================================
Currently supported architectures:
EOM
  rep='none sparcv7 sparcv8_super sparcv8_micro sparcv9
       m68k ix86 i386 i486 i586 i686 hppa alpha mips fx2800'
  . ./display
  echo $n ..."Which of these apply, if any ? $c"
  dflt=$arch; . ./myread; arch=$ans
fi

#
#   Test OS, using the info uname provided.
#
if test "$fastread" != yes; then
  cat << EOM
==========================================================================
I know of the following Operating Systems
EOM
  rep='os2 freebsd cygwin linux hpux aix osf1 solaris sunos nextstep concentrix irix';
  . ./display
  echo $n ..."Any of these apply ? $c"
  dflt=$osname; . ./myread
  osname=$ans
fi

#
#   A pretty name for the architecture
#   The asm file used (if any)
#
case "$arch" in
  sparc)         asmarch=sparcv8_micro; pretty=Sparc ;;
  sparcv7)       asmarch=$arch;         pretty=SparcV7 ;;
  sparcv8_micro) asmarch=$arch;         pretty=MicroSparc ;;
  sparcv8_super) asmarch=$arch;         pretty=SuperSparc ;;
  sparcv9)       asmarch=sparcv8_micro; pretty=UltraSparc ;;
  m68k)          asmarch=$arch;         pretty="MC680x0, x>=2" ;;
  i?86)          asmarch=ix86 ;         pretty=$arch ;;
  hppa)          asmarch=none ;         pretty=HP
        case "$osname-`uname -r`" in
        hpux-?.09.*)  asmarch=none  ;;
        hpux-?.10.*)  asmarch=$arch ;;
        esac ;;
  alpha)         asmarch=$arch;         pretty=Alpha ;;
  mips)          asmarch=none;          pretty=Mips ;;
  fx2800)        asmarch=none;          pretty="Alliant FX/2800" ;;
  none)          asmarch=none;          pretty="unknown" ;;
  *)             asmarch=none;          pretty=$arch
                 echo "        Warning ! architecture $arch not tested";;
esac

#
#   Modifications for pretty name and asm file
#
case "$osname" in
  cygwin*|linux|freebsd|os2) pretty="$pretty running $osname";;
  nextstep) pretty="$pretty running $osname";
            if test "$arch" = m68k; then asmarch=none; fi ;;
esac

if test "$kernel" = no; then
  asmarch=none;
  echo "assembler micro kernel disabled"
else
  if test "$fastread" != yes; then
  cat << EOM
==========================================================================
An optimized Pari kernel is available for these architectures
("none" means that we will use the portable C version of GP/PARI)
EOM
  rep='none sparcv7 sparcv8_super sparcv8_micro m68k ix86 alpha hppa'
  . ./display
  echo $n ..."Which of these apply, if any ? $c"
  dflt=$asmarch; . ./myread; asmarch=$ans
  cat << EOM
==========================================================================
EOM
  fi
fi
case "$asmarch" in
  none)          prettyk="C portable";;
  sparcv7)       prettyk=SparcV7;;
  sparcv8_super) prettyk=SuperSparc;;
  sparcv8_micro) prettyk=MicroSparc;;
  m68k)          prettyk="MC680x0, x>=2";;
  ix86)          prettyk=ix86;;
  hppa)          prettyk=HPPA;;
  alpha)         prettyk=Alpha;;
  ppc)           prettyk=PPC;;
  *)             prettyk="$asmarch";;
esac
# 'i386 (running ix86 kernel)'  looks ugly
if test "$arch" != "$asmarch" -a \( "$arch" != "i386" -o "$asmarch" != "ix86" \)
then
  pretty="$pretty ($prettyk kernel)"
fi
echo "Building for architecture: $pretty"

#
# Which copy, SHELL ?
#
case "$osname-$arch" in
  os2-*)  ln_s=cp; make_sh=sh; exe_suff=.exe; extraflag="-Zexe" ;;
  cygwin*) ln_s="ln -s"; make_sh="/bin/sh"; exe_suff=.exe; extraflag="" ;;
  *)       ln_s="ln -s"; make_sh="/bin/sh"; exe_suff=; extraflag="" ;;
esac

####################### CONFIGURE - LIBRARIES ###############################
#
# Looking for libraries now
#
case "$osname" in 
  cygwin*) ver=`uname -r | cut -d. -f1`
    cygtop=/cygdrive/c
    if test ! -d $cygtop; then
      cygtop=/Cygnus/cygwin/B$ver
      if test ! -d $cygtop; then
        cygtop=/Cygnus/cygwin-B$ver
        if test ! -d $cygtop; then
          cygtop=/usr/${arch}-pc-cygwin
          if test ! -d $cygtop; then
            echo ..."I could not find Cygwin top directory" >&2
          fi
        fi
      fi
    fi;;
esac
readline_enabledp="nil"
if test "$optimization" != profiling; then
# First, construct the PATHs
 case "$osname" in
   cygwin*) if test "$cygtop" = /cygdrive/c; then
# cygnus for version 1.*
	libpth="
	    /usr/local/lib\
            /lib\
        "
	cygtop=/
        else
# cygnus for version 0.*
	libpth="
 	    $cygtop/H-${arch}-cygwin32/lib\
 	    $cygtop/H-${arch}-cygwin32/${arch}-cygwin32/lib\
        "
	fi;;
      os2) libpth=`echo $LIBRARY_PATH | sed 's/;/ /g' | sed 's,\\\\,/,g'`;;
 	*) libpth="\
 	/usr/local/lib\
 	/lib\
 	/usr/lib\
 	/opt/lib\
 	/opt/local/lib\
 	/opt/gnu/lib\
 	/lib/pa1.1\
 	/usr/lib/large\
 	/lib/large\
 	/usr/lib/small\
 	/lib/small\
 	/usr/ccs/lib\
 	/usc/ucblib\
 	/usr/shlib\
 	.\
     ";;
     esac

  if (xmkmf) >/dev/null 2>&1 && test -f Makefile; then
    eval `make gp-X11 2> /dev/null | grep -v make`
    rm -f Makefile Makefile.bak
    x11pth="$usrlibdir $libdir";
  fi

# We want these libraries:
#
  echo Checking for optional libraries and headers...
#   LIB: X11
  pth=$x11pth
  lib=X11; . ./locatelib
  if test -f $Xincroot/X11/Xos.h -a -z "$graph_cmd"; then
    which_graphic_lib=X11
    test -n "$extralib" && echo ..."Extra Libraries are $extralib"
    echo ..."Found X11 header files in $Xincroot/X11"
  fi

  pth=$libpth
#   LIB: gnuplot
  opth="$pth"
  pth="$TOP/gnuplot-$osname-$arch $TOP/gnuplot $TOP/../gnuplot-$osname-$arch $TOP/../gnuplot $TOP/../../gnuplot-$osname-$arch $TOP/../../gnuplot $pth"
  gpth="$pth"
  lib=gnuplot; . ./locatelib
  gnuplot_fullpath="$try"
  pth="$opth"
  gnuplot_libs=
  case $gnuplot in
    /*|[c-z]:/*)
        addgnuplot=gnuplot
	for lib in vga vesa jmgraph linuxvga gd png z
	do
	    . ./locatelib
	    eval "elib=\$$lib"
	    case $elib in
	      /*|[c-z]:/*) gnuplot_libs="$gnuplot_libs -l$lib";;
	    esac
	done
	if test "$which_graphic_lib" = gnuplot; then
	    if test -z "$gnuplot_libs"; then
		echo "...I expect that no libraries are needed for gnuplot"
	    else
		echo "...I expect that libraries $gnuplot_libs are needed for gnuplot"
	    fi
	fi
	;;
    *)
	if test "$which_graphic_lib" = gnuplot; then
	    echo "###"
	    echo "### Could not find gnuplot library in:"
	    echo "###   ./gnuplot-$osname-$arch ./gnuplot"
	    echo "###   ../gnuplot-$osname-$arch ../gnuplot"
	    echo "###   ../../gnuplot-$osname-$arch ../../gnuplot"
	    echo "###   $pth"
	    echo "###"
	    case "$osname" in
		os2) tlib=gnuplot.a ;;
		*)   tlib=libgnuplot.a ;;
	    esac
	    echo "### You may need to execute"
	    echo "###   ar cr $tlib version.o util.o term.o bitmap.o stdfn.o"
	    echo "### In the build directory of gnuplot-3.7, and move"
	    echo "### $tlib to ./gnuplot-$osname-$arch or ./gnuplot subdirs"
	    echo "### or to similarly-named directories up the directory tree." 
	    echo "###"
	fi
	;;
  esac

#   LIB: GNU ReadLine
  readline_add="$GP_READLINE $TOP/readline-$osname-$arch $TOP/readline"
  pth="$readline_add $pth"
  lib=readline; . ./locatelib
  rl_fullname=$try

  if test -n "$readline"; then
# Readline -- TermCap
    lib=$rl_fullname; sym=tgetent; . ./locatesymbol
    if test -n "$try"; then # tgetent needed
      lib=ncurses; . ./locatelib
      if test -n "$try"; then # ncurses found. Does it contain tgetent ?
        lib=$try; . ./locatesymbol
      fi
      if test -n "$try"; then
        rl_ncurses=$ncurses
      else
        lib=termcap; . ./locatelib
        rl_termcap=$termcap
      fi
    fi
# Readline -- Allocation
    lib=$rl_fullname; sym=alloca; . ./locatesymbol
    if test -n "$try"; then # alloca needed
      lib=iberty; . ./locatelib
      rl_liberty="$try"
    fi
# Readline -- Headers
    case "$osname" in
      os2) incpth=`echo $C_INCLUDE_PATH | sed -e 's/\([^;]\)$/\1;/g' -e 's%;%/readline %g' -e 's,\\\\,/,g'` ;;
      cygwin*) incpth="\
       $cygtop/usr/local/include/readline\
       $cygtop/usr/local/include\
       $cygtop/usr/include/readline\
       $cygtop/usr/include\
       $cygtop/H-${arch}-cygwin32/${arch}-cygwin32/include\
     ";;
      *) incpth="\
      /usr/local/include/readline\
      /usr/include/readline\
      /opt/include/readline\
      /opt/local/include/readline\
      /opt/gnu/include/readline\
      /usr/unsupported/include/readline\
      /usr/local/include\
      /usr/include\
      /opt/include\
      /opt/local/include\
      /opt/gnu/include\
    ";;
    esac
    pth="$readline_add $incpth"
    x=`./locate 'readline.h' '' $pth`
    CPPF_defined=
    case $x in
     ?:/*|/*) rl_include=`echo $x | sed 's,/readline.h,,'`
         if (grep CPPFunction $x > /dev/null 2>&1); then CPPF_defined=yes; fi
         if (grep rl_message  $x > /dev/null 2>&1); then rl_message=yes; fi
         if (grep rl_completion_matches $x > /dev/null 2>&1); then
           rl_completion_matches=yes;
         fi
         if (grep rl_completion_func_t $x > /dev/null 2>&1); then
           rl_completion_func_t=yes;
         fi
         if (grep "rl_refresh_line *()" $x > /dev/null 2>&1); then
           rl_refresh_line_oldproto=yes
         fi
         if (grep rl_completion_append_character $x > /dev/null 2>&1); then
           rl_appendchar=yes
         fi
         if (grep rl_generic_bind $x > /dev/null 2>&1); then
           rl_genericbind=yes
         fi
         if (grep rl_save_prompt $x > /dev/null 2>&1); then
           rl_save_prompt=yes;
         else
          lib=$rl_fullname; sym=rl_save_prompt; . ./locatesymbol
          _rl_save_prompt=$try
         fi;;
      *) echo ..."But no header file has been found"
         readline=;;
    esac
  fi

  if test -n "$readline"; then
    echo ..."Found GNU readline header in $rl_include"
    if (echo $rl_include | grep "readline$" > /dev/null); then
      rl_include=`echo $rl_include | sed 's,/readline$,,'`
      RLINCLUDE="-I$rl_include"
    else
# in case headers are not installed correctly
      RLINCLUDE="-I$rl_include -DREADLINE_LIBRARY"
    fi
    RLLIBS="-L$readline -lreadline"
    if test -n "$rl_ncurses"; then
      echo ..."Library ncurses needed by readline"
      RLLIBS="$RLLIBS -lncurses"
    fi
    if test -n "$rl_termcap"; then
      echo ..."Library termcap needed by readline"
      RLLIBS="$RLLIBS -ltermcap"
    fi
    if test -n "$rl_liberty"; then
      echo ..."Library liberty needed by readline"
      RLLIBS="$RLLIBS -liberty"
    fi
    if test -z "$rl_appendchar"; then
      echo ..."Library readline does not have completion_append_char"
    fi
    if test -z "$rl_genericbind"; then
      echo ..."Library readline does not have rl_generic_bind"
    fi
    if test -z "$rl_save_prompt"; then
      echo ..."Library readline does not have rl_save_prompt"
      if test -n "$_rl_save_prompt"; then
        echo ......"but it has _rl_save_prompt"
      fi
    fi

    if test "$fastread" != yes; then
      cat << EOM
==========================================================================
EOM
      echo $n "Do you want to use GNU readline library within GP ? $c"
      rep='y n'; dflt=y; . ./myread
      case $ans in
        n) readline=;;
      esac
    fi
  fi

  if test -n "$readline"; then readline_enabledp="t"; fi

#  Graphic libs now.
#
  if test "$fastread" != yes; then
    if test -n "$X11"; then addX11=X11; fi
    cat << EOT
==========================================================================
GP contains high resolution plotting functions. Choose among
       none       $addX11         $addgnuplot
EOT
    echo $n ..."Use which graphic library (\"none\" means no hi-res plot) ? $c"
    rep="none $addX11 $addgnuplot";
    dflt=$which_graphic_lib; . ./myread
    which_graphic_lib=$ans

  case "$which_graphic_lib" in
    X11)
      gnuplot=;
      # If xmkmf did not give the right answer
      # X11 -- Headers
      if test ! -f $Xincroot/X11/Xos.h; then
        x11pth="\
          /usr/openwin/share/lib\
          /usr/openwin/lib\
          /usr/X11R6/lib\
          /usr/X11R5/lib\
          /usr/X11R4/lib\
          /usr/lib/X11R6\
          /usr/lib/X11R5\
          /usr/lib/X11R4\
          /usr/local/X11R6/lib\
          /usr/local/X11R5/lib\
          /usr/local/X11R4/lib\
          /usr/local/lib/X11R6\
          /usr/local/lib/X11R5\
          /usr/local/lib/X11R4\
          /usr/X11/lib\
          /usr/lib/X11\
          /usr/local/X11/lib\
          /usr/local/lib/X11\
          /usr/X386/lib\
          /usr/x386/lib\
          /usr/XFree86/lib/X11\
          /usr/lib\
          /usr/local/lib\
          /usr/unsupported/lib\
          /usr/athena/lib\
          /usr/local/x11r5/lib\
          /usr/lpp/Xamples/lib\
        ";
        pth=`echo $x11pth | s,/lib,/include,g`
        x=`./locate X11/Xos.h '' $pth`
        case $x in
         /*) Xincroot=`echo $x | sed 's,/X11/Xos.h,,'`;;
         *)  Xincroot=;;
        esac
        if test -n "$Xincroot"; then
          echo ..."Found X11 header files in $Xincroot/X11"
        fi
      fi
      # X11 -- Lib
      if test -f $Xincroot/X11/Xos.h -a -z "$X11"; then
        pth=$x11pth;
        lib=X11; . ./locatelib
      fi ;;
    gnuplot);;
    *)gnuplot=;;
  esac
  else # fastread = yes
    if test "$which_graphic_lib" = none -a -z "$graph_cmd" -a -n "$gnuplot"; then
      which_graphic_lib=gnuplot
    fi
    if test -z "$X11" -a -z "$gnuplot" -a -z "$readline"; then
      echo ...none
    fi
  fi
fi

####################### CONFIGURE - COMPILATION #############################
#
# Which optimization ?
#
if test "$fastread" != yes; then
  cat << EOT
==========================================================================
The default is to fully optimize the compilation. You may choose to build
  an executable for debugging or profiling instead. Choose among :
       full       debugging       profiling
EOT
  echo $n ..."Which optimization do you prefer ? $c"
  dflt=$optimization; rep='full debugging profiling'; . ./myread
  optimization=$ans
fi

#
# Which Compiler ?
#
if test -z "$CC"; then
  echo Looking for the compilers ...
  # Native Compilers
  cc=`./locate cc '' $pathspace`
  case "$osname" in
    hpux) if test "$cc" = /usr/ccs/bin/cc -a -f /opt/ansic/bin/cc; then
            cc=/opt/ansic/bin/cc; fi ;;  # This is a better compiler
  esac
  case "$cc" in ?:/*|/*) echo ..."cc is $cc";;
      *) echo ..."I could not find cc.";; esac
  # GNU Compilers
  gcc=`./locate gcc '' $pathspace`
  if test -z "$gcc"; then
    exe=$osname-$arch-gnu$$
    $cc $extraflag -o $exe gnu.c
    if $exe; then gcc=$cc; fi; rm -f $exe
  fi
  case "$gcc" in
?:/*|/*) echo ..."gcc is $gcc";;
      *) echo ..."I could not find gcc."; gcc=;;
  esac
  if test -n "$gcc"; then
    __gnuc__=`$gcc -v 2>&1 | sed -n 's/.*version //p'`
    if test -z "$__gnuc__"; then __gnuc__=unknown; fi
    echo GNU compiler version $__gnuc__
  fi
  case "$osname" in
    aix)   __gnuc__=;; # Native compilers are faster
    hpux)  __gnuc__=;; # versions older than 2.7 cannot build PIC code
                            # gp built with recent versions has bugs
    concentrix) case "$__gnuc__" in 2.[78].*);; *)
              __gnuc__=;; esac;;
  esac
  # Choosing the compiler
  if test -n "$__gnuc__"; then CC=$gcc; else CC=$cc; fi
fi

if test "$which_graphic_lib" = gnuplot -a -z "$gcc"; then
    lib=$gnuplot_fullpath; sym=_eprintf; . ./locatesymbol
    if test -n "$try"; then
	echo "...Looks like gcc-compiled gnuplot.  I add -lgcc to graphic libraries"
	_ogcc="$gcc"
	opth="$pth"
	pth="$pth /opt/local/gnu/lib /usr/local/gnu/lib"
	gcclibspec="`gcc -v 2>&1 | grep specs | sed 's/.*specs from //'`"
	if test -n "$gcclibspec"; then
	    pth="`dirname $gcclibspec` $pth"
	fi
	lib=gcc; . ./locatelib
	if test -n "$gcc"; then
	    gnuplot_libs="$gnuplot_libs -L$gcc"
	else
	    echo "...### I did not find -lgcc library in $pth."
	    echo "...### You may need to manually add something like -L/opt/gnu/lib to the "
	    echo "...###   PLOTLIBS = ..."
	    echo "...### line in your architecture-Makefile."
	fi
	pth="$opth"
	gcc="$_ogcc"
	gnuplot_libs="$gnuplot_libs -lgcc"
    fi
fi


if test "$fastread" != yes; then
  cat << EOT
==========================================================================
Only ANSI C and C++ compilers are supported. Choosing the GNU compiler
gcc/g++ enables the inlining of kernel routines (about 20% speedup; if you
use a recent g++, it is a good idea to include the -fpermissive flag).
If you choose not to use gcc, the C++ version of Pari will be a little
faster because of general inlining, but can be used in library mode only
with C++ programs (we **really** recommand using gcc all the way through).
EOT
  echo $n ..."Which C compiler shall I use ? $c"
  dflt=$CC; rep=; . ./myread
  CC=$ans
fi

#
# Which Flags for Compiler ?
#
if test "$CC" != "$gcc"; then __gnuc__=; fi
if test -z "$__gnuc__"; then
  exe=$osname-$arch-gnu$$
  $CC $extraflag -o $exe gnu.c
  if $exe; then __gnuc__=yes; fi
  rm -f $exe
fi

if test -n "$__gnuc__"; then
  __GNUC__="-D__GNUC__"
  warn="-Wall -Wno-implicit"
  OPTFLAGS="-O3 -DGCC_INLINE $warn"
  DBGFLAGS="-g $warn"
  # Some architectures need -fPIC for building dynamic lib
  case "$osname-$arch" in hpux-*) DLCFLAGS=-fPIC;; esac
  # Specific optimisations for some architectures
  case "$osname-$arch" in
    linux-i?86|cygwin*) OPTFLAGS="$OPTFLAGS \
      -malign-loops=2 -malign-jumps=2 -malign-functions=2";;
    os2-*) cflags=-Zmt;;
    *-sparcv8*) cflags=-mv8;;
  esac
  # omit-frame-pointer incompatible with -pg
  PRFFLAGS="-pg $OPTFLAGS"
  case "$optimization" in
    full) OPTFLAGS="$OPTFLAGS -fomit-frame-pointer";;
  esac
else
  cflags=
  DBGFLAGS="-g"
  PRFFLAGS="-pg"
  case "$osname-$arch" in
    hpux-*) # -Aa is for ANSI C, +z for PIC code (for commercial HPUX compilers)
                  OPTFLAGS=-O; cflags=-Aa; DLCFLAGS=+z;;
    # best tuning option, even for PPC604:
    aix-*)        OPTFLAGS=-O2; cflags='-qlanglvl=ansi -qtune=601';;
    cygwin*|linux-i?86|freebsd-i?86)
                  OPTFLAGS=-O2; cflags=-m486;;
    osf1-*)       OPTFLAGS='-O4 -migrate -ifo -Olimit 9999';;
    sunos-*)      OPTFLAGS=-fast; PRFFLAGS='-pg -Bstatic';;
    solaris-*)    OPTFLAGS=-fast; PRFFLAGS=-xpg;;
    concentrix-*) OPTFLAGS=-Ogi;;
    *)            OPTFLAGS=-O;;
  esac
  PRFFLAGS="$PRFFLAGS $OPTFLAGS"
fi
cflags="$cflags $DLCFLAGS"

case "$osname" in
  nextstep)  cflags="-traditional-cpp $cflags";;
esac

case "$optimization" in
  full)      suffix=; cflags="$OPTFLAGS $cflags";;
  profiling) suffix=.prf; cflags="$PRFFLAGS $cflags";;
  debugging) suffix=.dbg; cflags="-DMEMSTEP=1048576 $DBGFLAGS $cflags";;
esac

if test "$fastread" != yes; then
  echo $n ..."With which flags ? $c"
  dflt=${CFLAGS:-cflags}; rep=; . ./myread
  cflags=$ans
fi

# Here we should check it is an ANSI compiler...
echo "C compiler is          $CC  $cflags"

#
# Which Assembler ?
#
if test -z "$AS"; then
  echo Looking for an assembler ...
  if test "$osname" = hpux
  then AS=`./locate as '' /usr/ccs/bin /bin`   # We don't want GNU as
  else AS=`./locate as '' $pathspace`
  fi
  case "$AS" in ?:/*|/*) echo ..."as is $AS";;
      *) echo ..."I could not find as." ;; esac
fi
gnuas=no
if (echo | $AS --version 2>&1 | grep GNU > /dev/null); then
  gnuas=yes
else
  if (echo | $AS -v 2>&1 | grep GNU > /dev/null); then
    gnuas=yes
  fi
fi
if test "$gnuas" = yes; then
  echo "...Hum, this looks like GNU as"
  case "$osname-$asmarch" in
    solaris-sparc*) KERNELCPPFLAGS="-DNO_UNDERSCORE $__GNUC__";;
  esac
else
  case "$osname-$asmarch" in
    osf1-alpha)     ASFLAGS="-O1";;
    sunos-sparc*)   ASFLAGS="-P -I. $__GNUC__";;
    solaris-sparc*) ASFLAGS="-P -I. $__GNUC__ -T";;
    hpux-hppa)      ASFLAGS="+DA1.1";;
    *)              ASFLAGS=;;
  esac
fi
echo "Assembler is           $AS  $ASFLAGS"

#
# Which C PreProcessor ?
#
case "$osname" in
  nextstep) cppfl="-traditional-cpp" ;;
  freebsd)
    if test $PORTOBJFORMAT = "elf"; then
      cppfl="-DUSE_ELF"    
      FREEBSD_ELF=1
    else
      FREEBSD_ELF=0
    fi ;;
esac
CPP="$CC $cppfl -E -I."

echo "C PreProcessor is      $CPP"

#
# Which Executable Linker ?
#
LIBS=-lm
case "$osname" in
  darwin) LIBS= ;;
esac
case "$osname-$arch" in
  linux-*|cygwin*)
      LD=$CC; LDFLAGS="$cflags -Xlinker -export-dynamic"
      runpathprefix='-Xlinker -rpath -Xlinker ';;
  osf1-alpha)
      LD=$ld; LIBS="$LIBS -lots -lc"; runpathprefix='-rpath '
      LDFLAGS='-std0 -call_shared /usr/lib/cmplrs/cc/crt0.o'
      case "$optimization" in
	full|profiling) LDFLAGS="-g0 -O4 $LDFLAGS";;
      esac;;
  solaris-*) LD=$CC; LDFLAGS=$cflags; runpathprefix=-R ;;
  os2-*)     LD=$CC; LDFLAGS="$cflags -Zexe"
      case "$optimization" in
	full) LDFLAGS="$LDFLAGS -s";;
      esac;;
  *)         LD=$CC; LDFLAGS=$cflags ;;
esac

if test "$fastread" != yes; then
  echo $n ..."Which linker for building executables ? $c"
  dflt=$LD; rep=; . ./myread
  LD=$ans
fi

#
# Which Flags for Executable Linker?
#
if test "$fastread" != yes; then
  echo $n ..."With which flags ? $c"
  dflt=$LDFLAGS; rep=; . ./myread
  LDFLAGS=$ans
fi

echo "Executable linker is   $LD  $LDFLAGS"

if test "$optimization" = profiling; then DLLD=; else
  DLLD=${DLLD-ld}
  DLSUFFIX=so
# Which suffix for Dynamic Lib?
# Some linkers (SunOS 4) need minor and major lib version numbers.
# Some others (SunOS 5) need a link from a .so
# Some others (HPUX 09) do not want version numbers.
#
  soname=$soname_num
  case "$osname-$arch" in
#    aix-*)  DLSUFFIX=a  ;; dynamic linking does not work!
    sunos-*) sodest=$VersionMajor$VersionMinor.$patch
             soname=$sodest;;
    *-alpha|solaris-*|linux-*|freebsd-*)
      case $libpari_base in
        pari) sodest=$version.$patch;; # released versions
        *) sodest=$patch.0.0;; # unstable versions
      esac ;;
    cygwin*) soname= ; sodest= ; DLSUFFIX=dll;;
    hpux-*)  soname= ; sodest= ; DLSUFFIX=sl;;
    irix-*)  soname= ; sodest= ;;
    *) DLLD=;;
  esac
fi

if test -n "$DLLD"; then
# Which Dynamic Lib Linker?
#
  if test $DLLD = ld -a -n "$ld"; then
    DLLD=$ld;
  fi
  if test "$fastread" != yes; then
    echo $n ..."Which linker for building dynamic libs? $c"
    dflt=$DLLD; rep=; . ./myread
    DLLD=$ans
  fi

# Which Flags for Dynamic Lib Linker ?
#
  if ($DLLD -v 2>&1 | grep GNU > /dev/null); then
    echo "...Hum, this looks like GNU ld"
    DLLDFLAGS="-shared -soname \$(LIBPARI_SONAME)"
  else
    # not GNU ld
    case "$osname-$arch" in
      aix-*)      DLLDFLAGS="-r" ;;
      hpux-*)     DLLDFLAGS="-b -E" ;;
      freebsd-*)  DLLDFLAGS="-Bshareable -x" ;;
      linux-*)    DLLDFLAGS="-shared -soname \$(LIBPARI_SONAME)" ;;
      irix-*)     DLLDFLAGS="-shared -elf -no_unresolved -all" ;;
      *-alpha)    DLLDFLAGS="-shared"; EXTRADLLDFLAGS='${LIBS}'
         case "$optimization" in
           full) DLLDFLAGS="$DLLDFLAGS -O3" ;;
         esac;;
      sunos-*)    DLLDFLAGS="-assert nodefinitions" ;;
      solaris-*)  DLLDFLAGS="-G -h \$(LIBPARI_SONAME)" ;;
      *)          DLLD=;;
    esac
  fi

  if test "$fastread" != yes; then
    echo $n ..."Which flags for linker? $c"
    dflt=$DLLDFLAGS; rep=; . ./myread
    DLLDFLAGS=$ans
  fi
fi

if test -z "$DLLD"; then
  echo "No Dynamic Lib"
  static=y
else
  echo "Dynamic Lib linker is  $DLLD  $DLLDFLAGS"
  static=${static-n}
fi

if test "$fastread" != yes; then
  cat << EOT
==========================================================================
Should you change your mind, you only need to modify the lines
    CC="$CC"
    CFLAGS="$cflags"
    LD="$LD"
    LDFLAGS="$LDFLAGS"
    DLLD="$DLLD"
    DLLDFLAGS="$DLLDFLAGS"
in the Makefile
==========================================================================
EOT
fi

####################### CONFIGURE - READLINE VERSION ########################
if test -n "$readline"; then
  exe=$osname-$arch-rlv$$
  $CC $extraflag $RLINCLUDE -o $exe rl_version.c $RLLIBS 2>/dev/null
  if test -r $exe; then readline=`$exe`; else readline=1.0; fi
  rm -f $exe $exe$exe_suff
fi

####################### CONFIGURE - LIBC ####################################
#
#  Long integer ?
#
endian=4321;
exe=$osname-$arch-endian$$
if ($CC $extraflag endian.c -o $exe 2>/dev/null); then
  endian=`$exe`;
fi
rm -f $exe $exe$exe_suff

if test "$fastread" != yes; then
cat << EOT
Determining sizeof(long) and endianness. If your hardware supports different
size of longs (e.g SGI/MIPS), you can decide to use a particular word size
by specifying endianness (e.g answer 4321 instead of the proposed 87654321).
You'll probably have to specify some exotic compilation flag (e.g -o32,-n32)
============================================================================
EOT
  echo $n "What is the internal byte representation of long integer ? $c"
  dflt=$endian; rep='12345678 87654321 1234 4321'; . ./myread
  endian=$ans
fi
echo "The internal byte representation of your long integers is $endian."

case $endian in
  *8|8*) sizeof_long=8; pretty="$pretty 64-bit version";;
  *)     sizeof_long=4; pretty="$pretty 32-bit version";;
esac


#
# Looking in C lib for some functions.
#
exe=$osname-$arch-tmp$$
echo Checking some common types...
list=ulong; . ./look
echo Looking in C lib for some symbols...
extra_flags=
list=exp2; . ./look
list=strftime; . ./look
case "$arch" in
  alpha) list='times ftime';; # gp-dyn has problems with getrusage 
  *) case "$osname" in
    *cygwin*) list='times ftime';; # getrusage based timer always returns 0
    *) list='getrusage times ftime';;
    esac;;
esac; . ./look
list='sigrelse sigsetmask'; . ./look
list=TIOCGWINSZ; . ./look
list=getrlimit; . ./look
list=opendir; . ./look

# For install(). Do we need libdl.so?
# on irix and osf1 -ldl not needed
extra_flags=
list=dlopen; . ./look
if test "$has_dlopen" = no; then
  echo "Try again, with -ldl this time..."
  extra_flags=-ldl; . ./look
  if test "$has_dlopen" = yes; then
    LIBS="-ldl $LIBS"
  fi
fi

####################### CONFIGURE - MAKE ####################################
dflt=$prefix; rep=
test "$fastread" = yes || cat <<EOT
==========================================================================
By default, gp will be installed in $dflt/bin, manual pages under
  $dflt/man, etc..., with $dflt as prefix for all installation directories.
  If you wish to have binaries under /bin but manual pages under
  /usr/local/man, that's ok: you will be prompted separately for each of the
  installation directories, the prefix being only used to set the defaults.
  (You will be prompted before the actual installation is done.)
The names of executables and libraries contain their version number $version.
  A symbolic link to gp or libpari.[a/so] will point to the most recent
  installation of GP/PARI.
EOT
echo $n "Installation prefix ? $c"
. ./myread; prefix=$ans

echo $n "...for architecture-independant files (share-prefix) ? $c"
dflt=$share_prefix; . ./myread; share_prefix=$ans

if test -z "$share_prefix"; then
  dfltman=$prefix/man/man1
  dfltall=$prefix/lib/pari
else
  dfltman=$share_prefix/man/man1
  dfltall=$share_prefix/doc/pari
fi

echo $n ..."\"gp\" executable ? $c"
dflt=${dfltbindir:-$prefix/bin}; . ./myread; bindir=$ans

echo $n ..."\"pari\" library ? $c"
dflt=${dfltlibdir:-$prefix/lib}; . ./myread; libdir=$ans

echo $n ..."include files ? $c"
dflt=${dlftincludedir:-$prefix/include/pari}; . ./myread; includedir=$ans

echo $n ..."manual pages ? $c"
dflt=${dfltmandir:-$dfltman}; . ./myread; mandir=$ans

echo $n ..."documentation, examples, and emacs macros ? $c"
dflt=${dfltmiscdir:-$dfltall}; . ./myread; miscdir=$ans

if test -z "$share_prefix"; then
  dfltdat=$miscdir/galdata
else
  dfltdat=$share_prefix/pari/galdata
fi

echo $n ..."miscellaneous data (galois resolvents) ? $c"
dflt=${dfltdatadir:-$dfltdat}; . ./myread; datadir=$ans

if test "$optimization" = debugging; then static=y; fi
if test "$fastread" != yes; then
  if test -z "$DLLD"; then
    cat <<EOT
==========================================================================
We cannot build a dynamic executable. We will build the static version.
EOT
  else
    cat <<EOT
==========================================================================
By default, we will try to build the shared library and gp will be an
  executable dynamically linked with it. Do you prefer to have the static
  archive libpari.a and a statically linked executable (which is a bit
  faster, but takes more disk place) ?
You can always type "make all" in case you want both later.
EOT
  echo $n "Do you want static executable and library ? $c"
  dflt=$static; rep='y n'; . ./myread; static=$ans
  fi
fi
case "$static" in
  y) echo "Default is static executable and archive library, graphic=$which_graphic_lib" ;;
  n) echo "Default is dynamic executable and shared library, graphic=$which_graphic_lib" ;;
esac

#
# Target directory
#
pre=O
case "$optimization" in
  full)      objdir=$pre$osname-$arch ;;
  debugging) objdir=$pre$osname-$arch.dbg ;;
  profiling) objdir=$pre$osname-$arch.prf ;;
esac
if test "$fastread" != yes; then
  cat << EOT
==========================================================================
This is the name of the directory where all the object files will be :
EOT
  echo $n ..."Enter dir name : $c"
  dflt=$objdir; rep=; . ./myread
  objdir=$ans
fi

#
# For dynamic linking, before and after installing
#
case "$osname" in
  *cygwin*) LDDYN="-L$libdir -lpari_dll" ; runpath="$libdir" ;
	    DYNLIBS=-lpari_dll ; DYNFLAGS=-Dlibpari_USE_DLL ;;
  *)        LDDYN="-L$libdir -l$libpari_base" ; runpath="$libdir" ;;
esac

cat << EOT
==========================================================================
EOT

####################### CONFIGURE - SPIT ####################################
#
#  Now spit out the results
#
cd $TOP
if test ! -d $objdir; then mkdir -p $objdir; fi
dflt_conf_file=$objdir/$dflt_conf_file

cat > $dflt_conf_file << EOT
# Config file for Pari $release -- $pretty

EOT
case "$osname" in
  os2) shell_q='"'; echo "shell_q='\"'" >> $dflt_conf_file;;
    *) shell_q="'"; echo "shell_q=\"'\"" >> $dflt_conf_file;;
esac

for variable in\
  libpari_base version TOP config_dir src_dir emacs_dir doc_dir\
  bindir includedir mandir miscdir libdir datadir\
  optimization objdir static suffix\
  arch asmarch osname pretty prefix share_prefix\
  __gnuc__ gnuas CPP AS ASFLAGS CC cflags DBGFLAGS OPTFLAGS LD LDFLAGS\
  DLLD DLSUFFIX soname sodest KERNELCPPFLAGS DLLDFLAGS EXTRADLLDFLAGS\
  runpath runpathprefix LDDYN LIBS DYNLIBS DYNFLAGS DYNRELOC\
  ranlib gzip zcat emacs perl ln_s make_sh exe_suff\
  readline readline_enabledp CPPF_defined rl_refresh_line_oldproto\
  rl_appendchar rl_genericbind rl_save_prompt _rl_save_prompt rl_message\
  rl_completion_matches rl_completion_func_t\
  RLINCLUDE RLLIBS\
  sizeof_long endian has_exp2\
  has_getrusage has_times has_ulong has_ftime has_strftime has_opendir\
  has_sigrelse has_sigsetmask has_dlopen has_TIOCGWINSZ has_getrlimit\
  gnuplot extralib X11 Xincroot which_graphic_lib gnuplot_libs\
  ; do
  eval "echo $variable=\'"'$'"$variable\'" \>\> $dflt_conf_file
done

. $config_dir/extract_files

#
#  Building...
#
cat << EOT
==========================================================================
EOT

echo $n "Shall we try to build pari $version.$patch ($status) now (y/n)? $c"
dflt=n; rep='y n'; . $config_dir/myread

case $ans in
y) if (make gp); then
     echo $n "Shall we install the files where they belong (y/n)? $c"
     dflt=n; rep='y n'; . $config_dir/myread
     case $ans in
       y) make install;;
       n) echo "Ok. Type \"make install\" when you are ready";;
     esac
   fi;;
n) echo "Ok. Type \"make install\" when you are ready";;
esac
echo 'Bye !'