#!/bin/sh
# Generates the Makefile for PARI
# Bruno Haible 10.12.1992
# Modified by Babecool 23.7.1993

uname=`uname`
solaris=''
solarisaddlibs=''
sparcv8_s=_sparcv8.s
ARCHrep=
gccversioncflags='$(CFLAGS)'
STATIC_LIBS=

if [ $uname = SunOS ]; then
  case `uname -r` in
    5.*) solaris=-DSOLARIS; sparcv8_s=sparcv8.s; 
	#solarisaddlibs="-L/opt/SUNWspro/SC3.0.1/lib/ -lsunmath" ;
	STATIC_LIBS="-L/opt/SUNWspro/SC3.0.1/lib -lsunmath";
	gccversioncflags=1;;
  esac
fi

if [ $# = 0 ] ; then usage=yes ; else TARGET="$1"; shift; fi
if [ "$TARGET" = sparcv8 ] ; then
  if [ $# = 0 ] ; then usage=yes ; else ARCH="$1" ARCHrep=", architecture = \`$1'"; shift; fi
fi

if [ ! -z "$usage" ] ; then
	cat <<EOH
 Usage:
   Makemakefile port
   Makemakefile sun3
   Makemakefile sparcv7
   Makemakefile sparcv8 micro|super
   Makemakefile alpha
   Makemakefile hppa
   Makemakefile i386
   Makemakefile linux
   Makemakefile dos
   Makemakefile os/2

 Environment variables:
   CC		C compiler
   CFLAGS	flags for C compiler
   RANLIB	ranlib command
   READLINE	what readline support (2.0, yes or '' (empty) for none)
   PLOT		what hires plotting support (X11, sun, none, gnuplot)
   DYNAMIC	(y|n) whether to compile for dynamic linking (unsupported)
   GPDIR	directory with gnuplot3.5 files
   CPlPl	additional flags to enable C++ compile (like '-x c++')

 You can put definition on the command line thusly:
	$0 sparcv8 micro CC=CC
EOH
exit

fi

# Process variable definitions

### Old one: (no embedded spaces, alas!):
###if [ ! -z "$*" ] ; then eval "$@" ; fi

### New one: handles embedded spaces, but not embedded '='
if [ ! -z "$*" ] ; then 
  for i in  "$@" 
  do
    oldifs="$IFS"
    IFS="="
    set $i
    IFS="$oldifs"
    eval $1="\"$2\""
  done
fi

mv Makefile Makefile.old 2> /dev/null
mv sparcv8.s sparcv8.s.old 2> /dev/null
mv plot.c plot.c.old 2> /dev/null

: ${PLOT='x'} ${GPDIR='/opt/src/gnuplot'}

case "x$READLINE" in
	x2*)	noRLpref='#' RL1pref='#' RL2pref='' RL=2.0 ;;
	x?*)	noRLpref='#' RL1pref='' RL2pref='#' RL=version1 ;;
	x*)	noRLpref='' RL1pref='#' RL2pref='#' RL=none ;;
esac

case "x$PLOT" in
	x[xX]*)	noPLOTpref='#' PLOTSUNpref='#' PLOTGPpref='#' PLOTXpref='' PL=X11 ;;
	x[gG]*)	noPLOTpref='#' PLOTSUNpref='#' PLOTGPpref='' PLOTXpref='#' PL=GP ;;
	x[sS]*)	noPLOTpref='#' PLOTSUNpref='' PLOTGPpref='#' PLOTXpref='#' PL=Sun ;;
	x*)	noPLOTpref='' PLOTSUNpref='#' PLOTGPpref='#' PLOTXpref='#' PL=none ;;
esac

if test -z "$TARGET"; then
  TARGET=port
fi

if [ $TARGET = os/2 ] ; then TARGET=dos OS2=yes; fi

if [ $TARGET = dos ] ; then

EXE='.exe'
CC=${CC-gcc}
CFLAGS=${CFLAGS--O -DNOEXP2 -DMALLOC_PROCS}
RANLIB='$(COMSPEC) /c rem'
INSTALL='$(COMSPEC) /c copy'
stricmp='-DHAS_STRICMP'
VERSIONCFLAGS='$(CFLAGS)'

else

EXE=''
stricmp=

# Check for GCC
if test -z "$CC"; then
  # echo checking for gcc
  saveifs="$IFS"; IFS="${IFS}:"
  for dir in $PATH; do
    test -z "$dir" && dir=.
    if test -f $dir/gcc; then
      CC="gcc"
      break
    fi
  done
  IFS="$saveifs"
fi
test -z "$CC" && CC="cc"

VERSIONCFLAGS='$(CFLAGS)'

if test -z "$CFLAGS"; then
  if [ $CC = gcc -o $CC = g++ ] ; then
    CFLAGS="-O2 -g -ansi" # may use up to -O4 except for plotsun.c
    if [ ! -z "$solaris" ]; then VERSIONCFLAGS="-O2 -g -DSOLARIS" ; fi
  else
    if [ $TARGET = hppa ] ; then
      CFLAGS="-O -Aa"
    else
      CFLAGS="-O"
    fi
  fi
fi
if [ $TARGET = alpha ] ; then
   CFLAGS="$CFLAGS -DLONG_IS_64BIT"
else
   if [ $TARGET = hppa ] ; then
      CFLAGS="$CFLAGS -DHPPA"
   fi
fi
if [ $TARGET = linux ] ; then
   CFLAGS="-O2 -m486"
fi

# Check for ranlib
if test -z "$RANLIB"; then
  # echo checking for ranlib
  saveifs="$IFS"; IFS="${IFS}:"
  for dir in $PATH; do
    test -z "$dir" && dir=.
    if test -f $dir/ranlib; then
      RANLIB="ranlib"
      break
    fi
  done
  IFS="$saveifs"
fi
test -z "$RANLIB" && RANLIB="\#"

# Check for install
# Make sure to not get the incompatible SysV /etc/install 
# /usr/sbin/install, which might be in PATH before a BSD-like install,
# or the SunOS /usr/etc/install directory, or the AIX /bin/install.
if test -z "$INSTALL"; then
  # echo checking for install
  saveifs="$IFS"; IFS="${IFS}:"
  for dir in $PATH; do
    test -z "$dir" && dir=.
    case $dir in
    /etc|/usr/sbin|/usr/etc|/usr/ucb) ;;
    *)
      if test -f $dir/install; then
        if grep dspmsg $dir/install >/dev/null 2>&1; then
          : AIX
        else
          INSTALL="$dir/install -c"
          INSTALL_PROGRAM='$(INSTALL)'
          INSTALL_DATA='$(INSTALL) -m 644'
          break
        fi
      fi
      ;;
    esac
  done
  IFS="$saveifs"
fi

fi

INSTALL=${INSTALL-cp}
INSTALL_PROGRAM=${INSTALL_PROGRAM-'$(INSTALL)'}
INSTALL_DATA=${INSTALL_DATA-'$(INSTALL)'}

pic="-???"

case $TARGET in
  sun3) VERSIONFILE="version68k.c";;
  sparcv7) VERSIONFILE="versionsparcv7.c"; ASM_OBJ="sparc.\$(O)" pic="-Kpic";;
  sparcv8) VERSIONFILE="versionsparcv8.c"; ASM_OBJ="sparc.\$(O)" pic="-Kpic";;
  alpha) VERSIONFILE="versionalpha.c"; ASM_OBJ="alpha.\$(O)";;
  hppa) VERSIONFILE="versionhp.c"; ASM_OBJ="hppa.\$(O)";;
  i386 | dos | linux) VERSIONFILE="version386.c"; ASM_OBJ="i386.\$(O)";;
  *) VERSIONFILE="versionport.c" noasm=-D__HAS_NO_ASM__;;
esac
case $TARGET in
  sun3) INCLUDEFILE="gen68k.h"; GENPARIFILE="genpari68k.h";;
  *) INCLUDEFILE="genport.h"; GENPARIFILE="genpariother.h";;
esac
case $TARGET in
  sparcv7|sparcv8|i386)	if [ ! -z $solaris ]; then 
				CFLAGS="$CFLAGS $solaris"
			fi;;
esac

CFLAGS="$CFLAGS \$(PIC)"

case "x$DYNAMIC" in
	x[yY]*)	noDYNlink='#' DYNlink='' PIC="$pic";;
	x*)	noDYNlink='' DYNlink='#' PIC= ;;
esac


if [ "$CC" = gcc -a $TARGET = sun4 ] ; then
  DEBUGOPTION='-gstabs'
else
  DEBUGOPTION='-g'
fi
if [ $TARGET = hppa ] ; then
  XLIBOPTION='-L/usr/lib/X11R4'
fi

if [ $TARGET = sparcv8 -o $TARGET = sparcv7 -o $uname = SunOS ] ; then
  XLIBOPTION='-L/usr/openwin/lib'
fi


# Begin outputting the Makefile.
case $TARGET in
  sun3) echo "# Makefile for gp on sun3 and MC680x0 based machines (x>=2)">>Makefile;;
  sparcv7) echo "# Makefile for gp on sparcv7">>Makefile;;
  sparcv8) echo "# Makefile for gp on sparcv8">>Makefile;;
  alpha) echo "# Makefile for gp on alpha">>Makefile;;
  hppa) echo "# Makefile for gp on hppa-HPUX">>Makefile;;
  i386) echo "# Makefile for gp on i386">>Makefile;;
  linux) echo "# Makefile for gp on linux">>Makefile;;
  dos) echo "# Makefile for gp on DOS with emx/gcc">>Makefile;;
  *) echo "# General Makefile for C version of gp">>Makefile;;
esac

LIBS="-lm $solarisaddlibs"
DYNAMIC_LIBS='-lc'

cat >> Makefile <<!!

# Change these installation directories to suit your needs

PREFIX = /usr/local
LIBDIR = \$(PREFIX)/lib
BINDIR = \$(PREFIX)/bin
MANDIR = \$(PREFIX)/man
INCLUDEDIR = \$(PREFIX)/include/pari

CC = ${CC}
CFLAGS = ${CFLAGS}
VERSIONCFLAGS = ${VERSIONCFLAGS}
LIBS = ${LIBS}
LFLAGS =
STATIC_LIBS = ${STATIC_LIBS}
DYNAMIC_LIBS = ${DYNAMIC_LIBS}

# Additional flags to enable C++ compile (like '-x c++')

CPlPl = $CPlPl

# This is the flag needed for dynamic loading

${DYNlink}PIC = ${pic}

# If linking statically no flag is needed (this gives - very small - speedup)

${noDYNlink}PIC =

# You can (if you want to debug gp yourself) add the ${DEBUGOPTION} option
# in CFLAGS. However, remember that, while gcc accepts ${DEBUGOPTION} and -O
# simultaneously, cc usually does not.

!!
if [ $TARGET = sparcv8 ] ; then
cat >> Makefile  <<!!
# What file to assemble on SPARCs:

SPARCV8_S = $sparcv8_s

# What file is the above file based on:
SPARCV8_S_ORIG = sparcv8$ARCH.s

!!
fi
cat >> Makefile  <<!!
# Whether we have assembler routines:  -D__HAS_NO_ASM__ or empty:
NOASM = $noasm

!!

if [ $TARGET = dos ] ; then
cat >> Makefile  <<!!
O = o
A = a
AR = ar
LD = ld
RM = \$(COMSPEC) /c del
LN = \$(COMSPEC) /c copy
!!
else
cat >> Makefile  <<!!
O = o
A = a
AR = ar
LD = ld
RM = rm -f
LN = ln -s
!!
fi

libpari=libpari
libgnuplot=libgnuplot
if [ $TARGET = dos -a $CC = gcc ] ; then
  libpari=pari
  libgnuplot=gnuplot
fi

cat >> Makefile  <<!!
LIBPARI = $libpari.\$(A)
LIBGNUPLOT = $libgnuplot.\$(A)
RANLIB = ${RANLIB}
INSTALL = ${INSTALL}
INSTALL_PROGRAM = ${INSTALL_PROGRAM}
INSTALL_DATA = ${INSTALL_DATA}

# Choose the plot file:

# no plotting capabilities:
${noPLOTpref}PLOTFILE = plotnull.c
${noPLOTpref}PLOTCFLAGS =
${noPLOTpref}PLOTLIBS =

!!
if [ $TARGET = sun3 -o $TARGET = sparcv7 -o $TARGET = sparcv8 ] ; then
cat >> Makefile  <<!!
# plotting in Suntools windows:
${PLOTSUNpref}PLOTFILE = plotsun.c
${PLOTSUNpref}PLOTCFLAGS =
${PLOTSUNpref}PLOTLIBS = -lsuntool -lsunwindow -lpixrect

!!
fi
cat >> Makefile  <<!!
# plotting in X windows:
${PLOTXpref}PLOTFILE = plotX.c
${PLOTXpref}PLOTCFLAGS = -I/usr/openwin/share/include
${PLOTXpref}PLOTLIBS = ${XLIBOPTION} -lX11

# plotting in Gnuplot windows:
${PLOTGPpref}PLOTFILE = plotgnuplot.c
${PLOTGPpref}PLOTCFLAGS = -I\$(GNUPLOT_DIR)
${PLOTGPpref}PLOTLIBS = \$(LIBGNUPLOT)
${PLOTGPpref}PLOTBUILD = \$(LIBGNUPLOT)
#${PLOTGPpref}PLOTOBJS = \$(GNUPLOTOBJS)

# Choose whether you want the readline input facilities:

# This is good (bad?) if you have no readline
${noRLpref}RLLIBS =
${noRLpref}RLFLAGS =
${noRLpref}MORECFLAGS =

# This is good if you have old readline version nearby
#	You may need to edit some locations below. Comment first declaration
#	if you have libreadline.\$(A) compiled.
${RL1pref}RLLIBS = ../readline/libreadline.\$(A)
${RL1pref}RLFLAGS = -L../readline -lreadline -ltermcap
${RL1pref}MORECFLAGS = -DREADLINE -I.. $stricmp

# This is good if you have readline version 2.0 or later, already installed:
#	You may need to edit some locations below.
${RL2pref}RLLIBS = 
${RL2pref}RLFLAGS = -L/opt/gnu/lib -lreadline -ltermcap
${RL2pref}MORECFLAGS = -DREADLINE2 -I/opt/gnu/include $stricmp

# This should be the location of gnuplot 3.5 files
GNUPLOT_DIR = $GPDIR

OBJS = ${ASM_OBJ} mp.\$(O) anal.\$(O) alglin1.\$(O) alglin2.\$(O) base1.\$(O) base2.\$(O) base3.\$(O) arith1.\$(O) arith2.\$(O) bibli1.\$(O) bibli2.\$(O) elliptic.\$(O) es.\$(O) gen1.\$(O) gen2.\$(O) gen3.\$(O) init.\$(O) errmessages.\$(O) helpmessages.\$(O) polarit1.\$(O) polarit2.\$(O) trans1.\$(O) trans2.\$(O) trans3.\$(O) buch1.\$(O) buch2.\$(O) version.\$(O) gp_rl.\$(O) plotport.\$(O)

GNUPLOTOBJS =	\$(GNUPLOT_DIR)/term.\$(O) \$(GNUPLOT_DIR)/bitmap.\$(O) \
		\$(GNUPLOT_DIR)/util.\$(O) \$(GNUPLOT_DIR)/version.\$(O)

SRCS =  mp.c mpin.c anal.c alglin1.c alglin2.c base1.c base2.c base3.c arith1.c arith2.c bibli1.c bibli2.c elliptic.c es.c gen1.c gen2.c gen3.c init.c errmessages.c helpmessages.c polarit1.c polarit2.c trans1.c trans2.c trans3.c buch1.c buch2.c gp_rl.c ${VERSIONFILE} plotport.c

all:	genpari.h gp${EXE}

gp${EXE}:	genpari.h gp.\$(O) \$(OBJS) plot.\$(O) \$(RLLIBS) \$(PLOTBUILD)
!!
if [ $TARGET = dos -a -z "$OS2" ] ; then
cat >> Makefile  <<!!
	-\$(RM) gp1.\$(O)
	-\$(RM) gp2.\$(O)
	-\$(RM) gp3.\$(O)
	-\$(RM) gp4.\$(O)
	-\$(RM) gp5.\$(O)
	\$(LD) \$(LFLAGS) -o gp1.\$(O) -r mp.\$(O) i386.\$(O) anal.\$(O) alglin1.\$(O) alglin2.\$(O) base1.\$(O) base2.\$(O) base3.\$(O)
	\$(LD) \$(LFLAGS) -o gp2.\$(O) -r arith1.\$(O) arith2.\$(O) bibli1.\$(O) bibli2.\$(O) elliptic.\$(O) es.\$(O)
	\$(LD) \$(LFLAGS) -o gp3.\$(O) -r gen1.\$(O) gen2.\$(O) gen3.\$(O) init.\$(O) errmessages.\$(O) helpmessages.\$(O)
	\$(LD) \$(LFLAGS) -o gp4.\$(O) -r polarit1.\$(O) polarit2.\$(O) trans1.\$(O) trans2.\$(O) trans3.\$(O) version.\$(O)
	\$(LD) \$(LFLAGS) -o gp5.\$(O) -r buch1.\$(O) buch2.\$(O) gp_rl.\$(O) plotport.\$(O)
	\$(CC) \$(LFLAGS) -o gp.exe gp.\$(O) gp1.\$(O) gp2.\$(O) gp3.\$(O) gp4.\$(O) gp5.\$(O) plot.\$(O) \$(LIBS) \$(STATIC_LIBS) \$(PLOTLIBS) \$(RLFLAGS)
	-\$(RM) gp1.\$(O)
	-\$(RM) gp2.\$(O)
	-\$(RM) gp3.\$(O)
	-\$(RM) gp4.\$(O)
	-\$(RM) gp5.\$(O)

#gp.exe:	gp
#	emxbind -q c:\emx\bin\emx.exe gp gp.exe

!!
else
cat >> Makefile  <<!!
	\$(CC) \$(LFLAGS) -o gp${EXE} gp.\$(O) \$(OBJS) plot.\$(O) \$(LIBS) \$(STATIC_LIBS) \$(PLOTLIBS) \$(RLFLAGS)

!!
fi
cat >> Makefile  <<!!
genpari.h:	${GENPARIFILE}
	-\$(RM) genpari.h
	\$(LN) ${GENPARIFILE} genpari.h

!!
if [ $TARGET = sun3 ] ; then
cat >> Makefile  <<!!
mp.\$(O):	mp.s
	\$(CC) \$(CFLAGS) -c mp.s

!!
else
cat >> Makefile  <<!!
mp.\$(O):	mp.c
	\$(CC) \$(CFLAGS) \$(CPlPl) \$(NOASM) -c mp.c

!!
fi
if [ $TARGET = sparcv7 ] ; then
cat >> Makefile  <<!!
sparc.\$(O):	sparcv7.s
	as -P -o sparc.\$(O) sparcv7.s

!!
fi
if [ $TARGET = sparcv8 ] ; then
cat >> Makefile  <<!!
sparc.\$(O):	\$(SPARCV8_S)
	as -P -o sparc.\$(O) \$(SPARCV8_S)

_sparcv8.s:	\$(SPARCV8_S_ORIG)
	ln -s \$? \$@

sparcv8.s: _sparcv8.s
	sed s/_//g \$? > \$@

!!
fi
if [ $TARGET = alpha ] ; then
cat >> Makefile  <<!!
alpha.\$(O):	alpha.s
	as -O1 -o alpha.\$(O) alpha.s

!!
fi
if [ $TARGET = hppa ] ; then
cat >> Makefile  <<!!
hppa.\$(O):	hppa.s
	cc -c -o hppa.\$(O) hppa.s

!!
fi
if [ $TARGET = i386 -o $TARGET = dos -o $TARGET = linux ] ; then
cat >> Makefile  <<!!
i386.\$(O):	i386.s
	\$(CC) \$(CFLAGS) -c i386.s

i386.s:	i386.c
	\$(CC) -E i386.c > i386.s

!!
fi
for f in alglin1 alglin2 anal arith1 arith2 base1 base2 base3 buch1 buch2 bibli1 bibli2 elliptic es gen1 gen2 gen3 init errmessages helpmessages dummy polarit1 polarit2 trans1 trans2 trans3 plotport
do
cat >> Makefile  <<!!
$f.\$(O): $f.c
	\$(CC) \$(CFLAGS) \$(CPlPl) -c $f.c

!!
done
cat >> Makefile  <<!!
gp.\$(O): gp.c
	\$(CC) \$(CFLAGS) \$(CPlPl) \$(MORECFLAGS) -c gp.c

gp_rl.\$(O): gp_rl.c
	\$(CC) \$(VERSIONCFLAGS) \$(CPlPl) \$(MORECFLAGS) -c gp_rl.c

!!

cat >> Makefile  <<!!
plot.c:	\$(PLOTFILE)
	-\$(RM) plot.c
	\$(LN) \$(PLOTFILE) plot.c

plot.\$(O):	plot.c
	\$(CC) \$(CFLAGS) \$(CPlPl) \$(PLOTCFLAGS) -c plot.c

\$(LIBGNUPLOT): \$(GNUPLOTOBJS)
	\$(AR) r \$@ \$(GNUPLOTOBJS)

\$(GNUPLOTOBJS) :
	cd \$(GNUPLOT_DIR); make \$@

version.\$(O):	${VERSIONFILE}
	\$(CC) \$(VERSIONCFLAGS) \$(CPlPl) \$(NOASM) -c -o version.\$(O) ${VERSIONFILE}

../readline/Makefile:
	(cd ../readline ; CC='\$(CC)' ; export CC ; CFLAGS='\$(CFLAGS)' ; export CFLAGS ; configure)

../readline/libreadline.\$(A): ../readline/Makefile
	(cd ../readline ; make CC='\$(CC)' CFLAGS='\$(CFLAGS)')

install: install-lib install-bin install-man

library: \$(LIBPARI)

install-lib: \$(LIBPARI)
	-mkdir \$(INCLUDEDIR)
	\$(INSTALL_DATA) genpari.h \$(INCLUDEDIR)
	\$(INSTALL_DATA) gencom.h  \$(INCLUDEDIR)
	\$(INSTALL_DATA) genport.h \$(INCLUDEDIR)
	\$(INSTALL_DATA) gen68k.h \$(INCLUDEDIR)
	\$(INSTALL_DATA) erreurs.h \$(INCLUDEDIR)
	\$(INSTALL_DATA) mpansi.h \$(INCLUDEDIR)
	\$(INSTALL_DATA) mpdefs.h \$(INCLUDEDIR)
	\$(INSTALL_DATA) mpin.h \$(INCLUDEDIR)
	\$(INSTALL_DATA) \$(LIBPARI) \$(LIBDIR)

\$(LIBPARI): \$(OBJS) plot.\$(O)
	-\$(RM) \$(LIBPARI)
	\$(AR) r \$(LIBPARI) \$(OBJS) plot.\$(O)
	\$(RANLIB) \$(LIBPARI)

exe_library: \$(LIBPARI) genpari.h gp.\$(O) \$(RLLIBS) \$(PLOTBUILD)
	\$(CC) \$(LFLAGS) -o gp.exe gp.\$(O) -lpari \$(LIBS) \$(STATIC_LIBS) \$(PLOTLIBS) \$(RLFLAGS)

install-bin: gp$EXE
	\$(INSTALL_PROGRAM) gp$EXE \$(BINDIR)
	strip \$(BINDIR)/gp

install-man: gp.1
	\$(INSTALL_DATA) gp.1 \$(MANDIR)/man1

clean:	testclean
	-\$(RM) *.\$(O) \$(LIBPARI) gp$EXE genpari.h plot.c i386.s sparcv8.s _sparcv8.s \$(PARISO)

realclean:	clean
	-\$(RM) *~ *.orig *.rej *.old

testclean:	
	-\$(RM) testout.* 

test: testout.filtered
	@ if [ -z "\`cat testout.filtered\`" ] ; then echo OK ; \
		else echo not OK; cat testout.diff; fi

testout.test: gp$EXE testin
	./gp <testin > \$@ 2>&1

testout.diff: testouts testout.test
	@ -diff testouts testout.test > \$@

testout.filtered: testout.diff
	@ -grep -v "^[0-9-]" testout.diff | egrep -iv "Total time|version" > \$@

depend: genpari.h
	makedepend -- \$(CFLAGS) -- \$(SRCS)
!!

case $TARGET in
  sparcv7|sparcv8|i386)
cat >> Makefile  <<!!
### These are experimental dynamic linking targets. They are unsupported.
### They coredump on exit on my machine.

SO = so
PARISO = libpari.$(SO)

dynamic:	genpari.h gp-dynamic

# We put both the compilation directory and install directory in the 
# runtime lookup-path (see -R). It should be corrected in production

gp-dynamic:	genpari.h gp.\$(O) $(RLLIBS) $(PARISO)
	\$(LD) \$(LFLAGS) -o gp gp.\$(O) -R `pwd` -R \$(LIBDIR) -L. -lpari \$(STATIC_LIBS) \$(LIBS) \$(PLOTLIBS) \$(RLFLAGS) \$(DYNAMIC_LIBS)

install-dynamic: install-lib-dynamic install-bin install-man

install-lib-dynamic: \$(PARISO)
	\$(INSTALL_DATA) \$(PARISO) \$(LIBDIR)

\$(PARISO): \$(OBJS) plot.\$(O)
	@ if [ "x\$(PIC)" = "x" ]; then \
		echo "================================================"; \
		echo ">>>>> Need PIC to be specified             <<<<<"; \
		echo ">>>>> Remake with PIC set to '$pic' like <<<<<"; \
		echo "   make clean; make dynamic PIC='$pic'"; \
		echo "================================================"; \
		exit 1; fi
	\$(LD) -G -o \$@ \$(OBJS) \$(LIBS) \$(PLOTLIBS) \$(RLFLAGS) plot.\$(O) \$(DYNAMIC_LIBS)

!!
  ;;
esac

echo ============================================================
echo Now running makedepend
make depend
echo ============================================================

cat << !!
	Makefile for \`$TARGET'$ARCHrep written. Settings:
CC=\`$CC' CFLAGS=\`$CFLAGS' 
READLINE=\`$RL' PLOT=\`$PL' RANLIB=\`$RANLIB' PIC=\`$PIC'
LIBS=\`$LIBS' STATIC_LIBS=\`$STATIC_LIBS' DYNAMIC_LIBS=\`$DYNAMIC_LIBS'
GPDIR=\`$GPDIR'
	You may need to edit the resulting Makefile to get linking
with external libraries right. Usually you can postpone this until
linking fails (if it fails).

(Probably) you need only to type 
	make
	make test
			(optional, should finish with OK)
!!

if [ -z "$CPlPl" -a "X$CC" = "Xgcc" ]; then
	echo 'To compile with C++ and gcc, you may set CPlPl="-x c++" on make command line.'
fi