# Konstruktion des Makefiles fürs Compilieren von CLISP
# Bruno Haible 2.9.1991, 14.7.1992, 13.9.1992, 12.10.1992, 27.11.1992

# Simple usage:
#        ./makemake [--with-PACKAGE] [debug] > makefile

# Advanced usage:
#        ./makemake [--with-PACKAGE] TARGET COMPILER [debug] > makefile
#  where PACKAGE is one of
#        stdwin           the stdwin library
#        newreadline      the new (bash-1.14.1 based) readline library
#        readline         the old (gdb-4.13 based) readline library
#        noreadline       no readline library at all
#        module-stdwin    the stdwin library as a separate module
#        module-queens    the queens function as a separate module
#        dynamic-modules  an alternate way of managing separate modules
#  where TARGET is one of
#        sun3
#        sun4
#        i386      (any other 386 machine, e.g. Linux boxes or Sun386i)
#        i486      (any other 486 machine)
#        mips
#        atari     (ATARI ST microcomputers)
#        amiga     (Amiga 500/1000/2000 microcomputers)
#        acorn     (Acorn Archimedes running RiscOS)
#        dos       (PC or compatible running DOS, using EMX)
#        dosdjgpp  (PC or compatible running DOS, using DJGPP)
#        doswatcom (PC or compatible running DOS, using WATCOM)
#        windows   (PC or compatible running Windows, using EMX and RSXW32)
#        windowswatcom (PC or compatible running Windows, using WATCOM)
#        os2       (PC or compatible running OS/2 2.0)
#  and COMPILER is one of
#        gcc       (GNU C under the name gcc)
#        ansi      (any other ANSI compliant cc)
#        cc        (non-ANSI cc)
#        oldcc     (old and primitive non-ANSI cc)

# Examples:
#   makemake > makefile
#   makemake debug > makefile
#   makemake --with-stdwin debug > makefile
#   makemake i386 gcc > make.gcc/makefile
#   makemake i486 gcc > make.gcc/makefile
#   makemake sun4 gcc > make.gcc/makefile
#   makemake sun4 oldcc > make.cc/makefile
#   makemake atari gcc > make.atari/makefile
#   makemake cross atari gcc > make.atari/makefile
#   makemake amiga gcc > make.amiga/makefile
#   makemake acorn ansi > make.acorn.cc/makefile
#   makemake acorn gcc > make.acorn.gcc/makefile
#   makemake dos gcc > make.dos/makefile
#   makemake dosdjgpp gcc > make.dosdjgpp/makefile
#   makemake doswatcom wcl386 > make.doswatcom/makefile
#   makemake windows gcc > make.windows/makefile
#   makemake windowswatcom wcl386 > make.windowswatcom/makefile
#   makemake os2 gcc > make.os2/makefile

srcdir='.'
CP='cp -p'
LN_S='ln -s'
GOOD_SH='/bin/sh'

# NLS nuisances.
# Needed e.g. for some versions of `tr' so that character classes in `[]' work.
if test "${LC_ALL+set}" = 'set'; then LC_ALL=C ; export LC_ALL ; fi
if test "${LANG+set}"   = 'set'; then LANG=C   ; export LANG   ; fi
if [ `echo ABC | tr '[A-Z]' '[a-z]'` = "abc" ] ; then
  tolower="tr '[A-Z]' '[a-z]'"
else
  tolower="tr A-Z a-z"
fi

# Handle --with-... arguments
while test -z "$with_ok"; do
  case "$1" in
    -with-* | --with-*)
      package=`echo "$1"|sed 's/-*with-//'`
      # Delete all the valid chars; see if any are left.
      if test -n "`echo $package|sed 's/[-a-zA-Z0-9_]*//g'`"; then
        echo "makemake: $package: invalid package name" >&2; exit 1
      fi
      eval "with_`echo $package|sed s/-/_/g`=1"
      shift
      ;;
    *) with_ok=1 ;;
  esac
done

# HSYS, HSYSOS = host system
# HOS  = host operating system
# TSYS, TSYSOS = target system
# TOS  = target operating system
# CC, CFLAGS, CPP = compiler on host, for host
# XCC, XCFLAGS, XCPP = cross-compiler on host, for target

case $# in
  0 | 1)
     # Assume we are on Unix, and target=host (not cross-compiling).
     CROSS=false
     # Some shells (A/UX and OSF/1) need the parentheses around "arch" below.
     HSYS=`((arch) 2>/dev/null || uname -m 2>/dev/null) | $tolower` # system name in lowercase
     HSYSOS=`((uname) 2>/dev/null || arch 2>/dev/null) | $tolower` # OS name in lowercase
     if [ "$HSYS" = 386bsd -o "$HSYS" = sun386 -o "$HSYS" = "386/at" ] ; then
       HSYS='i386'
     fi
     if [ "$HSYS" = "i386 " ] ; then
       # May also check for `uname -v` = "COHERENT "
       HSYS='i386'
       HSYSOS='coherent'
     fi
     if [ "$HSYS" = sun4m ] ; then
       HSYS='sun4'
     fi
     HOS='unix'
     TSYS="$HSYS"
     TSYSOS="$HSYSOS"
     TOS="$HOS"
     COMPILER=??
     # These variables are set by configure:
     srcdir='@srcdir@'                   # either '.' or '../src'
     CP='@CP@'                           # either 'cp -p' or 'cp'
     LN_S='@LN_S@'                       # either 'ln -s' or 'ln'
     GOOD_SH='@GOOD_SH@'                 # either '/bin/sh' or '/bin/ksh' or ''
     CC="@CC@"                           # either 'gcc -O' or 'cc'
     CPP="@CPP@"                         # either $CC' -E' or '/lib/cpp'
     CC_GCC='@CC_GCC@'                   # either true or false
     CC_ANSI='@CC_ANSI@'                 # either true or false
     CC_NEED_CCPAUX='@CC_NEED_CCPAUX@'   # either true or false
     CC_NEED_DEELIF='@CC_NEED_DEELIF@'   # either true or false
     CC_NEED_DEERROR='@CC_NEED_DEERROR@' # either true or false
     CC_NEED_DEEMA='@CC_NEED_DEEMA@'     # either true or false
     CC_NEED_MERGESTRINGS='@CC_NEED_MERGESTRINGS@'   # either true or false
     AS_UNDERSCORE='@AS_UNDERSCORE@'     # either true or false
     RANLIB='@RANLIB@'                   # either 'ranlib' or 'true'
     INSTALL='@INSTALL@'                 # either 'install -c' or 'cp'
     INSTALL_PROGRAM='@INSTALL_PROGRAM@' # either 'install -c' or 'cp'
     INSTALL_DATA='@INSTALL_DATA@'       # either 'install -c -m 644' or 'cp'
     GMALLOC='@GMALLOC@'                 # either 'gmalloc' or ''
     LIBS='@LIBS@'                       # list of system libraries
     X_INCLUDES='@X_INCLUDES@'           # either '-I/usr/somewhere/include' or ''
     X_LIBS='@X_LIBS@'                   # either '-L/usr/somewhere/lib -lX11' or ''
     ;;
  *) if [ "$1" = cross ] ; then
       CROSS=true
       shift
       srcdir='../src'
     else
       CROSS=false
     fi
     TSYS=$1
     COMPILER=$2
     # TSYS should be master or sun3 or sun4 or i386 or i486 or mips or vax or atari or amiga or acorn or dos or dosdjgpp or doswatcom or windows or windowswatcom or os2.
     # COMPILER should be gcc or ansi or cc or oldcc
     if [ $TSYS = atari -o $TSYS = amiga -o $TSYS = acorn -o $TSYS = dos -o $TSYS = os2 ] ; then
       TOS=$TSYS
     else
       if [ $TSYS = dosdjgpp -o $TSYS = doswatcom -o $TSYS = windows -o $TSYS = windowswatcom ] ; then
         TOS='dos'
       else
         TOS='unix'
       fi
     fi
     TSYSOS=$TSYS
     if [ $CROSS = true ] ; then
       HOS='unix'
       HSYS=irrelevant
       HSYSOS=irrelevant
     else
       HOS="$TOS"
       HSYS="$TSYS"
       HSYSOS="$TSYSOS"
     fi
     if [ $TSYS = doswatcom -o $TSYS = windowswatcom ] ; then
       CC=$COMPILER # should be wcl386
       CC_GCC=false
       # CFLAGS='-d2 -ox -j -w4' # full debug info, optimize, char signed!, many warnings
       CFLAGS='-3r -oxet -j -zq -w0 -zp4' # Blake McBride prefers these settings
       CPP="${CC} -p -zq" # preprocess, quietly
       CC_ANSI=true
       CC_NEED_CCPAUX=false
       CC_NEED_DEELIF=false
       CC_NEED_DEERROR=false
       CC_NEED_MERGESTRINGS=false
       AS_UNDERSCORE=false
       CC_NEED_DEEMA=true
     else
       if [ $COMPILER = gcc ] ; then
         CC=gcc
         CC_GCC=true
       else
         CC=cc
         CC_GCC=false
       fi
       CFLAGS='-O'
       CPP="${CC} -E"
       if [ $COMPILER = gcc -o $COMPILER = ansi ] ; then
         CC_ANSI=true
         CC_NEED_CCPAUX=false
         CC_NEED_DEELIF=false
         CC_NEED_DEERROR=false
         CC_NEED_MERGESTRINGS=false
       else
         CC_ANSI=false
         if [ $COMPILER = oldcc ] ; then
           CC_NEED_CCPAUX=true
           CC_NEED_DEELIF=true
           CC_NEED_DEERROR=true
         else
           CC_NEED_CCPAUX=false
           CC_NEED_DEELIF=false
           CC_NEED_DEERROR=false
         fi
         CC_NEED_MERGESTRINGS=true
       fi
       if [ $COMPILER = gcc ] ; then
         # guess that if cross-compiling using gcc, then as preprends underscore
         AS_UNDERSCORE=true
       else
         AS_UNDERSCORE=false
       fi
       CC_NEED_DEEMA=false
     fi
     GMALLOC=''
     LIBS=''
     X_INCLUDES=''
     X_LIBS=''
     shift 2
     ;;
esac

if [ $CROSS = true ] ; then
  # We can cross-compile only with GCC 2
  XCC="gcc-${TSYS}"
  XCPP="${XCC} -E"
  XCC_GCC=true
  XCC_ANSI=true
  XCC_NEED_CCPAUX=false
  XCC_NEED_DEELIF=false
  XCC_NEED_DEERROR=false
  XCC_NEED_DEEMA=false
  XCC_NEED_MERGESTRINGS=false
else
  TSYS="$HSYS"
  TOS="$HOS"
  XCC="${CC}"
  XCPP="${CPP}"
  XCC_GCC="${CC_GCC}"
  XCC_ANSI="${CC_ANSI}"
  XCC_NEED_CCPAUX="${CC_NEED_CCPAUX}"
  XCC_NEED_DEELIF="${CC_NEED_DEELIF}"
  XCC_NEED_DEERROR="${CC_NEED_DEERROR}"
  XCC_NEED_DEEMA="${CC_NEED_DEEMA}"
  XCC_NEED_MERGESTRINGS="${CC_NEED_MERGESTRINGS}"
fi
XCC_NEED_DEDEFINED=false
XCC_UNUSABLE_CPP=false

# DEBUGGING should be debug or nothing
DEBUGGING=$1

if [ $srcdir = . ] ; then
  SRCDIR=''
else
  SRCDIR="${srcdir}/"
fi

TESTDIR=stage
TESTSDIR=suite

# Main host OS dependencies:

# HEXE = extension for executable files on host
if [ $HOS = dos -o $HOS = os2 ] ; then
  HEXE='.exe'
else
if [ $HOS = atari ] ; then
  HEXE='.prg'
else
  HEXE=''
fi
fi

# HERE = prefix to ensure that executables are looked up in current directory
if [ $HOS = unix ] ; then
  HERE='./'
else
  if [ $HOS = acorn ] ; then
    HERE='/'
  else
    HERE=''
  fi
fi

# PREFIX = prefix for installation directories
# (This should not end in a backslash. Add a space to avoid this.)
if [ $HOS = unix ] ; then
  PREFIX='/usr/local'
else
  PREFIX=''
fi

# PARENT = piece of path for parent directory
# NEXT = piece of path for next subdirectory
if [ $HOS = amiga ] ; then
  PARENT='/'
else
  if [ $HOS = acorn ] ; then
    PARENT='^.'
  else
    PARENT='../'
  fi
fi
if [ $HOS = acorn ] ; then
  NEXT='.'
else
  NEXT='/'
fi
if [ $HOS = atari -o $HOS = dos -o $HOS = os2 ] ; then
  # Replace '/' by '\':
  PARENT_=`echo $PARENT | sed -e 's,/,\\\\,g'`
  NEXT_=`echo $NEXT | sed -e 's,/,\\\\,g'`
else
  PARENT_=$PARENT
  NEXT_=$NEXT
fi
# Replace '\' by '\\':
PARENT_2=`echo $PARENT_ | sed -e 's,\\\\,\\\\\\\\,g'`

# RM = command for deleting files
if [ $HOS = dos -o $HOS = os2 -o $HOS = atari ] ; then
  RM='del'
else
  if [ $HOS = acorn ] ; then
    RM='remove'
  else
    RM='rm -f'
  fi
fi

# CP = command for copying files
if [ $HOS = dos -o $HOS = os2 -o $HOS = atari ] ; then
  CP='copy'
else
  if [ $HOS = acorn ] ; then
    CP='cp ~A~CN'
# else see above
  fi
fi

# LN_S = command for copying read-only files
if [ $HOS = dos -o $HOS = os2 -o $HOS = atari ] ; then
  LN_S='copy'
else
  if [ $HOS = acorn ] ; then
    LN_S='cp ~A~CN'
# else see above
  fi
fi

# MV = command for renaming files
if [ $HOS = dos -o $HOS = os2 -o $HOS = atari ] ; then
  MV='ren'
else
  if [ $HOS = acorn ] ; then
    MV='cp ~A~CDF'
  else
    MV='mv'
  fi
fi

# CAT = command for typing files to stdout
if [ $HOS = dos -o $HOS = os2 -o $HOS = atari ] ; then
  CAT='type'
else
  CAT='cat'
fi

# TOUCH = command for pretending files are new
if [ $HOS = acorn ] ; then
  TOUCH='stamp'
else
  TOUCH='touch'
fi

# RANLIB = command for finishing libraries
if [ -z "$RANLIB" ] ; then
  RANLIB='ranlib'
fi

# INSTALL = command for installing binaries/data
if [ -z "$INSTALL" ] ; then
  INSTALL=$CP
  INSTALL_PROGRAM='$(INSTALL)'
  INSTALL_DATA='$(INSTALL)'
fi

# On small systems it's a waste of space to build lisparit0.d.
# We may also have file naming problems on 8+3 character filesystems.
# Anyway, we need it only if debugging is desired.
if [ $HOS = dos -o $HOS = os2 -o $HOS = atari -o $HSYS = amiga -o $HSYS = acorn -o "$HSYSOS" = coherent -o "$DEBUGGING" != debug ] ; then
  LISPARIT='lisparit'
else
  LISPARIT='lisparit0'
fi

# Main target OS dependencies:

OS_INCLUDES=''
if [ $TSYS = master -o $TOS = unix ] ; then
  OS_INCLUDES=$OS_INCLUDES' unix'
  if [ "$TSYSOS" != coherent ] ; then
    LIBS=$LIBS' -ltermcap'
  else
    LIBS=$LIBS' -lterm'
  fi
fi
if [ $TSYS = master -o $TOS = atari ] ; then
  OS_INCLUDES=$OS_INCLUDES' atari'
fi
if [ $TSYS = master -o $TOS = amiga ] ; then
  OS_INCLUDES=$OS_INCLUDES' amiga'
fi
if [ $TSYS = master -o $TOS = acorn ] ; then
  OS_INCLUDES=$OS_INCLUDES' acorn'
fi
if [ $TSYS = master -o $TOS = dos -o $TOS = os2 ] ; then
  OS_INCLUDES=$OS_INCLUDES' msdos'
  if [ $TSYS = dos -o $TSYS = os2 ] ; then
    LIBS=$LIBS' -ltermcap -lgraph'
    if [ $TSYS = os2 ] ; then
      LIBS=$LIBS' -lvideo'
    fi
  fi
  if [ $TSYS = dosdjgpp ] ; then
    LIBS=$LIBS' -lpc'
  fi
  if [ $TSYS = windows ] ; then
    LIBS=$LIBS' /rsxwin/lib/libwin.a'
  fi
fi

if [ $CROSS = true ] ; then
  if [ $TOS = atari ] ; then
    # CHSCONVERT='$(HOME)/cc/convert-to-atari'
    # CHSCONVERT='/usr/local/utils/cv-to-atari'
    CHSCONVERT='./cv_lt_at'
  fi
  if [ $TOS = dos -o $TOS = os2 ] ; then
    # CHSCONVERT='$(HOME)/cc/convert-to-ibmpc'
    # CHSCONVERT='/usr/local/utils/cv-to-ibmpc'
    # CHSCONVERT='recode latin1:ibmpc | crlf-to-nl'
    CHSCONVERT='./cv_lt_pc'
  fi
fi

# TEXE = extension for executable files on target
# LEXE = extension for executable file LISP on target
if [ $TOS = dos -o $TOS = os2 ] ; then
  TEXE='.exe'
  LEXE='.exe'
else
if [ $TOS = atari ] ; then
  TEXE='.prg'
  LEXE='.prg'
else
if [ $TOS = acorn ] ; then
  TEXE=''
  LEXE=''
else
  TEXE=''
  LEXE='.run'
fi
fi
fi

# TOBJ = extension for compiled modules on target
if [ $TSYS = doswatcom -o $TSYS = windowswatcom ] ; then
  TOBJ='.obj'
else
  TOBJ='.o'
fi

# Main compiler dependencies:

# INCLUDEDIR = option that specifies another include file directory
if [ $TSYS = doswatcom -o $TSYS = windowswatcom ] ; then
  INCLUDEDIR='-i='
else
  INCLUDEDIR='-I'
fi

if [ $XCC_GCC = true ] ; then

  XCFLAGS='-W -Wswitch -Wcomment -Wpointer-arith '
  if [ $XCC_ANSI = true ] ; then
    XCFLAGS=$XCFLAGS'-Wimplicit -Wreturn-type '
  fi
  if [ $HOS = dos -o $HOS = os2 ] ; then
    # DOS has a very limited command line length
    XCFLAGS=''
  fi
  if [ "$DEBUGGING" != debug ] ; then
    # Frame-Pointer brauchen wir nicht. Da, wo wir ihn brauchen (in eval.d:
    # interpret_bytecode_()), erzwingen wir ihn durch Benutzung von alloca().
    # Unter Windows darf -fomit-frame-pointer i.a. nicht verwendet werden (da
    # sonst gcc womöglich Daten-Pointer nach %ebp legt, was wegen inkompatibler
    # Segmentregister nicht zulässig ist). Glücklicherweise ist das bei rsxw32
    # kein Problem, da dort %cs = 0x185F, %ds = %es = %fs = %gs = %ss = 0x1867,
    # insbesondere %ds = %ss.
    XCFLAGS=$XCFLAGS'-fomit-frame-pointer '
  fi
  if [ $TSYS = atari -o $TSYS = amiga ] ; then
    # Register A4 enthält den Stack.
    # Die GCC-Strength-Reduction ist auf dem 68000 nicht problemlos.
    XCFLAGS=$XCFLAGS'-ffixed-a4 -fno-strength-reduce '
  fi
  if [ $TSYS = windows ] ; then
    # Die Include-Files für MS-Windows 3.1
    XCFLAGS=$XCFLAGS'-I/emx/include.win '
  fi
  if [ $CROSS = false ] ; then
    XCC_GCC_VERSION=`$XCC -v 2>&1 | tail -1 | sed -e 's/.*version //g'`
    case "$XCC_GCC_VERSION" in
      # gcc 2.6 has an option for fast single precision ("float") computation.
      # It is only needed when -traditional is specified.
      2.[6-9]* )
        if [ $XCC_ANSI = false ] ; then
          XCFLAGS=$XCFLAGS'-fallow-single-precision '
        fi
        ;;
      * ) ;;
    esac
  fi
  if [ $TSYS = i386 -o $TSYS = i486 -o $TSYS = dos -o $TSYS = dosdjgpp -o $TSYS = windows -o $TSYS = os2 ] ; then
    # gcc <= 2.3.2 may crash when compiling lisparit with -O2
    # gcc 2.3.3 may produce incorrect code when compiling spvw(SPVW_PURE) with -O -fomit-frame-pointer
    if [ $CROSS = false ] ; then
      XCC_GCC_VERSION=`$XCC -v 2>&1 | tail -1 | sed -e 's/.*version //g'`
      case "$XCC_GCC_VERSION" in
        2.3.[3-9]* | 2.[4-9]* )
          # XCFLAGS=$XCFLAGS'-O2 -fno-omit-frame-pointer' ;;
          # Let's try it nevertheless!
          XCFLAGS=$XCFLAGS'-O2' ;;
        * )
          XCFLAGS=$XCFLAGS'-O' ;;
      esac
    else
      XCFLAGS=$XCFLAGS'-O'
    fi
  else
    XCFLAGS=$XCFLAGS'-O2'
  fi
  if [ $TSYS = sun4 -o $TSYS = acorn ] ; then
    XCLFLAGS='-static'
  else
    XCLFLAGS=''
  fi
  XCC_NOOPTFLAGS=' -O0'

else

  if [ "$TSYSOS" = coherent ] ; then
    # If one cannot use the default cc preprocessor: Use GNU cpp instead.
    # The Coherent386 cc preprocessor is not usable
    # 1. because of "macro expansion buffer overflow", 2. because it is an
    # ANSI like preprocessor (## and the like) in front of a K&R C compiler.
    XCC_UNUSABLE_CPP=true
    XCPP='../utils/gcc-cccp/cccp -traditional -U__GNUC__'
    if [ "$TSYSOS" = coherent ] ; then
      XCPP="$XCPP -DCOHERENT -D_I386 -D_IEEE"
    fi
    XCC_NEED_CCPAUX=false
    XCC_NEED_DEELIF=false
    XCC_NEED_DEERROR=false
    XCC_NEED_DEDEFINED=false
    XCC_NEED_DEEMA=false
  fi
  if [ $TSYS = doswatcom -o $TSYS = windowswatcom ] ; then
    XCFLAGS="$CFLAGS"
  else
    if [ "$HSYSOS" = hp-ux -o $TSYS = sun4 ] ; then
      # HP's HPPA compilers crash when optimizing.
      # SUN's cc is buggy when optimizing spvw.d, even with only -O1.
      XCFLAGS=''
    else
      XCFLAGS='-O'
    fi
  fi
  if [ $XCC_UNUSABLE_CPP = true ] ; then
    # GNU cpp has restricted command line flags. Pass them only to XCC.
    XCC="$XCC $XCFLAGS"
    XCFLAGS=''
  fi
  XCLFLAGS=''
  # if [ "$COMPILER" = oldcc ] ; then
  # XCPP='gcc -E -P -U__STDC__ -U__GNUC__'
  # TRADDECLFLAGS=' -DFOR_ANSI_PREPROCESSOR -DCUT_U_AND_L'
  # else
  if [ $XCC_ANSI = false ] ; then
    TRADDECLFLAGS=' -DCUT_U_AND_L'
  fi
  # fi
  case $TSYS in mips | ip*)
    # IRIX 4 "cc -ansi" sometimes barfs when a string constant contains one
    # or more quotes('). They must be written as \047.
    TRADDECLFLAGS="${TRADDECLFLAGS} -DQUOTE_QUOTES"
    ANSIDECLFLAGS="${ANSIDECLFLAGS} -DQUOTE_QUOTES"
    TXT2CFLAGS="${TXT2CFLAGS} -DQUOTE_QUOTES"
  esac
  if [ $TSYS = sun4 ] ; then
    XCFLAGS=$XCFLAGS' -dalign -fsingle'
    XCLFLAGS=$XCLFLAGS' -Bstatic'
  fi
  if [ $TSYS = acorn ] ; then
    XCFLAGS=$XCFLAGS' -D__arm -D__riscos -wanp -JUnix: -IUnix:'
    XCLFLAGS=$XCLFLAGS' -LUnix:o.Unixlib'
  fi
  XCC_NOOPTFLAGS=''

fi

if [ "$DEBUGGING" = debug ] ; then
  if [ $TSYS = sun4 -a $XCC_GCC = true ] ; then
    XCFLAGS=$XCFLAGS' -gstabs'
  else
    XCFLAGS=$XCFLAGS' -g'
  fi
fi

if [ $TSYS = windows ] ; then
  XCFLAGS=$XCFLAGS' -DWINDOWS'
fi

if [ $TSYS = os2 ] ; then
  XCFLAGS=$XCFLAGS' -DOS2'
fi

if [ "$TSYSOS" = coherent ] ; then
  XCFLAGS=$XCFLAGS' -Dunix'
fi

if [ $TSYS = i386 -a "$TSYSOS" = "sinix-z" ] ; then # SINIX-Z V5.41
  XCFLAGS=$XCFLAGS' -DSNI -DSVR4 -DUSL'
  LIBS=$LIBS' -lnsl -lsocket'
fi
if [ $TSYS = i386 -a "$TSYSOS" = "unix_sv" ] ; then # Onsite SVR4.2
  XCFLAGS=$XCFLAGS' -DUSL'
  LIBS=$LIBS' -lnsl -lsocket'
fi
if [ $TSYS = i386 -a "$TSYSOS" = linux -a $CROSS = false ] ; then # Linux
  # Generational GC requires Linux 1.1.52 or newer
  UNAME_R=`uname -r | $tolower`
  case "$UNAME_R" in
    0.* | 1.0.* | 1.1.[0-9] | 1.1.[1-4][0-9] | 1.1.5[0-1] )
      XCFLAGS=$XCFLAGS' -DNO_GENERATIONAL_GC' ;;
    *) ;;
  esac
fi

if [ $TSYS = sun4 -a $CROSS = false ] ; then
  ARCH_K=`arch -k` # kernel architecture, see arch(1)
  if [ "$ARCH_K" = sun4 -o "$ARCH_K" = sun4c ] ; then
    # sun4 and sun4c support only 29 bit addresses,
    # sun4m supports 32 bit addresses.
    XCFLAGS=$XCFLAGS' -DSUN4_29'
  fi
  # Distinguish good SunOS 4 from the SunOS 5 garbage called "Solaris 2":
  UNAME_S=`uname -s | $tolower`
  UNAME_R=`uname -r | $tolower`
  if [ "$UNAME_S" = sunos ] ; then
    case "$UNAME_R" in
      4*)
        # XCFLAGS=$XCFLAGS' -DUNIX_SUNOS4' # done in unix.d
      ;;
      [5-9]*)
        # XCFLAGS=$XCFLAGS' -DUNIX_SUNOS5' # done in unix.d
        # We need a lot of libraries. To check which libraries are necessary, do
        #   cd /usr/lib
        #   foreach f (lib*.a)
        #   echo $f ; nm $f | grep gethostbyname
        #   end
        # We conclude that
        # - for gethostname() we need libnsl.a,
        # - for connect() and socket() we need libsocket.a,
        # - for these we need libdl_stubs.a and everything required by this one,
        # - a second pass through the libraries is needed to satisfy cyclic
        #   dependencies.
        if test -f /usr/lib/libdl_stubs.a; then
          LIBS=$LIBS' -lnsl -lsocket -ldl_stubs -lnswfiles -lnswnis -lnswnisplus -ltcpip -lswitch -lnswcompat -lstraddr -lintl'
          LIBS=$LIBS' -lnsl -lsocket -ldl_stubs -lnswfiles -lnswnis -lnswnisplus -ltcpip -lswitch -lnswcompat -lstraddr -lintl'
        else
          # Newer versions of Solaris (Solaris 2.2 and newer) don't have
          # libdl_stubs.a any more. This means that you cannot link -static !
          LIBS=$LIBS' -lnsl -lsocket'
          LIBS=$LIBS' -lnsl -lsocket'
          XCLFLAGS=`echo "$XCLFLAGS" | sed -e 's/-B*static//g'`
          SOLARIS_LINKING=1 # Even more hacks needed??
        fi
        BINARY_DISTRIB=1
      ;;
    esac
  fi
fi
if [ "$TSYSOS" = coherent -a $CROSS = false ] ; then
  BINARY_DISTRIB=1
fi
if test -n "$BINARY_DISTRIB"; then
  XCFLAGS=$XCFLAGS' -DUNIX_BINARY_DISTRIB'
fi


# Other dependencies:

if test -n "$with_dynamic_modules"; then
  XCFLAGS="$XCFLAGS -DDYNAMIC_MODULES"
fi

if test -n "$with_stdwin"; then
  XCFLAGS="$XCFLAGS -DSTDWIN"
  XCL_STDWINLIB='stdwin/libstdwin.a'
  LIBS=$XCL_STDWINLIB' '$LIBS
else
  XCL_STDWINLIB=''
fi

TERMINAL='generic'
READLINELIB=''
XCL_READLINELIB=''
if [ $TOS = unix -a "$TSYSOS" != coherent -o $TOS = dos -a $TSYS != doswatcom -a $TSYS != windows -a $TSYS != windowswatcom -o $TOS = os2 ] ; then
  if test -n "$with_noreadline"; then
    XCFLAGS=$XCFLAGS' -DNO_READLINE'
  else
    TERMINAL='readline'
    READLINELIB='libreadline.a'
    if test -n "$with_newreadline"; then
      READLINEDIR='newreadline'
    else
      READLINEDIR='readline'
    fi
    READLINELIB=$READLINEDIR'/'$READLINELIB
    # Don't put "-lreadline" into LIBS for two reasons:
    # 1. The system may have its own libreadline.a.
    # 2. EMX 0.8h would be looking for readline.a instead of libreadline.a.
    if [ $HOS = unix ] ; then
      # use symbolic link, avoid -L in CFLAGS (doesn't work with Coherent cc)
      XCL_READLINELIB='libreadline.a'
    else
      XCL_READLINELIB=$READLINELIB
    fi
    LIBS=$XCL_READLINELIB' '$LIBS
  fi
fi

MODULES='         spvw spvwtabf spvwtabs spvwtabo'
MODULES=$MODULES' eval control'
MODULES=$MODULES' pathname stream'
if [ $TSYS = master -o $TOS = unix ] ; then
  MODULES=$MODULES' socket'
fi
MODULES=$MODULES' io'
MODULES=$MODULES' array hashtabl list package record sequence'
MODULES=$MODULES' charstrg debug error misc predtype symbol '$LISPARIT
if [ $TSYS = master ] || [ $TOS = unix -o $TSYS = dos -o $TSYS = dosdjgpp -o $TSYS = doswatcom -o $TSYS = windows -o $TSYS = windowswatcom -o $TSYS = os2 ] && [ -n "$with_stdwin" ] ; then
  MODULES=$MODULES' stdwin'
fi
if [ $TSYS = master -o $TSYS = amiga ] ; then
  MODULES=$MODULES' rexx'
fi
if [ $TSYS = master -o $TOS = unix -o $TSYS = dos -o $TSYS = dosdjgpp -o $TSYS = doswatcom -o $TSYS = windows -o $TSYS = windowswatcom -o $TSYS = os2 ] ; then
  MODULES=$MODULES' graph'
fi
if [ $TSYS = master -o $TSYS = atari ] ; then
  MODULES=$MODULES' alglobal'
fi
if [ $TSYS = master -o $TSYS = sun4 -a "$DEBUGGING" = debug ] ; then
  MODULES=$MODULES' dbxtypes'
fi
if [ $TSYS = master -o $TOS = unix -o $TSYS = dos -o $TSYS = os2 -o $TSYS = windows -o $TSYS = acorn ] ; then
  MODULES=$MODULES' unixaux'
fi
if [ $TSYS = master -o $TOS = acorn ] ; then
  MODULES=$MODULES' acornaux'
fi
if [ $TSYS = master -o $TSYS = windows -o $TSYS = windowswatcom ] ; then
  MODULES=$MODULES' windows'
fi

EVERY_INCLUDES='lispbibl fsubr subr pseudofun constsym constobj '$OS_INCLUDES

EVERY_INCLUDES_C=''
for f in $EVERY_INCLUDES ; do
  EVERY_INCLUDES_C=$EVERY_INCLUDES_C' '$f'.c'
done

OTHER_INCLUDES=' constpack avl sort'
if [ $TSYS = master -o $TSYS = amiga ] ; then
  OTHER_INCLUDES=$OTHER_INCLUDES' amiga2'
fi
if [ $TSYS = master -o $TSYS = windows -o $TSYS = windowswatcom ] ; then
  OTHER_INCLUDES=$OTHER_INCLUDES' wintext winstat winmain winaux'
fi

LISPARIT_SUBFILES=' aridecl arilev0 arilev1 intelem intlog intplus intcomp intbyte intmal intdiv intgcd int2adic intsqrt intprint intread rational'
LISPARIT_SUBFILES=$LISPARIT_SUBFILES' sfloat ffloat dfloat lfloat flo_konv flo_rest realelem realrand realtran compelem comptran'
if [ $LISPARIT = lisparit ] ; then
  LISPARIT_INCLUDES=$LISPARIT_SUBFILES
else
  LISPARIT_INCLUDES=''
  OTHER_INCLUDES=$OTHER_INCLUDES' aridecl arilev0'
fi
LISPARIT_INCLUDES=$LISPARIT_INCLUDES' arilev1c arilev1e arilev1i'

EXTRA_MODULES='noreadline main'
if [ $TOS = unix -o $TSYS = dos -o $TSYS = dosdjgpp -o $TSYS = doswatcom -o $TSYS = windows -o $TSYS = windowswatcom -o $TSYS = os2 ] && [ -n "$with_module_stdwin" ] ; then
  EXTRA_MODULES=$EXTRA_MODULES' stdwin'
fi

DFILES="$MODULES $EVERY_INCLUDES $OTHER_INCLUDES $LISPARIT_INCLUDES genclisph modules $EXTRA_MODULES"

ARI_ASMD=''
ARI_ASMC=''
ARI_ASMS=''
if [ $TSYS = sun3 -o $TSYS = hp300 -o $TSYS = m68k -o $TSYS = mc68040 -o $TSYS = atari -o $TSYS = amiga ] ; then
  ARI_ASMD=$ARI_ASMD' ari68000.mot ari68000.mit ari68000.atari ari68020.mot ari68020.mit'
  if [ $TSYS = sun3 -o $TSYS = hp300 -o $TSYS = m68k -o $TSYS = mc68040 ] ; then
    ARI_ASMS=$ARI_ASMS' ari68020'
  else
    ARI_ASMS=$ARI_ASMS' ari68000'
  fi
  ARI_ASMC=$ARI_ASMS
fi
if [ $TSYS = sun4 ] ; then
  ARI_ASMD=$ARI_ASMD' arisparc'
  ARI_ASMS=$ARI_ASMS' arisparc'
fi
case $TSYS in mips | ip* | sgi | risc | r4000)
  ARI_ASMD=$ARI_ASMD' arimips'
  ARI_ASMS=$ARI_ASMS' arimips'
esac
if [ $TSYS = i386 -o $TSYS = i486 -o $TSYS = dos -o $TSYS = dosdjgpp -o $TSYS = windows -o $TSYS = os2 ] ; then
  ARI_ASMD=$ARI_ASMD' ari80386'
  ARI_ASMS=$ARI_ASMS' ari80386'
fi
case $TSYS in 9000/7* | 9000/8* | hp7*)
  # HP 9000 Series 700, 800
  ARI_ASMD=$ARI_ASMD' arihppa'
  ARI_ASMS=$ARI_ASMS' arihppa'
esac
if [ $TSYS = acorn ] ; then
  ARI_ASMD=$ARI_ASMD' ariarm'
  ARI_ASMS=$ARI_ASMS' ariarm'
fi

SP_ASMD=''
SP_ASMS=''
if [ $XCC_GCC = false ] ; then
  if [ $TSYS = sun3 -o $TSYS = hp300 -o $TSYS = m68k -o $TSYS = mc68040 -o $TSYS = atari -o $TSYS = amiga ] ; then
    SP_ASMD=$SP_ASMD' sp68000.mot sp68000.mit'
    SP_ASMS=$SP_ASMS' sp68000'
  fi
  # durch cc_sparc.il überflüssig:
  # if [ $TSYS = sun4 ] ; then
  #   SP_ASMD=$SP_ASMD' spsparc'
  #   SP_ASMS=$SP_ASMS' spsparc'
  # fi
  case $TSYS in mips | ip* | sgi | risc | r4000)
    SP_ASMD=$SP_ASMD' spmips'
    SP_ASMS=$SP_ASMS' spmips'
  esac
  if [ $TSYS = i386 -o $TSYS = i486 -o $TSYS = dos -o $TSYS = dosdjgpp -o $TSYS = windows -o $TSYS = os2 ] ; then
    SP_ASMD=$SP_ASMD' sp80386'
    SP_ASMS=$SP_ASMS' sp80386'
  fi
fi

COMMENTS=''

CODE='      init defseq backquot defmacro macros1 macros2 defs1 timezone places floatpri type defstruc'
CODE=$CODE' format user1 user2 trace macros3 config compiler defs2 loop clos conditio defs3'
CODE=$CODE' gstream foreign screen stdwin1 stdwin2 rexx editor'

DOC='LISP-tutorial CLOS-guide cltl2'

TXT_FILES='README clisp.1 clisp.html impnotes.txt'
if [ $CROSS = false -a $HOS = unix ] ; then
  TXT_FILES=$TXT_FILES' distmakefile'
fi

OBSOLETE=''

# Output the makefile:

# echotab line
# outputs a line, preceding it with a tab. cat is needed to output tabs.
if [ "$HSYSOS" != coherent ] ; then
echotab () {
cat <<!!
	$1
!!
}
else
# Coherent's ksh produces error relating to /tmp/sh<pid> files...
echotab () {
echo "\t""$1"
}
fi

# echotabpipe line
# outputs a line, split along pipe symbols, preceding with tabs.
if [ $HSYS != acorn ] ; then
echotabpipe() {
echotab "$1"
}
else
echotabpipe() {
line="$1"
junk=''
i=1
while
  linefirst=`echo "$line" | sed -e 's/|.*$//'`
  test "$linefirst" != "$line"
do
  linefirst=`echo "$linefirst" | sed -e 's/[ 	]*$//'`
  linerest=`echo "$line" | sed -e 's/^[^|]*|//' | sed -e 's/^[ 	]*//'`
  tempfile='TMPPIPE'"$i"
  echotab "$linefirst"" > $tempfile"
  if test -n "$junk"; then
    echotab "\$(RM) $junk"
  fi
  junk="$tempfile"
  i=`expr "$i" + 1`
  line=`echo "$linerest" | sed -e 's/[<>|].*$//' | sed -e 's/[ 	]*$//'`" < $tempfile "`echo "$linerest" | sed -e 's/^[^<>|]*//'`
done
echotab "$line"
if test -n "$junk"; then
  echotab "\$(RM) $junk"
fi
}
fi

# echolist prefix list suffix prefix
# outputs a list of items, prefixed by backslashes and newlines to break long
# lines.
if [ "$HSYSOS" != coherent ] ; then
echolist () {
line="$1"
for f in $2 ; do
  echo $line" \\"
  line="$4${f}$3"
done
echo $line
}
else
# Coherent's ksh produces funny characters after the newlines, avoid newlines.
if true; then
echolist () {
line="$1"
for f in $2 ; do
  line="$line $4${f}$3"
done
echo $line
}
else
echolist () {
# This would be another possible implementation if "echo -n" were portable.
echo -n "$1"
for f in $2 ; do
  echo -n " $4${f}$3"
done
echo
}
fi
fi

# echodummyrule target
# outputs a dummy rule for the given target.
if [ "$HSYSOS" != coherent -a $HSYS != acorn ] ; then
echodummyrule () {
:
}
else
echodummyrule () {
echotab "\$(TOUCH) $1"
}
fi

echo "# Makefile for the CLISP binaries"
echo "# DO NOT EDIT! GENERATED AUTOMATICALLY!"
echo
echo '# -------------- Start of configurable section --------------------'
echo
echo '# Directories used by "make install":'
echo "prefix = ${PREFIX}"
echo "exec_prefix = \$(prefix)"
echo "bindir = \$(exec_prefix)${NEXT_}bin"
echo "mandir = \$(exec_prefix)${NEXT_}man"
echo "libdir = \$(exec_prefix)${NEXT_}lib"
echo "lisplibdir = \$(libdir)${NEXT_}lisp"
echo
echo '# Programs used by "make":'
if [ $CROSS = true ] ; then
  echo "CC = ${CC}"
  echo "CFLAGS = ${CFLAGS}"
  echo "CPP = ${CPP}"
  echo "XCC = ${XCC}"
  echo "XCFLAGS = ${XCFLAGS}"
  echo "XCPP = ${XCPP}"
  echo "XCLFLAGS = ${XCLFLAGS}"
  echo "XLIBS = ${LIBS}"
  XCC="\$(XCC)"
  XCFLAGS="\$(XCFLAGS)"
  XCPP="\$(XCPP)"
  XCLFLAGS="\$(XCLFLAGS)"
  LIBS="\$(XLIBS)"
else
  echo "CC = ${XCC}"
  echo "CFLAGS = ${XCFLAGS}"
  echo "CPP = ${XCPP}"
  echo "CLFLAGS = ${XCLFLAGS}"
  echo "LIBS = ${LIBS}"
  XCC="\$(CC)"
  XCFLAGS="\$(CFLAGS)"
  XCPP="\$(CPP)"
  XCLFLAGS="\$(CLFLAGS)"
  LIBS="\$(LIBS)"
fi
echo "X_LIBS = ${X_LIBS}"
X_LIBS="\$(X_LIBS)"
# if [ $TSYS = sun4 -a "$CC" = cc ] ; then
#   echo "INLINE = /usr/lib/inline"
# fi
if [ $HSYS = doswatcom -o $HSYS = windowswatcom ] ; then
  echo "DISASM = wdisasm -au -s" # -au: Intel/Unix syntax, -s: include source
fi
if [ $HSYS = dos -o $HSYS = dosdjgpp -o $TSYS = windows -o $HSYS = os2 ] ; then
  echo "LD = ld"
fi
if [ $TSYS = windows -o $TSYS = windowswatcom ] ; then
  echo 'RC = wrc -i=d:\watcom95\h\win'
fi
if [ $TSYS = windows ] ; then
  echo 'RSXW32 = \rsxwin\rsxw32.exe'
fi
# echotab_to_HEXE command target
# outputs a `make' statement that executes command and creates target${HEXE}.
if [ $HSYS != dosdjgpp -a $HSYS != doswatcom -a $HSYS != windowswatcom ] ; then
  echotab_to_HEXE () {
  echotab "$1 -o $2${HEXE}"
  }
else
  if [ $HSYS = dosdjgpp ] ; then
    # echo "COFF2EXE = coff2exe"
    # would work too, but then all the programs would depend on the environment
    # variable GO32 and the existence of go32.exe. We prefer to do it this way:
    echo "COFF2EXE = copy /b c:\djgpp\bin\go32.exe +"
    echotab_to_HEXE () {
    echotab "$1 -o $2"
    echotab "\$(COFF2EXE) $2 $2${HEXE}"
    echotab "\$(RM) $2"
    }
  fi
  if [ $HSYS = doswatcom -o $HSYS = windowswatcom ] ; then
    echotab_to_HEXE () {
    echotab "$1 -fo=$2${HEXE}"
    }
  fi
fi
if [ -n "$CHSCONVERT" ] ; then
  echo "CHARSETCONVERT = ${CHSCONVERT}"
  CHSCONVERT_FILTER=" | \$(CHARSETCONVERT)"
else
  CHSCONVERT_FILTER=''
fi
echo
echo "MAKE = make"
echo "RM = ${RM}"
echo "CP = ${CP}"
echo "LN = ${LN_S}"
echo "MV = ${MV}"
echo "CAT = ${CAT}"
echo "TOUCH = ${TOUCH}"
echo "AR = ar"
echo "RANLIB = ${RANLIB}"
echo
echo '# Programs used by "make install":'
echo "INSTALL = ${INSTALL}"
echo "INSTALL_PROGRAM = ${INSTALL_PROGRAM}"
echo "INSTALL_DATA = ${INSTALL_DATA}"
echo
echo '# Programs used by "make distrib":'
echo
# Auxiliary routines for linking lisp.a:
if [ $HOS = unix -a $XCC_GCC = true ] ; then
  # We need the full libgcc.a in general. But we don't know its location.
  MAIN_O=''
  LIBGCC='`'"${XCC} -print-libgcc-file-name"'` # something like /usr/somewhere/libgcc.a'
  if [ $TSYS = atari -o $TSYS = sun4 ] && [ -z "$with_dynamic_modules" ] ; then
    # All arithmetic is done inline, only __main must be resolved.
    MAIN_O=" main${TOBJ}"
    LIBGCC=''
  else
    if [ $CROSS = false ] ; then
      if [ "$HSYSOS" = linux ] ; then
        # gcc2 is cc on Linux. Don't need main.o or libgcc.a
        MAIN_O=''
        LIBGCC=''
      fi
    fi
  fi
else
  MAIN_O=''
  LIBGCC=''
fi
if test -n "$LIBGCC"; then
  echo "LIBGCC = ${LIBGCC}"
fi
if [ "$HSYSOS" = linux -o "$HSYSOS" = 386bsd -o "$HSYSOS" = netbsd ] ; then
  ROFF_MAN="groff -Tascii -mandoc"
  ROFF_DVI="groff -Tdvi -mandoc"
else
  ROFF_MAN="nroff -man"
  if [ $HSYS = sun4 -a $CROSS = false ] ; then
    if [ "$UNAME_S" = sunos ] ; then
      case "$UNAME_R" in 4*)
        # SunOS 4
        ROFF_MAN="nroff -a -man" ;;
      esac
    fi
  fi
fi
echo '# formatter for manual page'
echo "ROFF_MAN = ${ROFF_MAN}"' # try "groff -Tascii -mandoc" or "nroff -man"'
echo "ROFF_DVI = ${ROFF_DVI}"' # try "groff -Tdvi -mandoc"'
echo
echo '# -------------- End of configurable section --------------------'
echo
if [ $HOS = unix ] ; then
  # On some systems (IRIX SVR3 and others) the default shell is csh.
  echo "SHELL = /bin/sh"
  echo
fi
echo "COMMENT5 = ${HERE}comment5"

if [ $CC_ANSI = false ] ; then
  if [ $CC_NEED_DEERROR = true ] ; then
    CC_NEED_CCPAUX=true
    if [ $HSYS = sun4 -a "$CC" = cc ] ; then
      # The Sun4 SunOS4.1 cc claims to support #elif. In fact, not in all cases.
      CC_NEED_DEELIF=true
    fi
  fi
fi
if [ $XCC_ANSI = false ] ; then
  if [ $XCC_NEED_DEERROR = true ] ; then
    XCC_NEED_CCPAUX=true
    if [ $TSYS = sun4 -a "$CC" = cc ] ; then
      # The Sun4 SunOS4.1 cc claims to support #elif. In fact, not in all cases.
      XCC_NEED_DEELIF=true
    fi
  fi
fi

if [ $CC_NEED_CCPAUX = true -o $XCC_NEED_CCPAUX = true ] ; then
  NEED_CCPAUX=true
else
  NEED_CCPAUX=false
fi
NEED_ANSIDECL=false
NEED_TRADDECL=false
if [ $XCC_ANSI = true ] ; then
  NEED_ANSIDECL=true
  XDECL_FILTER="| \$(ANSIDECL)"
  XDECL_DEPENDENCIES=" ansidecl${HEXE}"
else
  NEED_TRADDECL=true
  XDECL_FILTER="\$(TRADDECL)"
  XDECL_DEPENDENCIES=" traddecl${HEXE}"
fi
if [ $CC_NEED_DEELIF = true -o $XCC_NEED_DEELIF = true -o $XCC_NEED_MERGESTRINGS = true ] ; then
  if [ $CC_ANSI = true ] ; then
    NEED_ANSIDECL=true
  else
    NEED_TRADDECL=true
  fi
fi

if [ $NEED_ANSIDECL = true ] ; then
  echo "ANSIDECL = ${HERE}ansidecl"
fi
if [ $CC_NEED_CCPAUX = true ] ; then
  CCPAUX='ccpaux'$HEXE
  CCPAUX_FILTER=' | '$HERE'ccpaux'
else
  CCPAUX=''
  CCPAUX_FILTER=''
fi
if [ $XCC_NEED_CCPAUX = true ] ; then
  XCCPAUX='ccpaux'$HEXE
  XCCPAUX_FILTER=' | '$HERE'ccpaux'
else
  XCCPAUX=''
  XCCPAUX_FILTER=''
fi
if [ $CC_NEED_DEELIF = true ] ; then
  DEELIF='deelif'$HEXE
  DEELIF_FILTER=' | '$HERE'deelif'
else
  DEELIF=''
  DEELIF_FILTER=''
fi
if [ $XCC_NEED_DEELIF = true ] ; then
  XDEELIF='deelif'$HEXE
  XDEELIF_FILTER=' | '$HERE'deelif'
else
  XDEELIF=''
  XDEELIF_FILTER=''
fi
if [ $XCC_NEED_DEERROR = true ] ; then
  DEERROR='deerror'$HEXE
  DEERROR_FILTER=' | '$HERE'deerror'
else
  DEERROR=''
  DEERROR_FILTER=''
fi
if [ $XCC_NEED_DEDEFINED = true ] ; then
  DEDEFINED='dedefined'$HEXE
  DEDEFINED_FILTER=' | '$HERE'dedefined'
else
  DEDEFINED=''
  DEDEFINED_FILTER=''
fi
if [ $NEED_TRADDECL = true ] ; then
  TRADDECL_FILTER=' | '$HERE'traddecl'
  if [ $XCC_ANSI = false ] ; then
    echo "TRADDECL = ${XCCPAUX_FILTER}${XDEELIF_FILTER}${DEERROR_FILTER}${DEDEFINED_FILTER}${TRADDECL_FILTER}"
    XDECL_DEPENDENCIES=" ${XCCPAUX} ${XDEELIF} ${DEERROR} ${DEDEFINED} ${XDECL_DEPENDENCIES}"
  fi
fi
if [ $XCC_NEED_DEEMA = true ] ; then
  if [ $HOS = unix ] ; then
    echo "DEEMA = sed -e 's/,)/,_EMA_)/g'"
  else
    echo "DEEMA = deema"
    XDECL_DEPENDENCIES="${XDECL_DEPENDENCIES} deema${HEXE}"
  fi
  XDECL_FILTER="${XDECL_FILTER} | \$(DEEMA)"
fi
if [ $XCC_NEED_MERGESTRINGS = true ] ; then
  echo "MERGESTRINGS = ${HERE}mergestrings"
fi

echo "TXT2C = ${HERE}txt2c"
if [ $CROSS = true ] ; then
  TXT2CFLAGS="${TXT2CFLAGS} -DCROSS"
  TXT_INCLUDES=' lispbibl.h'
else
  TXT2CFLAGS="${TXT2CFLAGS}"
  TXT_INCLUDES=$EVERY_INCLUDES_C
fi

if [ $HSYS = sun4 ] ; then
  echo "TEMPDIR = /usr1/tmp"
fi

echo

echolist "DFILES =" "$DFILES $ARI_ASMD $SP_ASMD" ".d"
echo

echolist "CFILES =" "$DFILES $ARI_ASMD $ARI_ASMC $SP_ASMD" ".c"
echo

echolist "OBJECTS =" "$MODULES $ARI_ASMS $SP_ASMS $GMALLOC" "${TOBJ}"
echo

echolist "LSPFILES =" "$CODE" ".lsp"
echo

echolist "FASFILES =" "$CODE" ".fas"
echo

echolist "TXTFILES =" "$DOC" ".txt"
echo

echolist "TESTLSPFILES =" "$CODE" ".lsp" "${TESTDIR}${NEXT_}"
echo

echolist "TESTFASFILES =" "$CODE" ".fas" "${TESTDIR}${NEXT_}"
echo

echo

echo "all : init allc allo lisp${LEXE} interpreted.mem halfcompiled.mem compiled.mem manual"
echodummyrule all
echo

echo

UTILDIR="${PARENT}utils${NEXT}"
DOCDIR="${PARENT}doc${NEXT}"
if [ $HOS = dos -o $HOS = os2 -o $HOS = atari ] ; then
  # Replace '/' by '\':
  UTILDIR_=`echo $UTILDIR | sed -e 's,/,\\\\,g'`
  DOCDIR_=`echo $DOCDIR | sed -e 's,/,\\\\,g'`
else
  UTILDIR_=$UTILDIR
  DOCDIR_=$DOCDIR
fi
if [ $CROSS = false ] && [ $HSYS = doswatcom -o $HSYS = windowswatcom ] ; then
  NEXT_CC="$NEXT_"
  UTILDIR_CC="$UTILDIR_"
else
  NEXT_CC="$NEXT"
  UTILDIR_CC="$UTILDIR"
fi

UTILS=''
if [ $NEED_CCPAUX = true ] ; then
  UTILS=$UTILS' ccpaux'
fi
UTILS=$UTILS' comment5'
if [ $CC_NEED_DEELIF = true -o $XCC_NEED_DEELIF = true ] ; then
  UTILS=$UTILS' deelif'
fi
if [ $XCC_NEED_DEERROR = true ] ; then
  UTILS=$UTILS' deerror'
fi
if [ $XCC_NEED_DEDEFINED = true ] ; then
  UTILS=$UTILS' dedefined'
fi
if [ $XCC_ANSI = true ] ; then
  UTILS=$UTILS' ansidecl'
fi
if [ $XCC_ANSI = false ] ; then
  UTILS=$UTILS' traddecl'
fi
if [ $XCC_NEED_DEEMA = true -a $HOS != unix ] ; then
  UTILS=$UTILS' deema'
fi
if [ $XCC_NEED_MERGESTRINGS = true ] ; then
  UTILS=$UTILS' mergestrings'
fi
UTILS=$UTILS' txt2c'
if [ "$CHSCONVERT" = "./cv_lt_at" ] ; then
  UTILS=$UTILS' cv_lt_at'
fi
if [ "$CHSCONVERT" = "./cv_lt_pc" ] ; then
  UTILS=$UTILS' cv_lt_pc'
fi

line="init :"
if [ $TOS = unix ] ; then
  line=$line" machine.h"
fi
if [ $XCC_UNUSABLE_CPP = true ] ; then
  line=$line" ../utils/gcc-cccp/cccp"
fi
if [ $CROSS = true ] ; then
  line=$line" unixconf.h"
fi
for util in $UTILS ; do
  line=$line" ${util}${HEXE}"
done
line=$line" \$(DFILES) modules.h"
if [ $TSYS = sun4 -a "$CC" = cc ] ; then
  line=$line" cc_sparc.il"
fi
echo $line
echodummyrule init
echo
if [ $TOS = unix ] ; then
  echo "machine.h : ${SRCDIR}machine.c"
  echotab_to_HEXE "\$(CC) \$(CFLAGS) ${SRCDIR}machine.c" "machine"
  echotab "${HERE}machine${HEXE} > machine.h"
  echotab "\$(RM) machine${HEXE}"
  echo
fi
if [ $XCC_UNUSABLE_CPP = true ] ; then
  echo "../utils/gcc-cccp/cccp :"
  echotab "cd ../utils/gcc-cccp ; \$(MAKE)"
  echo
fi
if [ $CROSS = true ] ; then
  echo "unixconf.h :"
  echotab "if [ ! -f unixconf.h ] ; then \$(TOUCH) unixconf.h ; fi"
  echo
fi
for util in $UTILS ; do
  if [ $util = ccpaux -o $util = deerror -o $util = deema ] ; then
    echo "${util}${HEXE} : ${UTILDIR_}${util}.c"
    echotab_to_HEXE "\$(CC) \$(CFLAGS) ${UTILDIR_CC}${util}.c" "${util}"
    echo
  fi
  if [ $util = dedefined ] ; then
    echo "${util}${HEXE} : ${UTILDIR_}${util}.c"
    echotab "\$(LN) ${UTILDIR_}${util}.c ${util}.c"
    echotab_to_HEXE "\$(CC) \$(CFLAGS) ${util}.c" "${util}"
    echotab "\$(RM) ${util}.c"
    echo
  fi
  if [ $util = cv_lt_at ] ; then
    # Only used when $CROSS = true
    echo "${util}${HEXE} : ../atari/${util}.c"
    echotab_to_HEXE "\$(CC) \$(CFLAGS) ../atari/${util}.c" "${util}"
    echo
  fi
  if [ $util = cv_lt_pc ] ; then
    # Only used when $CROSS = true
    echo "${util}${HEXE} : ../dos/${util}.c"
    echotab_to_HEXE "\$(CC) \$(CFLAGS) ../dos/${util}.c" "${util}"
    echo
  fi
  if [ $util = txt2c ] ; then
    echo "${util}${HEXE} : ${UTILDIR_}${util}.c"
    echotab_to_HEXE "\$(CC) \$(CFLAGS)${TXT2CFLAGS} ${UTILDIR_CC}${util}.c" "${util}"
    echo
  fi
  if [ $util = comment5 ] ; then
    if [ $CC_NEED_CCPAUX = true ] ; then
      echo "${util}${HEXE} : ${UTILDIR_}${util}.c ${CCPAUX}"
      echotab "${HERE}ccpaux${HEXE} < ${UTILDIR_}${util}.c > ${util}.c"
      echotab_to_HEXE "\$(CC) \$(CFLAGS) ${util}.c" "${util}"
      echotab "\$(RM) ${util}.c"
      echo
      OBSOLETE=$OBSOLETE" ${util}.c"
    else
      echo "${util}${HEXE} : ${UTILDIR_}${util}.c"
      echotab_to_HEXE "\$(CC) \$(CFLAGS) ${UTILDIR_CC}${util}.c" "${util}"
      echo
    fi
  fi
  if [ $util = ansidecl -o $util = traddecl ] ; then
    if [ $util = traddecl ] ; then
      flags="${TRADDECLFLAGS}"
    fi
    if [ $util = ansidecl ] ; then
      flags="${ANSIDECLFLAGS}"
    fi
    echo "${util}${HEXE} : ${UTILDIR_}${util}.d comment5${HEXE}"
    echotab "\$(LN) ${UTILDIR_}${util}.d ${util}.d"
    echotab "\$(COMMENT5) ${util}.d ${util}.c"
    echotab "\$(RM) ${util}.d"
    echotab_to_HEXE "\$(CC) \$(CFLAGS)${flags} ${util}.c" "${util}"
    echotab "\$(RM) ${util}.c"
    echo
    OBSOLETE=$OBSOLETE" ${util}.c"
  fi
  if [ $util = deelif -o $util = mergestrings ] ; then
    if [ $CC_ANSI = true ] ; then
      echo "${util}${HEXE} : ${UTILDIR_}${util}.d comment5${HEXE} ansidecl${HEXE}"
      echotab "\$(COMMENT5) ${UTILDIR_}${util}.d | \$(ANSIDECL) > ${util}.c"
      echotab_to_HEXE "\$(CC) \$(CFLAGS) ${util}.c" "${util}"
      echotab "\$(RM) ${util}.c"
      echo
    else
      echo "${util}${HEXE} : ${UTILDIR_}${util}.d comment5${HEXE} ${CCPAUX} traddecl${HEXE}"
      echotab "\$(COMMENT5) ${UTILDIR_}${util}.d${CCPAUX_FILTER}${TRADDECL_FILTER} > ${util}.c"
      echotab_to_HEXE "\$(CC) \$(CFLAGS) ${util}.c" "${util}"
      echotab "\$(RM) ${util}.c"
      echo
    fi
    OBSOLETE=$OBSOLETE" ${util}.c"
  fi
done

echo

if [ $LISPARIT = lisparit0 ] ; then
  line="${SRCDIR}${LISPARIT}.d :"
  for f in lisparit $LISPARIT_SUBFILES ; do
    line=$line" ${SRCDIR}${f}.d"
  done
  echo $line
  echotab "\$(RM) ${SRCDIR}${LISPARIT}.d ${SRCDIR}${LISPARIT}.tmp"
  # echotab "head -19 ${SRCDIR}lisparit.d > ${SRCDIR}${LISPARIT}.tmp" # not portable!
  echotab "sed 19q ${SRCDIR}lisparit.d > ${SRCDIR}${LISPARIT}.tmp"
  for f in $LISPARIT_SUBFILES ; do
    echotab "\$(CAT) ${SRCDIR}${f}.d >> ${SRCDIR}${LISPARIT}.tmp"
  done
  # echotab "tail +53 ${SRCDIR}lisparit.d >> ${SRCDIR}${LISPARIT}.tmp" # maybe not portable
  echotab "sed 1,52d ${SRCDIR}lisparit.d >> ${SRCDIR}${LISPARIT}.tmp"
  echotab "\$(MV) ${SRCDIR}${LISPARIT}.tmp ${SRCDIR}${LISPARIT}.d"
  echo
  OBSOLETE=$OBSOLETE" ${SRCDIR}${LISPARIT}.tmp"
fi

if [ $HOS = unix ] ; then
  echo "${SRCDIR}version.h : ${SRCDIR}VERSION"
  echotab "sed -e 's/^/#define VERSION \"/' -e 's/\$\$/\"/' ${SRCDIR}VERSION > ${SRCDIR}version.h"
  echo
fi

if [ -n "${SRCDIR}" ] ; then
  if [ $HOS = unix ] ; then
    for f in $DFILES $ARI_ASMD $SP_ASMD ; do
      echo "${f}.d : ${SRCDIR}${f}.d"
      echotab "-\$(LN) ${SRCDIR}${f}.d ${f}.d"
      echo
    done
    for f in version.h modules.h module.cc ; do
      echo "${f} : ${SRCDIR}${f}"
      echotab "-\$(LN) ${SRCDIR}${f} ${f}"
      echo
    done
    if [ $TSYS = sun4 -a "$CC" = cc ] ; then
      echo "cc_sparc.il : ${SRCDIR}cc_sparc.il"
      echotab "-\$(LN) ${SRCDIR}cc_sparc.il cc_sparc.il"
      echo
    fi
    echo
  fi
fi

echo "allc : init \$(CFILES)"
echodummyrule allc
echo

for f in $DFILES ; do
  echo "${f}.c : ${f}.d comment5${HEXE}${XDECL_DEPENDENCIES}"
  echotabpipe "\$(COMMENT5) ${f}.d${CHSCONVERT_FILTER} ${XDECL_FILTER} > ${f}.c"
  echo
done

for f in $ARI_ASMD $SP_ASMD ; do
  echo "${f}.c : ${f}.d comment5${HEXE} ${XCCPAUX} ${XDEELIF}"
  echotabpipe "\$(COMMENT5) ${f}.d${XCCPAUX_FILTER}${XDEELIF_FILTER} > ${f}.c"
  echo
done

for f in $ARI_ASMS $SP_ASMS ; do
  case $f in
    *68*) g="${f}.mit"
          if [ $TSYS = atari -a "${f}" = ari68000 ] ; then
            echo "# Change \"${f}.mit\" to \"${f}.atari\" when using \"gcc-atari -mshort\""
          fi
          echo "${f}.c : ${g}.c"
          echotab "\$(LN) ${g}.c ${f}.c"
          echo
          ;;
  esac
done

if [ $AS_UNDERSCORE = true ] ; then
  ASMFLAGS=' -DUNDERSCORE'
else
  ASMFLAGS=''
fi
if [ $XCC_ANSI = true -a $XCC_GCC = false ] ; then
  # Remove the line number information etc. and convert "% ecx" back to "%ecx":
  ASM_FILTER=" | grep -v '^#' | sed 's,% ,%,g'"
else
  if [ $AS_UNDERSCORE = false ] ; then
    # These are the less modern assemblers or SYSV assemblers.
    # Remove the line number information etc.
    if [ "$HSYSOS" = coherent ] ; then
      # Coherent386 make needs a backslash before '#', even within quotes!
      ASM_FILTER=" | grep -v '^\\#'"
    else
      ASM_FILTER=" | grep -v '^#'"
    fi
  else
    ASM_FILTER=''
  fi
fi
for f in $ARI_ASMS $SP_ASMS ; do
  # The preprocessor barfs on arihppa: "unterminated character constant".
  # We ignore this:
  case $f in
    *hppa) g='-' ;;
    *)     g='' ;;
  esac
  # In ari68020.mit.d the dollars must be replaced:
  case $f in
    ari68020*)
      if [ $AS_UNDERSCORE = false ] ; then
        h=' | sed -e '"'"'s/\$$/%/g'"'"
      else
        h=' | sed -e '"'"'s/\$$//g'"'"
      fi
      ;;
    *) h='' ;;
  esac
  echo "${f}.s : ${f}.c"
  echotab "${g}${XCPP}${ASMFLAGS} ${f}.c${h}${ASM_FILTER} > ${f}.s"
  echo
done

line="allo : allc"
for f in $MODULES ; do
  line=$line" ${f}${TOBJ}"
done
echo $line
echodummyrule allo
echo

line="alls : allc"
for f in $MODULES ; do
  line=$line" ${f}.s"
done
echo $line
echodummyrule alls
echo

for f in $MODULES genclisph modules $EXTRA_MODULES ; do
  depends=$EVERY_INCLUDES
  if [ $f = spvw -o $f = package ] ; then
    depends=$depends' constpack'
  fi
  if [ $f = spvw ] ; then
    depends=$depends' avl sort'
  fi
  if [ $f = array -o $f = hashtabl -o $f = io -o $f = misc -o $f = package -o $f = spvw -o $f = stream -o $f = graph ] ; then
    depends=$depends' arilev0'
  fi
  if [ $f = spvw -o $f = hashtabl ] ; then
    depends=$depends' aridecl'
  fi
  if [ $f = $LISPARIT ] ; then
    depends=$depends''$LISPARIT_INCLUDES''$ARI_ASMS
  fi
  if [ $f = rexx ] ; then
    depends=$depends' amiga2'
  fi
  if [ $f = windows ] ; then
    depends=$depends' wintext winstat winmain winaux'
  fi
  dependsc=''
  for g in $depends ; do
    dependsc=$dependsc' '$g'.c'
  done
  if [ $f = spvw ] ; then
    dependsc=$dependsc' version.h'
  fi
  flags=$XCFLAGS
  if [ $f = stream -o $f = noreadline ] ; then
    if [ $TERMINAL = readline ] ; then
      flags=$flags" ${INCLUDEDIR}${SRCDIR}${READLINEDIR}"
    fi
  fi
  if [ $f = stdwin ] ; then
    flags=$flags" ${INCLUDEDIR}stdwin${NEXT_CC}H"
  fi
  if [ $f = graph ] ; then
    flags=$flags' '$X_INCLUDES
  fi
  if [ $f = modules ] ; then
    if [ $HOS = unix -a $CROSS = false ] ; then
      dependsc=$dependsc' clisp.h'
    else
      flags=$flags' -DNO_CLISP_H'
    fi
    dependsc=$dependsc' modules.h'
  fi
  if [ $TSYS = sun4 -a "$CC" = cc ] ; then
    flags2=$flags' cc_sparc.il'
    dependsc2=' cc_sparc.il'
  else
    if [ "$TSYSOS" = coherent -a $f = $LISPARIT -a $XCC_GCC = false ] ; then
      flags2=$flags' -T0' # avoid "Out of memory" message
      dependsc2=''
    else
      flags2=$flags
      dependsc2=''
    fi
  fi
  if [ $f = genclisph -a $XCC_GCC = true ] ; then
    flags2=$flags2' -O0' # no need to optimize this
  fi
  if [ $XCC_NEED_MERGESTRINGS = true ] ; then
    echo "${f}.i : ${f}.c${dependsc}"
    echotab "(echo \"# 1 \\\"${f}.i\\\"\" ; ${XCPP} ${flags} ${f}.c | \$(MERGESTRINGS)) > ${f}.i"
    echo
    # if [ $TSYS = sun4 -a "$CC" = cc ] ; then
    # # Die .s-Files nach dem Optimieren nochmal durch inline jagen
    # echo "${f}.s : ${f}.i${dependsc2} il_sparc.il"
    # echotab "${XCC} ${flags2} -S ${f}.i"
    # echotab "\$(MV) ${f}.s ${f}.tmp"
    # echotab "\$(INLINE) -i il_sparc.il < ${f}.tmp > ${f}.s"
    # echotab "\$(RM) ${f}.tmp"
    # echo
    # echo "${f}${TOBJ} : ${f}.s"
    # echotab "${XCC} -c ${f}.s"
    # echo
    # OBSOLETE=$OBSOLETE" ${f}.tmp"
    # else
    echo "${f}.s : ${f}.i${dependsc2}"
    echotab "${XCC} ${flags2} -S ${f}.i"
    echo
    echo "${f}${TOBJ} : ${f}.i${dependsc2}"
    echotab "${XCC} ${flags2} -c ${f}.i"
    echo
    # fi
  else
    echo "${f}.i : ${f}.c${dependsc}"
    echotab "${XCPP} ${flags} ${f}.c > ${f}.i"
    echo
    if [ $XCC_UNUSABLE_CPP = true ] ; then
      echo "${f}.s : ${f}.c${dependsc}${dependsc2}"
      echotab "${XCPP} ${flags} ${f}.c > ${f}.i.c"
      echotab "${XCC} ${flags2} -S ${f}.i.c"
      echotab "\$(MV) ${f}.i.s ${f}.s"
      echotab "\$(RM) ${f}.i.c"
      echo
      echo "${f}${TOBJ} : ${f}.c${dependsc}${dependsc2}"
      echotab "${XCPP} ${flags} ${f}.c > ${f}.i.c"
      echotab "${XCC} ${flags2} -c ${f}.i.c"
      echotab "\$(MV) ${f}.i${TOBJ} ${f}${TOBJ}"
      echotab "\$(RM) ${f}.i.c"
      echo
    else
      if [ $HSYS = doswatcom -o $HSYS = windowswatcom ] ; then
        echo "${f}.s : ${f}${TOBJ}"
        echotab "\$(DISASM) ${f}${TOBJ} -l=${f}.s"
        echo
      else
        echo "${f}.s : ${f}.c${dependsc}${dependsc2}"
        echotab "${XCC} ${flags2} -S ${f}.c"
        echo
      fi
      echo "${f}${TOBJ} : ${f}.c${dependsc}${dependsc2}"
      echotab "${XCC} ${flags2} -c ${f}.c"
      echo
    fi
  fi
done

if [ -n "$with_dynamic_modules" ] ; then
  modules=''
  if [ -n "$with_module_stdwin" ] ; then
    modules=$modules' stdwin'
  fi
  for n in $modules ; do
    depends=$EVERY_INCLUDES
    dependsc=''
    for g in $depends ; do
      dependsc=$dependsc' '$g'.c'
    done
    flags=$XCFLAGS
    if [ $HOS = unix -a $CROSS = false ] ; then
      dependsc=' clisp.h'
    else
      flags=$flags' -DNO_CLISP_H'
    fi
    f=$n'_module'
    echo "${f}.cc : module.cc"
    echotab "-\$(LN) module.cc ${f}.cc"
    echo
    echo "${f}.s : ${f}.cc${dependsc}"
    echotab "${XCC} ${flags} -DMODULE=${n} -S ${f}.cc"
    echo
    echo "${f}${TOBJ} : ${f}.cc${dependsc}"
    echotab "${XCC} ${flags} -DMODULE=${n} -c ${f}.cc"
    echo
  done
fi

if test -n "$GMALLOC"; then
  for f in $GMALLOC ; do
    echo "${f}${TOBJ} : ${SRCDIR}malloc${NEXT_}${f}.c"
    echotab "${XCC} ${XCFLAGS} -c ${SRCDIR}malloc${NEXT_}${f}.c -o ${f}${TOBJ}"
    echo
  done
fi

for f in $ARI_ASMS $SP_ASMS ; do
  echo "${f}${TOBJ} : ${f}.s"
  # Call the assembler, preferrably through the C compiler:
  if [ "$TSYSOS" = coherent -a $XCC_GCC = false ] ; then
    echotab "as -g ${f}.s"
  else
    if [ $f = arihppa ] ; then
      # Only the native as groks the .SHORTDATA statements in arihppa.d
      echotab "${XCC} ${XCFLAGS} -c ${f}.s || /bin/as ${f}.s -o ${f}${TOBJ}"
    else
      echotab "${XCC} ${XCFLAGS} -c ${f}.s"
    fi
  fi
  echo
done

if [ $HOS = unix ] ; then
  echo "lisp.o : \$(OBJECTS)"
  echotab "ld -r -o lisp.o \$(OBJECTS)"
  echotab "chmod a-x lisp.o"
  echo
  echo "lisp.a : lisp.o modules.o${MAIN_O}"
  if test -z "$LIBGCC"; then
    echotab "\$(AR) rcv lisp.a lisp.o modules.o${MAIN_O}"
  else
    echotab "mkdir libgcc"
    echotab "cd libgcc ; \$(AR) xv \$(LIBGCC)"
    echotab "\$(AR) rcv lisp.a lisp.o modules.o libgcc/*.o"
    echotab "\$(RM) -rf libgcc"
  fi
  echotab "\$(RANLIB) lisp.a"
  echo
  echo "libnoreadline.a : noreadline.o"
  echotab "\$(AR) rcv libnoreadline.a noreadline.o"
  echotab "\$(RANLIB) libnoreadline.a"
  echo
fi

if [ -n "$with_stdwin" -o -n "$with_module_stdwin" ] ; then
  if [ $HOS = unix ] ; then
    echo "stdwin/libstdwin.a :"
    echotab "(cd stdwin ; \$(MAKE) libstdwin.a)"
    echo
  fi
fi

if [ $TERMINAL = readline -a $HOS = unix ] ; then

  echo "readline_ : libreadline.a readline.tar.Z readline.tar.gz"
  echodummyrule readline_
  echo
  echo "${READLINELIB} :"
  echotab "(cd ${READLINEDIR} ; \$(MAKE) -r CC='${XCC}' CFLAGS='${XCFLAGS} -DCLISP' RANLIB='\$(RANLIB)')"
  echo
  echo "libreadline.a : ${READLINELIB}"
  echotab "-\$(LN) ${READLINELIB} libreadline.a"
  echo
  echo "readline.tar.Z :"
  echotab "(cd ${SRCDIR} ; tar -cvf - readline | compress -c) > readline.tar.Z"
  echo
  echo "readline.tar.gz :"
  echotab "(cd ${SRCDIR} ; tar -cvf - readline | gzip -c) > readline.tar.gz"
  echo

  echo

fi

if [ $TSYS = windows -o $TSYS = windowswatcom ] ; then
  RESOURCE='lisp.res'
  echo "lisp.res : clispwin.rc clispwin.ico clispwin.cur"
  echotab "\$(RC) -r clispwin.rc -fo=lisp.res"
  echo
else
  RESOURCE=''
fi

echo "lisp${LEXE} : \$(OBJECTS) modules${TOBJ} ${XCL_STDWINLIB} ${XCL_READLINELIB} ${RESOURCE}"
if [ $HOS != dos -a $HOS != os2 ] ; then
  if [ $XCC_GCC = true -a -n "$SOLARIS_LINKING" ] ; then
    # Dynamically linking on Solaris 2.[23] is a pain.
    LIBGCC_DIR='`'"${XCC} -print-libgcc-file-name"' | sed -e '"'"'s,[^/]*$$,,'"'"'`'
    echotab "${XCC} ${XCFLAGS} ${XCLFLAGS} \$(OBJECTS) modules${TOBJ} ${LIBS} ${X_LIBS} -o lisp${LEXE} || /usr/ccs/bin/ld -V -dy -Bdynamic -Y P,/usr/ccs/lib:/usr/lib -Qy -o lisp${LEXE} ${LIBGCC_DIR}crt1.o ${LIBGCC_DIR}crti.o /usr/ccs/lib/values-Xa.o ${LIBGCC_DIR}crtbegin.o \$(OBJECTS) modules.o -L${LIBGCC_DIR} -L/usr/ccs/bin ${LIBS} ${X_LIBS} -lgcc -lc ${LIBGCC_DIR}crtend.o ${LIBGCC_DIR}crtn.o -lgcc"
  else
    echotab "${XCC} ${XCFLAGS} ${XCLFLAGS} \$(OBJECTS) modules${TOBJ} ${LIBS} ${X_LIBS} -o lisp${LEXE}"
  fi
  if [ $HOS = unix ] ; then
    echotab "-sync"
  fi
  echo
else
  # DOS has a very limited command line length
  if [ $HSYS = doswatcom -o $HSYS = windowswatcom ] ; then
    echotab "\$(RM) lisp${LEXE}"
    if [ $HSYS = doswatcom ] ; then
      echotab "${XCC} ${XCFLAGS} -fe=lisp${LEXE} -fd=wcclink.lnk" # generate linker commands
      echotab "wlink @wcclink.lnk @wcclink.in" # execute linker commands
    fi
    if [ $HSYS = windowswatcom ] ; then
      echotab "${XCC} ${XCFLAGS} -l=win386 -fe=lisp -fd=wcclink.lnk" # generate linker commands
      echotab "wlink @wcclink.lnk @wcclink.in" # execute linker commands, generate lisp.rex
      echotab "wbind lisp${LEXE} -R lisp.res" # generate lisp.exe from lisp.rex and lisp.res
      echotab "\$(RM) lisp.rex"
    fi
    echotab "\$(RM) wcclink.lnk"
  else
    # XCLFLAGS=$XCLFLAGS' -s' # strip, geht unter emx0.8f nicht mehr
    if [ $TSYS = windows ] ; then
      LAOUT='.w32'
    else
      LAOUT=''
    fi
    echotab "\$(RM) lisp${LAOUT}"
    echotab "\$(RM) lisp${LEXE}"
    if true; then
      echotab "${XCC} ${XCFLAGS} -o lisp${LAOUT} @gcclink.in ${XCLFLAGS} ${LIBS}"
    else
      echotab "\$(LD) -o lisp1.o -r spvw.o spvwtabf.o spvwtabs.o spvwtabo.o"
      echotab "\$(LD) -o lisp2.o -r eval.o control.o pathname.o stream.o io.o"
      echotab "\$(LD) -o lisp3.o -r array.o hashtabl.o list.o package.o record.o sequence.o"
      echotab "\$(LD) -o lisp4.o -r charstrg.o debug.o error.o misc.o predtype.o symbol.o"
      echotab "\$(LD) -o lisp5.o -r lisparit.o graph.o ari80386.o"
      echotab "${XCC} ${XCFLAGS} -o lisp lisp1.o lisp2.o lisp3.o lisp4.o lisp5.o ${XCLFLAGS} ${LIBS}"
      echotab "\$(RM) lisp?.o"
    fi
    if [ $TSYS = windows ] ; then
      # Strippen, da wir sowieso nicht debuggen können.
      echotab "strip lisp${LAOUT}"
      # lisp.exe enthält den Extender und die Ressource und startet lisp.w32.
      echotab "copy /b \$(RSXW32) lisp${LEXE}"
      echotab "\$(RC) -t lisp.res lisp${LEXE}"
    else
      if [ $HSYS = dosdjgpp ] ; then
        echotab "strip lisp"
        echotab "\$(COFF2EXE) lisp lisp${HEXE}"
      else
        if [ $TSYS = dos ] ; then
          echotab "strip lisp"
          # emx-Option -p hält das untere Megabyte frei, damit EXECUTE geht.
          #   Bei lisp_1mb.exe nutzen wir dagegen soviel RAM wie möglich.
          # emx-Option -C0 bewirkt, daß malloc() bei fehlendem Speicher und
          #   Plattenplatz NULL liefert, statt es später auf einen Programm-Ausstieg
          #   wegen "Out of swap space" ankommen zu lassen.
          # emx-Option -aim bewirkt, daß der Zugriff auf die Grafikkarte und
          #   den Bildschirmspeicher funktioniert.
          echotab "emxbind -q c:\emx\bin\emx.exe lisp lisp${LEXE} -p -C0 -aim"
          echotab "emxbind -q c:\emx\bin\emx.exe lisp lisp_1mb${LEXE} -C0 -aim"
        else
          # emx-Option -acmi bewirkt, daß unter DOS der Zugriff auf den Bildschirm-
          #   speicher und die Grafikkarten-Ports funktioniert.
          echotab "emxbind -q c:\emx\bin\emx.exe lisp lisp${LEXE} -p -acmi"
          # Strippen darf man wegen -lvideo erst hinterher.
          echotab "emxbind -s lisp${LEXE}"
        fi
      fi
    fi
  fi
  echo
fi

echo

echo "alllsp : \$(LSPFILES)"
echodummyrule alllsp
echo

if [ $TOS = atari ] ; then
  CONFIG=cfgathd
fi
if [ $TOS = amiga ] ; then
  CONFIG=cfgamiga
fi
if [ $TOS = acorn ] ; then
  CONFOG=cfgacorn
fi
if [ $TOS = dos -o $TOS = os2 ] ; then
  CONFIG=cfgdos
fi
if [ $TOS = unix -a $CROSS = false ] ; then
  if [ "$HSYSOS" = sunos ] ; then
    CONFIG=cfgsunux
  fi
  # cfglinux is obsolete now.
  # if [ "$HSYSOS" = linux ] ; then
  #   CONFIG=cfglinux
  # fi
  if test -z "$CONFIG"; then
    CONFIG=cfgunix
  fi
fi
for f in $CODE ; do
  if [ $f = config ] ; then
    echo "${f}.lsp : ${SRCDIR}${CONFIG}.lsp"
    echotab "\$(CP) ${SRCDIR}${CONFIG}.lsp ${f}.lsp"
    echo
  else
    if [ -n "${SRCDIR}" ] ; then
      echo "${f}.lsp : ${SRCDIR}${f}.lsp"
      echotab "-\$(LN) ${SRCDIR}${f}.lsp ${f}.lsp"
      echo
    fi
  fi
done

if [ $CROSS = false ] ; then

  echo "interpreted.mem : lisp${LEXE} \$(LSPFILES)"
  if [ $HOS != dos -a $HOS != os2 ] ; then
    echotab "${HERE}lisp${LEXE} -m 750KW"' -x "(load \"init.lsp\") (sys::%saveinitmem) (exit)"'
  else
    echotab "${HERE}lisp${LEXE} -m 750KW < interpreted.in"
    echotab "-\$(RM) interpreted.mem"
  fi
  echotab "\$(MV) lispinit.mem interpreted.mem"
  echo

fi

if [ $CROSS = false ] ; then

  for f in $CODE ; do
    echo "${f}.fas : ${f}.lsp lisp${LEXE} interpreted.mem"
    echotab "${HERE}lisp${LEXE} -m 750KW -M interpreted.mem -q -c ${f}.lsp"
    echo
  done

else

  for f in $CODE ; do
    echo "${f}.fas : ${f}.lsp"
    echotab 'clisp -M cross.mem -q -x "(cross:compile-file \"'"${f}.lsp"'\")"'
    echo
  done

fi

if [ $CROSS = false ] ; then

  echo "halfcompiled.mem : lisp${LEXE} \$(LSPFILES) compiler.fas"
  if [ $HOS != unix ] ; then
    echotab "-\$(RM) interpreted.mem"
  fi
  if [ $HOS != dos -a $HOS != os2 ] ; then
    echotab "${HERE}lisp${LEXE} -m 750KW"' -x "(load \"init.lsp\") (sys::%saveinitmem) (exit)"'
  else
    echotab "${HERE}lisp${LEXE} -m 750KW < interpreted.in"
  fi
  echotab "\$(MV) lispinit.mem interpreted.mem"
  echotab "\$(TOUCH) compiler.fas"
  if [ $HOS != acorn ] ; then
    echotab "\$(TOUCH) halfcompiled.mem"
  else
    echotab "echo > halfcompiled.mem"
  fi
  echo

  echo "compiled.mem : lisp${LEXE} \$(FASFILES)"
  if [ $HOS != dos -a $HOS != os2 ] ; then
    echotab "${HERE}lisp${LEXE}"' -x "(load \"init.fas\") (sys::%saveinitmem) (exit)"'
  else
    echotab "${HERE}lisp${LEXE} < compiled.in"
    echotab "-\$(RM) compiled.mem"
  fi
  echotab "\$(MV) lispinit.mem compiled.mem"
  echo

fi

echo

if [ $CROSS = false ] ; then

  echo "# Perform self-tests."
  if [ $HOS = unix ] ; then
    echo "check : test testsuite"
  else
    echo "check : test"
  fi
  echodummyrule check
  echo

  echo "# Test: recompile \$(LSPFILES) and check if the resulting .mem file has the same length."
  echo "test : compiled.mem ${TESTDIR} \$(TESTLSPFILES) \$(TESTFASFILES)"
  if [ $HOS = unix ] ; then
    for f in $CODE ; do
      echotab "cmp -s ${f}.fas ${TESTDIR}/${f}.fas"' || (echo "Test failed." ; exit 1)'
    done
    echotab 'echo "Test passed."'
    echo
  else
    if [ $HOS = dos -o $HOS = os2 ] ; then
      echotab "comp *.fas ${TESTDIR}"
      echotab "REM The test passed if no differences were found."
      echo
    else
      echotab 'echo "Compare the .fas files by hand."'
      echo
    fi
  fi

  echo "${TESTDIR} :"
  echotab "-mkdir ${TESTDIR}"
  echo

  for f in $CODE ; do
    echo "${TESTDIR}${NEXT_}${f}.lsp : ${f}.lsp"
    if [ $HOS = unix ] ; then
      echotab "cd ${TESTDIR} ; \$(LN) ${PARENT_}${f}.lsp ${f}.lsp"
    else
      echotab "\$(LN) ${f}.lsp ${TESTDIR}"
    fi
    echo
  done

  for f in $CODE ; do
    echo "${TESTDIR}${NEXT_}${f}.fas : ${TESTDIR}${NEXT_}${f}.lsp lisp${LEXE} compiled.mem"
    echotab "${HERE}lisp${LEXE} -M compiled.mem -q -c ${TESTDIR}${NEXT}${f}.lsp"
    echo
  done

  echo "compiled2.mem : lisp${LEXE} \$(TESTFASFILES)"
  echotab "${HERE}lisp${LEXE}"' -x "(cd \"'"${TESTDIR}${NEXT}"'\") (load \"init.fas\") (cd \"'"${PARENT_2}"'\") (sys::%saveinitmem) (exit)"'
  echotab "-\$(RM) compiled2.mem"
  echotab "\$(MV) lispinit.mem compiled2.mem"
  echo

  echo

  if [ $HOS = unix ] ; then
    echo "testsuite : ${TESTSDIR} lisp${LEXE} compiled.mem"
    echotab "LISP=\""'`pwd`'"/lisp${LEXE} -M "'`pwd`'"/compiled.mem\"; export LISP; cd ${TESTSDIR}; \$(MAKE) LISP=\"\$\$LISP\""
    echo
    echo "${TESTSDIR} :"
    echotab "-mkdir ${TESTSDIR}"
    echotab "cd ${TESTSDIR} ; \$(LN) ${PARENT_}${PARENT_}tests/Makefile ."
    echotab "cd ${TESTSDIR} ; \$(LN) ${PARENT_}${PARENT_}tests/*.lsp ."
    echotab "cd ${TESTSDIR} ; \$(LN) ${PARENT_}${PARENT_}tests/*.tst ."
    echo
    echo
  fi

fi

if [ $HOS = unix -a $XCC_GCC = true ] ; then
  echo "lispbibl.h :${EVERY_INCLUDES_C}"
  echotab "((${XCPP} ${XCFLAGS} -P lispbibl.c | grep -v \"^ *\$\$\") ; (${XCPP} ${XCFLAGS} -P -dM lispbibl.c | sort) ) > lispbibl.h"
  echo
  echo
fi

if [ $HOS = unix -a $CROSS = false ] ; then
  echo "clisp.h : genclisph.o unixconf.h machine.h"
  echotab_to_HEXE "\$(CC) \$(CFLAGS) genclisph.o" "genclisph"
  echotab "${HERE}genclisph > clisp1.h"
  echotab "\$(RM) genclisph${HEXE}"
  echotab "grep '^#' unixconf.h > clisp2.h"
  echotab "grep '^#' machine.h > clisp3.h"
  echotab "sed -e '/#include \"unixconf.h\"/r clisp2.h' -e '/#include \"unixconf.h\"/d' -e '/#include \"machine.h\"/r clisp3.h' -e '/#include \"machine.h\"/d' < clisp1.h > clisp.h"
  echotab "\$(RM) clisp1.h clisp2.h clisp3.h"
  echo
  echo
  echo "makevars :"
  echotab "(echo 'CC='\"'\"'\$(CC)'\"'\" ; echo 'CFLAGS='\"'\"'\$(CFLAGS)'\"'\" ; echo 'CLFLAGS='\"'\"'\$(CLFLAGS)'\"'\" ; echo 'LIBS='\"'\"'\$(LIBS)'\"'\" ; echo 'X_LIBS='\"'\"'\$(X_LIBS)'\"'\" ; echo 'RANLIB='\"'\"'\$(RANLIB)'\"'\" ; echo 'FILES='\"'\"'lisp.a libnoreadline.a libreadline.a'\"'\") > makevars"
  echo
  for f in clisp-link ; do
    echo "${f} : ${SRCDIR}${f}.in"
    echotab "sed -e 's/@with_dynamic_modules@/${with_dynamic_modules}/g' < ${SRCDIR}${f}.in > ${f}"
    echotab "chmod a+x ${f}"
    echo
  done
  for f in stdwin-link1.sh stdwin-link2.sh ; do
    if [ -n "${SRCDIR}" ] ; then
      echo "${f} : ${SRCDIR}${f}"
      echotab "-\$(LN) ${SRCDIR}${f} ${f}"
      echo
    fi
  done
  echo
fi
OBSOLETE=$OBSOLETE" genclisph${HEXE} clisp1.h clisp2.h clisp3.h"

if [ $TERMINAL = readline ] ; then
  manual_readline=' clreadline.3 readline.dvi'
  manualx_readline=' clreadline.man'
else
  manual_readline=''
  manualx_readline=''
fi
echo "manual : ANNOUNCE COPYRIGHT GNU-GPL SUMMARY NEWS README clisp.1 clisp.html impnotes.txt \$(TXTFILES)${manual_readline}"
echodummyrule manual
echo
echo "manualx : manual clisp.man${manualx_readline}"
echodummyrule manualx
echo

for f in ANNOUNCE COPYRIGHT GNU-GPL SUMMARY ; do
  echo "${f} : ${PARENT_}${f}"
  echotab "-\$(LN) ${PARENT_}${f} ${f}"
  echo
done

for f in NEWS ; do
  if [ -n "${SRCDIR}" ] ; then
    echo "${f} : ${SRCDIR}${f}"
    echotab "-\$(LN) ${SRCDIR}${f} ${f}"
    echo
  fi
done

for f in $TXT_FILES ; do
  echo "${f} : ${SRCDIR}_${f}${TXT_INCLUDES} txt2c${HEXE} ${DEELIF}"
  echotab "\$(TXT2C) < ${SRCDIR}_${f}${DEELIF_FILTER} > txt.c"
  if [ $CROSS = false -a $XCC_UNUSABLE_CPP = true ] ; then
    echotab "${XCPP} ${XCFLAGS} txt.c > txt.i.c"
    echotab_to_HEXE "${XCC} ${XCFLAGS}${XCC_NOOPTFLAGS} txt.i.c" "txt"
    echotab "\$(RM) txt.i.c"
  else
    echotab_to_HEXE "\$(CC) \$(CFLAGS)${XCC_NOOPTFLAGS} txt.c" "txt"
  fi
  line="${HERE}txt"
  if [ $f = clisp.1 ] ; then
    if [ $HOS != dos -a $HOS != os2 ] ; then
      line=$line" | grep -v '^ *\$\$'"
    else
      # DOS command line args may not contain spaces. grep.in contains "^ *$"
      line=$line" | grep -v -f grep.in"
    fi
  fi
  echotab "${line} > ${f}"
  echotab "\$(RM) txt.c"
  echotab "\$(RM) txt${HEXE}"
  echo
done
OBSOLETE=$OBSOLETE" txt.c txt${HEXE}"
if [ $CROSS = false -a $XCC_UNUSABLE_CPP = true ] ; then
  OBSOLETE=$OBSOLETE" txt.i.c"
fi

if [ $TERMINAL = readline ] ; then
  echo "clreadline.3 : ${SRCDIR}readline${NEXT_}doc${NEXT_}clreadline.3"
  echotab "-\$(LN) ${SRCDIR}readline${NEXT_}doc${NEXT_}clreadline.3 clreadline.3"
  echo
fi

echo "clisp.man : clisp.1"
echotab "\$(ROFF_MAN) clisp.1 > clisp.man"
echo
echo "clisp.dvi : clisp.1"
echotab "\$(ROFF_DVI) clisp.1 > clisp.dvi"
echo

if [ $TERMINAL = readline ] ; then
  echo "clreadline.man : clreadline.3"
  echotab "\$(ROFF_MAN) clreadline.3 > clreadline.man"
  echo
  echo "clreadline.dvi : clreadline.3"
  echotab "\$(ROFF_DVI) clreadline.3 > clreadline.dvi"
  echo
fi

for f in $DOC ; do
  echo "${f}.txt : ${DOCDIR_}${f}.txt"
  echotab "-\$(LN) ${DOCDIR_}${f}.txt ${f}.txt"
  echo
done

if [ $TERMINAL = readline ] ; then
  echo "${SRCDIR}readline${NEXT_}doc${NEXT_}rluserman.dvi :"
  echotab "cd ${SRCDIR}readline${NEXT_}doc ; \$(MAKE) rluserman.dvi"
  echo
  echo "readline.dvi : ${SRCDIR}readline${NEXT_}doc${NEXT_}rluserman.dvi"
  echotab "-\$(LN) ${SRCDIR}readline${NEXT_}doc${NEXT_}rluserman.dvi readline.dvi"
  echo
fi

echo

if [ $CROSS = false ] ; then
  if [ $HOS = unix ] ; then
    echo "install : install-bin install-man"
    echodummyrule install
    echo
    echo "installdirs : force"
    echotab "if [ ! -d \$(libdir) ] ; then mkdir \$(libdir) ; fi"
    echotab "if [ ! -d \$(lisplibdir) ] ; then mkdir \$(lisplibdir) ; fi"
    echotab "if [ ! -d \$(bindir) ] ; then mkdir \$(bindir) ; fi"
    echotab "if [ ! -d \$(mandir) ] ; then mkdir \$(mandir) ; fi"
    echotab "if [ ! -d \$(mandir)/man1 ] ; then mkdir \$(mandir)/man1 ; fi"
    if [ $TERMINAL = readline ] ; then
      echotab "if [ ! -d \$(mandir)/man3 ] ; then mkdir \$(mandir)/man3 ; fi"
    fi
    echotab "if [ ! -d \$(mandir)/html ] ; then mkdir \$(mandir)/html ; fi"
    echo
    echo "install-bin : lisp${LEXE} compiled.mem force"
    echotab "if [ ! -d \$(libdir) ] ; then mkdir \$(libdir) ; fi"
    echotab "if [ ! -d \$(lisplibdir) ] ; then mkdir \$(lisplibdir) ; fi"
    echotab "\$(INSTALL_PROGRAM) lisp${LEXE} \$(lisplibdir)/lisp${LEXE}"
    echotab "strip \$(lisplibdir)/lisp${LEXE}"
    echotab "\$(RM) \$(lisplibdir)/lispinit.mem"
    echotab "\$(INSTALL_DATA) compiled.mem \$(lisplibdir)/lispinit.mem"
    echotab "if [ ! -d \$(bindir) ] ; then mkdir \$(bindir) ; fi"
    if test -n "${GOOD_SH}" ; then
      echotab "(echo '#!${GOOD_SH}' ; echo 'exec \$(lisplibdir)/lisp${LEXE} -M \$(lisplibdir)/lispinit.mem \"\$\$@\"') > \$(bindir)/clisp"
    else
      echotab "(echo '#!/bin/sh' ; echo 'if test \$\$# = 0; then' ; echo '  exec \$(lisplibdir)/lisp${LEXE} -M \$(lisplibdir)/lispinit.mem' ; echo 'else' ; echo '  exec \$(lisplibdir)/lisp${LEXE} -M \$(lisplibdir)/lispinit.mem \"\$\$@\"' ; echo 'fi') > \$(bindir)/clisp"
    fi
    echotab "chmod a+x \$(bindir)/clisp"
    echo
    if [ $TERMINAL = readline ] ; then
      echo "install-man : clisp.1 clisp.html clreadline.3 force"
    else
      echo "install-man : clisp.1 clisp.html force"
    fi
    echotab "if [ ! -d \$(mandir) ] ; then mkdir \$(mandir) ; fi"
    echotab "if [ ! -d \$(mandir)/man1 ] ; then mkdir \$(mandir)/man1 ; fi"
    echotab "\$(INSTALL_DATA) clisp.1 \$(mandir)/man1/clisp.1"
    if [ $TERMINAL = readline ] ; then
      echotab "if [ ! -d \$(mandir)/man3 ] ; then mkdir \$(mandir)/man3 ; fi"
      echotab "\$(INSTALL_DATA) clreadline.3 \$(mandir)/man3/clreadline.3"
    fi
    echotab "if [ ! -d \$(mandir)/html ] ; then mkdir \$(mandir)/html ; fi"
    echotab "\$(INSTALL_DATA) clisp.html \$(mandir)/html/clisp.html"
    echo
    echo
    echo "installcheck : ${TESTSDIR} force"
    echotab "cd ${TESTSDIR}; \$(MAKE) LISP=\"\$(bindir)/clisp\""
    echo
    echo
    echo "uninstall : uninstall-bin uninstall-man"
    echodummyrule uninstall
    echo
    echo "uninstall-bin : force"
    echotab "\$(RM) \$(lisplibdir)/lisp${LEXE}"
    echotab "\$(RM) \$(lisplibdir)/lispinit.mem"
    echotab "\$(RM) \$(bindir)/clisp"
    echo
    echo "uninstall-man : force"
    echotab "\$(RM) \$(mandir)/man1/clisp.1"
    if [ $TERMINAL = readline ] ; then
      echotab "\$(RM) \$(mandir)/man3/clreadline.3"
    fi
    echotab "\$(RM) \$(mandir)/html/clisp.html"
    echo
    echo
  fi
  if [ $HOS = dos -o $HOS = os2 ] ; then
    echo "install : install-bin"
    echodummyrule install
    echo
    echo "installdirs : force"
    echotab "-mkdir \$(libdir)"
    echotab "-mkdir \$(lisplibdir)"
    echotab "-mkdir \$(bindir)"
    echo
    echo "install-bin : lisp${LEXE} compiled.mem force"
    echotab "-mkdir \$(libdir)"
    echotab "-mkdir \$(lisplibdir)"
    echotab "\$(INSTALL_PROGRAM) lisp${LEXE} \$(lisplibdir)\lisp${LEXE}"
    echotab "\$(INSTALL_DATA) compiled.mem \$(lisplibdir)\lispinit.mem"
    echotab "-mkdir \$(bindir)"
    if [ $HOS = dos ] ; then
      echotab "echo \$(lisplibdir)\lisp${LEXE} -M \$(lisplibdir)\lispinit.mem %1 %2 %3 %4 %5 %6 %7 %8 %9 > \$(bindir)\clisp.bat"
    fi
    if [ $HOS = os2 ] ; then
      echotab "echo \$(lisplibdir)\lisp${LEXE} -M \$(lisplibdir)\lispinit.mem %1 %2 %3 %4 %5 %6 %7 %8 %9 > \$(bindir)\clisp.cmd"
    fi
    echo
    echo "uninstall : uninstall-bin"
    echodummyrule uninstall
    echo
    echo "uninstall-bin : force"
    echotab "\$(RM) \$(lisplibdir)/lisp${LEXE}"
    echotab "\$(RM) \$(lisplibdir)/lispinit.mem"
    if [ $HOS = dos ] ; then
      echotab "\$(RM) \$(bindir)/clisp.bat"
    fi
    if [ $HOS = os2 ] ; then
      echotab "\$(RM) \$(bindir)/clisp.cmd"
    fi
    echo
  fi
fi

if [ $HOS = unix ] ; then
cat <<!!
# Choose one of the packers:

# Standard Unix packer. Compress afterwards.
#PACK = tar
#PACKOPT = -cvf
#PACKEXT = .tar

# GNU tar together with compress.
#PACK = tar
#PACKOPT = cvfhz
#PACKEXT = .tar.Z

# GNU tar together with GNU gzip. Excellent performance.
PACK = tar
PACKOPT = cvfhz
PACKEXT = .tar.z

# Popular Amiga packer. Good performance.
#PACK = lha
#PACKOPT = a
#PACKEXT = .lzh

# Popular DOS packer.
#PACK = zip
#PACKOPT = -r
#PACKEXT = .zip

# Popular Atari packer.
#PACK = zoo
#PACKOPT = -add
#PACKEXT = .zoo

!!
echo "# The distribution's top directory"
if test -f "${SRCDIR}VERSION"; then
  echo "TOPDIR=clisp-`cat ${SRCDIR}VERSION`"
else
  if test -f "src/VERSION"; then
    echo "TOPDIR=clisp-`cat src/VERSION`"
else
    echo "TOPDIR=clisp"
  fi
fi
echo
if test -z "$BINARY_DISTRIB"; then
  needs='all lisp.a manualx distmakefile libnoreadline.a libreadline.a clisp-link modules.d modules.c module.cc clisp.h modules.h makevars'
  if test -n "$with_module_stdwin"; then
    stdwin_needs=''
    if test -n "$with_dynamic_modules"; then
      stdwin_needs=$stdwin_needs' stdwin_module.o'
    fi
    stdwin_needs=$stdwin_needs' stdwin.o stdwin/libstdwin.a'
    needs=$needs''$stdwin_needs' stdwin-link1.sh stdwin-link2.sh'
  fi
  echo "distrib : force $needs"
  echotab "\$(RM) /tmp/clisp\$(PACKEXT)"
  echotab "mkdir \$(TOPDIR)"
  echotab "ln ANNOUNCE COPYRIGHT GNU-GPL SUMMARY NEWS README \$(TOPDIR)"
  echotab "ln distmakefile \$(TOPDIR)/Makefile"
  echotab "mkdir \$(TOPDIR)/base"
  echotab "ln lisp.a libnoreadline.a libreadline.a modules.h makevars \$(TOPDIR)/base"
  echotab "ln compiled.mem \$(TOPDIR)/base/lispinit.mem"
  echotab "mkdir \$(TOPDIR)/doc"
  echotab "ln clisp.1 clisp.man clisp.html impnotes.txt \$(TXTFILES)${manual_readline}${manualx_readline} \$(TOPDIR)/doc"
  echotab "mkdir \$(TOPDIR)/src"
  echotab "ln \$(LSPFILES) \$(FASFILES) \$(TOPDIR)/src"
  echotab "mkdir \$(TOPDIR)/linkkit"
  echotab "ln clisp-link modules.d modules.c module.cc clisp.h \$(TOPDIR)/linkkit"
  if test -n "$with_module_stdwin"; then
    echotab "mkdir \$(TOPDIR)/stdwin"
    echotab "ln${stdwin_needs} stdwin1.lsp stdwin2.lsp \$(TOPDIR)/stdwin"
    echotab "ln stdwin-link1.sh \$(TOPDIR)/stdwin/link1.sh"
    echotab "ln stdwin-link2.sh \$(TOPDIR)/stdwin/link2.sh"
  fi
  if test -n "$with_module_queens"; then
    echotab "mkdir \$(TOPDIR)/queens"
    echotab "ln queens/* \$(TOPDIR)/queens"
  fi
  echotab "chmod -R a+rX \$(TOPDIR)"
  echotab "\$(PACK) \$(PACKOPT) /tmp/clisp\$(PACKEXT) \$(TOPDIR)"
  echotab "\$(RM) -rf \$(TOPDIR)"
  echo
else
  echo "distrib : force all manualx distmakefile"
  echotab "\$(RM) /tmp/clisp\$(PACKEXT)"
  echotab "mkdir \$(TOPDIR)"
  echotab "ln ANNOUNCE COPYRIGHT GNU-GPL SUMMARY NEWS README \$(TOPDIR)"
  echotab "ln distmakefile \$(TOPDIR)/Makefile"
  echotab "mkdir \$(TOPDIR)/base"
  echotab "cp lisp.run \$(TOPDIR)/base/lisp.run"
  echotab "strip \$(TOPDIR)/base/lisp.run"
  echotab "chmod a+x \$(TOPDIR)/base/lisp.run"
  echotab "ln compiled.mem \$(TOPDIR)/base/lispinit.mem"
  echotab "mkdir \$(TOPDIR)/doc"
  echotab "ln clisp.1 clisp.man clisp.html impnotes.txt \$(TXTFILES)${manual_readline}${manualx_readline} \$(TOPDIR)/doc"
  echotab "mkdir \$(TOPDIR)/src"
  echotab "ln \$(LSPFILES) \$(FASFILES) \$(TOPDIR)/src"
  echotab "chmod -R a+rX \$(TOPDIR)"
  echotab "\$(PACK) \$(PACKOPT) /tmp/clisp\$(PACKEXT) \$(TOPDIR)"
  echotab "\$(RM) -rf \$(TOPDIR)"
  echo
fi
echo
fi

cat <<!!
# clean0 is harmless: removes only superfluous things: temporary files.
clean0 : force
	-\$(RM) core${OBSOLETE}

# clean1 removes everything that becomes obsolete once lisp${LEXE} is recompiled
# without changing the bytecode format and the tables in
# constobj.d, constpack.d, constsym.d, subr.d, fsubr.d, pseudofun.d.
clean1 : clean0
	-\$(RM) lispbibl.h clisp.h *.i *.s *${TOBJ} *.a lisp${LEXE} ${TESTDIR}${NEXT}* ${TESTSDIR}${NEXT}*
	-rmdir ${TESTDIR}
	-rmdir ${TESTSDIR}
	-\$(RM) README clisp.1 clisp.html impnotes.txt \$(TXTFILES) clreadline.3 readline.dvi

# clean2 removes everything that becomes obsolete once lisp${LEXE} is recompiled
# without changing the bytecode format.
clean2 : clean1
	-\$(RM) interpreted.mem halfcompiled.mem compiled.mem compiled2.mem

# clean3 removes everything that becomes obsolete once lisp${LEXE} is recompiled.
# It leaves everything generated by "make allc".
clean3 : clean2
	-\$(RM) \$(FASFILES) *.lib

# clean4 removes everything that becomes obsolete
# when switching to a new version of the C compiler.
# It leaves everything generated by "make init".
clean4 : clean3
	-\$(RM) \$(CFILES)

# clean5 even undoes "make init".
!!
echo "clean5 : clean4"
if [ -n "${SRCDIR}" ] ; then
  echotab "-\$(RM) \$(DFILES) modules.h \$(LSPFILES) COPYRIGHT"
else
  echotab "-\$(RM) config.lsp"
fi
echotab "-\$(RM) comment5${HEXE} ansidecl${HEXE} ccpaux${HEXE} deelif${HEXE} deerror${HEXE} dedefined${HEXE} traddecl${HEXE} deema${HEXE} mergestrings${HEXE} txt2c${HEXE}"
echo
cat <<!!
# clean6 lets us go back to "makemake > makefile".
clean6 : clean5
	-\$(RM) makefile

# clean7 lets us go back to the main "configure".
clean7 : clean6
	-\$(RM) config.status config.log config.cache machine.h unixconf.h makemake
	-\$(RM) readline.tar.Z
!!
if [ $TERMINAL = readline ] ; then
cat <<!!
	cd ${READLINEDIR} && \$(MAKE) clean
!!
fi
cat <<!!

# clean8 moreover cleans up the SRCDIR.
clean8 : clean7
	-\$(RM) ${SRCDIR}lisparit0.d

# The normal "start over" command:
mostlyclean : clean4

# Clear all files that are built by "make ...":
clean : clean5

# Make "clear for distribution":
distclean : clean7

# Remove everything that can be generated otherwise:
realclean : clean8

!!

echo

echo "force:"
echodummyrule force

echo

