1#! @SHELL@
2# -*- coding: utf-8; mode: shell-script -*- vim:filetype=sh
3CONFIG_SHELL="@SHELL@"  # mind the quoting, for args like -x.
4# Creation of the Makefile used for compiling CLISP
5# Bruno Haible 1991-2010
6# Sam Steingold 1999-2012, 2016
7
8# Simple usage:
9#        ./makemake [--with-PACKAGE] > Makefile
10
11HSDEFAULT="http://www.ai.mit.edu/projects/iiip/doc/CommonLISP/HyperSpec/"
12hyperspec=${CLHSROOT:-${HSDEFAULT}}
13
14fail () { echo "$0: $*" >&2; exit 1; }
15
16info_help () {
17cat << EOP
18Usage: ./makemake [options] > Makefile
19options:
20    The following general options are recognized:
21       --help                  print this message and exit
22       --version               print the CLISP version and exit
23       --verbose               print some config information to the stderr
24    The following options set installation parameters:
25       --srcdir=SRCDIR         sets the source directory to SRCDIR
26       --prefix=PREFIX         sets the installation directory prefix to PREFIX
27       --exec-prefix=EXECPREFIX  sets the architecture dependent installation
28                                  directory prefix to EXECPREFIX
29       --fsstnd=std            installation according to FileSystem Standards:
30                               suse - SuSE-Linux conventions
31                               redhat - RedHat
32                               debian - Debian, Slackware
33                               *bsd - NetBSD, OpenBSD, FreeBSD
34       --hyperspec=URL         the path to the Common Lisp HyperSpec
35           (the default is ${HSDEFAULT}
36            or the value of the environment variable CLHSROOT, if set).
37      Fine tuning of the installation directories:
38       --bindir=DIR            user executables
39       --libdir=DIR            object code libraries
40       --includedir=DIR        C header files
41       --datarootdir=DIR       read-only arch.-independent data root
42       --datadir=DIR           read-only architecture-independent data
43       --localedir=DIR         locale-dependent data
44       --docdir=DIR            documentation root
45       --mandir=DIR            man documentation
46       --infodir=DIR           GNU Info documentation
47       --htmldir=DIR           html documentation
48       --dvidir=DIR            TeX DVI documentation
49       --psdir=DIR             PostScript documentation
50       --pdfdir=DIR            PDF documentation
51       --elispdir=DIR          Emacs Lisp files
52       --vimdir=DIR            VIM files
53       --aclocaldir=DIR        autoconf files
54    The following options add support for specific separate packages. See the
55    main INSTALL file for how to get them.
56       --with-noreadline       do not use readline library (even when present)
57       --with-gettext          internationalization, needs GNU gettext
58       --with-nogettext        static internationalization (en only)
59       --without-unicode       no Unicode character set, only 8-bit characters
60       --with-dynamic-ffi      a foreign language interface
61       --without-dynamic-modules  no dynamic loading of foreign modules
62       --with-threads=FLAVOR   MT [_experimental_!]
63                      FLAVOR: POSIX_THREADS SOLARIS_THREADS WIN32_THREADS
64       --with-jitc=FLAVOR      use a given Just-In-Time Compiler.
65                The only flavor at this time is lightning
66                  (GNU lightning must be installed in the standard place).
67       --enable-portability    favour portability over optimization: disable
68                               optimizations that could lead to build failures
69       --with-gmalloc          use the GNU malloc instead of the libc one
70                               (needed on HP-UX and OpenBSD)
71       --with-debug            if you will need to debug the C sources.
72    See modules/ directory for available modules and add them to the full
73    linking set using --with-module option, e.g.,
74       --with-module=bindings/glibc
75       --with-module=pari
76Example:
77       ./makemake --with-dynamic-ffi > Makefile
78EOP
79}
80
81# Advanced usage:
82#        ./makemake [--with-PACKAGE] [cross] TARGET COMPILER > Makefile
83#  where PACKAGE is one of
84#        noreadline       no readline library
85#        gettext          internationalization, needs GNU gettext
86#        nogettext        static internationalization (en only)
87#        unicode          Unicode character set
88#        dynamic-ffi      a dynamic foreign language interface
89#        dynamic-modules  dynamic loading of foreign language modules
90#        module=MODULE    an add-on module
91#  where TARGET is one of
92#        master
93#        win32msvc
94#  and COMPILER is one of
95#        gcc       (GNU C under the name gcc)
96#        cc        (any other ANSI C compliant cc)
97
98# Examples:
99#   makemake > Makefile
100#   makemake --with-debug > Makefile
101#   makemake --with-noreadline --with-debug > Makefile
102#   makemake master gcc > make.gcc/makefile
103#   makemake --win32gcc gcc > make.win32gcc/makefile
104#   makemake --with-dynamic-ffi win32msvc msvc4 > make.win32msvc/makefile.msvc4
105#   makemake --with-dynamic-ffi win32msvc msvc5 > make.win32msvc/makefile.msvc5
106#   makemake --with-dynamic-ffi win32msvc msvc6 > make.win32msvc/makefile.msvc6
107
108
109# Fix the "echo" command. The SysV /bin/sh (and also ksh, and also bash if
110# built with --enable-usg-echo-default, and also GNU sh-utils-1.16) are broken:
111# They have an echo command which interprets backslashes in the string to be
112# output. We cannot fix this by defining a function called "echo", because the
113# HP/UX, OSF/1, AIX /bin/sh would nevertheless call the builtin, broken "echo".
114# `echol' stands for "echo line".
115if echo 'rs\tuv' | grep t > /dev/null 2> /dev/null; then
116  # Uff. Found a BSD or POSIX compliant "echo" command.
117  echol () {
118    echo "$*"
119  }
120elif type printf >/dev/null 2>/dev/null; then
121  # The "Single Unix Specification" (which also adheres to this broken
122  # "echo") recommends the following workaround.
123  echol () {
124    printf '%s\n' "$*"
125  }
126else
127  # This one looks harmless, but in Solaris /bin/sh, when called inside
128  # shell backquote `...`, it prefixes every character with a backslash!
129  # Therefore we use this only as a last resort, if `printf' is missing
130  # (for example, on OpenStep V4.2).
131echol () {
132cat <<ECHOVAL_END
133$*
134ECHOVAL_END
135}
136fi
137
138link_dep() {
139  echol "$1 : $2"
140  echotab "-\$(RM) $1"
141  echotab "-\$(LN_S) ${3-$2} $1"
142  echol
143}
144
145# Handle --help and --version arguments.
146for arg do
147  case "$arg" in
148    --help | --hel | --he | --h)
149      info_help
150      exit 0 ;;
151    --version | --versio | --versi | --vers | --ver | --ve | --v)
152      echol "@PACKAGE_STRING@ (@PACKAGE_BUGREPORT@)"
153      exit 0 ;;
154  esac
155done
156
157# Save the argument list for reference.
158makemake_args=''
159for arg do
160  # Approximate a shell-quote.
161  case "$arg" in
162    *" "* | *"	"* | *[\[\]\~\#\$\^\&\*\(\)\{\}\\\|\;\<\>\?]* ) makemake_args="$makemake_args '$arg'" ;;
163    * ) makemake_args="$makemake_args $arg" ;;
164  esac
165done
166hostname=`(hostname || uname -n) 2>/dev/null | sed 1q`
167
168srcdir='@srcdir@'
169prefix=''
170exec_prefix=''
171fsstnd='' # supported styles: gnu, gnu_ext, suse, redhat, debian, *bsd
172bindir=''
173libdir=''
174includedir=''
175datarootdir=''
176datadir=''
177localedir=''
178docdir=''
179mandir=''
180infodir=''
181htmldir=''
182dvidir=''
183psdir=''
184pdfdir=''
185MODULES=''
186elispdir=''
187vimdir=''
188aclocaldir=''
189CP='cp -p'
190LN_S='ln -s'
191HLN='ln'
192
193# <http://thread.gmane.org/gmane.comp.sysutils.autoconf.general/13368>
194# <https://lists.gnu.org/archive/html/autoconf/2010-09/msg00089.html>
195# strip out -srcdir* & -cache-file*
196keep_next=maybe
197module_configure_flags=''
198for arg in @module_configure_flags@; do
199  case $arg in
200    *\'*) arg=`$echo "$arg" | sed "s/'/'\\\\\\\\''/g"` ;;
201  esac
202  case $keep_next in
203    yes ) module_configure_flags="$module_configure_flags '$arg'";
204      keep_next=maybe; ;;
205    no ) keep_next=maybe; ;;
206    maybe ) case $arg in
207      --cache-file=* | --srcdir=*) continue ;;
208      --cache-file | --srcdir ) keep_next=no; ;;
209      *=* ) module_configure_flags="$module_configure_flags '$arg'"; ;;
210      *) module_configure_flags="$module_configure_flags '$arg'";
211        keep_next=yes; ;;
212    esac ;;
213  esac
214done
215unset arg
216unset keep_next
217
218# NLS nuisances.
219# Needed e.g. for some versions of `tr' so that character classes in `[]' work.
220if test "${LC_ALL+set}" = 'set'; then LC_ALL=C ; export LC_ALL ; fi
221if test "${LANG+set}"   = 'set'; then LANG=C   ; export LANG   ; fi
222if [ `echo ABC | tr '[A-Z]' '[a-z]'` = "abc" ] ; then
223  tolower="tr '[A-Z]' '[a-z]'"
224else
225  tolower="tr A-Z a-z"
226fi
227my_eval(){
228  eval "$*"
229  test "${verbose}" = true -o "${verbose}" = yes && echo "$*" >&2
230}
231
232# Set the defaults for the --with and --enable options.
233with_termcap_ncurses=yes # no effect if missing termcap/ncurses
234with_readline=ifpossible # no effect if no libreadline found
235with_gettext=yes         # no effect if no glibc/libintl found
236with_unicode=yes
237with_dynamic_ffi=no      # often set to yes by the toplevel configure
238with_dynamic_modules=default
239with_threads=no
240enable_portability=ifuseful
241with_gmalloc=no
242with_debug=no
243# i18n: essential for internationalized programs
244# syscalls: very useful for scripting
245# regexp: useful for scripting and text processing
246# readline: additional facilities for REPL, added later if appropriate
247BASE_MODULES="i18n syscalls regexp"
248
249verbose=${CLISP_MAKEMAKE_VERBOSE:-false}
250# Handle --with-... arguments
251while test -z "$endofargs"; do
252  case "$1" in
253    -verb* | --verb* )
254      verbose=`echol "$1"|sed 's/-*v[^=]*=*//'`
255      test -n "${verbose}" || verbose=true
256      shift
257      ;;
258    -with-module=* | --with-module=*)
259      module=`echol "$1"|sed 's/-*with-module=//'`
260      # We don't need to add $module to MODULES if it's already contained
261      # in BASE_MODULES.
262      case " $BASE_MODULES readline " in
263        *" $module "*) cat <<EOF >&2
264$0: argument $1 is ignored because $module is a base module
265$0: see http://clisp.org/impnotes/modules.html#base-modules
266EOF
267          ;;
268        *) MODULES="$MODULES $module" ;;
269      esac
270      shift
271      ;;
272    # Accept --with and --without options like configure does.
273    # Extensions:
274    # - Accept --with-no-foo and --with-nofoo as synonyms of --without-foo.
275    # - Accept --with-foo=off as synonym of --with-foo=no.
276    # - Accept --with-foo=on as synonym of --with-foo=yes.
277    # Testing for yes:   test "${with_foo}" != no
278    # Testing for no:    test "${with_foo}" = no
279    -without-* | --without-* | -with-no* | --with-no*)
280      package=`echol "$1" | sed -e 's/^-*without-//' -e 's/^-*with-no-*//'`
281      # Delete all the valid chars; see if any are left.
282      test -n "`echol $package|sed 's/[-a-zA-Z0-9_]*//g'`" && \
283        fail "$package: invalid package name"
284      my_eval "with_`echol $package|sed s/-/_/g`=no"
285      shift
286      ;;
287    -with-* | --with-*)
288      package=`echol "$1"|sed 's/-*with-//'`
289      case "$package" in
290        *=*) packopt=`echol "${package}" | sed -e 's/^[^=]*=//'` ;;
291        *) packopt=yes ;;
292      esac
293      package=`echol "${package}" | sed -e 's/=.*//'`
294      # Delete all the valid chars; see if any are left.
295      test -n "`echol $package|sed 's/[-a-zA-Z0-9_]*//g'`" && \
296        fail "$package: invalid package name";
297      if test "${packopt}" = "on"; then
298        packopt=yes
299      elif test "${packopt}" = "off"; then
300        packopt=no
301      fi
302      my_eval "with_`echol $package|sed s/-/_/g`=${packopt}"
303      shift
304      ;;
305    -disable-* | --disable-*)
306      feature=`echol "$1"|sed 's/-*disable-//'`
307      # Delete all the valid chars; see if any are left.
308      test -n "`echol $feature|sed 's/[-a-zA-Z0-9_]*//g'`" && \
309        fail "$feature: invalid feature name"
310      feature=`echol $feature | sed 's/-/_/g'`
311      my_eval "enable_$feature=no"
312      shift
313      ;;
314    -enable-* | --enable-*)
315      feature=`echol "$1"|sed 's/-*enable-//'`
316      # Delete all the valid chars; see if any are left.
317      test -n "`echol $feature|sed 's/[-a-zA-Z0-9_]*//g'`" && \
318        fail "$feature: invalid feature name"
319      feature=`echol $feature | sed 's/-/_/g'`
320      my_eval "enable_$feature=yes"
321      shift
322      ;;
323    -srcdir* | --srcdir*)
324      srcdir=`echol "$1" | sed 's/-*srcdir=*//'`
325      shift
326      if test -z "$srcdir" ; then
327        srcdir=$1
328        shift
329      fi
330      ;;
331    -prefix* | --prefix*)
332      prefix=`echol "$1" | sed 's/-*prefix=*//'`
333      shift
334      if test -z "$prefix" ; then
335        prefix=$1
336        shift
337      fi
338      ;;
339    -exec-prefix* | --exec-prefix*)
340      exec_prefix=`echol "$1" | sed 's/-*exec-prefix=*//'`
341      shift
342      if test -z "$exec_prefix" ; then
343        exec_prefix=$1
344        shift
345      fi
346      ;;
347    --fsstnd=*)
348      fsstnd=`echol "$1" | sed 's/-*fsstnd=//'`
349      shift
350      ;;
351    -bindir* | --bindir*)
352      bindir=`echol "$1" | sed 's/-*bindir=*//'`
353      shift
354      if test -z "$bindir" ; then
355        bindir=$1
356        shift
357      fi
358      ;;
359    -libdir* | --libdir*)
360      libdir=`echol "$1" | sed 's/-*libdir=*//'`
361      shift
362      if test -z "$libdir" ; then
363        libdir=$1
364        shift
365      fi
366      ;;
367    -includedir* | --includedir*)
368      includedir=`echol "$1" | sed 's/-*includedir=*//'`
369      shift
370      if test -z "$includedir" ; then
371        includedir=$1
372        shift
373      fi
374      ;;
375    -datarootdir* | --datarootdir*)
376      datarootdir=`echol "$1" | sed 's/-*datarootdir=*//'`
377      shift
378      if test -z "$datarootdir" ; then
379        datarootdir=$1
380        shift
381      fi
382      ;;
383    -datadir* | --datadir*)
384      datadir=`echol "$1" | sed 's/-*datadir=*//'`
385      shift
386      if test -z "$datadir" ; then
387        datadir=$1
388        shift
389      fi
390      ;;
391    -localedir* | --localedir*)
392      localedir=`echol "$1" | sed 's/-*localedir=*//'`
393      shift
394      if test -z "$localedir" ; then
395        localedir=$1
396        shift
397      fi
398      ;;
399    -docdir* | --docdir*)
400      docdir=`echol "$1" | sed 's/-*docdir=*//'`
401      shift
402      if test -z "$docdir" ; then
403        docdir=$1
404        shift
405      fi
406      ;;
407    -mandir* | --mandir*)
408      mandir=`echol "$1" | sed 's/-*mandir=*//'`
409      shift
410      if test -z "$mandir" ; then
411        mandir=$1
412        shift
413      fi
414      ;;
415    -infodir* | --infodir*)
416      infodir=`echol "$1" | sed 's/-*infodir=*//'`
417      shift
418      if test -z "$infodir" ; then
419        infodir=$1
420        shift
421      fi
422      ;;
423    -htmldir* | --htmldir*)
424      htmldir=`echol "$1" | sed 's/-*htmldir=*//'`
425      shift
426      if test -z "$htmldir" ; then
427        htmldir=$1
428        shift
429      fi
430      ;;
431    -dvidir* | --dvidir*)
432      dvidir=`echol "$1" | sed 's/-*dvidir=*//'`
433      shift
434      if test -z "$dvidir" ; then
435        dvidir=$1
436        shift
437      fi
438      ;;
439    -psdir* | --psdir*)
440      psdir=`echol "$1" | sed 's/-*psdir=*//'`
441      shift
442      if test -z "$psdir" ; then
443        psdir=$1
444        shift
445      fi
446      ;;
447    -pdfdir* | --pdfdir*)
448      pdfdir=`echol "$1" | sed 's/-*pdfdir=*//'`
449      shift
450      if test -z "$pdfdir" ; then
451        pdfdir=$1
452        shift
453      fi
454      ;;
455    -elispdir* | --elispdir*)
456      elispdir=`echol "$1" | sed 's/-*elispdir=*//'`
457      shift
458      if test -z "$elispdir" ; then
459        elispdir=$1
460        shift
461      fi
462      ;;
463    -vimdir* | --vimdir*)
464      vimdir=`echol "$1" | sed 's/-*vimdir=*//'`
465      shift
466      if test -z "$vimdir" ; then
467        vimdir=$1
468        shift
469      fi
470      ;;
471    -aclocaldir* | --aclocaldir*)
472      aclocaldir=`echol "$1" | sed 's/-*aclocaldir=*//'`
473      shift
474      if test -z "$aclocaldir" ; then
475        aclocaldir=$1
476        shift
477      fi
478      ;;
479    --win32gcc) HSYS="win32gcc"; shift; ;;
480    --hyperspec=*)
481      arg=`echol "$1" | sed 's/-*hyperspec=//'`
482      case "$arg" in
483        */FrontMatter* ) arg=`echo "$arg" | sed -e 's,FrontMatter.*$,,'` ;;
484      esac
485      case "$arg" in
486        *://*) hyperspec="$arg" ;;
487        /*) if test -d "$arg" -a -d "${arg}FrontMatter" ; then
488              hyperspec="file:${arg}"
489            else
490              echo "makemake: --hyperspec=${arg} argument ignored, does not point to the Common Lisp HyperSpec" 1>&2
491            fi
492            ;;
493        *)  case "$arg" in
494              file:*) arg=`echo "$arg" | sed -e 's,^file:,,'` ;;
495            esac
496            if test -d "$arg" -a -d "${arg}FrontMatter" ; then
497              hyperspec="file:"`cd "$arg" > /dev/null && pwd`
498            else
499              echo "makemake: --hyperspec=${arg} argument ignored, does not point to the Common Lisp HyperSpec" 1>&2
500            fi
501            ;;
502      esac
503      shift
504      ;;
505    *) endofargs=1 ;;
506  esac
507done
508
509# Ensure trailing slash in hyperspec URL.
510case "$hyperspec" in
511  */)  ;;
512  *) hyperspec=${hyperspec}/ ;;
513esac
514
515# HSYS, HSYSOS = host system
516# HOS  = host operating system
517# TSYS, TSYSOS = target system
518# TOS  = target operating system
519# CC, CPPFLAGS, CFLAGS, CLFLAGS, CPP = compiler on host, for host
520# XCC, XCPPFLAGS, XCFLAGS, XCLFLAGS, XCPP = cross-compiler on host, for target
521
522# These variables are set by configure:
523# srcdir='@srcdir@'                 # either '.' or '../src', see above
524CP='cp -p'                          # either 'cp -p' or 'cp'
525LN_S='@LN_S@'                       # either 'ln -s' or 'ln' or 'cp -p'
526LN='@LN@'                           # either 'ln' or ${CP}
527HLN='@HLN@'                         # either 'ln' or 'hln'
528CC="@CC@"                           # either 'gcc -O' or 'cc'
529CPP="@CPP@"                         # either $CC' -E' or '/lib/cpp'
530CPPFLAGS='@CPPFLAGS@'               # additional options for $CC and $CPP
531CFLAGS='@CFLAGS@'                   # additional options for $CC
532LDFLAGS='@LDFLAGS@'                 # additional options for linking
533CC_GCC='@CC_GCC@'                   # either true or false
534CC_SUNPRO='@CC_SUNPRO@'             # either true or false
535CC_CPLUSPLUS='@CC_CPLUSPLUS@'       # either true or false
536CC_NEED_DEEMA='@CC_NEED_DEEMA@'     # either true or false
537AS_UNDERSCORE='@AS_UNDERSCORE@'     # either true or false
538WINDRES='@WINDRES@'                 # something like i686-w64-mingw32-windres
539LD='@LD@'                           # the linker used by $CC, such as 'ld' or '/usr/bin/ld -m elf_i386'
540AR='@AR@'                           # usually 'ar'
541RANLIB='@RANLIB@'                   # either 'ranlib' or ':'
542DSYMUTIL='@DSYMUTIL@'               # either 'dsymutil' or ''
543INSTALL='@INSTALL@'                 # either 'install -c' or 'cp'
544INSTALL_PROGRAM='@INSTALL_PROGRAM@' # either 'install -c' or 'cp'
545INSTALL_SCRIPT='@INSTALL_SCRIPT@'   # either 'install -c' or 'cp', avoid 'strip'
546INSTALL_DATA='@INSTALL_DATA@'       # either 'install -c -m 644' or 'cp'
547GROFF='@GROFF@'                     # either 'groff' or ''
548PS2PDF='@PS2PDF@'                   # either 'ps2pdf' or ''
549LIBS='@LIBS@'                       # list of system libraries
550LIBTERMCAP='@LIBTERMCAP@'           # '-L/usr/??/lib' or 'broken' or ''
551INCTERMCAP='@INCTERMCAP@'           # '-I/usr/??/include' or ''
552LIBICONV='@LIBICONV@'               # either '-liconv' or ''
553LIBSIGSEGV='@LIBSIGSEGV@'           # '-lsigsegv -L/usr/local/lib' or ''
554LIBUNISTRING='@LIBUNISTRING@'       # '-lunistring ...' or ''
555LIBSOCKET='@LIBSOCKET@'             # '-lnet' or '-lsocket' or '-lws2_32' or ''
556X_CFLAGS='@X_CFLAGS@'               # either '-I/usr/somewhere/include' or ''
557X_LIBS='@X_LIBS@'                   # either '-L/usr/somewhere/lib -lX11' or ''
558FFCALL_LIBS='@LIBAVCALL@ @LIBCALLBACK@' # libavcall.a libcallback.a
559host='@host@'                       # something like 'sparc-sun-sunos4'
560host_cpu='@host_cpu@'               # something like 'sparc'
561host_cpu_c_abi='@HOST_CPU_C_ABI@'   # ditto
562host_vendor='@host_vendor@'         # something like 'sun'
563host_os='@host_os@'                 # something like 'sunos4'
564GNU_MAKE='@GNU_MAKE_FALSE@'         # '#' if non-gnu; '' if gnu
565
566if test -x ./libtool; then # normal autoconf-based build
567  # -rdynamic or -Wl,-E or -Wl,--export-dynamic
568  eval "`./libtool --tag=CC --config | grep '^wl='`"
569  eval "`./libtool --tag=CC --config | grep '^export_dynamic_flag_spec='`"
570  eval EXPORT_DYNAMIC_FLAG_SPEC=\"$export_dynamic_flag_spec\"
571else # generating Makefiles for MS compiler from Makefile.devel
572  :
573fi
574
575# Important: Don't rely on this host classification.
576# 1. GNU's database config.guess is not always up to date.
577# 2. New operating systems are emerging at every corner.
578# 3. People tend to change their systems locally.
579# Use this classification ONLY if we know no better way to check for a
580# feature or bug than to look at various `uname ...` results and list
581# the buggy systems explicitly. ONLY in this case!
582
583UTILCOMPILE="\$(CC) \$(CPPFLAGS) \$(CFLAGS) \$(CLFLAGS)"
584case $# in
585  0 | 1)
586     # Assume we are on Unix (or win32gcc); target=host (not cross-compiling).
587     CROSS=false
588     if [ -z "$HSYS" ]; then # not win32gcc
589       # some shells (A/UX and OSF/1) need the parentheses around "arch" below.
590       HSYS=`((arch) 2>/dev/null || uname -m 2>/dev/null) | $tolower` # system name in lowercase
591       HSYSOS=`((uname) 2>/dev/null || arch 2>/dev/null) | $tolower` # OS name in lowercase
592       if [ "$HSYS" = 386bsd -o "$HSYS" = sun386 -o "$HSYS" = "386/at" -o "$HSYS" = i86pc ] ; then
593         HSYS='i386'
594       fi
595       if [ "$HSYS" = sun4m ] ; then
596         HSYS='sun4'
597       fi
598       case "$HSYSOS" in
599         # Canonicalize cygwin32/nt and cygwin32/95 to plain cygwin.
600         cygwin*) HSYSOS=cygwin ;;
601       esac
602       HOS='unix'
603       COMPILER=??
604     else                       # win32gcc
605       HSYSOS=$HSYS
606       HOS=win32
607       COMPILER=gcc
608       # Compile the utils as native Windows binaries, even on Cygwin.
609       UTILCOMPILE="\$(CC) \$(CPPFLAGS)"
610     fi
611     TSYS="$HSYS"
612     TSYSOS="$HSYSOS"
613     case "$host_os" in
614       mingw*) TOS=win32 ;;
615       *)      TOS="$HOS" ;;
616     esac
617     ;;
618  *) if [ "$1" = cross ] ; then
619       CROSS=true
620       shift
621     else
622       CROSS=false
623     fi
624     TSYS=$1
625     COMPILER=$2
626     module_configure_flags=${module_configure_flags}" --build=${TSYS}"
627     # TSYS should be (master|win32msvc).
628     # COMPILER should be <host...>-gcc or cc
629     case ${TSYS} in
630       win32msvc ) TOS='win32' ;;
631       *)          TOS='unix' ;;
632     esac
633     TSYSOS=$TSYS
634     if [ $CROSS = true ] ; then
635       HOS='unix'
636       HSYS=irrelevant
637       HSYSOS=irrelevant
638     else
639       HOS="$TOS"
640       HSYS="$TSYS"
641       HSYSOS="$TSYSOS"
642     fi
643     if [ $TSYS = win32msvc ] ; then
644       CC='cl'
645       CC_GCC=false
646       CFLAGS='$(MFLAGS)'
647       CC_NEED_DEEMA=true
648       AS_UNDERSCORE=false
649       LD='link'
650       FFCALL_LIBS='avcall.lib callback.lib'
651     else
652       CC=${COMPILER}
653       case $COMPILER in
654         *-gcc ) CC_GCC=true ;;
655         *) CC_GCC=false ;;
656       esac
657       CFLAGS='-O'
658       CPP="${CC} -E"
659       LD='ld'
660     fi
661     shift 2
662     ;;
663esac
664
665# Like WIDE_HARD in lispbibl.d
666if [ $CROSS = false ] ; then
667  if grep 'define long_bitsize 64' intparam.h > /dev/null && grep 'define long_long_bitsize 64' intparam.h > /dev/null; then
668    WIDE_HARD='true'
669  else
670    WIDE_HARD='false'
671  fi
672else
673  WIDE_HARD='false' # just a guess
674fi
675
676if [ "${with_gmalloc}" = yes ]; then GMALLOC=gmalloc; else GMALLOC=""; fi
677
678if [ $CROSS = true ] ; then
679  # We can cross-compile only with GCC
680  XCC=${COMPILER}  # ${TSYS}-gcc
681  XCPP="${XCC} -E"
682  XCPPFLAGS=''
683  XCFLAGS=''
684  XLDFLAGS=''
685  XCC_GCC=true
686  XCC_NEED_DEEMA=false
687else
688  TSYS="$HSYS"
689  TOS="$HOS"
690  XCC="${CC}"
691  XCPP="${CPP}"
692  XCPPFLAGS="${CPPFLAGS}"
693  XCFLAGS="${CFLAGS}"
694  XLDFLAGS="${LDFLAGS}"
695  XCC_GCC="${CC_GCC}"
696  XCC_NEED_DEEMA="${CC_NEED_DEEMA}"
697fi
698
699if [ "${with_dynamic_modules}" = default ]; then
700  # if --with-dynamic-modules is not supplied:
701  # C=yes, C++=no because of symbol mangling:
702  # ;; Loading module libsvm from lib-FOO.so
703  # SYSTEM::DYNLOAD-MODULES: "dlsym"("module__FOO__init_function_1") ->
704  # "lib-FOO.so: undefined symbol: module__FOO__init_function_1"
705  # $ nm lib-FOO.so | grep module__FOO__init_function_1
706  # 000008f8 T _Z31module__FOO__init_function_1P8module_t
707  if [ "${CC_CPLUSPLUS}" = true ]; then
708    with_dynamic_modules=no
709  else
710    # - Don't enable dynamic modules by default on AIX.
711    #   libtool's archive_cmds variable is empty on AIX.
712    #   Cf. <https://sourceforge.net/p/clisp/bugs/726/>
713    # - Don't enable dynamic modules by default on HP-UX.
714    #   See the comment regarding HAVE_DYNLOAD in unix.d.
715    if [ $CROSS = false ] ; then
716      case "$host_os" in
717        aix* | hpux*) with_dynamic_modules=no ;;
718        *)            with_dynamic_modules=yes ;;
719      esac
720    else
721      with_dynamic_modules=yes
722    fi
723  fi
724elif [ "${with_dynamic_modules}" = yes -a "${CC_CPLUSPLUS}" = true ]; then
725  fail "dynamic modules do not work with C++ because of symbol mangling"
726fi
727
728# now set appropriate MSVC cflags
729if [ $TSYS = win32msvc ] ; then
730  # -G5 means to optimize for i586.
731  # "-Od -Z7" means to compile for debugging.
732  # "-O1" means to optimize on msvc4,
733  # "-Os -Oy -Ob1 -Gs -Gf -Gy" means to optimize on msvc5+
734  # ("-O1" and "-O2" are buggy in msvc5 ... msvc7).
735  # -Zi - include debug info (-ZI for debug-and-continue)
736  # -GZ - runtime debug checks
737  case $COMPILER in
738    msvc6 | msvc7)
739      if [ "${with_debug}" = no ] ; then
740        CFLAGS=${CFLAGS}" -G5 -Os -Oy -Ob1 -Gs -Gf -Gy"
741      else
742        CFLAGS=${CFLAGS}" -Zi -Od -GZ"
743      fi
744      ;;
745    *) fail "unsupported compiler [${COMPILER}]"
746      ;;
747  esac
748fi
749
750if [ "$srcdir" = . ] ; then
751  SRCDIR=''
752else
753  SRCDIR="${srcdir}/"
754fi
755
756# SRCTOPDIR is the parent directory of $srcdir, ending in a slash.
757case "$srcdir" in
758  *"/src" ) SRCTOPDIR=`echol "$srcdir" | sed -e 's,src$,,'` ;;
759  "." )     SRCTOPDIR="../" ;;
760  * )       SRCTOPDIR="$srcdir/../" ;;
761esac
762case "$SRCTOPDIR" in
763  /*) PARENT_SRCTOPDIR="${SRCTOPDIR}" ;;
764  *)  PARENT_SRCTOPDIR="../${SRCTOPDIR}" ;;
765esac
766
767RECOMPILEDIR=stage
768TESTSDIR=tests
769SACLATESTSDIR=sacla-tests
770ANSITESTSDIR=ansi-tests
771BENCHDIR=benchmarks
772
773# Main host OS dependencies:
774
775# DOS-style filenames and file utilities
776H_DOS="false"
777test $HOS = win32 -a $HSYS != win32gcc && H_DOS="true"
778
779# HEXE = extension for executable files on host
780if [ $HOS = win32 ] ; then
781  HEXE='.exe'
782else
783  HEXE=''
784fi
785
786# make sure the Darwin foo.dSYM directories are removed by clean et al
787# exefile: list of files generated by compilation
788#   ("foo.exe" or "foo" or "foo foo.dSYM")
789# EXERM: make variable that will remove the above
790#   (RMRF on darwin because dSYM is a directory, RM otherwise)
791if [ $HSYSOS = darwin ]; then
792  exefiles () {
793    echo $1 $1.dSYM
794  }
795  EXERM=RMRF
796else
797  exefiles () {
798    echo $1${HEXE}
799  }
800  EXERM=RM
801fi
802
803# HERE = prefix to ensure that executables are looked up in current directory
804HERE='./'
805
806# PREFIX = prefix for installation directories
807# (This should not end in a backslash. Add a space to avoid this.)
808if [ $HOS = unix ] ; then
809  test -n "$prefix" ||
810    prefix='@prefix@' # usually '/usr/local'
811  PREFIX="${prefix}"
812else
813  PREFIX=''
814fi
815
816# EXEC_PREFIX = prefix for architecture dependent installation directories
817brace_to_paren='s,\${\([^{}]*\)},$(\1),g'
818if [ $HOS = unix ] ; then
819  test -n "$exec_prefix" ||
820    exec_prefix='@exec_prefix@' # usually '${prefix}'
821  EXEC_PREFIX=`echo "$exec_prefix" | sed -e "$brace_to_paren"`
822else
823  EXEC_PREFIX='$(prefix)'
824fi
825
826# PARENT = piece of path for parent directory
827# NEXT = piece of path for next subdirectory
828# PARENT, NEXT: For interpretation by CLISP.
829# PARENT_, NEXT_: For interpretation by the system's shell (called by make).
830# PARENT_M, NEXT_M: For interpretation by the make program.
831PARENT='../'
832NEXT='/'
833if [ $H_DOS = "true" ] ; then
834  # Replace '/' with '\':
835  PARENT_=`echol $PARENT | sed -e 's,/,\\\\,g'`
836  NEXT_=`echol $NEXT | sed -e 's,/,\\\\,g'`
837else
838  PARENT_=$PARENT
839  NEXT_=$NEXT
840fi
841# Replace '\' with '\\':
842#PARENT_2=`echol $PARENT_ | sed -e 's,\\\\,\\\\\\\\,g'`
843if [ $HSYS = win32gcc ] ; then
844  PARENT_M="$PARENT"
845  NEXT_M="$NEXT"
846else
847  PARENT_M="$PARENT_"
848  NEXT_M="$NEXT_"
849fi
850
851# Various other installation directories.
852if [ $HOS = unix ] ; then
853  test -n "$bindir" || bindir='@bindir@' # usually '${exec_prefix}/bin'
854  BINDIR=`echo "$bindir" | sed -e "$brace_to_paren"`
855else
856  bindir="\$(exec_prefix)${NEXT_}bin"
857  BINDIR="$bindir"
858fi
859if [ $HOS = unix ] ; then
860  test -n "$libdir" || libdir='@libdir@' # usually '${exec_prefix}/lib'
861  LIBDIR=`echo "$libdir" | sed -e "$brace_to_paren"`
862else
863  libdir="\$(exec_prefix)${NEXT_}lib"
864  LIBDIR="$libdir"
865fi
866if [ $HOS = unix ] ; then
867  test -n "$includedir" || includedir='@includedir@' # '${prefix}/include'
868  INCLUDEDIR=`echo "$includedir" | sed -e "$brace_to_paren"`
869else
870  includedir="\$(prefix)${NEXT_}include"
871  INCLUDEDIR="$includedir"
872fi
873if [ $HOS = unix ] ; then
874  test -n "$datarootdir" || datarootdir='@datarootdir@' # '${prefix}/share'
875  DATAROOTDIR=`echo "$datarootdir" | sed -e "$brace_to_paren"`
876else
877  datarootdir="\$(prefix)${NEXT_}share"
878  DATAROOTDIR="$datarootdir"
879fi
880if [ $HOS = unix ] ; then
881  test -n "$localedir" || localedir='@localedir@' # '${datarootdir}/locale'
882  LOCALEDIR=`echo "$localedir" | sed -e "$brace_to_paren"`
883else
884  localedir="\$(datarootdir)${NEXT_}locale"
885  LOCALEDIR="$localedir"
886fi
887if [ -z "$fsstnd" ]; then       # default fsstnd depends on the OS
888  case ${TSYSOS} in
889    cygwin | win32gcc )  fsstnd=redhat; ;; # cygwin == redhat!
890    *bsd|dragonfly ) fsstnd=bsd; ;;
891    linux )
892      if test -r /etc/lsb-release; then
893        . /etc/lsb-release;
894        case "${DISTRIB_ID}" in
895          *buntu | Debian | Slackware ) fsstnd=debian; ;;
896          Fedora | Redhat ) fsstnd=redhat; ;;
897          SuSE ) fsstnd=suse; ;;
898          * )  fsstnd=gnu_ext; ;;
899        esac
900      elif test -r /etc/redhat-release; then
901        fsstnd=redhat
902      else
903        fsstnd=gnu_ext
904      fi ;;
905    * )  fsstnd=gnu_ext; ;;
906  esac
907  test "${verbose}" = true -o "${verbose}" = yes && \
908    echo "inferred: fsstnd = $fsstnd" >&2
909fi
910
911# An explicitly given --docdir overrides the implied value from fsstnd,
912# and the implied value from fsstnd overrides the default.
913if [ -z "$docdir" ] ; then
914  if [ $HOS = unix ] ; then
915    docdir='@docdir@' # usually '${datarootdir}/doc/${PACKAGE_TARNAME}'
916    if [ "$docdir" = '${datarootdir}/doc/${PACKAGE_TARNAME}' ] ; then
917      docdir=
918    else
919      PACKAGE_TARNAME=clisp ; eval docdir=\"$docdir\"
920    fi
921    DOCDIR=`echo "$docdir" | sed -e "$brace_to_paren"`
922  fi
923  if [ -z "$docdir" ] ; then
924    case "$fsstnd" in
925      suse)
926        docdir="\$(datarootdir)${NEXT_}doc${NEXT_}packages${NEXT_}clisp"
927        ;;
928      redhat)
929        docdir="\$(datarootdir)${NEXT_}doc${NEXT_}\$(TOPDIR)"
930        ;;
931      debian | gnu_ext | *bsd | dragonfly)
932        docdir="\$(datarootdir)${NEXT_}doc${NEXT_}clisp"
933        ;;
934    esac
935    DOCDIR="$docdir"
936  fi
937else
938  DOCDIR="$docdir"
939fi
940if [ $HOS = unix ] ; then
941  test -n "$mandir" || mandir='@mandir@' # usually '${datarootdir}/man'
942  MANDIR=`echo "$mandir" | sed -e "$brace_to_paren"`
943else
944  mandir="\$(datarootdir)${NEXT_}man"
945  MANDIR="$mandir"
946fi
947if [ $HOS = unix ] ; then
948  test -n "$htmldir" || htmldir='@htmldir@' # usually '${docdir}'
949  HTMLDIR=`echo "$htmldir" | sed -e "$brace_to_paren"`
950else
951  htmldir="\$(docdir)"
952  HTMLDIR="$htmldir"
953fi
954if [ $HOS = unix ] ; then
955  test -n "$dvidir" || dvidir='@dvidir@'
956  DVIDIR=`echo "$dvidir" | sed -e "$brace_to_paren"`
957else
958  dvidir="\$(docdir)"
959  DVIDIR="$dvidir"
960fi
961if [ $HOS = unix ] ; then
962  test -n "$psdir" || psdir='@psdir@' # usually '${docdir}'
963  PSDIR=`echo "$psdir" | sed -e "$brace_to_paren"`
964else
965  psdir="\$(docdir)"
966  PSDIR="$psdir"
967fi
968if [ $HOS = unix ] ; then
969  test -n "$pdfdir" || pdfdir='@pdfdir@' # usually '${docdir}'
970  PDFDIR=`echo "$pdfdir" | sed -e "$brace_to_paren"`
971else
972  pdfdir="\$(docdir)"
973  PDFDIR="$pdfdir"
974fi
975if [ $HOS = unix ] ; then
976  test -n "$elispdir" || elispdir='${datarootdir}/emacs/site-lisp'
977  ELISPDIR=`echo "$elispdir" | sed -e "$brace_to_paren"`
978else
979  elispdir="\$(datarootdir)/emacs/site-lisp"
980  ELISPDIR="$elispdir"
981fi
982vimdir_default='vim/vimfiles/after/syntax'
983if [ $HOS = unix ] ; then
984  test -n "$vimdir" || vimdir='${datarootdir}/'${vimdir_default}
985  VIMDIR=`echo "$vimdir" | sed -e "$brace_to_paren"`
986else
987  vimdir="\$(datarootdir)/${vimdir_default}"
988  VIMDIR="$vimdir"
989fi
990aclocaldir_default='aclocal'
991if [ $HOS = unix ] ; then
992  test -n "$aclocaldir" || aclocaldir='${datarootdir}/'${aclocaldir_default}
993  ACLOCALDIR=`echo "$aclocaldir" | sed -e "$brace_to_paren"`
994else
995  aclocaldir="\$(datarootdir)/${aclocaldir_default}"
996  ACLOCALDIR="$aclocaldir"
997fi
998
999if [ $H_DOS = "true" ] ; then
1000  # Replace '/' with '\':
1001  SRCTOPDIR_=`echol ${SRCTOPDIR} | sed -e 's,/,\\\\,g'`
1002  PARENT_SRCTOPDIR_=`echol ${PARENT_SRCTOPDIR} | sed -e 's,/,\\\\,g'`
1003else
1004  SRCTOPDIR_=$SRCTOPDIR
1005  PARENT_SRCTOPDIR_=${PARENT_SRCTOPDIR}
1006fi
1007if [ $HSYS = win32gcc ] ; then
1008  SRCTOPDIR_M="$SRCTOPDIR"
1009  PARENT_SRCTOPDIR_M="${PARENT_SRCTOPDIR}"
1010else
1011  SRCTOPDIR_M="$SRCTOPDIR_"
1012  PARENT_SRCTOPDIR_M="${PARENT_SRCTOPDIR_}"
1013fi
1014UTILDIR="${SRCTOPDIR}utils${NEXT}"
1015UTILDIR_="${SRCTOPDIR_}utils${NEXT_}"
1016UTILDIR_M="${SRCTOPDIR_M}utils${NEXT_M}"
1017SRCDOCDIR="${SRCTOPDIR}doc${NEXT}"
1018SRCDOCDIR_="${SRCTOPDIR_}doc${NEXT_}"
1019SRCDOCDIR_M="${SRCTOPDIR_M}doc${NEXT_M}"
1020MODULESDIR="${SRCTOPDIR}modules${NEXT}"
1021MODULESDIR_="${SRCTOPDIR_}modules${NEXT_}"
1022MODULESDIR_M="${SRCTOPDIR_M}modules${NEXT_M}"
1023
1024if [ $CROSS = false -a $HSYS = win32msvc ] ; then
1025  NEXT_CC="$NEXT_"
1026  UTILDIR_CC="$UTILDIR_"
1027else
1028  NEXT_CC="$NEXT"
1029  UTILDIR_CC="$UTILDIR"
1030fi
1031
1032# RM = command for deleting files; RMRF - recursively
1033if [ $H_DOS = "true" ] ; then
1034  RM='del /q'
1035  RMRF='del /q /s'
1036else
1037  RM='rm -f'
1038  RMRF='rm -rf'
1039fi
1040
1041# CP = command for copying files
1042if [ $H_DOS = "true" ] ; then
1043  CP='copy'
1044# else see above
1045fi
1046
1047# LN_S = command for copying read-only files
1048if [ $H_DOS = "true" ] ; then
1049  LN_S='copy'
1050else
1051  # Set by configure, above.
1052  # On mingw in the Cygwin environment, the built native Windows programs don't
1053  # understand the symlinks created by Cygwin's 'ln -s'. Therefore avoid
1054  # creating such symlinks.
1055  case "$host_os" in
1056    mingw*) LN_S=${LN-ln} ;;
1057  esac
1058fi
1059
1060# LN_HARD = command for copying files, saving disk space if possible
1061LN_HARD=${LN-ln}
1062
1063# HLN = command for making hard links ($HOS = unix only)
1064if [ "$HLN" = hln ] ; then
1065  HLN="`pwd`/hln"
1066fi
1067
1068# MV = command for renaming files
1069if [ $H_DOS = "true" ] ; then
1070  MV='ren'
1071else
1072  MV='mv'
1073fi
1074
1075# CAT = command for typing files to stdout
1076if [ $H_DOS = "true" ] ; then
1077  CAT='type'
1078else
1079  CAT='cat'
1080fi
1081
1082# TOUCH = command for pretending files are new
1083TOUCH='touch'
1084
1085# GREP = command for filtering text according to regular expressions
1086GREP='grep'
1087
1088# SED = command for filtering text according to a script
1089SED='sed'
1090
1091# RANLIB = command for finishing libraries
1092if [ -z "${RANLIB}" ] ; then RANLIB='ranlib'; fi
1093
1094# INSTALL = command for installing binaries/data
1095if [ -z "$INSTALL" ] ; then
1096  INSTALL=$CP
1097  INSTALL_PROGRAM='$(INSTALL)'
1098  INSTALL_DATA='$(INSTALL)'
1099fi
1100
1101# Main target OS dependencies:
1102
1103OS_INCLUDES=''
1104if [ "$TSYSOS" = osf1 ] ; then
1105  # On OSF/1 4.0, libtool adds -lc, but this -lc flag causes link errors when
1106  # comes anywhere except at the end of the link command line, complaining
1107  # about _OtsDivide32, __lc_ctype and others.
1108  remove_lc () { echo " $1 " | sed -e 's, -lc ,,g' -e 's,^ ,,' -e 's, $,,'; }
1109  LIBICONV=$(remove_lc " $LIBICONV ")
1110  LIBINTL=$(remove_lc " $LIBINTL ")
1111  LIBSIGSEGV=$(remove_lc " $LIBSIGSEGV ")
1112  LIBUNISTRING=$(remove_lc " $LIBUNISTRING ")
1113  LIBSOCKET=$(remove_lc " $LIBSOCKET ")
1114fi
1115if [ $TSYS = master -o $TOS = unix ] ; then
1116  OS_INCLUDES=$OS_INCLUDES' unix'
1117  LIBS=$LIBS" $LIBICONV $LIBSIGSEGV $LIBUNISTRING"
1118fi
1119if [ $TSYS = master -o $TOS = win32 ] ; then
1120  OS_INCLUDES=$OS_INCLUDES' win32'
1121  if [ $TSYS = win32gcc ] ; then
1122    LIBS=$LIBS" -luser32 -lole32 -loleaut32 -luuid $LIBICONV $LIBSIGSEGV $LIBUNISTRING"
1123  else
1124    if [ $TSYS = win32msvc ] ; then
1125      LIBS=$LIBS" user32.lib ws2_32.lib advapi32.lib $LIBSIGSEGV $LIBUNISTRING"
1126    fi
1127    LIBS=$LIBS' ole32.lib shell32.lib'
1128  fi
1129fi
1130if [ $TSYS = master -o $TOS = unix -o $TOS = win32 ] ; then
1131  OS_INCLUDES=$OS_INCLUDES' xthread'
1132fi
1133
1134# TEXE = extension for executable files on target
1135# LEXE = extension for executable file LISP on target
1136# SHREXT = extension for shared object files (a.k.a. shared libraries) on target
1137PWD_POSTPROC=''
1138if [ ${TOS} = win32 -o ${HSYSOS} = cygwin ] ; then
1139  TEXE='.exe'
1140  LEXE='.exe'
1141  SHREXT='.dll'
1142  # no path conversion on msys
1143  # http://thread.gmane.org/gmane.comp.gnu.mingw.msys/1707/
1144  # https://sourceforge.net/p/mingw/mailman/mingw-msys/thread/4B9FD2A4.2050805@gnu.org/
1145  # http://stackoverflow.com/questions/12015348/msys-path-conversion-or-cygpath-for-msys
1146  if cygpath -v > /dev/null 2>&1; then
1147    PWD_POSTPROC='cygpath -m'
1148  fi
1149else
1150  TEXE=''
1151  LEXE='.run'
1152  case "$host_os" in
1153    darwin*) SHREXT='.dylib' ;;
1154    hpux*)   SHREXT='.sl' ;;
1155    *)       SHREXT='.so' ;;
1156  esac
1157fi
1158HEREP=`pwd`
1159test -n "${PWD_POSTPROC}" && HEREP=`${PWD_POSTPROC} ${HEREP}`
1160HERE_="${HEREP}${NEXT_}"
1161
1162# for systems that lack stdint (or have a broken stdint) (e.g., solaris[89])
1163# gllib path must be absolute because CPPFLAGS is passed on to module subdirs
1164# cf m4/clisp.m4: GNULIB_INCLUDE must contain no colons
1165x=${HEREP}; GNULIB_INCLUDE="-I$(@CLISP_DECOLONIZE@)/gllib"
1166if [ -n "${SRCDIR}" ] ; then
1167  x=`cd ${SRCDIR} && pwd`;
1168  test -n "${PWD_POSTPROC}" && x=`${PWD_POSTPROC} ${x}`
1169  x="$(@CLISP_DECOLONIZE@)"
1170  XCPPFLAGS="${XCPPFLAGS} -I$x"
1171  GNULIB_INCLUDE="${GNULIB_INCLUDE} -I$x/gllib"
1172fi
1173CPPFLAGS="${CPPFLAGS} ${GNULIB_INCLUDE}"
1174XCPPFLAGS="${XCPPFLAGS} ${GNULIB_INCLUDE}"
1175
1176# TOBJ = extension for compiled modules on target
1177if [ $TSYS = win32msvc ] ; then
1178  TOBJ='.obj'
1179  OUT='/link /out:'
1180else
1181  TOBJ='.o'
1182  OUT='-o '
1183fi
1184
1185# Main cpu dependencies:
1186cpu="${host_cpu_c_abi}"
1187if test -z "$cpu"; then
1188  echo "$0: WARNING: host_cpu_c_abi is void; using host_cpu=${host_cpu}" >&2
1189  cpu="${host_cpu}"
1190fi
1191
1192test "${verbose}" = true -o "${verbose}" = yes && \
1193  cat <<EOF >&2
1194EXPORT_DYNAMIC_FLAG_SPEC=${EXPORT_DYNAMIC_FLAG_SPEC}
1195module_configure_flags=${module_configure_flags}
1196# host system:
1197 hostname = "${hostname}"
1198     HSYS = "${HSYS}"
1199   HSYSOS = "${HSYSOS}"
1200      HOS = "${HOS}"
1201 host_cpu = "${host_cpu}"
1202 host_ABI = "${host_cpu_c_abi}"
1203      cpu = "${cpu}"
1204  host_os = "${host_os}"
1205     host = "${host}"
1206# target system:
1207     TSYS = "${TSYS}"
1208   TSYSOS = "${TSYSOS}"
1209      TOS = "${TOS}"
1210EOF
1211# e.g.:
1212### msys/mingw
1213# # host system:
1214#   hostname = "stnt067"
1215#       HSYS = "win32gcc"
1216#     HSYSOS = "win32gcc"
1217#        HOS = "win32"
1218#   host_cpu = "i686"
1219#        cpu = "i386"
1220#    host_os = "mingw32"
1221#       host = "i686-pc-mingw32"
1222# # target system:
1223#       TSYS = "win32gcc"
1224#     TSYSOS = "win32gcc"
1225#        TOS = "win32"
1226### cygwin/--with-mingw
1227# # host system:
1228#  hostname = "nyc-qsv-term01"
1229#      HSYS = "win32gcc"
1230#    HSYSOS = "win32gcc"
1231#       HOS = "win32"
1232#  host_cpu = "i686"
1233#       cpu = "i386"
1234#   host_os = "cygwin"
1235#      host = "i686-pc-cygwin"
1236# # target system:
1237#      TSYS = "win32gcc"
1238#    TSYSOS = "win32gcc"
1239#       TOS = "win32"
1240### cygwin
1241# # host system:
1242#  hostname = "nyc-qsv-term01"
1243#      HSYS = "i686"
1244#    HSYSOS = "cygwin"
1245#       HOS = "unix"
1246#  host_cpu = "i686"
1247#       cpu = "i386"
1248#   host_os = "cygwin"
1249#      host = "i686-pc-cygwin"
1250# # target system:
1251#      TSYS = "i686"
1252#    TSYSOS = "cygwin"
1253#       TOS = "unix"
1254### linux
1255# # host system:
1256#  hostname = "nyc-qws-005"
1257#      HSYS = "x86_64"
1258#    HSYSOS = "linux"
1259#       HOS = "unix"
1260#  host_cpu = "x86_64"
1261#       cpu = "x86_64"
1262#   host_os = "linux-gnu"
1263#      host = "x86_64-unknown-linux-gnu"
1264# # target system:
1265#      TSYS = "x86_64"
1266#    TSYSOS = "linux"
1267#       TOS = "unix"
1268
1269# Main compiler dependencies:
1270
1271if [ $XCC_GCC = true ] ; then
1272  XCC_SUNPRO=false
1273  # Recognize clang. It disguises as GCC.
1274  if LC_ALL=C $XCC --version | grep 'Apple LLVM' > /dev/null; then
1275    XCC_BRAND=clang
1276  else
1277    XCC_BRAND=`LC_ALL=C $XCC --version | sed -e '2,$d' -e 's/ .*//'` # either gcc or clang
1278  fi
1279  XCC_GCC_VERSION=`LC_ALL=C $XCC -v 2>&1 | grep version | sed -n -e '$p' | sed -e 's/.*version //g' -e 's/gcc //'`
1280  # Assume gcc 2.95 or newer.
1281  # Diagnostic flags:
1282  # Syntax errors at identifiers that are produced by macro expansion
1283  # (e.g. at 'local', which expands to 'static') are shown with the
1284  # location of the macro only, in gcc 5.x at least, which is confusing.
1285  # Use option '-no-integrated-cpp' to provide better syntax error reporting.
1286  if [ "$XCC_BRAND" = gcc ] ; then
1287    case "$XCC_GCC_VERSION" in
1288      2.* | 3.* | 4.[0-7]*) ;;
1289      *)
1290        XCFLAGS=$XCFLAGS' -no-integrated-cpp'
1291        ;;
1292    esac
1293  fi
1294  # Warnings flags:
1295  XCFLAGS=${XCFLAGS}' -W -Wswitch -Wcomment -Wpointer-arith -Wreturn-type'
1296  if [ $CC_CPLUSPLUS = false ] ; then
1297    XCFLAGS=${XCFLAGS}' -Wmissing-declarations -Wimplicit'
1298  fi
1299  # gcc 2.7 introduced an annoying warning, but gcc 2.8 has a workaround:
1300  XCFLAGS=$XCFLAGS' -Wno-sign-compare -Wno-format-nonliteral'
1301  # clisp assumes two's complement arithmetic, therefore disable
1302  # "warning: left shift of negative value".
1303  # https://gcc.gnu.org/ml/gcc-patches/2015-04/msg01353.html
1304  if [ $CROSS = false ] ; then
1305    case "$XCC_GCC_VERSION" in
1306      2.* | 3.* | 4.* | 5.*) ;;
1307      *)
1308        XCFLAGS=$XCFLAGS' -Wno-shift-negative-value'
1309        ;;
1310    esac
1311  fi
1312  if [ $CROSS = false -a $CC_CPLUSPLUS = true ] ; then
1313    # g++ 3.4 introduced an annoying warning, but has a workaround:
1314    case "$XCC_GCC_VERSION" in
1315      2.* | 3.[1-3]*) ;;
1316      *)
1317        XCFLAGS=$XCFLAGS' -Wno-invalid-offsetof'
1318        ;;
1319    esac
1320  fi
1321  # Code generation flags:
1322  # Select optimizations.
1323  if [ "${with_debug}" = no ] ; then
1324    if [ "$cpu" = i386 ] ; then
1325      XCFLAGS=$XCFLAGS' -O2 -fexpensive-optimizations'
1326    elif [ "$cpu" = sparc ] ; then
1327      XCFLAGS=$XCFLAGS' -O2'
1328    elif [ "$cpu" = sparc64 ] ; then
1329      # gcc-3.3.1 produces incorrect code when -O2 is used, even with
1330      # -fno-schedule-insns and -fno-gcse.
1331      XCFLAGS=$XCFLAGS' -O'
1332    elif [ "$cpu" = x86_64 ] ; then
1333      # gcc-3.2.2 produces incorrect code when -O2 is used.
1334      XCFLAGS=$XCFLAGS' -O'
1335    else
1336      XCFLAGS=$XCFLAGS' -O2'
1337    fi
1338    # For platforms that use global register variables...
1339    case "$cpu" in
1340      m68k | i386 | sparc | sparc64 | hppa | arm | armhf | alpha | s390*)
1341        if [ $CROSS = false ] ; then
1342          case "$XCC_GCC_VERSION" in
1343            3.1*)
1344              # gcc-3.1 produces incorrect code when compiling record
1345              # (function C_make_instance).
1346              XCFLAGS=$XCFLAGS' -fno-gcse' ;;
1347          esac
1348        fi
1349        ;;
1350    esac
1351  fi # with_debug
1352  # clisp assumes two's complement arithmetic. Therefore use -fwrapv.
1353  # No need to use -fno-strict-overflow, since we only need to disable
1354  # strict overflow rules for integer types, not for pointer types, and
1355  # for integer types it's already implied by -fwrapv.
1356  if [ $CROSS = false ] ; then
1357    case "$XCC_GCC_VERSION" in
1358      2.* | 3.[1-3]*) ;;
1359      *)
1360        XCFLAGS=$XCFLAGS' -fwrapv'
1361        ;;
1362    esac
1363  fi
1364  # On arm64, gcc 4.8.4 with binutils 2.24 produces code that, when TYPECODES
1365  # is used, leads to a link error when linking lisp.run:
1366  #   relocation truncated to fit: R_AARCH64_ADR_PREL_PG_HI21 against symbol `symbol_tab_data' defined in .data section in spvwtabs.o
1367  # The option -fPIC is a workaround.
1368  if [ "$cpu" = arm64 ] ; then
1369    XCFLAGS=$XCFLAGS' -fPIC'
1370  fi
1371  if [ $TSYS = win32gcc ] ; then
1372    XCFLAGS=$XCFLAGS' -D_WIN32'
1373  fi
1374  if [ $TSYS = sun4 ] ; then
1375    XCLFLAGS='-static'
1376  else
1377    XCLFLAGS=''
1378  fi
1379  # Override any "-x c++" options which may be present in $XCC or $XCFLAGS.
1380  XCLFLAGS="$XLDFLAGS $XCLFLAGS"
1381  XCC_NOOPTFLAGS=' -O0'
1382
1383  if [ "${with_threads}" = "POSIX_THREADS" ]; then
1384    XCFLAGS=${XCFLAGS}" -pthread"
1385  fi
1386
1387else
1388
1389  if [ $CROSS = false ] ; then
1390    # Detect SUNWspro C compiler - defines __SUNPRO_C
1391    XCC_SUNPRO=${CC_SUNPRO}
1392  else
1393    XCC_SUNPRO=false
1394  fi
1395  if [ $TSYS = win32msvc ] ; then
1396    XCPP="cl -E"
1397    case ${COMPILER} in
1398      msvc6) XCPP="$XCPP -D_MSC_VER=1200 -D_INTEGRAL_MAX_BITS=64"
1399        ;;
1400      msvc7) XCPP="$XCPP -D_MSC_VER=1300 -D_INTEGRAL_MAX_BITS=64 -I\$(MSVCDIR)/PlatformSDK/include"
1401        ;;
1402      *) fail "unsupported compiler [${COMPILER}]"
1403        ;;
1404    esac
1405    XCFLAGS="$CFLAGS -U__GNUC__ -DANSI -D_M_IX86=500 -D_WIN32 -I\$(MSVCDIR)/include"
1406  elif "$XCC_SUNPRO" ; then
1407    # SUNWspro cc flags:
1408    XCFLAGS=${XCFLAGS}' -xO3 -xstrconst'
1409  elif [ "$HSYSOS" = hp-ux -o $TSYS = sun4 ] ; then
1410    # HP's HPPA compilers crash when optimizing.
1411    # SUN's cc is buggy when optimizing spvw.d, even with only -O1.
1412    # we do not reset XCFLAGS so that the user can pass -xarch=v8 et al
1413    # XCFLAGS=''
1414    :
1415  else
1416    XCFLAGS=${XCFLAGS}' -O'
1417  fi
1418  case "$host_os" in
1419    hpux*)
1420      # HP's C compiler (HP C B.11.11.24 on hppa) crashes when compiling
1421      # stream.d with -g. So remove -g if it was specified.
1422      XCFLAGS=`echo " $XCFLAGS " | sed -e 's/ -g //' -e 's/^ *//' -e 's/ *$//'`
1423      ;;
1424  esac
1425  XCLFLAGS=''
1426  if [ $TSYS = sun4 ] ; then
1427    XCFLAGS=$XCFLAGS' -dalign'
1428    if [ $CC_CPLUSPLUS = false ] ; then
1429      XCFLAGS=$XCFLAGS' -fsingle'
1430    fi
1431    XCLFLAGS=$XCLFLAGS' -Bstatic'
1432  fi
1433  XCC_NOOPTFLAGS=''
1434
1435fi
1436
1437# Relocatable machine pointers are machine pointers that are visible to the GC.
1438# In the HEAPCODES object representation, they must satisfy alignment
1439# constraints. When these constraints are not defined, we run into
1440#   C_CODE_ALIGNMENT is wrong. &equal = 0x4c8de7.
1441# This can happen
1442# - with gcc on Linux, when not optimizing,
1443# - with Apple's gcc 4 on MacOS X,
1444# - with gcc >= 4 when "gcc -Os" is used,
1445# - with clang when "clang -Os" is used.
1446# gcc has an option to fix this. clang 3.9 doesn't.
1447if [ $XCC_GCC = true ] && [ "$XCC_BRAND" != clang ] ; then
1448  if $WIDE_HARD; then
1449    # GENERIC64C_HEAPCODES requires an 8-byte alignment of all C functions
1450    # that are used as relocatable machine pointers.
1451    FALIGNFLAGS='-falign-functions=8'
1452  else
1453    if [ "$cpu" = arm -o "$cpu" = armhf ] ; then
1454      # On ARM, function pointer alignment depends on the arm/thumb mode:
1455      # C_CODE_ALIGNMENT is 4 with -marm, but only 1 with -mthumb.
1456      XCFLAGS=${XCFLAGS}' -marm'
1457      FALIGNFLAGS=''
1458    else
1459      FALIGNFLAGS='-falign-functions=4'
1460    fi
1461  fi
1462else
1463  FALIGNFLAGS=''
1464fi
1465
1466# We access the same memory through pointers of different types, for example
1467# as TheVarobject(obj)->..., TheRecord(obj)->..., TheInstance(obj)->... .
1468# This violates the strict type-based aliasing rules of C. In other words, we
1469# still use C as a portable assembler, but now the compilers want to outsmart
1470# us. There are two ways to tell them not to do this: to use union types, or
1471# specific compiler options. I prefer to do it through compiler options.
1472if [ $XCC_GCC = true ] ; then
1473  XCFLAGS=$XCFLAGS' -fno-strict-aliasing'
1474else
1475  if [ "$HSYSOS" = aix ] ; then # for xlc
1476    XCFLAGS=$XCFLAGS' -qalias=noansi'
1477  fi
1478  if "$XCC_SUNPRO" ; then # for SUNWspro cc
1479    XCFLAGS=$XCFLAGS' -xalias_level=weak'
1480  fi
1481fi
1482
1483if [ "${with_dynamic_modules}" != no ]; then # not on msvc
1484  # Support for dynamic loading.
1485  eval "`./libtool --tag=CC --config | grep '^pic_flag='`"
1486  eval XCC_PICFLAG=\"${pic_flag}\"
1487  if [ "$HSYSOS" != cygwin ]; then
1488    eval "`./libtool --tag=CC --config | grep '^allow_undefined_flag='`"
1489    eval "`./libtool --tag=CC --config | grep '^archive_cmds='`"
1490  else
1491    archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags -o $output_objdir/$soname'
1492  fi
1493  # http://article.gmane.org/gmane.comp.shells.bash.bugs:17158
1494  # http://lists.gnu.org/archive/html/bug-bash/2011-08/msg00280.html
1495  CC_set=${CC+set}
1496  CC_save=$CC
1497  CC='${CC}' libobjs='$libs' deplibs='${CLFLAGS}' compiler_flags='${CFLAGS}' \
1498    soname='$dll' lib='$lib' output_objdir='$dyndir' \
1499    eval XCC_CREATESHARED=\"${archive_cmds}\"
1500  # archive_cmds can contain several commands, separated by ~.
1501  # But here we need only the first one. The second command occurs only on
1502  # Mac OS X, and is a $DSYMUTIL invocation that merely extracts debugging
1503  # information to the file system.
1504  XCC_CREATESHARED=`echo "$XCC_CREATESHARED" | sed -e 's/~.*//'`
1505  if test "$CC_set" = set
1506  then CC=$CC_save
1507  else unset CC
1508  fi
1509  test "${verbose}" = true -o "${verbose}" = yes && \
1510    echo "XCC_CREATESHARED = ${XCC_CREATESHARED}" >&2
1511fi
1512
1513if [ "${with_debug}" != no ] ; then
1514  if [ $TSYS = sun4 -a $XCC_GCC = true ] ; then
1515    XCFLAGS=$XCFLAGS' -gstabs'
1516  elif [ ${HSYS} != "win32msvc" ]; then
1517    XCFLAGS=$XCFLAGS' -ggdb -O0'
1518  fi
1519  XCFLAGS=$XCFLAGS' -DDEBUG_OS_ERROR -DDEBUG_SPVW -DDEBUG_BYTECODE -DSAFETY=3'
1520  case "$CC" in
1521    *"g++"* ) XCFLAGS=$XCFLAGS' -DDEBUG_GCSAFETY'; ;;
1522  esac
1523fi
1524
1525if [ $CC_CPLUSPLUS = true -a \( ${HSYSOS} = win32gcc -o ${HSYSOS} = cygwin \) ]
1526then # This is necessary for g++ to handle w32shell.c:
1527  # The member lpVtbl is not defined by the w32api include files if
1528  #   defined(__cplusplus) && !defined(CINTERFACE)
1529  # cf <http://article.gmane.org/gmane.comp.gnu.mingw.user/8213>
1530  #    <https://sourceforge.net/p/mingw/mailman/message/14900754/>
1531  XCFLAGS=$XCFLAGS' -DCINTERFACE'
1532fi
1533
1534if [ "$cpu" = i386 -a "$TSYSOS" = "sunos" ] ; then # Solaris 2
1535  XCFLAGS=$XCFLAGS'' # maybe add -DUSL
1536fi
1537
1538# uname -r may contain arbitrary junk not suitable for pathnames:
1539# cygwin: 1.5.18(0.132/4/2)
1540UNAME_R=`uname -r | $tolower | sed 's/[^A-Za-z0-9.].*//'`
1541
1542if [ "${enable_mmap}" = no ]; then
1543  XCFLAGS=${XCFLAGS}" -DNO_SINGLEMAP -DNO_TRIVIALMAP"
1544fi
1545
1546# When to define BINARY_DISTRIB?
1547# There is no general pro or cons of distributing an executable versus a
1548# static library, except for the unavailability of the compiler and linker
1549# on some platforms.
1550# Other than that, it mostly depends on whether the host you are building
1551# on has a recent or an old set of system shared libraries. Old is better
1552# here, since vendors usually only add functions to libc and rarely remove
1553# some functions. If the host you use for the build is not the oldest OS
1554# version, then distributing the static library is better: when you distribute
1555# a Unix executable, it is _certain_ to not run on older versions of the OS
1556# (thanks to the shared library versioning check), whereas when you distribute
1557# a static library, it has good chances to link and work fine on older versions
1558# of the OS.
1559# So the general rule is:
1560#   IF platform frequently comes without compiler and linker
1561#     THEN use BINARY_DISTRIB
1562#     ELSE
1563#       IF platform has strict libc version checking
1564#         THEN use static library distribution
1565#         ELSE use BINARY_DISTRIB
1566# cf <http://article.gmane.org/gmane.lisp.clisp.devel:10411>
1567#    <https://sourceforge.net/p/clisp/mailman/message/12562837/>
1568if [ $CROSS = false ] ; then
1569  case "$host_os" in
1570    solaris*)
1571      # Newer versions of Solaris (Solaris 2.2 and newer) don't have
1572      # libdl_stubs.a any more. This means that you cannot link -static !
1573      XCLFLAGS=`echol "$XCLFLAGS" | sed -e 's/-B*static//g'`
1574      SOLARIS_LINKING=1 # Even more hacks needed??
1575      BINARY_DISTRIB=1
1576    ;;
1577    hpux*)
1578      # Newer versions of HP-UX (HP-UX 10.20 and HP-UX 11) ship with no ANSI C
1579      # compiler, only with K&R "cc" whose only use may be to bootstrap gcc.
1580      BINARY_DISTRIB=1
1581    ;;
1582    darwin*)
1583      # Douglas Philips <dgou@mac.com>:
1584      # Mac OS/X does not come with developer tools
1585      BINARY_DISTRIB=1; ;;
1586  esac
1587fi
1588test -n "$BINARY_DISTRIB" && XCFLAGS=$XCFLAGS' -DUNIX_BINARY_DISTRIB'
1589
1590
1591# Handle --enable-portability:
1592# --enable-portability disables several optimizations.
1593# --disable-portability allows these optimizations.
1594# The default is to allow those optimizations that we have tested to work fine,
1595# on a per-platform basis.
1596if [ "${enable_portability}" = no ]; then
1597  :
1598else
1599  if [ "${enable_portability}" != yes ]; then
1600    case "$host_os--$host_cpu_c_abi" in
1601      # Sort order: Keep this list sorted by
1602      #   1. word size (32-bit before 64-bit),
1603      #   2. operating system (Linux, *BSD, Mac OS X, proprietary Unices, Windows)
1604      #   3. CPU and ABI (alphabetically, x86_64 mapping to amd64, like in
1605      #      lispbibl.d and Makefile.devel)
1606
1607      # 32-bit platforms
1608
1609      # Linux/x86_64 with 32-bit x32 ABI
1610      linux*--x86_64-x32)
1611        XCFLAGS="$XCFLAGS -DNO_ASM"
1612        ;;
1613
1614      # Linux/arm
1615      linux*--arm | linux*--armhf)
1616        XCFLAGS="$XCFLAGS -DNO_ASM"
1617        ;;
1618
1619      # Linux/hppa
1620      linux*--hppa)
1621        XCFLAGS="$XCFLAGS -DNO_ASM"
1622        ;;
1623
1624      # Linux/i386
1625      linux*--i386)
1626        XCFLAGS="$XCFLAGS -DNO_ASM"
1627        ;;
1628
1629      # Linux/m68k
1630      linux*--m68k)
1631        XCFLAGS="$XCFLAGS -DNO_ASM"
1632        ;;
1633
1634      # Linux/mipseb and Linux/mipsel with o32 ABI
1635      linux*--mips)
1636        XCFLAGS="$XCFLAGS -DNO_ASM"
1637        ;;
1638
1639      # Linux/mips64eb and Linux/mips64el with n32 ABI
1640      linux*--mipsn32)
1641        XCFLAGS="$XCFLAGS -DNO_ASM"
1642        ;;
1643
1644      # Linux/powerpc64 with 32-bit ABI
1645      linux*--powerpc)
1646        XCFLAGS="$XCFLAGS -DNO_ASM"
1647        ;;
1648
1649      # Linux/s390x with 32-bit ABI
1650      linux*--s390)
1651        XCFLAGS="$XCFLAGS -DNO_ASM"
1652        ;;
1653
1654      # Linux/sparc64 with 32-bit ABI
1655      linux*--sparc)
1656        XCFLAGS="$XCFLAGS -DNO_ASM"
1657        ;;
1658
1659      # Hurd/i386
1660      gnu*--i386)
1661        XCFLAGS="$XCFLAGS -DNO_ASM"
1662        ;;
1663
1664      # FreeBSD/i386
1665      freebsd*--i386)
1666        XCFLAGS="$XCFLAGS -DNO_ASM"
1667        ;;
1668
1669      # GNU/kFreeBSD/i386
1670      kfreebsd*-gnu*--i386)
1671        XCFLAGS="$XCFLAGS -DNO_ASM"
1672        ;;
1673
1674      # DragonFly/i386
1675      dragonfly*--i386)
1676        XCFLAGS="$XCFLAGS -DNO_ASM"
1677        ;;
1678
1679      # NetBSD/i386
1680      netbsd*--i386)
1681        XCFLAGS="$XCFLAGS -DNO_ASM"
1682        ;;
1683
1684      # NetBSD/sparc
1685      netbsd*--sparc)
1686        XCFLAGS="$XCFLAGS -DNO_ASM"
1687        ;;
1688
1689      # OpenBSD/i386
1690      openbsd*--i386)
1691        XCFLAGS="$XCFLAGS -DNO_ASM"
1692        ;;
1693
1694      # Mac OS X/x86_64 with 32-bit ABI
1695      darwin*--i386)
1696        XCFLAGS="$XCFLAGS -DNO_ASM"
1697        ;;
1698
1699      # Mac OS X/PowerPC
1700      darwin*--powerpc)
1701        XCFLAGS="$XCFLAGS -DNO_ASM"
1702        ;;
1703
1704      # AIX/POWER with 32-bit ABI
1705      aix*--powerpc)
1706        XCFLAGS="$XCFLAGS -DNO_ASM"
1707        ;;
1708
1709      # HP-UX/hppa with 32-bit ABI
1710      hpux*--hppa)
1711        XCFLAGS="$XCFLAGS -DNO_ASM"
1712        ;;
1713
1714      # HP-UX/ia64 with 32-bit ABI
1715      hpux*--ia64-ilp32)
1716        XCFLAGS="$XCFLAGS -DNO_ASM"
1717        ;;
1718
1719      # IRIX 6.5 with o32 ABI
1720      irix*--mips)
1721        XCFLAGS="$XCFLAGS -DNO_ASM"
1722        ;;
1723
1724      # IRIX 6.5 with n32 ABI
1725      irix*--mipsn32)
1726        XCFLAGS="$XCFLAGS -DNO_ASM"
1727        ;;
1728
1729      # Solaris 10/x86_64 with 32-bit ABI
1730      solaris2.10--i386)
1731        XCFLAGS="$XCFLAGS -DNO_ASM"
1732        ;;
1733
1734      # Solaris 11/x86_64 with 32-bit ABI
1735      solaris2.11--i386)
1736        XCFLAGS="$XCFLAGS -DNO_ASM"
1737        ;;
1738
1739      # Solaris 10/sparc64 with 32-bit ABI
1740      solaris2.10--sparc)
1741        XCFLAGS="$XCFLAGS -DNO_ASM"
1742        ;;
1743
1744      # Haiku (32-bit)
1745      haiku*--i386) # TODO
1746        XCFLAGS="$XCFLAGS -DNO_ASM -DNO_ARI_ASM -DNO_SP_ASM"
1747        XCFLAGS="$XCFLAGS -DNO_FAST_DISPATCH"
1748        XCFLAGS="$XCFLAGS -DNO_FAST_FLOAT -DNO_FAST_DOUBLE"
1749        XCFLAGS="$XCFLAGS -DNO_ALLOCA"
1750        XCFLAGS="$XCFLAGS -DNO_ADDRESS_SPACE_ASSUMPTIONS"
1751        XCFLAGS="$XCFLAGS -DNO_GENERATIONAL_GC"
1752        XCFLAGS="$XCFLAGS -DNO_SYMBOLFLAGS"
1753        ;;
1754
1755      # Minix/i386
1756      minix*--i386)
1757        XCFLAGS="$XCFLAGS -DNO_ASM"
1758        ;;
1759
1760      # Cygwin, running on Windows 10 (64-bit)
1761      cygwin--i386) # TODO
1762        XCFLAGS="$XCFLAGS -DNO_ASM -DNO_ARI_ASM -DNO_SP_ASM"
1763        XCFLAGS="$XCFLAGS -DNO_FAST_DISPATCH"
1764        XCFLAGS="$XCFLAGS -DNO_FAST_FLOAT -DNO_FAST_DOUBLE"
1765        XCFLAGS="$XCFLAGS -DNO_ALLOCA"
1766        XCFLAGS="$XCFLAGS -DNO_ADDRESS_SPACE_ASSUMPTIONS"
1767        XCFLAGS="$XCFLAGS -DNO_GENERATIONAL_GC"
1768        XCFLAGS="$XCFLAGS -DNO_SYMBOLFLAGS"
1769        ;;
1770
1771      # mingw, running on Windows 10 (64-bit)
1772      mingw*--i386) # TODO
1773        XCFLAGS="$XCFLAGS -DNO_ASM -DNO_ARI_ASM -DNO_SP_ASM"
1774        XCFLAGS="$XCFLAGS -DNO_FAST_DISPATCH"
1775        XCFLAGS="$XCFLAGS -DNO_FAST_FLOAT -DNO_FAST_DOUBLE"
1776        XCFLAGS="$XCFLAGS -DNO_ALLOCA"
1777        XCFLAGS="$XCFLAGS -DNO_ADDRESS_SPACE_ASSUMPTIONS"
1778        XCFLAGS="$XCFLAGS -DNO_GENERATIONAL_GC"
1779        XCFLAGS="$XCFLAGS -DNO_SYMBOLFLAGS"
1780        ;;
1781
1782      # 64-bit platforms
1783
1784      # Linux/x86_64
1785      linux*--x86_64)
1786        XCFLAGS="$XCFLAGS -DNO_ASM"
1787        ;;
1788
1789      # Linux/arm64
1790      linux*--arm64)
1791        XCFLAGS="$XCFLAGS -DNO_ASM"
1792        ;;
1793
1794      # Linux/alpha
1795      linux*--alpha)
1796        XCFLAGS="$XCFLAGS -DNO_ASM"
1797        ;;
1798
1799      # Linux/ia64
1800      linux*--ia64)
1801        XCFLAGS="$XCFLAGS -DNO_ASM"
1802        ;;
1803
1804      # Linux/mips64eb and Linux/mips64el with 64-bit ABI
1805      linux*--mips64)
1806        XCFLAGS="$XCFLAGS -DNO_ASM"
1807        ;;
1808
1809      # Linux/powerpc64
1810      linux*--powerpc64)
1811        XCFLAGS="$XCFLAGS -DNO_ASM"
1812        ;;
1813
1814      # Linux/powerpc64le
1815      linux*--powerpc64-elfv2)
1816        XCFLAGS="$XCFLAGS -DNO_ASM"
1817        ;;
1818
1819      # Linux/riscv64
1820      linux*--riscv64*)
1821        XCFLAGS="$XCFLAGS -DNO_ASM"
1822        ;;
1823
1824      # Linux/s390x
1825      linux*--s390x)
1826        XCFLAGS="$XCFLAGS -DNO_ASM"
1827        ;;
1828
1829      # Linux/sparc64
1830      linux*--sparc64)
1831        XCFLAGS="$XCFLAGS -DNO_ASM"
1832        ;;
1833
1834      # FreeBSD/x86_64
1835      freebsd*--x86_64)
1836        XCFLAGS="$XCFLAGS -DNO_ASM"
1837        ;;
1838
1839      # GNU/kFreeBSD/x86_64
1840      kfreebsd*-gnu*--x86_64)
1841        XCFLAGS="$XCFLAGS -DNO_ASM -DNO_ARI_ASM -DNO_SP_ASM"
1842        ;;
1843
1844      # FreeBSD/arm64
1845      freebsd*--arm64)
1846        XCFLAGS="$XCFLAGS -DNO_ASM"
1847        ;;
1848
1849      # NetBSD/x86_64
1850      netbsd*--x86_64)
1851        XCFLAGS="$XCFLAGS -DNO_ASM"
1852        ;;
1853
1854      # NetBSD/sparc64
1855      netbsd*--sparc64) # TODO
1856        XCFLAGS="$XCFLAGS -DNO_ASM -DNO_ARI_ASM -DNO_SP_ASM"
1857        XCFLAGS="$XCFLAGS -DNO_FAST_DISPATCH"
1858        XCFLAGS="$XCFLAGS -DNO_FAST_FLOAT -DNO_FAST_DOUBLE"
1859        XCFLAGS="$XCFLAGS -DNO_ALLOCA"
1860        XCFLAGS="$XCFLAGS -DNO_ADDRESS_SPACE_ASSUMPTIONS"
1861        XCFLAGS="$XCFLAGS -DNO_GENERATIONAL_GC"
1862        XCFLAGS="$XCFLAGS -DNO_SYMBOLFLAGS"
1863        ;;
1864
1865      # OpenBSD/x86_64
1866      openbsd*--x86_64)
1867        XCFLAGS="$XCFLAGS -DNO_ASM"
1868        ;;
1869
1870      # Mac OS X/x86_64
1871      darwin*--x86_64)
1872        XCFLAGS="$XCFLAGS -DNO_ASM"
1873        ;;
1874
1875      # AIX/POWER with 64-bit ABI
1876      aix*--powerpc64)
1877        XCFLAGS="$XCFLAGS -DNO_ASM"
1878        ;;
1879
1880      # HP-UX/hppa64 with 64-bit ABI
1881      hpux*--hppa64)
1882        XCFLAGS="$XCFLAGS -DNO_ASM"
1883        ;;
1884
1885      # HP-UX/ia64 with 64-bit ABI
1886      hpux*--ia64)
1887        XCFLAGS="$XCFLAGS -DNO_ASM"
1888        ;;
1889
1890      # Solaris 10/x86_64
1891      solaris2.10--x86_64)
1892        XCFLAGS="$XCFLAGS -DNO_ASM"
1893        ;;
1894
1895      # Solaris 11/x86_64
1896      solaris2.11--x86_64)
1897        XCFLAGS="$XCFLAGS -DNO_ASM"
1898        ;;
1899
1900      # Solaris 10/sparc64
1901      solaris2.10--sparc64)
1902        XCFLAGS="$XCFLAGS -DNO_ASM"
1903        ;;
1904
1905      # Cygwin, running on Windows 10
1906      cygwin--x86_64) # TODO
1907        XCFLAGS="$XCFLAGS -DNO_ASM -DNO_ARI_ASM -DNO_SP_ASM"
1908        XCFLAGS="$XCFLAGS -DNO_FAST_DISPATCH"
1909        XCFLAGS="$XCFLAGS -DNO_FAST_FLOAT -DNO_FAST_DOUBLE"
1910        XCFLAGS="$XCFLAGS -DNO_ALLOCA"
1911        XCFLAGS="$XCFLAGS -DNO_ADDRESS_SPACE_ASSUMPTIONS"
1912        XCFLAGS="$XCFLAGS -DNO_GENERATIONAL_GC"
1913        XCFLAGS="$XCFLAGS -DNO_SYMBOLFLAGS"
1914        ;;
1915
1916      *) # On unknown platforms, use --enable-portability.
1917         enable_portability=yes
1918         ;;
1919    esac
1920  fi
1921  if [ "${enable_portability}" = yes ]; then
1922    # Do NOT enable -DSAFETY=3 here, because -DSAFETY=3 not only disables some
1923    # optimizations but also enables some debugging features (STACKCHECKs), which
1924    # is not in the scope of --enable-portability.
1925    XCFLAGS="$XCFLAGS -DNO_ASM -DNO_ARI_ASM -DNO_SP_ASM"
1926    XCFLAGS="$XCFLAGS -DNO_FAST_DISPATCH"
1927    XCFLAGS="$XCFLAGS -DNO_FAST_FLOAT -DNO_FAST_DOUBLE"
1928    XCFLAGS="$XCFLAGS -DNO_ALLOCA"
1929    XCFLAGS="$XCFLAGS -DNO_ADDRESS_SPACE_ASSUMPTIONS"
1930    XCFLAGS="$XCFLAGS -DNO_GENERATIONAL_GC"
1931    XCFLAGS="$XCFLAGS -DNO_SYMBOLFLAGS"
1932  fi
1933fi
1934
1935
1936# Other dependencies:
1937
1938FILES=''
1939
1940if [ "${with_unicode}" != no ]; then
1941  XCFLAGS="$XCFLAGS -DENABLE_UNICODE"
1942fi
1943if [ "${with_threads}" != no ]; then
1944  XCFLAGS="$XCFLAGS -DMULTITHREAD -D${with_threads}"
1945fi
1946if [ "${with_jitc}" != "" ]; then
1947  XCFLAGS="$XCFLAGS -DHEAPCODES -DUSE_JITC -D${with_jitc}"
1948fi
1949
1950if [ "${with_termcap_ncurses}" = no -o "${LIBTERMCAP}" = "broken" ] ; then
1951  XCFLAGS=$XCFLAGS' -DNO_TERMCAP_NCURSES'
1952  LIBTERMCAP=""
1953fi
1954if [ "${LIBTERMCAP}" != "broken" -a -n "${LIBTERMCAP}" ]; then
1955  XCFLAGS=${XCFLAGS}" ${INCTERMCAP}"
1956  XLDFLAGS=${XLDFLAGS}" ${LIBTERMCAP}"
1957fi
1958
1959test "${with_dynamic_ffi}" != no && XCFLAGS="$XCFLAGS -DDYNAMIC_FFI"
1960
1961test "${with_dynamic_modules}" != no && XCFLAGS="$XCFLAGS -DDYNAMIC_MODULES"
1962
1963if [ "${with_readline}" = no ]; then
1964  # --without-readline was supplied
1965  XCFLAGS=$XCFLAGS' -DNO_READLINE'
1966else
1967  FILES='libnoreadline.a '$FILES
1968  if grep "#undef HAVE_READLINE" config.h >/dev/null 2>&1; then
1969    # --with-readline was supplied ==> barf when readline is missing
1970    test "${with_readline}" != ifpossible && \
1971      fail "configure failed to detect readline"
1972  else                          # readline is present
1973    test "${with_dynamic_ffi}" != no && \
1974      BASE_MODULES=${BASE_MODULES}" readline"
1975  fi
1976fi
1977
1978USE_GETTEXT=''
1979XCL_GETTEXTLIB=''
1980if [ "${with_gettext}" = no -o "@USE_NLS@" != yes ]; then
1981  XCFLAGS=$XCFLAGS' -DNO_GETTEXT'
1982else
1983  USE_GETTEXT=yes
1984  LIBS='@LIBINTL@ '$LIBS
1985  XCL_GETTEXTLIB=$XCL_GETTEXTLIB' locale'
1986fi
1987
1988# For 32-bit builds, determine whether lispbibl.d will enable WIDE_SOFT.
1989USE_WIDE_SOFT=''
1990case " ${XCPPFLAGS} ${XCFLAGS} " in
1991  *" -DWIDE "* | *" -DWIDE_SOFT "* | *" -DNO_ADDRESS_SPACE_ASSUMPTIONS "*)
1992    USE_WIDE_SOFT=yes
1993    ;;
1994esac
1995
1996GLLIB_A=libgnu.a
1997# libgnu.a must come _before_ -lws2_32 -lintl &c
1998LIBS="${GLLIB_A} ${LIBS} ${LIBSOCKET}"
1999FILES="${GLLIB_A} "${FILES}
2000
2001FILES='lisp.a '$FILES
2002
2003CPARTS='        spvw spvwtabf spvwtabs spvwtabo'
2004CPARTS=$CPARTS' eval control'
2005CPARTS=$CPARTS' encoding pathname stream'
2006test $TSYS = master -o $TOS = unix -o $TOS = win32 && CPARTS=$CPARTS' socket'
2007CPARTS=$CPARTS' io funarg'
2008CPARTS=$CPARTS' array hashtabl list package record weak sequence'
2009CPARTS=$CPARTS' charstrg debug error misc time predtype symbol lisparit i18n'
2010test $TSYS = master -o "${with_dynamic_ffi}" != no && CPARTS=$CPARTS' foreign'
2011test $TSYS = master -o $TOS = unix && CPARTS=$CPARTS' unixaux'
2012test $TSYS = master -o $TOS = win32 && CPARTS=$CPARTS' win32aux'
2013test "${with_threads}" != no && CPARTS=$CPARTS' zthread'
2014CPARTS=$CPARTS' built'
2015
2016EVERY_INCLUDES='lispbibl fsubr subr pseudofun constsym constobj constobj_tl '$OS_INCLUDES
2017
2018EVERY_INCLUDES_C=''
2019for f in $EVERY_INCLUDES ; do
2020  EVERY_INCLUDES_C=$EVERY_INCLUDES_C' '$f'.c'
2021done
2022
2023# on UNIX and MINGW PACKAGE_* (and OS capabilities!) is in config.h,
2024# otherwise PACKAGE_* is in version.h and OS capabilities are in win32.c
2025if [ ${TOS} = unix -o ${HSYS} = win32gcc ]; then
2026  EVERY_INCLUDES_H=' config.h'
2027  SPVW_VERSION=''
2028else
2029  EVERY_INCLUDES_H=''
2030  SPVW_VERSION=version.h
2031fi
2032
2033OTHER_INCLUDES=' constpack avl sort bytecode'
2034
2035SPVW_INCLUDES=' spvw_module spvw_debug spvw_alloca spvw_mmap spvw_singlemap spvw_page spvw_heap spvw_heap_old spvw_global spvw_global_old spvw_gcstat spvw_space spvw_mark spvw_objsize spvw_update spvw_fault spvw_fault_old spvw_sigsegv spvw_sigcld spvw_sigpipe spvw_sigint spvw_sigwinch spvw_sigterm spvw_garcol spvw_garcol_old spvw_genera1 spvw_genera1_old spvw_gcmark spvw_genera2 spvw_weak spvw_genera3 spvw_genera3_old spvw_allocate spvw_allocate_old spvw_typealloc spvw_circ spvw_circ_old spvw_walk spvw_ctype spvw_language spvw_memfile'
2036
2037UNICODE_INCLUDES=''
2038if [ "${with_unicode}" != no ] ; then
2039  UNICODE_INCLUDES=$UNICODE_INCLUDES' uni_upcase uni_downcase uni_attribute'
2040fi
2041
2042NLS_INCLUDES=''
2043if [ "${with_unicode}" != no ] ; then
2044  NLS_INCLUDES=$NLS_INCLUDES' nls_ascii'
2045  NLS_INCLUDES=$NLS_INCLUDES' nls_iso8859_1 nls_iso8859_2 nls_iso8859_3'
2046  NLS_INCLUDES=$NLS_INCLUDES' nls_iso8859_4 nls_iso8859_5 nls_iso8859_6'
2047  NLS_INCLUDES=$NLS_INCLUDES' nls_iso8859_7 nls_iso8859_8 nls_iso8859_9'
2048  NLS_INCLUDES=$NLS_INCLUDES' nls_iso8859_10 nls_iso8859_13 nls_iso8859_14'
2049  NLS_INCLUDES=$NLS_INCLUDES' nls_iso8859_15 nls_iso8859_16'
2050  NLS_INCLUDES=$NLS_INCLUDES' nls_koi8_r nls_koi8_u'
2051  NLS_INCLUDES=$NLS_INCLUDES' nls_mac_arabic nls_mac_centraleurope'
2052  NLS_INCLUDES=$NLS_INCLUDES' nls_mac_croatian nls_mac_cyrillic nls_mac_dingbat'
2053  NLS_INCLUDES=$NLS_INCLUDES' nls_mac_greek nls_mac_hebrew nls_mac_iceland'
2054  NLS_INCLUDES=$NLS_INCLUDES' nls_mac_roman nls_mac_romania nls_mac_symbol'
2055  NLS_INCLUDES=$NLS_INCLUDES' nls_mac_thai nls_mac_turkish nls_mac_ukraine'
2056  NLS_INCLUDES=$NLS_INCLUDES' nls_cp437_ms nls_cp437_ibm nls_cp737 nls_cp775'
2057  NLS_INCLUDES=$NLS_INCLUDES' nls_cp850 nls_cp852_ms nls_cp852_ibm nls_cp855'
2058  NLS_INCLUDES=$NLS_INCLUDES' nls_cp857 nls_cp860_ms nls_cp860_ibm nls_cp861_ms'
2059  NLS_INCLUDES=$NLS_INCLUDES' nls_cp861_ibm nls_cp862_ms nls_cp862_ibm'
2060  NLS_INCLUDES=$NLS_INCLUDES' nls_cp863_ms nls_cp863_ibm nls_cp864_ms'
2061  NLS_INCLUDES=$NLS_INCLUDES' nls_cp864_ibm nls_cp865_ms nls_cp865_ibm'
2062  NLS_INCLUDES=$NLS_INCLUDES' nls_cp866 nls_cp869_ms nls_cp869_ibm nls_cp874_ms'
2063  NLS_INCLUDES=$NLS_INCLUDES' nls_cp874_ibm'
2064  NLS_INCLUDES=$NLS_INCLUDES' nls_cp1250 nls_cp1251 nls_cp1252 nls_cp1253'
2065  NLS_INCLUDES=$NLS_INCLUDES' nls_cp1254 nls_cp1256 nls_cp1257'
2066  NLS_INCLUDES=$NLS_INCLUDES' nls_hp_roman8'
2067  NLS_INCLUDES=$NLS_INCLUDES' nls_jisx0201'
2068fi
2069
2070if [ -n "${SRCDIR}" ] ; then
2071  INCLUDES="${UNICODE_INCLUDES}"
2072  UNICODE_INCLUDES=''
2073  for i in ${INCLUDES}; do
2074    UNICODE_INCLUDES="${UNICODE_INCLUDES} ${SRCDIR}${i}"
2075  done
2076  INCLUDES="${NLS_INCLUDES}"
2077  NLS_INCLUDES=''
2078  for i in ${INCLUDES}; do
2079    NLS_INCLUDES="${NLS_INCLUDES} ${SRCDIR}${i}"
2080  done
2081fi
2082
2083ERROR_INCLUDES='errunix'
2084test $TSYS = master -o $TOS = win32 && ERROR_INCLUDES=$ERROR_INCLUDES' errwin32'
2085
2086LISPARIT_SUBFILES=' aridecl arilev0 arilev1 intelem intlog intplus intcomp intbyte intmal intdiv intgcd int2adic intsqrt intprint intread intserial rational'
2087LISPARIT_SUBFILES=$LISPARIT_SUBFILES' sfloat ffloat dfloat lfloat flo_konv flo_rest realelem realrand realtran compelem comptran'
2088LISPARIT_INCLUDES=$LISPARIT_SUBFILES' arilev1c arilev1e arilev1i arilev1dbg'
2089
2090EXTRA_CPARTS='arilev1_asm_proto noreadline'
2091
2092DFILES="$CPARTS $EVERY_INCLUDES $OTHER_INCLUDES $SPVW_INCLUDES $ERROR_INCLUDES $LISPARIT_INCLUDES genclisph $EXTRA_CPARTS"
2093
2094ARI_ASMD=''
2095ARI_ASMC=''
2096ARI_ASMS=''
2097case " ${XCPPFLAGS} ${XCFLAGS} " in
2098  *" -DNO_ARI_ASM "*) ;;
2099  *)
2100    if [ "$cpu" = sparc ] ; then
2101      ARI_ASMD=$ARI_ASMD' ari_asm_sparc'
2102      ARI_ASMS=$ARI_ASMS' ari_asm_sparc'
2103    fi
2104    if [ "$cpu" = sparc64 ] ; then
2105      ARI_ASMD=$ARI_ASMD' ari_asm_sparc64'
2106      ARI_ASMS=$ARI_ASMS' ari_asm_sparc64'
2107    fi
2108    if [ "$cpu" = mips -o "$cpu" = mipsn32 ] ; then
2109      ARI_ASMD=$ARI_ASMD' ari_asm_mips'
2110      ARI_ASMS=$ARI_ASMS' ari_asm_mips'
2111    fi
2112    if [ "$cpu" = mips64 ] ; then
2113      ARI_ASMD=$ARI_ASMD' ari_asm_mips64'
2114      ARI_ASMS=$ARI_ASMS' ari_asm_mips64'
2115    fi
2116    if [ "$cpu" = i386 ] ; then
2117      ARI_ASMD=$ARI_ASMD' ari_asm_i386'
2118      ARI_ASMS=$ARI_ASMS' ari_asm_i386'
2119    fi
2120    if [ "$cpu" = hppa ] ; then
2121      ARI_ASMD=$ARI_ASMD' ari_asm_hppa'
2122      ARI_ASMS=$ARI_ASMS' ari_asm_hppa'
2123    fi
2124    if [ "$cpu" = arm -o "$cpu" = armhf ] ; then
2125      ARI_ASMD=$ARI_ASMD' ari_asm_arm'
2126      ARI_ASMS=$ARI_ASMS' ari_asm_arm'
2127    fi
2128    ;;
2129esac
2130
2131SP_ASMD=''
2132SP_ASMS=''
2133case " ${XCPPFLAGS} ${XCFLAGS} " in
2134  *" -DNO_SP_ASM "*) ;;
2135  *)
2136    if [ "$cpu" = m68k ] ; then
2137      SP_ASMD=$SP_ASMD' sp_asm_m68k'
2138      SP_ASMS=$SP_ASMS' sp_asm_m68k'
2139    fi
2140    if [ "$cpu" = sparc ] ; then
2141      SP_ASMD=$SP_ASMD" sp_asm_sparc"
2142      SP_ASMS=$SP_ASMS" sp_asm_sparc"
2143    fi
2144    if [ "$cpu" = sparc64 ] ; then
2145      SP_ASMD=$SP_ASMD" sp_asm_sparc64"
2146      SP_ASMS=$SP_ASMS" sp_asm_sparc64"
2147    fi
2148    if [ "$cpu" = mips -o "$cpu" = mipsn32 -o "$cpu" = mips64 ] ; then
2149      SP_ASMD=$SP_ASMD' sp_asm_mips'
2150      SP_ASMS=$SP_ASMS' sp_asm_mips'
2151    fi
2152    if [ "$cpu" = i386 ] ; then
2153      SP_ASMD=$SP_ASMD' sp_asm_i386'
2154      SP_ASMS=$SP_ASMS' sp_asm_i386'
2155    fi
2156    ;;
2157esac
2158
2159COMMENTS=''
2160
2161LPARTS='        init defseq backquote defmacro macros1 macros2 defs1'
2162test ${TOS} = unix -o ${TOS} = win32 || LPARTS=$LPARTS' timezone'
2163LPARTS=$LPARTS' lambdalist places floatprint defpackage type subtypep'
2164LPARTS=$LPARTS' clos-package clos-macros clos-class0 clos-metaobject1'
2165LPARTS=$LPARTS' clos-slotdef1 clos-stablehash1 clos-specializer1 clos-class1'
2166LPARTS=$LPARTS' clos-class2 clos-class3 defstruct format'
2167LPARTS=$LPARTS' international savemem functions trace cmacros compiler'
2168LPARTS=$LPARTS' defs2 loop clos'
2169LPARTS=$LPARTS' clos-stablehash2'
2170LPARTS=$LPARTS' clos-specializer2 clos-specializer3'
2171LPARTS=$LPARTS' clos-class4 clos-class5 clos-class6'
2172LPARTS=$LPARTS' clos-slotdef2 clos-slotdef3 clos-slots1 clos-slots2'
2173LPARTS=$LPARTS' clos-method1 clos-method2 clos-method3 clos-method4'
2174LPARTS=$LPARTS' clos-methcomb1 clos-methcomb2 clos-methcomb3 clos-methcomb4'
2175LPARTS=$LPARTS' clos-genfun1 clos-genfun2a clos-genfun2b clos-genfun3 clos-genfun4 clos-genfun5'
2176LPARTS=$LPARTS' clos-dependent clos-print clos-custom documentation'
2177LPARTS=$LPARTS' fill-out disassem condition loadform gstream xcharin keyboard'
2178LPARTS=$LPARTS' screen runprog query reploop dribble complete'
2179LPARTS=$LPARTS' pprint describe room edit macros3 clhs inspect gray'
2180test "${with_threads}" = no || LPARTS=$LPARTS' threads'
2181LPARTS=$LPARTS' case-sensitive'
2182test $TSYS = master -o "${with_dynamic_ffi}" != no && LPARTS=$LPARTS' foreign1'
2183LPARTS=$LPARTS' exporting '
2184test "${with_unicode}" = no -o "${with_gettext}" = no || \
2185  LPARTS=$LPARTS' german french spanish russian danish dutch'
2186LPARTS=$LPARTS' deprecated'
2187
2188TXT_DOCS='LISP-tutorial.txt CLOS-guide.txt'
2189
2190TXT_FILES='README README.de README.es clisp.c'
2191test $CROSS = false -a $HOS = unix && TXT_FILES=$TXT_FILES' distmakefile'
2192MANPAGES="clisp clisp-link"
2193for f in ${MANPAGES}; do
2194  TXT_FILES="$TXT_FILES $f.1 $f.html $f-1.html"
2195done
2196
2197OBSOLETE=''
2198
2199# Output the makefile:
2200
2201# echotab line
2202# outputs a line, preceding it with a tab. cat is needed to output tabs.
2203if [ $HSYS != win32msvc ] ; then
2204echotab () {
2205cat <<!!
2206	$1
2207!!
2208}
2209else
2210# Win32 "nmake" stupidly passes the command lines through `printf', thus
2211# interpreting % characters.
2212echotab () {
2213cmd=`echol "$1" | sed -e 's,%,%%,g'`
2214cat <<!!
2215	$cmd
2216!!
2217}
2218fi
2219
2220# echolist prefix list suffix prefix
2221# outputs a list of items, prefixed by backslashes and newlines to break long
2222# lines.
2223echolist () {
2224line="$1"
2225suffix="$3"
2226prefix="$4"
2227for f in $2 ; do
2228  echol $line" \\"
2229  line="${prefix}${f}${suffix}"
2230done
2231echol $line
2232}
2233
2234# echodummyrule target
2235# outputs a dummy rule for the given target.
2236case "$host_os" in
2237  aix*) # GNU make on AIX starts an interactive shell for every empty rule
2238echodummyrule () {
2239echotab "true"
2240}
2241  ;;
2242  *)
2243echodummyrule () {
2244:
2245}
2246  ;;
2247esac
2248
2249echol "# -*- Makefile -*- for the CLISP binaries"
2250echol "# DO NOT EDIT! GENERATED AUTOMATICALLY!"
2251echol "# This file was created on host $hostname as the output of the command:"
2252echol "# $0$makemake_args"
2253echol
2254echol '# -------------- Start of configurable section --------------------'
2255echol "srcdir = ${srcdir}"
2256# cannot do this: "Circular ../src/build-aux <- ../src/build-aux dependency dropped."
2257#echol "VPATH = ${srcdir}"
2258echol
2259if [ $TSYS = win32msvc ] ; then
2260  echol "# Flags that can be set on the nmake command line:"
2261  echol "#   MFLAGS={-ML|-MT|-MD} for defining the compilation model"
2262  echol "#     MFLAGS=-ML (the default)  Single-threaded, statically linked - libc.lib"
2263  echol "#     MFLAGS=-MT                Multi-threaded, statically linked  - libcmt.lib"
2264  echol "#     MFLAGS=-MD                Multi-threaded, dynamically linked - msvcrt.lib"
2265  echol '!if !defined(MFLAGS)'
2266  echol 'MFLAGS='
2267  echol '!endif'
2268  echol
2269fi
2270
2271PACKAGE_VERSION="@PACKAGE_VERSION@"
2272VERSION_NUMBER=`echo "${PACKAGE_VERSION}" | sed -e 's, .*,,'`
2273echol "# The official version number"
2274echol "PACKAGE_VERSION=${PACKAGE_VERSION}"
2275echol "VERSION=${VERSION_NUMBER}"
2276echol "# The official package name"
2277echol "PACKAGE_NAME=@PACKAGE_NAME@"
2278echol "# If you want to distribute a modified version of CLISP,"
2279echol "# use this to distinguish your distribution from the official one."
2280echol "# This can also be used for pre-test and post-release distributions:"
2281echol "#   make distrib VERSION_SUFFIX=pre"
2282echol "VERSION_SUFFIX="
2283echol "# The distribution's top directory"
2284echol 'TOPDIR=clisp-$(VERSION)$(VERSION_SUFFIX)'
2285echol
2286echol '# Directories used by "make install":'
2287echol "prefix = ${PREFIX}"
2288echol "exec_prefix = ${EXEC_PREFIX}"
2289echol "bindir  = ${BINDIR}"
2290echol "datarootdir = ${DATAROOTDIR}"
2291echol "mandir  = ${MANDIR}"
2292echol "docdir  = ${DOCDIR}"
2293echol "htmldir = ${HTMLDIR}"
2294echol "psdir   = ${PSDIR}"
2295echol "pdfdir  = ${PDFDIR}"
2296echol "libdir  = ${LIBDIR}"
2297echol "lisplibdir = \$(libdir)${NEXT_}clisp"
2298test -n "$USE_GETTEXT" && echol "localedir = ${LOCALEDIR}"
2299echol "elispdir = ${ELISPDIR}"
2300echol "vimdir = ${VIMDIR}"
2301echol "aclocaldir = ${ACLOCALDIR}"
2302echol "# The value of following variable is prepended to all the paths for"
2303echol "# installation. This is useful when preparing a binary distribution."
2304echol "DESTDIR ="
2305echol
2306echol     "# (partial) list of available add-on modules"
2307echol     "# (see directory modules/ for the full list"
2308echol     "#  or pass --help-modules to top-level configure):"
2309echol     "# asdf                 Another System Definition Facility"
2310echol     "# queens               the queens function (a toy example)"
2311echol     "# dirkey               the directory access (LDAP, win32 registry)"
2312echol     "# berkeley-db          the Berkeley DB access"
2313echol     "# gdbm                 the GNU DataBase manager"
2314echol     "# rawsock              raw socket access"
2315echol     "# pcre                 Perl-compatible regular expressions"
2316if [ "${with_dynamic_ffi}" != no ]; then
2317  echol   "# libsvm               build Support Vector Machine models"
2318  echol   "# postgresql           interface to PostgreSQL ODBMS"
2319  echol   "# fastcgi              FastCGI (http://www.fastcgi.com/) interface"
2320  echol   "# oracle               Oracle (http://www.oracle.com/) interface"
2321  echol   "# netica               Netica (http://norsys.com/netica_c_api.htm)"
2322  echol   "# pari                 PARI/gp (http://pari.math.u-bordeaux.fr/)"
2323  echol   "# zlib                 ZLIB (http://www.zlib.org)"
2324  test "$cpu" = i386 -a "$TSYSOS" = linux && \
2325    echol "# bindings/glibc       Linux glibc bindings (GNU libc version 2)"
2326  test "$cpu" = i386 -a \( "$TSYSOS" = win32gcc -o "$TSYSOS" = cygwin \) && \
2327    echol "# bindings/win32       win32 bindings"
2328  echol   "# gtk2                 GTK2 interface"
2329fi
2330test $TOS = unix -o $TOS = win32 && \
2331  echol   "# clx/mit-clx          classical X11 interface"
2332test $TOS = unix && \
2333  echol   "# clx/new-clx          faster X11 interface (replaces clx/mit-clx)"
2334echol "MODULES = ${MODULES}"
2335echol
2336echol "# Command line options passed to the configure files of add-on modules"
2337echol "MODULE_CONFIGURE_FLAGS = ${module_configure_flags}"
2338echol
2339echol '# Programs used by "make":'
2340if [ $CROSS = true ] ; then
2341  echol "CC = ${CC}"
2342  echol "CPPFLAGS = ${CPPFLAGS}"
2343  echol "CFLAGS = ${CFLAGS}"
2344  echol "CLFLAGS = ${CLFLAGS}"
2345  echol "CPP = ${CPP}"
2346  echol "XCC = ${XCC}"
2347  echol "XCPPFLAGS = ${XCPPFLAGS}"
2348  echol "XCFLAGS = ${XCFLAGS}"
2349  echol "XCPP = ${XCPP}"
2350  echol "XCLFLAGS = ${XCLFLAGS}"
2351  echol "XLIBS = ${LIBS}"
2352  XCC="\$(XCC)"
2353  XCPPFLAGS="\$(XCPPFLAGS)"
2354  XCFLAGS="\$(XCFLAGS)"
2355  XCPP="\$(XCPP)"
2356  XCLFLAGS="\$(XCLFLAGS)"
2357  LIBS="\$(XLIBS)"
2358else
2359  echol "CC = ${XCC}"
2360  echol "CPPFLAGS = ${XCPPFLAGS}"
2361  echol "CFLAGS = ${XCFLAGS}"
2362  echol "CPP = ${XCPP}"
2363  echol "CLFLAGS = ${XCLFLAGS}"
2364  echol "LIBS = ${LIBS}"
2365  XCC="\$(CC)"
2366  XCPPFLAGS="\$(CPPFLAGS)"
2367  XCFLAGS="\$(CFLAGS)"
2368  XCPP="\$(CPP)"
2369  XCLFLAGS="\$(CLFLAGS)"
2370  LIBS="\$(LIBS)"
2371fi
2372echol "X_LIBS = ${X_LIBS}"
2373X_LIBS="\$(X_LIBS)"
2374echol "FALIGNFLAGS = ${FALIGNFLAGS}"
2375FALIGNFLAGS="\$(FALIGNFLAGS)"
2376echol "LD = ${LD}"
2377LD="\$(LD)"
2378echol 'MODULE_CPPFLAGS = $(CPPFLAGS)' # this includes ${GNULIB_INCLUDE}
2379if [ "${with_dynamic_modules}" != no ]; then
2380  echol 'MODULE_CFLAGS = $(CFLAGS) '"${XCC_PICFLAG}"
2381  echol 'MODULE_CLFLAGS = $(CLFLAGS) '"${EXPORT_DYNAMIC_FLAG_SPEC}"
2382  MODULE_CFLAGS_VAR='MODULE_CFLAGS'
2383  MODULE_CLFLAGS_VAR='MODULE_CLFLAGS'
2384  XCLFLAGS="\$(MODULE_CLFLAGS)"
2385else
2386  MODULE_CFLAGS_VAR='CFLAGS'
2387  MODULE_CLFLAGS_VAR='CLFLAGS'
2388fi
2389if [ $HSYS = win32msvc ] ; then
2390  echol "#MSVCDIR = d:/msdev"
2391  echol "#MSVCDIR = d:/devstudio/vc"
2392  echol "#MSVCDIR = c:/msvs/vc98"
2393  echol "#MSVCDIR = \"C:/Program Files/Microsoft Visual Studio/VC98\""
2394  echol '#MSVCDIR = "C:\Programme\Microsoft Visual Studio\VC98"'
2395fi
2396# echotab_to_HEXE command source target
2397# outputs a `make' statement that executes "command source" and creates
2398# target${HEXE}.
2399if [ $HSYS != win32msvc ] ; then
2400  echotab_to_HEXE () {
2401    echotab "$1 $2 -o $3${HEXE}"
2402  }
2403else
2404  echotab_to_HEXE () {
2405    echotab "$1 $2 /Fe$3${HEXE}"
2406  }
2407fi
2408echol
2409if [ $HOS = win32 -a $HSYS != win32gcc ] ; then
2410  if [ $HSYS = win32msvc ] ; then
2411    echol "MAKE = nmake"
2412  else
2413    echol "MAKE = amake"
2414  fi
2415  echol "RM = -${RM}"
2416  echol "RMRF = -${RMRF}"
2417  echol "TOUCH = -${TOUCH}"
2418else
2419  SET_MAKE="@SET_MAKE@"
2420  test -n "${SET_MAKE}" && echol "${SET_MAKE}"
2421  echol "RM = ${RM}"
2422  echol "RMRF = ${RMRF}"
2423  echol "TOUCH = ${TOUCH}"
2424fi
2425echol "CP = ${CP}"
2426echol "LN_S = ${LN_S}"
2427echol "MV = ${MV}"
2428echol "CAT = ${CAT}"
2429echol "GREP = ${GREP}"
2430echol "SED = ${SED}"
2431echol "AR = ${AR}"
2432echol "RANLIB = ${RANLIB}"
2433echol
2434echol '# Programs used by "make install":'
2435echol "INSTALL = ${INSTALL}"
2436echol "INSTALL_PROGRAM = ${INSTALL_PROGRAM}"
2437echol "INSTALL_SCRIPT = ${INSTALL_SCRIPT}"
2438echol "INSTALL_DATA = ${INSTALL_DATA}"
2439echol
2440echol '# Programs used by "make distrib":'
2441echol
2442# Auxiliary routines for linking lisp.a:
2443if [ $HOS = unix -a $XCC_GCC = true ] ; then
2444  # We need the full libgcc.a in general. But we don't know its location.
2445  LIBGCC='`'"${XCC} -print-libgcc-file-name"'` # something like /usr/somewhere/libgcc.a'
2446  if [ $CROSS = false ] ; then
2447    if [ "$HSYSOS" = linux -o "$HSYSOS" = beos -o "$HSYSOS" = cygwin ] ; then
2448      # gcc2 is cc on Linux, BeOS and Cygwin. Don't need libgcc.a
2449      LIBGCC=''
2450    fi
2451  fi
2452else
2453  LIBGCC=''
2454fi
2455test -n "$LIBGCC" && echol "LIBGCC = ${LIBGCC}"
2456if test -n "$GROFF"; then
2457  ROFF_MAN="$GROFF -Tascii -mandoc"
2458  ROFF_PS="$GROFF -Tps -mandoc"
2459else
2460  ROFF_MAN="nroff -man"
2461  if [ $HSYS = sun4 -a $CROSS = false ] ; then
2462    if [ "$UNAME_S" = sunos ] ; then
2463      case "$UNAME_R" in 4*)
2464        # SunOS 4
2465        ROFF_MAN="nroff -a -man" ;;
2466      esac
2467    fi
2468  fi
2469fi
2470echol '# formatter for manual page'
2471echol "ROFF_MAN = ${ROFF_MAN}"' # try "groff -Tascii -mandoc" or "nroff -man"'
2472if test -n "$GROFF"; then
2473  echol "ROFF_PS  = ${ROFF_PS}"' # try "groff -Tps -mandoc"'
2474  test -n "$PS2PDF" && echol "PS2PDF = ${PS2PDF}"
2475fi
2476echol
2477echol '# -------------- End of configurable section --------------------'
2478echol
2479cat <<\!!
2480#
2481#                       Requirements for add-on modules
2482#                       -------------------------------
2483#
2484# The general layout of add-on modules is described in
2485#  <http://clisp.org/impnotes/modules.html>.
2486# The requirements made there (i.e. the existence of a "link.sh" file
2487# which defines certain variables) make sure that such an add-on module
2488# can be distributed with CLISP.
2489#
2490# If you want an add-on module to be _built_ automatically with CLISP,
2491# the following additional requirements have to be obeyed.
2492#
2493# 1. The module must be located in a subdirectory of clisp's build
2494#    directory.
2495#    Examples: clisp/build/regexp/
2496#              clisp/build/bindings/glibc/
2497#
2498# 2. If the module contains a file called "configure", it is assumed
2499#    to be a GNU autoconf generated configuration file, and is called
2500#    with a "--cache-file=..." argument. It should generate platform
2501#    dependent header files, Makefiles and the like.
2502#
2503# 3. The module should contain a Makefile (maybe generated by requirement 2),
2504#    which defines the following targets:
2505#
2506#     clisp-module
2507#
2508#      This target builds the file(s) mentioned by the link.sh file.
2509#      The following makefile variables can be used:
2510#        CC        the C compiler used to compile the CLISP source
2511#        CPPFLAGS  the C compiler flags when compiling some source
2512#        CFLAGS    the C compiler flags
2513#        CLFLAGS   the C compiler flags when linking an executable
2514#        LIBS      the libraries used when linking an executable
2515#        RANLIB    the name of the "ranlib" command
2516#        CLISP     a command which calls the already built "boot" clisp.
2517#        CLISP_LINKKIT  the directory containing the CLISP header file clisp.h
2518#                       (defaults to $$($(CLISP) -b)/linkkit)
2519#        SHREXT    the shared object extension (.so or .dll)
2520#      Typically, you will have rules like this in your Makefile:
2521#        foo.o : foo.c
2522#                $(CC) $(CPPFLAGS) $(CFLAGS) -I$(CLISP_LINKKIT) -c foo.c
2523#        foo.fas : foo.lisp
2524#                $(CLISP) -c foo.lisp
2525#
2526#     clisp-module-distrib
2527#
2528#      This target copies the module into a temporary distribution
2529#      directory, on the same disk.
2530#      The following makefile variables can be used:
2531#        distribdir  the name of temporary distribution directory
2532#        LN          command to make hard links (works also for symbolic links)
2533#      Typically, this target will look like this:
2534#        DISTRIBFILES = <the NEW_FILES mentioned in link.sh> <doc files>
2535#        clisp-module-distrib : clisp-module force
2536#               $(LN) $(DISTRIBFILES) $(distribdir)
2537#
2538# If these requirements are obeyed, this Makefile will automatically build
2539# the add-on module and make it part of the "full" distribution -- all you
2540# need to do is to add its name to the MODULES definition line above.
2541#
2542!!
2543echol
2544if [ $HOS = unix ] ; then
2545  # On some systems (IRIX SVR3 and others) the default shell is csh.
2546  # The sh and ksh on HP-UX 10 have severe bugs that cause
2547  #   1. Most invocations of lisp.run crash like this (from HP-UX make):
2548  #        ./lisp.run ...
2549  #        /bin/sh: 18546 Bus error
2550  #      or like this (from GNU make):
2551  #        ./lisp.run ...
2552  #        *** Termination signal 11
2553  #   2. A command such as  'grep -v "^ *$$"'  to be executed incorrectly.
2554  # As a workaround, we use GNU bash instead.
2555  case "$host_os" in
2556    hpux*) echol "SHELL = "`which bash` ;;
2557    *)     echol "SHELL = ${CONFIG_SHELL-/bin/sh}" ;;
2558  esac
2559  echol
2560fi
2561echol "# Add-on modules that are present in all linking sets (including base)"
2562echol "# syscalls             export some POSIX (and other) system calls"
2563echol "# regexp               POSIX regular expressions"
2564echol "# i18n                 Lisp program internationalization"
2565echol "# readline             extra fine REPL controls"
2566echol "BASE_MODULES = ${BASE_MODULES}"
2567echol
2568echol "COMMENT5 = ${HERE}comment5"
2569
2570if "$XCC_SUNPRO" ; then
2571  XASM_NEED_CCPAUX=true
2572else
2573  XASM_NEED_CCPAUX=false
2574fi
2575
2576if [ $XASM_NEED_CCPAUX = true ] ; then
2577  NEED_CCPAUX=true
2578else
2579  NEED_CCPAUX=false
2580fi
2581XDECL_FILTER="| \$(GCTRIGGER) | \$(VARBRACE)"
2582XDECL_DEPENDENCIES=" gctrigger${HEXE} varbrace${HEXE}"
2583
2584echol "GCTRIGGER = ${HERE}gctrigger"
2585echol "VARBRACE = ${HERE}varbrace"
2586if [ $XASM_NEED_CCPAUX = true ] ; then
2587  XASMCCPAUX='ccpaux'$HEXE
2588  XASMCCPAUX_FILTER=' | '$HERE'ccpaux'
2589else
2590  XASMCCPAUX=''
2591  XASMCCPAUX_FILTER=''
2592fi
2593if [ $XCC_NEED_DEEMA = true ] ; then
2594  if [ $HOS = unix ] ; then
2595    echol "DEEMA = sed -e 's/, *)/,_EMA_)/g' -e 's/, *,/,_EMA_,/g'"
2596  else
2597    echol "DEEMA = deema"
2598    XDECL_DEPENDENCIES="${XDECL_DEPENDENCIES} deema${HEXE}"
2599  fi
2600  XDECL_FILTER="${XDECL_FILTER} | \$(DEEMA)"
2601fi
2602
2603if [ -n "${SRCDIR}" ] ; then
2604  TXT2CINCL="-I${SRCDIR}"
2605else
2606  TXT2CINCL=""
2607fi
2608echol "TXT2C = ${HERE}txt2c ${TXT2CINCL}"
2609if [ $CROSS = true ] ; then
2610  TXT2CFLAGS="${TXT2CFLAGS} -DCROSS"
2611  TXT_INCLUDES=' lispbibl.h'
2612else
2613  TXT2CFLAGS="${TXT2CFLAGS}"
2614  TXT_INCLUDES="${EVERY_INCLUDES_C}${EVERY_INCLUDES_H}"
2615fi
2616
2617echol
2618
2619echolist "CFILES =" "$DFILES $ARI_ASMD $ARI_ASMC $SP_ASMD gen.lispbibl" ".c"
2620echol
2621
2622echolist "OBJECTS =" "$CPARTS $ARI_ASMS $SP_ASMS $GMALLOC" "${TOBJ}"
2623echol
2624
2625echolist "LISPFILES =" "$LPARTS" ".lisp" "${SRCDIR}"
2626echol
2627
2628echolist "FASFILES =" "$LPARTS config" ".fas"
2629echol
2630
2631echolist "TXTFILES =" "$TXT_DOCS" ""
2632echol
2633
2634echolist "TESTFASFILES =" "$LPARTS config" ".fas" "${RECOMPILEDIR}${NEXT_M}"
2635echol
2636
2637echol
2638
2639SUBDIRS=gllib
2640needs="gllib/libgnu.a init allc allo lisp${LEXE} marc.out interpreted.mem halfcompiled.mem lispinit.mem manual"
2641if [ \( $HOS = unix -o ${HSYS} = win32gcc \) -a $CROSS = false ] ; then
2642  needs=".gdbinit "$needs' modular $(BASE_MODULES) $(MODULES) '"clisp${TEXE} boot base full"
2643fi
2644if [ $TSYS = win32msvc -a "${with_debug}" != no ] ; then
2645  needs=$needs" lisp.bsc"
2646fi
2647echol "all : $needs"
2648echodummyrule all
2649echol
2650echol "SUBDIRS = ${SUBDIRS}"
2651echol '.PHONY: subdirs clean0 clean1 clean2 clean3 clean4 clean5 clean6 clean7 clean8 mostlyclean distclean clean maintainer-clean clean-modules am--refresh'
2652echol
2653echol 'subdirs: gllib/libgnu.a'
2654echol
2655# gnulib cannot be compiled with C++, thus NO_CXX
2656echol 'SUBDIR_CFLAGS = $(CFLAGS) '"${XCC_PICFLAG} @NO_CXX@"
2657echol 'gllib/libgnu.a: config.status build-aux'
2658echotab 'mkdir -p gllib'
2659echotab 'test -f gllib/Makefile || sh config.status gllib/Makefile depfiles'
2660top_srcdir=`cd "${SRCDIR}"; pwd`
2661echotab 'cd gllib && $(MAKE) CFLAGS="$(SUBDIR_CFLAGS)" top_srcdir="'"${top_srcdir}"'"'
2662echol
2663echol "${GLLIB_A}: gllib/libgnu.a"
2664echotab "test -r ${GLLIB_A} || \$(LN_S) gllib/${GLLIB_A} ${GLLIB_A}"
2665echol
2666
2667# in the toplevel Makefile.devel, makemake depends also on version.sh.
2668# we do not need that here because makemake depends on config.status -
2669# depends on src/configure - depends on version.sh in Makefile.devel
2670echol "makemake : ${SRCDIR}makemake.in config.status"
2671echotab "sh config.status --file=makemake"
2672echol
2673echol "config.h : ${SRCDIR}config.h.in config.status"
2674echotab "sh config.status --header=config.h"
2675# when config.status detects that it did not change config.h, it
2676# will not touch it, and on the next make config.h will be remade
2677# again and again ... - avoid it
2678echotab "touch config.h"
2679echol
2680echol "Makefile : makemake"
2681echotab "$0$makemake_args > Makefile.tmp"
2682echotab "\$(MV) Makefile Makefile~"
2683echotab "\$(MV) Makefile.tmp Makefile"
2684OBSOLETE="$OBSOLETE Makefile~"
2685echol
2686echol "config.status : ${SRCDIR}configure"
2687echotab "\$(RMRF) config.cache \$(SUBDIRS)"
2688echotab "sh config.status --recheck"
2689echol
2690echol "libtool : @LIBTOOL_DEPS@"
2691echotab "sh config.status --recheck"
2692echol
2693echol "am--refresh : config.status Makefile config.h"
2694echol
2695
2696if [ $TSYS = win32msvc ] ; then
2697  # quote for command arguments when they are unnecessary on DOS
2698  ARGQ=""
2699  # .. when they are mandatory
2700  ARGQ1="\""
2701  # quotes to pass to a command escaped
2702  QQUOT="\\\""
2703else
2704  ARGQ="'"
2705  ARGQ1="'"
2706  QQUOT="\""
2707fi
2708
2709# cf. ac_precious_vars in configure
2710PRECIOUS_VARS='CC CFLAGS LDFLAGS CLFLAGS LIBS CPPFLAGS CPP CXX CXXFLAGS X_LIBS'
2711# Do not touch cflags.h when the changes to Makefile do not modify it.
2712# Cost: maybe a few extra "echo"s on each make
2713# Benefit: lispinit.mem is not re-dumped when we add something to MODULES
2714echol "cflags.h : cflags.h.stamp"
2715echodummyrule "cflags.h"
2716echol
2717echol "cflags.h.stamp : Makefile"
2718echotab "echo $ARGQ/* generated from Makefile */$ARGQ > cflags.h.new"
2719for x in ${PRECIOUS_VARS}; do
2720  echotab "echo $ARGQ#define $x \"\$($x)\"$ARGQ >> cflags.h.new"
2721done
2722if [ $TSYS = win32msvc ] ; then
2723  echotab '$(RM) cflags.h'
2724  echotab '$(MV) cflags.h.new cflags.h'
2725else
2726  echotab 'if cmp cflags.h.new cflags.h > /dev/null 2>&1; then $(RM) cflags.h.new; else $(MV) cflags.h.new cflags.h; fi'
2727fi
2728echotab '$(TOUCH) cflags.h.stamp'
2729echol
2730
2731UTILS=''
2732test $NEED_CCPAUX = true && UTILS=$UTILS' ccpaux'
2733UTILS=$UTILS' comment5'
2734UTILS=$UTILS' gctrigger'
2735UTILS=$UTILS' varbrace'
2736test $XCC_NEED_DEEMA = true -a $HOS != unix && UTILS=$UTILS' deema'
2737UTILS=$UTILS' txt2c'
2738UTILS=$UTILS' ccmp2c' # needed by clx module
2739LUTILS='modprep'
2740
2741PARAMS="intparam floatparam"
2742PARAMS_H=""
2743line="init :"
2744for parf in ${PARAMS}; do
2745  test ${TOS} != win32 && line=$line" "${parf}.h
2746  PARAMS_H=${PARAMS_H}" "${parf}.h
2747done
2748test $CROSS = true && line=$line" config.h"
2749for util in ${UTILS} ; do line=$line" ${util}${HEXE}"; done
2750line=$line" modules.h"
2751echol $line
2752echodummyrule init
2753echol
2754for parf in ${PARAMS}; do
2755  if [ $CROSS = true ]; then
2756    # everything is in config.h
2757    echol "${parf}.h : ${SRCDIR}${parf}.c config.h"
2758    echotab '$(TOUCH) '"${parf}.h"
2759  else
2760    echol "${parf}.h : ${SRCDIR}${parf}.c config.h"
2761    echotab "{ echo '#include \"config.h\"' && cat '${SRCDIR}${parf}.c'; } > gen-${parf}.c"
2762    echotab_to_HEXE "\$(CC)" "gen-${parf}.c" "${parf}"
2763    echotab "${HERE}${parf}${HEXE} ${parf}.h"
2764    echotab "\$($EXERM) $(exefiles ${parf}) gen-${parf}.c"
2765  fi
2766  echol
2767done
2768for util in ${UTILS} ; do
2769  echol "${util}${HEXE} : ${UTILDIR_M}${util}.c ${GLLIB_A}"
2770  echotab_to_HEXE "${UTILCOMPILE} -I." "${UTILDIR_CC}${util}.c ${GLLIB_A}" "${util}"
2771  echol
2772done
2773
2774echol
2775
2776echol "modules.h :"
2777echotab "touch modules.h"
2778echol
2779
2780if [ -n "${SRCDIR}" ] ; then
2781  if [ ${HSYS} = win32gcc ] ; then
2782    # install.lisp requires dirkey module which is built by mingw but not msvc
2783    for f in install.lisp install.bat ; do
2784      link_dep "${f}" "${SRCDIR}${f}"
2785    done
2786  fi
2787fi
2788
2789if [ ${HOS} = win32 ]; then
2790  for f in env_var_update.nsh is_user_admin.nsh; do
2791    link_dep "${f}" "${SRCTOPDIR_}win32msvc/nsis/${f}"
2792  done
2793  echol "install.nsi : ${SRCTOPDIR_}win32msvc/nsis/install.nsi config.status"
2794  # comma used as separator in patterns below to allow embedded
2795  # slashes in module names (e.g., bindings/win32)
2796  echotab "sed -e 's/\@NAME\@/\$(PACKAGE_NAME)/g' -e 's/\@VERSION\@/\$(VERSION)/g' -e 's,\@BASE_MODULES\@,\$(BASE_MODULES),g' -e 's,\@MODULES\@,\$(MODULES),g' ${SRCTOPDIR_}win32msvc/nsis/install.nsi > install.nsi"
2797  echol
2798  echol "COPYRIGHT.rtf : COPYRIGHT ${SRCTOPDIR_}win32msvc/nsis/text_to_rtf.lisp config.status"
2799  echotab "\$(RUN) -M lispinit.mem -q ${SRCTOPDIR_}win32msvc/nsis/text_to_rtf.lisp COPYRIGHT COPYRIGHT.tmp"
2800  echotab "sed -e 's/\@NAME\@/\$(PACKAGE_NAME)/g' -e 's/\@VERSION\@/\$(VERSION)/g' COPYRIGHT.tmp > COPYRIGHT.rtf"
2801  echotab '$(RM) COPYRIGHT.tmp'
2802  echol
2803fi
2804
2805echol "allc : init \$(CFILES)"
2806echodummyrule allc
2807echol
2808
2809for f in $DFILES ; do
2810  echol "${f}.c : ${SRCDIR}${f}.d comment5${HEXE}${XDECL_DEPENDENCIES}"
2811  gen_filter=
2812  case "${f}" in
2813    lispbibl) gen_filter=" | sed -e 's/^\\(%% .*\\)//'" ;;
2814  esac
2815  echotab "\$(COMMENT5) ${SRCDIR}${f}.d${gen_filter} ${XDECL_FILTER} > ${f}.c"
2816  echol
2817done
2818
2819for f in $ARI_ASMD $SP_ASMD ; do
2820  echol "${f}.c : ${SRCDIR}${f}.d comment5${HEXE} ${XASMCCPAUX}"
2821  echotab "\$(COMMENT5) ${SRCDIR}${f}.d${XASMCCPAUX_FILTER} > ${f}.c"
2822  echol
2823done
2824
2825if [ $TSYS != win32msvc ] ; then
2826  if [ $AS_UNDERSCORE = true ] ; then
2827    ASMFLAGS=' -DASM_UNDERSCORE'
2828  else
2829    ASMFLAGS=''
2830  fi
2831  # The assembly-language syntax processing is CPU specific.
2832  # Makefile.devel uses asm-${asmsyntax}.sh and asm-${asmsyntax}.h (if present).
2833  # Keep this computation of asmsyntax consistent with Makefile.devel!
2834  case "$cpu" in
2835    arm | armhf | arm64)
2836      asmsyntax=arm ;;
2837    mips | mipsn32 | mips64)
2838      asmsyntax=mips ;;
2839    powerpc | powerpc64 | powerpc64-elfv2)
2840      asmsyntax=powerpc ;;
2841    s390 | s390x)
2842      asmsyntax=s390 ;;
2843    sparc | sparc64)
2844      asmsyntax=sparc ;;
2845    *)
2846      asmsyntax="$cpu" ;;
2847  esac
2848  for f in $ARI_ASMS $SP_ASMS ; do
2849    # The preprocessor barfs on ari_asm_hppa: "unterminated character constant".
2850    # This gets ignored, because it occurs in a pipe.
2851    echol "${f}.s : ${SRCDIR}${f}-macro.c"
2852    # Preprocess, then remove the line number information etc. and convert
2853    # "% ecx" back to "%ecx" and ". align" to ".align" and ". Lxxx" to ".Lxxx":
2854    if test -n "${SRCDIR}"; then
2855      i_option="-I${SRCDIR} "
2856    else
2857      i_option=''
2858    fi
2859    case "$asmsyntax" in
2860      i386 | x86_64 | sparc)
2861        # Use "- <" because the Sun Studio 11 compiler should not assume C syntax of the input.
2862        cpp_from='- < '
2863        ;;
2864      *)
2865        cpp_from=''
2866        ;;
2867    esac
2868    case "$asmsyntax" in
2869      arm)
2870        asmfilter2="\$(SED) -e 's,% ,%,g' -e 's,//,@,g' -e 's,\\\$\$,#,g'"
2871        ;;
2872      hppa)
2873        asmfilter2="\$(SED) -e \"s,!,',g\""
2874        ;;
2875      i386 | x86_64)
2876        asmfilter2="\$(SED) -e 's,% ,%,g' -e 's,\\. ,.,g' -e 's,@ ,@,g' -e 's,//.*\$\$,,' -e 's/##//g'"
2877        ;;
2878      m68k)
2879        if [ $AS_UNDERSCORE = true ] ; then
2880          final_sed_invocation="\$(SED) -e 's/\\\$\$//g'"
2881        else
2882          final_sed_invocation="\$(SED) -e 's/\\\$\$/%/g'"
2883        fi
2884        asmfilter2="\$(SED) -e 's,% ,%,g' -e 's,//.*\$\$,,' | ${final_sed_invocation}"
2885        ;;
2886      sparc)
2887        asmfilter2="\$(SED) -e 's,% ,%,g' -e 's,\\. ,.,g' -e 's,//.*\$\$,,' -e 's,\\\$\$,#,g' -e 's,# ,#,g'"
2888        ;;
2889      *)
2890        asmfilter2="\$(SED) -e 's,% ,%,g' -e 's,//.*\$\$,,'"
2891        ;;
2892    esac
2893    echotab "${XCPP}${ASMFLAGS} ${i_option}${cpp_from}${SRCDIR}${f}-macro.c | \$(GREP) -v '^ *#line' | \$(GREP) -v '^#' | ${asmfilter2} > ${f}.s"
2894    echol
2895  done
2896fi
2897
2898for f in lispbibl; do
2899  echol "gen.${f}.c : ${SRCDIR}${f}.d comment5${HEXE}"
2900  echotab "\$(COMMENT5) ${SRCDIR}${f}.d | sed -e '/^%% /{s///;p;d;}' -e '/^#line /!s/.*//' | sed -e 's/puts(/fprintf(header_f,\"%s\\\\n\",/g' -e 's/print(\"/fprint(header_f,\"/g' -e 's/printf(\"/fprintf(header_f,\"/g' > gen.${f}.c"
2901  echol
2902done
2903
2904line="allo : allc"
2905for f in $CPARTS ; do
2906  line=$line" ${f}${TOBJ}"
2907done
2908echol $line
2909echodummyrule allo
2910echol
2911
2912line="alls : allc"
2913for f in $CPARTS ; do
2914  line=$line" ${f}.s"
2915done
2916echol $line
2917echodummyrule alls
2918echol
2919
2920echol "# Normally not used (just for debugging)."
2921line="alli : allc"
2922for f in $CPARTS ; do
2923  line=$line" ${f}.i"
2924done
2925echol $line
2926echodummyrule alli
2927echol
2928
2929for f in $CPARTS genclisph modules $EXTRA_CPARTS ; do
2930  depends=$EVERY_INCLUDES
2931  dependsc=''
2932  c=${f}.c
2933  test $f = spvw -o $f = package && depends=$depends' constpack'
2934  test $f = spvw -o $f = predtype && depends=$depends' avl'
2935  test $f = spvw && depends=$depends''$SPVW_INCLUDES" sort ${SRCDIR}spvw_calendar"
2936  test $f = eval && depends=$depends' bytecode '${with_jitc}
2937  test $f = array -o $f = hashtabl -o $f = io -o $f = time -o $f = package -o $f = spvw -o $f = stream -o $f = foreign && depends=$depends' arilev0'
2938  test $f = spvw -o $f = hashtabl && depends=$depends' aridecl'
2939  if [ $f = charstrg -a "${with_unicode}" != no ] ; then
2940    depends=$depends${UNICODE_INCLUDES}
2941    dependsc=${dependsc}' '${GLLIB_A}
2942  fi
2943  test $f = encoding && depends=$depends''$NLS_INCLUDES
2944  test $f = error && depends=$depends' '$ERROR_INCLUDES
2945  test $f = lisparit -o $f = arilev1_asm_proto && depends=$depends''$LISPARIT_INCLUDES''$ARI_ASMS
2946  test $f = genclisph && depends=$depends' gen.lispbibl'
2947  for g in $depends ; do
2948    dependsc=$dependsc' '$g'.c'
2949  done
2950  dependsc=$dependsc''$EVERY_INCLUDES_H
2951  test $f = spvw -a -n "${SPVW_VERSION}" && dependsc=$dependsc' '${SPVW_VERSION}
2952  if [ $f = pathname ] ; then
2953    dependsc=$dependsc" ${SRCDIR}execname.c"
2954    test ${TOS} = win32 && dependsc=$dependsc" ${SRCDIR}w32shell.c"
2955  fi
2956  test $f = built && dependsc=${dependsc}' cflags.h'
2957  flags="$XCPPFLAGS $XCFLAGS"
2958  # HP-UX cc and Sun cc don't look for include files in the current directory
2959  # any more after a preprocessor directive '#line 1 "../src/file.d"'.
2960  flags=$flags" -I."
2961  test $f = foreign -a $HOS = win32 && flags=$flags" -I${SRCTOPDIR}ffcall"
2962  test $f = genclisph && flags=$flags" -DCOMPILE_STANDALONE"
2963  if [ $f = modules ] ; then
2964    c=${SRCDIR}${c}
2965    if [ $HOS = unix -a $CROSS = false ] ; then
2966      dependsc=$dependsc' clisp.h'
2967    else
2968      flags=$flags' -DNO_CLISP_H'
2969    fi
2970    flags="${flags} -I."
2971    dependsc=$dependsc' modules.h'
2972  fi
2973  flags2=$flags
2974  # Reduce optimizations in special cases.
2975  if [ $XCC_GCC = true ] ; then
2976    case " $XCFLAGS " in
2977      *" -O0 "*) ;;
2978      *)
2979        if [ $f = eval -a "$cpu" = ia64 ] ; then
2980          # gcc-2.96 on Linux/ia64 miscompiles eval.d when -O is used.
2981          flags2=$flags2' -O0'
2982        fi
2983        if [ $f = eval -a "$cpu" = sparc ] ; then
2984          # gcc-7.2.0 on Linux/sparc appears to miscompile eval.d when -O2 is used.
2985          flags2=$flags2' -O1'
2986        fi
2987        if [ $f = eval -a "$cpu" = sparc64 ] ; then
2988          # gcc-4.6.3 on Linux/sparc64 miscompiles eval.d when -O is used.
2989          flags2=$flags2' -O0'
2990        fi
2991        if [ "$cpu" = mips -a -n "$USE_WIDE_SOFT" ] ; then
2992          # gcc-4.9.2 on Linux/mips (o32 ABI) miscompiles spvw.o, eval.o,
2993          # control.o, list.o and others when -DWIDE and -O is used.
2994          flags2=$flags2' -O0'
2995        fi
2996        if [ "$cpu" = mipsn32 -a -n "$USE_WIDE_SOFT" ] ; then
2997          # gcc-3.4.6 on IRIX/mips (n32 ABI) miscompiles something
2998          # when -DWIDE and -O2 is used.
2999          flags2=$flags2' -O1'
3000        fi
3001        if [ "$cpu" = i386 -a -n "$USE_WIDE_SOFT" ] ; then
3002          # gcc-6.3.0 on Hurd/i386 miscompiles something when -DWIDE is in use
3003          # and -O2 is used on all of spvw.o eval.o control.o encoding.o stream.o io.o
3004          # array.o hashtabl.o list.o record.o sequence.o charstrg.o predtype.o symbol.o.
3005          # The effect is a crash in loadmem_from_handle.
3006          # Also, clang 3.8.0 on FreeBSD/i386 miscompiles stream.o when -DWIDE is in
3007          # use and -O2.
3008          flags2=$flags2' -O1'
3009        fi
3010        if [ $f = hashtabl ] ; then
3011          case "$cpu" in
3012            riscv64*)
3013              # gcc-7.3.1 on Linux/riscv64 miscompiles hash_table_iterate in hashtabl.d
3014              # when -O2 is used. <https://bugzilla.redhat.com/show_bug.cgi?id=1567505>
3015              flags2=$flags2' -O1'
3016              ;;
3017          esac
3018        fi
3019        if [ $f = lisparit -a "$cpu" = s390x ] ; then
3020          # gcc-4.9.2 on Linux/s390x miscompiles lisparit.d when -O2 is used.
3021          flags2=$flags2' -O1'
3022        fi
3023        ;;
3024    esac
3025  else
3026    case "$host_os" in
3027      aix*)
3028        if [ $f = lisparit -a -n "$USE_WIDE_SOFT" ] ; then
3029          # xlc 12.01 on AIX/powerpc miscompiles lisparit.o when -DWIDE is in use
3030          # and -O.
3031          flags2=$flags2' -O0'
3032        fi
3033        ;;
3034    esac
3035  fi
3036  if [ $f = eval -a "${with_jitc}" = lightning ]; then
3037    flags2=$flags2' -Wno-unused' # should be gone - eventually...
3038  fi
3039  if [ $f = arilev1_asm_proto -a $XCC_GCC = true ]; then
3040    # We don't want debugging information in arilev1_asm_proto.s.
3041    flags2=$flags2' -g0 -fno-dwarf2-cfi-asm'
3042  fi
3043  # Files that define C functions that are used as argument of make_machine_code
3044  # (such as the PSEUDOFUNs) need to make sure to align them properly for the
3045  # HEAPCODES object representation. Fortunately, modules cannot define
3046  # PSEUDOFUNs, therefore we don't need to apply this to the MODULE_CFLAGS.
3047  # encoding.d, stream.d, hashtabl.d, predtype.d define PSEUDOFUNs.
3048  # funarg.d defines test functions for list.d.
3049  # socket.d needs this flag, too, for ONE_FREE_BIT_HEAPCODES on Linux/x86_64. Very bizarre.
3050  if [ $f = encoding -o $f = stream -o $f = hashtabl -o $f = predtype -o $f = funarg -o $f = socket ] ; then
3051    flags2=$flags2" ${FALIGNFLAGS}"
3052  fi
3053  if [ $f = genclisph -a $XCC_GCC = true ] ; then
3054    # When using -O2 or higher, the compilation of genclisph.c takes several
3055    # minutes, which is unnecessary since it gets run only once.
3056    # When using -O0, the compilation of genclisph.c fails on AIX:
3057    # "1252-171 The displacement must be greater than or equal to -32768 and less than or equal to 32767."
3058    flags2=$flags2' -O1'
3059  fi
3060  echol "${f}.i : ${c}${dependsc}"
3061  echotab "${XCPP} ${flags} ${c} > ${f}.i"
3062  echol
3063  echol "${f}.s : ${c}${dependsc}"
3064  echotab "${XCC} ${flags2} -S ${c}"
3065  echol
3066  echol "${f}${TOBJ} : ${c}${dependsc}"
3067  echotab "${XCC} ${flags2} -c ${c}"
3068  echol
3069done
3070
3071if [ "${with_gmalloc}" = yes ]; then
3072  for f in $GMALLOC ; do
3073    echol "${f}${TOBJ} : ${SRCDIR}${f}.c"
3074    # gmalloc.c needs -DUSG on Solaris and then needs -DMEMMOVE_MISSING for SunOS 4.
3075    echotab "${XCC} ${XCPPFLAGS} ${XCFLAGS} -DUSG -DMEMMOVE_MISSING -c ${SRCDIR}${f}.c -o ${f}${TOBJ}"
3076    echol
3077  done
3078fi
3079
3080for f in $ARI_ASMS $SP_ASMS ; do
3081  if [ $TSYS = win32msvc ] ; then
3082    echol "${f}.i : ${SRCDIR}${f}-macro.c"
3083    echotab "${XCPP} ${XCPPFLAGS} ${XCFLAGS} ${SRCDIR}${f}-macro.c > ${f}.i"
3084    echol
3085    echol "${f}.s : ${SRCDIR}${f}-macro.c"
3086    if false; then # old
3087      echotab "${XCPP} ${XCPPFLAGS} ${XCFLAGS} ${SRCDIR}${f}-macro.c > ${f}.i.c"
3088      echotab "${XCC} ${XCFLAGS} -c ${f}.i.c /FAs /Fa${f}.s"
3089      echotab "\$(RM) ${f}.i${TOBJ}"
3090      echotab "\$(RM) ${f}.i.c"
3091    else
3092      echotab "${XCC} ${XCPPFLAGS} ${XCFLAGS} -c ${SRCDIR}${f}-macro.c /FAs /Fa${f}.s"
3093      echotab "\$(RM) ${f}-macro${TOBJ}"
3094    fi
3095    echol
3096    echol "${f}${TOBJ} : ${SRCDIR}${f}-macro.c"
3097    if false; then # old
3098      echotab "${XCPP} ${XCPPFLAGS} ${XCFLAGS} ${SRCDIR}${f}-macro.c > ${f}.i.c"
3099      echotab "${XCC} ${XCFLAGS} -c ${f}.i.c /Fo${f}${TOBJ}"
3100      echotab "\$(RM) ${f}.i.c"
3101    else
3102      echotab "${XCC} ${XCPPFLAGS} ${XCFLAGS} -c ${SRCDIR}${f}-macro.c /Fo${f}${TOBJ}"
3103    fi
3104    echol
3105  else
3106    echol "${f}${TOBJ} : ${f}.s"
3107    # Call the assembler, preferrably through the C compiler:
3108    if [ $f = ari_asm_hppa ] ; then
3109      # Only the native as groks the .SHORTDATA statements in ari_asm_hppa.d
3110      echotab "${XCC} ${XCPPFLAGS} ${XCFLAGS} -c ${f}.s || /usr/ccs/bin/as ${f}.s -o ${f}${TOBJ} || /bin/as ${f}.s -o ${f}${TOBJ}"
3111    elif [ $XCC_GCC = true ] ; then
3112      echotab "${XCC} ${XCPPFLAGS} ${XCFLAGS} -x assembler -c ${f}.s"
3113    else
3114      echotab "${XCC} ${XCPPFLAGS} ${XCFLAGS} -c ${f}.s"
3115    fi
3116    echol
3117  fi
3118done
3119
3120if [ $HOS = unix -o $HSYS = win32gcc ] ; then
3121  # on w32 -g, using lisp.o leads to a crash on the first statement in main()
3122  test $HSYSOS = win32gcc -o $HSYSOS = cygwin; no_lisp_o=$?
3123  echol "lisp.a : \$(OBJECTS)"
3124  if [ $no_lisp_o = 1 ]; then
3125    echotab "\$(LD) -r -o lisp.o \$(OBJECTS)"
3126    echotab "chmod a-x lisp.o"
3127  fi
3128  if test -z "$LIBGCC"; then
3129    if [ $no_lisp_o = 1 ]; then
3130      echotab "\$(AR) rcv lisp.a lisp.o"
3131    else
3132      echotab "\$(AR) rcv lisp.a \$(OBJECTS)"
3133    fi
3134  else
3135    # Test for libgcc.a because NeXT cc does not have it.
3136    echotab "if test -f \$(LIBGCC) ; then mkdir libgcc ; (cd libgcc ; \$(AR) xv \$(LIBGCC)) ; \$(AR) rcv lisp.a lisp.o libgcc/*.o* ; \$(RM) -r libgcc ; else \$(AR) rcv lisp.a lisp.o ; fi"
3137  fi
3138  test $no_lisp_o = 1 && echotab "\$(RM) lisp.o"
3139  echotab "\$(RANLIB) lisp.a"
3140  echol
3141  echol "libnoreadline.a : noreadline.o"
3142  echotab "\$(AR) rcv libnoreadline.a noreadline.o"
3143  echotab "\$(RANLIB) libnoreadline.a"
3144  echol
3145fi
3146if [ ${SHREXT} = .dll -a "${with_dynamic_modules}" != no ]; then
3147  # win32 (SHREXT=.dll) requires all accessed libraries when linking a DLL.
3148  # i.e. when creating a dynamic module dll, we must give lisp.dll to the
3149  # linker, and when creating lisp.dll, we must give $(LIBS) to it.
3150  # Some unixes (SHREXT=.so) need -fPIC when compiling clisp core for a DLL,
3151  # which loses performance; besides, we do not need lisp.so on unix anyway.
3152  echol "lisp${SHREXT} : ${GLLIB_A} \$(OBJECTS) modules.o"
3153  CLISP_DEF=" lisp.def"
3154  XCC_CREATESHARED_=`echo ${XCC_CREATESHARED} | sed -e 's/\\${/\\\\$\\\\(/g' -e 's/}/\\\\)/g'`
3155  echotab "`eval \"lib=\$\@; libs=\$^\ \$\(LIBS\); echo ${XCC_CREATESHARED_}\"`"
3156  echol
3157else
3158  CLISP_DEF=""
3159fi
3160FILES="${FILES}${CLISP_DEF}"
3161
3162if [ -n "$USE_GETTEXT" ] ; then
3163  echol "po : config.status ${SRCDIR}po/LINGUAS ${SRCDIR}po/Makefile.in.in"
3164  echotab "mkdir -p po"
3165  echotab "test -f po/Makefile.in || sh config.status po/Makefile.in po-directories"
3166  echol
3167  echol "LN_HARD=${LN_HARD}"
3168  echol "locale : po"
3169  if [ $HOS = unix ] ; then
3170    echotab "if test -d locale; then \$(RMRF) locale; fi"
3171    echotab "mkdir locale"
3172    echotab "(cd po && \$(MAKE) && \$(MAKE) install datarootdir=.. localedir='\$\$(datarootdir)/locale' INSTALL_DATA='\$(LN_HARD)') || (\$(RMRF) locale ; exit 1)"
3173    case "$host_os" in
3174      solaris*)
3175        # The non-GNU dgettext() function in Solaris libc needs symbolic links.
3176        # For the list of locale names, see spvw_language:init_language().
3177        for localename in en_US de_DE fr_FR es_ES nl_NL ru_RU da_DK sv_SE; do
3178          ll=`echo "${localename}" | sed -e 's/_.*//'`
3179          echotab "test -d 'locale/${localename}.UTF-8/LC_MESSAGES' || ln -s '${ll}' 'locale/${localename}.UTF-8'"
3180        done
3181        ;;
3182    esac
3183  else
3184    echotab "mkdir locale"
3185    if test -f ${SRCDIR}po/LINGUAS; then
3186      LINGUAS=`sed 's/#.*//' ${SRCDIR}po/LINGUAS`
3187    else fail "missing ${SRCDIR}po/LINGUAS"
3188    fi
3189    for lang in ${LINGUAS}; do
3190      echotab "mkdir -p locale${NEXT_}${lang}${NEXT_}LC_MESSAGES"
3191      echotab "\$(LN_S) ${SRCDIR}po${NEXT_}${lang}.gmo locale${NEXT_}${lang}${NEXT_}LC_MESSAGES${NEXT_}clisp.mo"
3192    done
3193  fi
3194  echol
3195fi
3196
3197DATA_FILES="UnicodeDataFull.txt Symbol-Table.text"
3198DATA_FILES_TOP_PATH="utils${NEXT_}unicode${NEXT_}UnicodeDataFull.txt doc${NEXT_}Symbol-Table.text"
3199data_target="data :"
3200for f in ${DATA_FILES_TOP_PATH}; do
3201  data_target="${data_target} ${SRCTOPDIR_}${f}"
3202done
3203echol "${data_target}"
3204echotab "\$(RMRF) data"
3205echotab "mkdir data"
3206for f in ${DATA_FILES_TOP_PATH}; do
3207  echotab "cd data && \$(LN_S) ${PARENT_SRCTOPDIR_}${f} ."
3208done
3209echol
3210
3211if [ ${HSYS} = win32gcc -a "${with_debug}" = no ]; then
3212finish_runtime () {
3213  # woe32 users do not have gcc, so they cannot disassemble CAR anyway
3214  echotab "strip -s lisp${LEXE}"
3215  echol
3216}
3217else
3218finish_runtime () {
3219  echol
3220}
3221fi
3222
3223echol "lisp${LEXE} : ${GLLIB_A} \$(OBJECTS) modules${TOBJ} ${XCL_GETTEXTLIB} data"
3224if [ $HOS != win32 ] ; then
3225  if [ $XCC_GCC = true -a -n "$SOLARIS_LINKING" ] ; then
3226    # Dynamically linking on Solaris 2.[23] is a pain.
3227    LIBGCC_DIR='`'"${XCC} -print-libgcc-file-name"' | sed -e '"'"'s,[^/]*$$,,'"'"'`'
3228    echotab "${XCC} ${XCFLAGS} ${XCLFLAGS} \$(OBJECTS) modules${TOBJ} ${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${TOBJ} -L${LIBGCC_DIR} -L/usr/ccs/bin ${LIBS} -lgcc -lc ${LIBGCC_DIR}crtend.o ${LIBGCC_DIR}crtn.o -lgcc"
3229  else
3230    echotab "${XCC} ${XCFLAGS} ${XCLFLAGS} \$(OBJECTS) modules${TOBJ} ${LIBS} ${OUT}lisp${LEXE}"
3231  fi
3232else
3233  # MSVC's incremental linking is buggy, avoid it.
3234  if [ $HSYS = win32msvc ] ; then echotab "\$(RM) lisp.ilk"; fi
3235  echotab "${XCC} ${XCFLAGS} ${XCLFLAGS} \$(OBJECTS) modules${TOBJ} ${LIBS} ${OUT}lisp${LEXE}"
3236  # With msvc4/5, need at least 1200 KB stack for creating the first
3237  # interpreted.mem, but the default stack size is only 1 MB.
3238  # With msvc6, need more than 2 MB for compiling compiler.lisp.
3239  if [ $HSYS = win32msvc -a ${COMPILER} != msvc7 ]; then
3240    # Jay Kint <jkint@icosahedron.org> says that msvc7(.NET) does not need this
3241    echotab "editbin /stack:3145728 lisp${LEXE}"
3242  fi
3243fi
3244finish_runtime lisp${LEXE}
3245
3246if [ $TSYS = win32msvc -a "${with_debug}" != no ] ; then
3247  echol "${SRCDIR}lisp.bsc : lisp${LEXE}"
3248  echotab "bscmake /n /o lisp *.sbr"
3249  echol
3250fi
3251
3252echol "marc.out : lisp${LEXE}"
3253echotab "${HERE}lisp${LEXE} -marc > marc.out"
3254echol
3255
3256CONFIG=cfg${TOS}
3257echol "config.lisp : ${SRCDIR}${CONFIG}.lisp"
3258echotab "\$(CP) ${SRCDIR}${CONFIG}.lisp config.lisp"
3259if [ $TOS = unix ] ; then
3260  echotab "chmod +w config.lisp"
3261  echotab "echo '(setq *clhs-root-default* \"${hyperspec}\")' >> config.lisp"
3262  if [ ${TSYSOS} = cygwin ]; then
3263    # maybe convert the cygwin cygdrive pathnames
3264    # http://article.gmane.org/gmane.os.cygwin:67868
3265    # https://cygwin.com/ml/cygwin/2005-08/msg00460.html
3266    DEVPREFIX=`mount -p | sed -nr '2s,/([^ ]+) +\S+ +\S+$,\1,p'`
3267    echotab "echo '(setq *device-prefix* \"${DEVPREFIX}\")' >> config.lisp"
3268  fi
3269fi
3270echol
3271
3272if [ -n "$USE_GETTEXT" ] ; then
3273  localeflags='-B . -N locale'
3274else
3275  localeflags='-B .'
3276fi
3277if [ "${with_unicode}" != no ] ; then
3278  # make sure that no encoding is left as ASCII (the C locale encoding)
3279  # The first "-E" sets all encodings to UTF-8, so that we can read
3280  #   CLISP source files and dump everything to the terminal;
3281  #   this is also important for the regexp test suite.
3282  # The second "-E" ensures that syscalls tests pass (user names may be 8bit)
3283  encflags=' -E UTF-8 -Emisc 1:1'
3284  if [ "${TSYSOS}" != darwin ]; then # utf-8 on Darwin is good enough
3285    # The last "-E" ensures that we can parse all pathnames.
3286    encflags=${encflags}' -Epathname 1:1'
3287  fi
3288else
3289  encflags=''
3290fi
3291someflags=${encflags}' -norc'
3292echol "RUN= ${HERE}lisp${LEXE} ${localeflags}${someflags}"
3293echol
3294
3295for f in ${LUTILS} ; do
3296  echol "${f}.fas : ${UTILDIR_M}${f}.lisp lisp${LEXE} lispinit.mem"
3297  echotab "\$(RUN) -M lispinit.mem -q -c ${UTILDIR}${f}.lisp -o ./"
3298  echol
3299done
3300
3301# The strict minimum needed for building interpreted.mem is between 1400KW
3302# and 1500KW. To reduce GCs, we spend 30% more than this. 8MB is not a big deal.
3303MEMOPT="-m 2MW"
3304
3305if [ $CROSS = false ] ; then
3306
3307  if [ "$HSYS" = win32gcc ]; then
3308    # work around an msys "feature": ":" after "/" is converted to a ";"
3309    # <http://article.gmane.org/gmane.comp.gnu.mingw.msys/4281>
3310    # <https://sourceforge.net/p/mingw/mailman/message/18351247/>
3311    # <http://article.gmane.org/gmane.lisp.clisp.devel/17589>
3312    # <https://sourceforge.net/p/clisp/mailman/message/18541077/>
3313    # <http://article.gmane.org/gmane.lisp.clisp.devel/17895>
3314    # <https://sourceforge.net/p/clisp/mailman/message/18996399/>
3315    SAFE_SRCDIR=`echo ${SRCDIR} | sed 's,/,\\\\\\\\,g'`
3316  else
3317    SAFE_SRCDIR=${SRCDIR}
3318  fi
3319
3320  echol "interpreted.mem : lisp${LEXE} \$(LISPFILES) config.lisp"
3321  test $HOS != unix && echotab "-\$(RM) interpreted.mem"
3322  if [ $HSYSOS = beos ] ; then
3323    # Work around BeOS 5 kernel bug which causes subsequent invocations
3324    # of lisp${LEXE} to be incorrectly relocated. On BeOS, executables and
3325    # shared libraries are relocated page-by-page by a kernel routine.
3326    echotab "cp -p lisp${LEXE} lisp.tmp"
3327    echotab "mv lisp.tmp lisp${LEXE}"
3328  fi
3329  echotab "\$(RUN) ${MEMOPT} -lp ${SAFE_SRCDIR} -x '(and (load \"${SAFE_SRCDIR}init.lisp\") (sys::%saveinitmem) (ext::exit)) (ext::exit t)'"
3330  echotab "\$(MV) lispimag.mem interpreted.mem"
3331  echol
3332
3333fi
3334
3335if [ $CROSS = false ] ; then
3336
3337  for f in $LPARTS ; do
3338    if [ $f = "compiler" ]; then
3339      image=interpreted.mem
3340    else
3341      image=halfcompiled.mem
3342    fi
3343    echol "${f}.fas : ${SRCDIR}${f}.lisp lisp${LEXE} $image"
3344    echotab "\$(RUN) ${MEMOPT} -M ${image} -q -c ${SRCDIR}${f}.lisp -o ./"
3345    echol
3346  done
3347  echol "config.fas : config.lisp lisp${LEXE} halfcompiled.mem"
3348  echotab "\$(RUN) ${MEMOPT} -M ${image} -q -c config.lisp"
3349  echol
3350
3351  echol "halfcompiled.mem : lisp${LEXE} \$(LISPFILES) config.lisp compiler.fas"
3352  test $HOS != unix && echotab "-\$(RM) halfcompiled.mem"
3353  if [ $HSYSOS = beos ] ; then
3354    # Workaround BeOS 5 kernel bug, see explanation above.
3355    echotab "cp -p lisp${LEXE} lisp.tmp"
3356    echotab "mv lisp.tmp lisp${LEXE}"
3357  fi
3358  echotab "\$(RUN) ${MEMOPT} -lp ${SAFE_SRCDIR} -x '(and (load \"${SAFE_SRCDIR}init.lisp\") (sys::%saveinitmem) (ext::exit)) (ext::exit t)'"
3359  echotab "\$(MV) lispimag.mem halfcompiled.mem"
3360  echol
3361
3362  echol "lispinit.mem : lisp${LEXE} \$(FASFILES)"
3363  test $HOS != unix && echotab "-\$(RM) lispinit.mem"
3364  if [ $HSYSOS = beos ] ; then
3365    # Workaround BeOS 5 kernel bug, see explanation above.
3366    echotab "cp -p lisp${LEXE} lisp.tmp"
3367    echotab "mv lisp.tmp lisp${LEXE}"
3368  fi
3369  echotab '$(RUN) -x "(and (load \"init.fas\") (ext::saveinitmem) (ext::exit)) (ext::exit t)"'
3370  echol
3371
3372fi
3373
3374echol
3375
3376if [ -n "$USE_GETTEXT" ] ; then
3377  localeflags="-B ${HEREP} -N ${HERE_}locale"
3378else
3379  localeflags="-B ${HEREP}"
3380fi
3381CLISP_="${HERE_}lisp${LEXE} -M ${HERE_}lispinit.mem ${localeflags}${someflags}"
3382
3383if [ $CROSS = false ] ; then
3384  CHECK_DEPS="check-recompile check-fresh-line check-script check-tests"
3385
3386  echol "# check the sources:"
3387  echol "# 1. subr.d, fsubr.d and all the LISPFUNs must add up"
3388  echol "# 2. no variables of type gcv_object_t - only pointers to it"
3389  echol "check-sources : # lisp${LEXE} lispinit.mem"
3390  echotab '$(RUN) -M lispinit.mem -C -i '"${SRCDIR}"'check-lispfun.lisp -x "(check-lisp-defs \"'"${SRCDIR}"'\")"'
3391  echotab "if egrep ' var gcv_object_t *[^* ]' ${SRCDIR}*.d; then false; else true; fi"
3392  echol
3393
3394  echol "# Test: recompile \$(LISPFILES) and compare their contents."
3395  echol "check-recompile : lispinit.mem ${RECOMPILEDIR} \$(TESTFASFILES)"
3396  if [ $HOS = unix -o $HSYS = win32gcc ] ; then
3397    for f in $LPARTS config; do
3398      echotab "cmp -s ${f}.fas ${RECOMPILEDIR}/${f}.fas "' || (echo "Test failed." ; exit 1)'
3399    done
3400    echotab 'echo "Test passed."'
3401    echol
3402  elif [ $HSYS = win32msvc ] ; then
3403    echotab "comp *.fas ${RECOMPILEDIR}"
3404    echotab "echo The test passed if only GENSYM differences were found."
3405    echol
3406  else
3407    echotab 'echo "Compare the .fas files by hand."'
3408    echol
3409  fi
3410
3411  echol "${RECOMPILEDIR} :"
3412  echotab "-mkdir ${RECOMPILEDIR}"
3413  echol
3414
3415  for f in $LPARTS; do
3416    echol "${RECOMPILEDIR}${NEXT_M}${f}.fas : ${SRCDIR}${f}.lisp lisp${LEXE} lispinit.mem"
3417    echotab "\$(RUN) -m 1MW -M lispinit.mem -q -d -c ${SRCDIR}${f}.lisp -o ${RECOMPILEDIR}${NEXT_}"
3418    echol
3419  done
3420  echol "${RECOMPILEDIR}${NEXT_M}config.fas : config.lisp lisp${LEXE} lispinit.mem"
3421  echotab "\$(RUN) -m 1MW -M lispinit.mem -q -d -c config.lisp -o ${RECOMPILEDIR}${NEXT_}"
3422  echol
3423
3424  echol "lispinit2.mem : lisp${LEXE} \$(TESTFASFILES)"
3425  if [ $HSYSOS = beos ] ; then
3426    # Workaround BeOS 5 kernel bug, see explanation above.
3427    echotab "cp -p lisp${LEXE} lisp.tmp"
3428    echotab "mv lisp.tmp lisp${LEXE}"
3429  fi
3430  echotab '$(RUN) -x "(and (cd \"'"${RECOMPILEDIR}${NEXT}"'\") (load \"init.fas\") (cd \"'"${PARENT}"'\") (sys::%saveinitmem) (ext::exit)) (ext::exit t)"'
3431  echotab "-\$(RM) lispinit2.mem"
3432  echotab "\$(MV) lispimag.mem lispinit2.mem"
3433  echol
3434
3435  echol
3436
3437  # Check that fresh-line works, when clisp is used in batch mode (option -x)
3438  # and when the stdout and stderr are the same (2>&1), even when this output
3439  # is a pipe.
3440  # On win32, this test fails, and we cannot fix it, because given two pipe
3441  # handle for stdout and stderr, we cannot determine equality. Instead test
3442  # only the (easier) case of stdout and stderr going to a file.
3443  echol "check-fresh-line : lisp${LEXE} lispinit.mem"
3444  OBSOLETE="$OBSOLETE fresh-line.out"
3445  echotab "-\$(RM) fresh-line.out"
3446  if [ "$HOS" = win32 -o "$HSYS" = win32gcc ] ; then
3447    echotab "\$(RUN) -q -M lispinit.mem -x '(progn (dolist (s (quote (*terminal-io* *standard-output* *error-output* *query-io* *debug-io* *trace-output*))) (format t \"~S = ~S~%\" s (symbol-value s))) (values))' 2>&1 > fresh-line.out"
3448    for stream1 in '*terminal-io*' '*standard-output*' '*error-output*' '*query-io*' '*debug-io*' '*trace-output*'; do
3449      for stream2 in '*terminal-io*' '*standard-output*' '*error-output*' '*query-io*' '*debug-io*' '*trace-output*'; do
3450        echotab "\$(RUN) -q -M lispinit.mem -x '(progn (format ${stream1} \"~&Line1 to ${stream1}\") (format ${stream2} \"~&Line2 to ${stream2}\") (values))' 2>&1 >> fresh-line.out"
3451      done
3452    done
3453  else
3454    echotab "\$(RUN) -q -M lispinit.mem -x '(progn (dolist (s (quote (*terminal-io* *standard-output* *error-output* *query-io* *debug-io* *trace-output*))) (format t \"~S = ~S~%\" s (symbol-value s))) (values))' 2>&1 | cat > fresh-line.out"
3455    for stream1 in '*terminal-io*' '*standard-output*' '*error-output*' '*query-io*' '*debug-io*' '*trace-output*'; do
3456      for stream2 in '*terminal-io*' '*standard-output*' '*error-output*' '*query-io*' '*debug-io*' '*trace-output*'; do
3457        echotab "\$(RUN) -q -M lispinit.mem -x '(progn (format ${stream1} \"~&Line1 to ${stream1}\") (format ${stream2} \"~&Line2 to ${stream2}\") (values))' 2>&1 | cat >> fresh-line.out"
3458      done
3459    done
3460  fi
3461  echotab "if grep 'Line1.*Line2' fresh-line.out > /dev/null; then exit 1; fi"
3462  echotab "\$(RM) fresh-line.out"
3463  echol
3464
3465  # check that the scripting works
3466  echol "check-script : lisp${LEXE} lispinit.mem"
3467  # Check for decent behaviour when stdin is not readable
3468  # (cf. https://sourceforge.net/p/clisp/bugs/523/)
3469  case "$host_os" in
3470    aix* | irix*)
3471      # On AIX 7.1 and IRIX 6.5, inside 'make' or 'gmake', a command that has
3472      # stdin with mode O_RDWR gets the current stdin or tty assigned to stdin
3473      # instead. This would make the test hang. 'bash -c' is the workaround.
3474      # Whereas 'sh -c' would not help.
3475      if type bash >/dev/null 2>/dev/null; then
3476        echotab "bash -c '\$(RUN) -q -M lispinit.mem 0>/dev/null'"
3477      fi
3478      ;;
3479    *)
3480      echotab "\$(RUN) -q -M lispinit.mem 0>/dev/null"
3481      ;;
3482  esac
3483  TRCR="| tr -d '\r'"; TRLF="| tr '\n' '_'"
3484  echotab "output=\`echo '(princ (+ 11 99))' | \$(RUN) -q -M lispinit.mem - ${TRCR}\`; test \"\$\$output\" = 110 || exit 1"
3485  echotab "test \"\`echo '(+ foo bar)' | \$(RUN) -q -M lispinit.mem -x '(setq foo 11 bar 99)' -repl ${TRCR}${TRLF}\`\" = '99_[1]> _110_' || exit 1"
3486  echotab "\$(RM) script.lisp; echo '(error \"loading script.lisp\")' > script.lisp"
3487  echotab "if \$(RUN) -q -M lispinit.mem -x '(load \"script.lisp\")' -repl < /dev/null; then exit 1; else :; fi"
3488  echotab "\$(RM) script.lisp; echo '(eval-when (:compile-toplevel) (princ *args*))' > script.lisp"
3489  echotab "output=\`\$(RUN) -q -q -M lispinit.mem -c script.lisp foo bar\`; test \"\$\$output\" = '(foo bar)' || exit 1"
3490  if [ "$HOS" != win32 ]; then # woe32 has unpredictable exit codes
3491    # http://article.gmane.org/gmane.lisp.clisp.devel/18967
3492    # https://sourceforge.net/p/clisp/mailman/message/20318073/
3493    echotab "(echo '(progn (setf (stream-element-type *standard-input*) (quote (unsigned-byte 8))) (exit 42))' | \$(RUN) -q -M lispinit.mem -; test \$\$? = 42) || exit 1"
3494  fi
3495  if [ "${with_unicode}" = no ]; then
3496    seq42="(map (quote (vector (unsigned-byte 8))) (function char-code) \"42\")"
3497  else
3498    seq42='(convert-string-to-bytes "42" charset:ascii)'
3499  fi
3500  echotab "output=\`echo '(setf (stream-element-type *standard-output*) (quote (unsigned-byte 8))) (write-sequence ${seq42} *standard-output*) (setf (stream-element-type *standard-output*) (quote character)) (terpri)' | \$(RUN) -q -M lispinit.mem - ${TRCR}\`; test \"\$\$output\" = 42 || exit 1"
3501  echotab "\$(RM) script.lisp; echo '(+ 11 99)' > script.lisp"
3502  echotab "output=\`\$(RUN) -q -M lispinit.mem < script.lisp ${TRCR}\`; test \"\$\$output\" = 110 || exit 1"
3503  echotab "\$(RM) script.lisp; echo '(princ (+ 11 99))' > script.lisp"
3504  echotab "output=\`\$(RUN) -q -M lispinit.mem script.lisp ${TRCR}\`; test \"\$\$output\" = 110 || exit 1"
3505  echotab "\$(RM) script.lisp; echo '(+ foo bar)' > script.lisp"
3506  echotab "output=\`\$(RUN) -q -M lispinit.mem -x '(setq foo 11 bar 99)' -repl < script.lisp ${TRCR}${TRLF}\`; test \"\$\$output\" = 99_110_ || exit 1"
3507  # "-x with lisp-file is invalid"
3508  # echotab "\$(RM) script.lisp; echo '(princ (+ foo bar))' > script.lisp"
3509  # echotab "output=\`\$(RUN) -q -M lispinit.mem -x '(setq foo 11 bar 99)' -repl script.lisp ${TRCR}${TRLF}\`; test \"\$\$output\" = 99_110_ || exit 1"
3510  if [ "$HOS" != win32 ]; then # woe32 has unpredictable exit codes (see above)
3511    echotab "\$(RM) script.lisp; echo '(progn (setf (stream-element-type *standard-input*) (quote (unsigned-byte 8))) (exit 42))' > script.lisp"
3512    echotab "(\$(RUN) -q -M lispinit.mem < script.lisp; test \$\$? = 42) || exit 1"
3513    echotab "(\$(RUN) -q -M lispinit.mem script.lisp; test \$\$? = 42) || exit 1"
3514  fi
3515  echotab "\$(RM) script.lisp; echo '(setf (stream-element-type *standard-output*) (quote (unsigned-byte 8))) (write-sequence ${seq42} *standard-output*) (setf (stream-element-type *standard-output*) (quote character)) (terpri)' > script.lisp"
3516  # ??? echotab "output=\`\$(RUN) -q -M lispinit.mem < script.lisp ${TRCR}\`; test \"\$\$output\" = 42 || exit 1"
3517  echotab "output=\`\$(RUN) -q -M lispinit.mem script.lisp ${TRCR}\`; test \"\$\$output\" = 42 || exit 1"
3518  echotab "\$(RM) script.lisp; echo '(with-open-stream (s (make-stream :output :element-type (quote (unsigned-byte 8)))) (write-sequence ${seq42} s) (values))' > script.lisp"
3519  echotab "output=\`\$(RUN) -q -M lispinit.mem < script.lisp ${TRCR}\`; test \"\$\$output\" = 42 || exit 1"
3520  echotab "output=\`\$(RUN) -q -M lispinit.mem script.lisp ${TRCR}\`; test \"\$\$output\" = 42 || exit 1"
3521  case "$host_os"  in
3522    darwin* )
3523      # http://stackoverflow.com/questions/29112446/nohup-doesnt-work-with-os-x-yosmite-get-error-cant-detach-from-console-no-s
3524      # http://stackoverflow.com/questions/23898623/nohup-cant-detach-from-console
3525      ;;
3526    * )
3527      echotab "\$(RM) script.lisp; nohup \$(RUN) -q -M lispinit.mem -x 42 2>&1 > script.lisp; output_last_line=\`sed -n -e '\$\$p' script.lisp ${TRCR}\`; test \"\$\$output_last_line\" = 42 || exit 1 "
3528      ;;
3529  esac
3530  echotab "\$(RM) script.lisp script.fas script.lib"
3531  RAISE='(setq *error-output* *standard-output*) (error "myerror")'
3532  echotab "output=\"\`\$(RUN) -q -M lispinit.mem -x '(progn ${RAISE})' ${TRCR}\`\"; test \"\$\$output\" = '*** - myerror' || exit 1"
3533  echotab "if \$(RUN) -q -M lispinit.mem -x '(progn ${RAISE})'; then exit 1; fi"
3534  case "$host_os" in
3535    aix* | hpux* | beos* | haiku* | minix* | mingw*)
3536      # On these platforms, there is no /dev/fd/1.
3537      ;;
3538    *)
3539      echotab "\$(RUN) -q -M lispinit.mem -x '(truename (make-stream :output))'"
3540      echotab "\$(RUN) -q -M lispinit.mem -x '(truename (make-stream :output))'|cat"
3541      ;;
3542  esac
3543  echol
3544
3545  echol "check-tests : ${TESTSDIR} lisp${LEXE} lispinit.mem"
3546  echotab "cd ${TESTSDIR} && \$(MAKE) SHELL='\$(SHELL)' LEXE=${LEXE}"
3547  echol
3548  echol "check-tests-all : ${TESTSDIR} lisp${LEXE} lispinit.mem"
3549  echotab "cd ${TESTSDIR} && \$(MAKE) SHELL='\$(SHELL)' LEXE=${LEXE} clean complete compare"
3550  echol
3551  if [ "${with_threads}" != no ]; then
3552    CHECK_DEPS=${CHECK_DEPS}" check-tests-parallel"
3553    echol "check-tests-parallel : ${TESTSDIR} lisp${LEXE} lispinit.mem"
3554    echotab "cd ${TESTSDIR} && \$(MAKE) SHELL='\$(SHELL)' LEXE=${LEXE} clean parallel compare"
3555    echol
3556  fi
3557  echol "${TESTSDIR} :"
3558  echotab "-mkdir ${TESTSDIR}"
3559  # on win32, LN_S=copy and it accepts exactly 2 arguments
3560  for f in Makefile '*.lisp' '*.tst'; do
3561    echotab "cd ${TESTSDIR} && \$(LN_S) ${PARENT_SRCTOPDIR_}tests${NEXT_}${f} ."
3562  done
3563  echol
3564
3565  # sacla-tests are not included in the source distribution
3566  if test -d "${SRCTOPDIR_}sacla-tests"; then
3567    CHECK_DEPS=${CHECK_DEPS}" check-sacla-tests"
3568    SACLA_CLISP="../lisp${LEXE} -ansi -B .. -M ../lispinit.mem -N ../locale ${someflags} -i tests.lisp"
3569    echol "check-sacla-tests : ${SACLATESTSDIR} lisp${LEXE} lispinit.mem"
3570    echotab "cd ${SACLATESTSDIR} && ${SACLA_CLISP} -x '(ext:exit (plusp (run-all-tests)))'"
3571    echol
3572    echol "${SACLATESTSDIR} :"
3573    echotab "-mkdir ${SACLATESTSDIR}"
3574    # on win32, LN_S=copy and it accepts exactly 2 arguments
3575    for f in '*.lisp'; do
3576      echotab "cd ${SACLATESTSDIR} && \$(LN_S) ${PARENT_SRCTOPDIR_}sacla-tests${NEXT_}${f} ."
3577    done
3578    echol
3579  fi
3580
3581  # ansi-tests are not included in the source distribution
3582  if test -d "${SRCTOPDIR_}ansi-tests"; then
3583    CHECK_DEPS=${CHECK_DEPS}" check-ansi-tests check-ansi-tests-compiled"
3584    ANSI_CLISP="../lisp${LEXE} -B .. -M ../lispinit.mem -N ../locale ${someflags} -m 30000KW -ansi -i clispload.lisp -p CL-TEST"
3585    echol "check-ansi-tests : ${ANSITESTSDIR} lisp${LEXE} lispinit.mem"
3586    echotab "cd ${ANSITESTSDIR} && ${ANSI_CLISP} -x '(time (regression-test:do-tests)) (ext:exit (regression-test:pending-tests))' 2>&1 | tee ../ansi-tests-log"
3587    echol
3588    echol "check-ansi-tests-debug : ${ANSITESTSDIR} lisp${LEXE} lispinit.mem"
3589    echotab "cd ${ANSITESTSDIR} && ${ANSI_CLISP}"
3590    echol
3591    echol "check-ansi-tests-compiled : ${ANSITESTSDIR} lisp${LEXE} lispinit.mem"
3592    echotab "cd ${ANSITESTSDIR} && ${ANSI_CLISP} -x '(setq regression-test::*compile-tests* t) (time (regression-test:do-tests)) (ext:exit (regression-test:pending-tests))' 2>&1 | tee ../ansi-tests-compiled-log"
3593    echol
3594    echol "check-ansi-tests-compiled-debug : ${ANSITESTSDIR} lisp${LEXE} lispinit.mem"
3595    echotab "cd ${ANSITESTSDIR} && ${ANSI_CLISP} -x '(setq regression-test::*compile-tests* t)' -repl"
3596    echol
3597    echol "${ANSITESTSDIR} :"
3598  # Do NOT update the ansi-tests directory automatically, because
3599  # 1. "make check-ansi-tests" would fail as soon as Paul Dietz adds a test
3600  #    that happens to fail in clisp. But we don't want to put out new releases
3601  #    on a weekly or monthly basis, nor do we want to get flooded by reports
3602  #    of failing "make check".
3603  # 2. 'svn' does not work on machines that are not connected to the internet.
3604  # 3. Makefile.devel does not work if 'make' is not GNU make.
3605  # echotab "cd ${SRCTOPDIR_} && \$(MAKE) -f Makefile.devel update-ansi-tests"
3606    echotab "-mkdir ${ANSITESTSDIR}"
3607    # on win32, LN_S=copy and it accepts exactly 2 arguments
3608    for f in Makefile '*.lsp'; do
3609      echotab "cd ${ANSITESTSDIR} && \$(LN_S) ${PARENT_SRCTOPDIR_}ansi-tests${NEXT_}${f} ."
3610    done
3611    echotab "cd ${ANSITESTSDIR} && \$(LN_S) ${PARENT_SRCTOPDIR_}utils${NEXT_}clispload.lisp ."
3612    echol
3613  fi
3614
3615  # benchmarks are not included in the source distribution
3616  if [ -d "${SRCTOPDIR_}benchmarks" -a -n "${GNU_MAKE}" ]; then
3617    CHECK_DEPS=${CHECK_DEPS}" bench"
3618    echol "bench : ${BENCHDIR}"
3619    echotab "CLISP=\"`pwd`/clisp -norc\"; export CLISP; cd ${BENCHDIR}; \$(MAKE) CLISP=\"\$\$CLISP\" clisp"
3620    echol
3621    echol "${BENCHDIR} :"
3622    echotab "-mkdir ${BENCHDIR}"
3623    for f in Makefile '*.lisp'; do
3624      echotab "cd ${BENCHDIR} && \$(LN_S) ${PARENT_SRCTOPDIR_}benchmarks${NEXT_}${f} ."
3625    done
3626    echol
3627  fi
3628
3629  # have .git + developer with a network connection => check id-href.map
3630  # Try wget, lynx, curl in order. wget is common, but MacOS X only has curl.
3631  # use beta pages for the latest id-href.map
3632  # NB: keep in sync with doc/Makefile:DIST
3633  # FIXME: temp hack to work around:
3634  #  * clisp.org redirects to SourceForge which is HTTPS-only
3635  #  * CLISP does not support HTTPS yet
3636  #MYIMPROOT=http://clisp.org/beta/impnotes/
3637  MYIMPROOT=http://www.gnu.org/software/clisp/impnotes/
3638  MYTESTURL=${MYIMPROOT}id-href.map
3639  if test -d "${SRCTOPDIR_}.git" \
3640     && { if wget --version >/dev/null 2>/dev/null ; then \
3641            wget --execute netrc=off --tries=1 --timeout=10 -q ${MYTESTURL}; \
3642          elif lynx --version >/dev/null 2>/dev/null ; then \
3643            lynx -connect_timeout=10 -source ${MYTESTURL} > id-href.map; \
3644          elif curl --version >/dev/null 2>/dev/null ; then \
3645            curl --max-time 10 --silent ${MYTESTURL} > id-href.map; \
3646          else false; \
3647          fi; \
3648        }; then
3649    rm -f id-href.map
3650    CHECK_DEPS=${CHECK_DEPS}" check-doc"
3651    echol "IMPNOTES = \"${MYIMPROOT}\""
3652    echol "CLHSROOT = \"${hyperspec}\""
3653    echol "check-doc: clisp${TEXE} base"
3654    echotab 'IMPNOTES=$(IMPNOTES) ./clisp'" ${someflags} -x '(sys::ensure-impnotes-map t)'"
3655    echotab 'CLHSROOT=$(CLHSROOT) ./clisp'" ${someflags} -x '(sys::ensure-clhs-map)'"
3656    echol
3657  fi
3658
3659  echol "# Perform self-tests."
3660  echol "check : ${CHECK_DEPS}"
3661  echodummyrule check
3662  echol
3663
3664  EXTRACHECK_DEPS=
3665  # TODO: Enable this check only on those platforms where it is
3666  # supported (Linux, FreeBSD, etc.), or disable it on those platforms
3667  # where it is known to be not supported (OpenBSD, etc.).
3668  EXTRACHECK_DEPS="${EXTRACHECK_DEPS} check-exec-image"
3669
3670  # check that the executable images work
3671  EXEIMG=image
3672  OBSOLETE="$OBSOLETE $(exefiles ${EXEIMG}) ${EXEIMG}.mem"
3673  echol "check-exec-image: lisp${LEXE} lispinit.mem"
3674  echotab '$(RUN) -M lispinit.mem -x "(saveinitmem \"'"${EXEIMG}"'\" :executable t :norc t)"'
3675  echotab "${HERE}${EXEIMG}${HEXE}"' -x "(setq zz 10) (saveinitmem \"'"${EXEIMG}"'\")"'
3676  # check that the executable image still honors -M
3677  echotab "${HERE}${EXEIMG}${HEXE} -norc -M ${EXEIMG}.mem -x zz"
3678  # check that *ARGS* do not seep from image to image (https://sourceforge.net/p/clisp/bugs/519/)
3679  echotab '$(RUN) -M lispinit.mem -x "(saveinitmem \"'"${EXEIMG}"'\" :executable t :norc t :quiet t :init-function (lambda () (prin1 *args*) (exit)))" -- a 1'
3680  echotab "test \"\`${HERE}${EXEIMG}${HEXE} b ${TRCR}\`\" = '(\"b\")' || exit 1"
3681  echotab "test \"\`${HERE}${EXEIMG}${HEXE} b 2 ${TRCR}\`\" = '(\"b\" \"2\")' || exit 1"
3682  echotab '$(RUN) -M lispinit.mem -x "(saveinitmem \"'"${EXEIMG}"'\" :executable t :norc t :quiet t :init-function (function exit))"'
3683  echotab ${HERE}${EXEIMG}${HEXE}
3684  echotab "test -z \"\`${HERE}${EXEIMG}${HEXE}\`\" || exit 1"
3685  echotab '$(RUN) -M lispinit.mem -x '"'"'(saveinitmem "'"${EXEIMG}"'" :executable t :norc t :quiet t :init-function (lambda () '"${RAISE}))'"
3686  echotab "output=\"\`${HERE}${EXEIMG}${HEXE} -on-error exit ${TRCR}\`\"; test \"\$\$output\" = '*** - myerror' || exit 1"
3687  echotab "if ${HERE}${EXEIMG}${HEXE} -on-error exit; then exit 1; fi"
3688  echotab '$(RUN) -M lispinit.mem -x '"'"'(saveinitmem "'"${EXEIMG}"'" :executable t :norc t :quiet t :init-function (lambda () (exit-on-error '"${RAISE})))'"
3689  echotab "output=\"\`${HERE}${EXEIMG}${HEXE} ${TRCR}\`\"; test \"\$\$output\" = '*** - myerror' || exit 1"
3690  echotab "if ${HERE}${EXEIMG}${HEXE}; then exit 1; fi"
3691  echotab "-ls -l lisp${LEXE} lispinit.mem ${EXEIMG}${HEXE} ${EXEIMG}.mem"
3692  echotab "\$(RM) ${EXEIMG}${HEXE} ${EXEIMG}.mem"
3693  echol
3694
3695  echol "# Perform extra tests."
3696  echol "# Failure of these does not indicate that the built clisp is unusable,"
3697  echol "# but rather than some non-vital features are not supported."
3698  echol "extracheck : ${EXTRACHECK_DEPS}"
3699  echodummyrule extracheck
3700  echol
3701  echol
3702fi
3703
3704if [ $XCC_GCC = true ] ; then
3705  echol "lispbibl.h :${EVERY_INCLUDES_C}${EVERY_INCLUDES_H}"
3706  echotab "( (${XCPP} ${XCPPFLAGS} ${XCFLAGS} -P lispbibl.c | \$(GREP) -v \"^ *\$\$\") ; (${XCPP} ${XCPPFLAGS} ${XCFLAGS} -P -dM lispbibl.c | sort) ) > lispbibl.h"
3707  echol
3708  echol "gc : lispbibl.h # show GC-related definitions"
3709  echotab "egrep '[^[:alpha:]](MEMORY|SPVW|GC|SIGSEGV|SAFETY|ASM|FAST|DEBUG)[^[:alpha:]]' lispbibl.h | grep -v 'define _' | egrep '^#define'"
3710  echol
3711  echol
3712fi
3713
3714echol "clisp.h clisp-test.c${CLISP_DEF} : genclisph.o config.h ${PARAMS_H} ${GLLIB_A}"
3715echotab_to_HEXE "\$(CC) \$(CFLAGS) \$(CLFLAGS)" "genclisph.o" "genclisph"
3716if test -z "${CLISP_DEF}"; then
3717  echotab "${HERE}genclisph clisp.h.tmp clisp-test.c"
3718else
3719  echotab "${HERE}genclisph clisp.h.tmp clisp-test.c ${CLISP_DEF}"
3720  # new-clx depends on the symbol "hostent_to_lisp", which is defined in the
3721  # syscalls module and therefore doesn't get put into lisp.def on Cygwin.
3722  # So we just force it.
3723  echotab "echo -e \"\tlisp.exe.hostent_to_lisp\" >> ${CLISP_DEF}"
3724fi
3725echotab "(echo '#ifndef _CLISP_H' ; echo '#define _CLISP_H' ; echo; echo '/* ==== config.h ==== */' ; cat config.h ) > clisp.h"
3726for parf in ${PARAMS_H}; do
3727  echotab "(echo; echo '/* '${parf}' */' ; grep '^#' ${parf} ) >> clisp.h"
3728done
3729echotab "(echo; echo '/* genclisph */' ; cat clisp.h.tmp; echo ; echo '#endif /* _CLISP_H */') >> clisp.h"
3730echotab_to_HEXE "\$(CC) \$(CPPFLAGS) \$(CFLAGS) \$(CLFLAGS) -I. -DUSE_CLISP_H=1 -DCOMPILE_STANDALONE" "clisp-test.c ${GLLIB_A}" "clisp-test-clisp"
3731echotab_to_HEXE "\$(CC) \$(CPPFLAGS) \$(CFLAGS) \$(CLFLAGS) -I. -DUSE_CLISP_H=0 -DCOMPILE_STANDALONE" "clisp-test.c ${GLLIB_A}" "clisp-test-lispbibl"
3732echotab "${HERE}clisp-test-clisp > clisp-test-clisp.out"
3733echotab "${HERE}clisp-test-lispbibl > clisp-test-lispbibl.out"
3734if [ $HOS = unix -o $HSYS = win32gcc ]; then
3735  echotab  "cmp clisp-test-clisp.out clisp-test-lispbibl.out"
3736else
3737  echotab "comp clisp-test-clisp.out clisp-test-lispbibl.out"
3738fi
3739echotab "if grep lispbibl.d clisp.h; then false; else true; fi"
3740echotab "\$($EXERM) $(exefiles genclisph) clisp.h.tmp $(exefiles clisp-test-clisp) $(exefiles clisp-test-lispbibl) clisp-test-clisp.out clisp-test-lispbibl.out"
3741OBSOLETE="$OBSOLETE clisp-test.c $(exefiles genclisph)"
3742echol
3743LINKKIT_SOURCES="${SRCDIR}modules.c clisp.h ${UTILDIR}modprep.lisp"
3744LINKKIT=''
3745echol "linkkit : ${LINKKIT_SOURCES}"
3746echotab "-\$(RMRF) linkkit"
3747echotab "mkdir linkkit"
3748for f in ${LINKKIT_SOURCES}; do
3749  b=`basename $f`
3750  d=`dirname $f`; d=`cd $d; pwd`
3751  LINKKIT="${LINKKIT} ${b}"
3752  echotab "cd linkkit && \$(LN_S) ${d}/${b} ${b}"
3753done
3754echol
3755
3756# scripts in build-aux
3757MODULE_CONFIGURES=`find ${MODULESDIR_} -name configure`
3758BUILD_AUX_ALL=`grep '$ac_aux_dir/' ${MODULE_CONFIGURES} | sed 's,.*$ac_aux_dir/\([a-z.-]*\).*,\1,' | sort -u`
3759BUILD_AUX=''
3760# must have build-aux in build directory because it is the lisplibdir for
3761# building modules, see src/m4/general.m4:CL_MODULE_COMMON_CHECKS:
3762#   AC_CONFIG_AUX_DIR([$cl_cv_clisp_libdir/build-aux])
3763test -n "${SRCDIR}" && case "${LN_S}" in
3764  cp* )                         # ln is not available
3765    echol "build-aux : ${SRCDIR}build-aux"
3766    echotab "-\$(RMRF) build-aux"
3767    echotab "-cp -r ${SRCDIR}build-aux build-aux"
3768    echol
3769    ;;
3770  * ) link_dep "build-aux" "${SRCDIR}build-aux"
3771    ;;
3772esac
3773for f in ${BUILD_AUX_ALL}; do
3774  test -r ${SRCDIR}build-aux/$f && BUILD_AUX="${BUILD_AUX} $f"
3775done
3776
3777test "${verbose}" = true -o "${verbose}" = yes && \
3778  echo "BUILD_AUX =${BUILD_AUX}" >&2
3779
3780echol "modular : ${FILES} clisp-link linkkit modules.h modules.o makevars build-aux"
3781echodummyrule modular
3782echol
3783# while the top-level makevars can contain arbitrary paths in LIBS and FILES,
3784# makevars in each linking set (boot/base/full) must point to local files only
3785echol "makevars : Makefile"
3786echotab "(echo 'CC='\"'\"'\$(CC)'\"'\" ;\\"
3787echotab " echo 'CPPFLAGS='\"'\"'\$(MODULE_CPPFLAGS)'\"'\" ;\\"
3788echotab " echo 'CFLAGS='\"'\"'\$(${MODULE_CFLAGS_VAR})'\"'\" ;\\"
3789echotab " echo 'CLFLAGS='\"'\"'\$(${MODULE_CLFLAGS_VAR})'\"'\" ;\\"
3790echotab " echo 'LIBS='\"'\"'lisp.a${CLISP_DEF} \$(LIBS)'\"'\" ;\\"
3791echotab " echo 'X_LIBS='\"'\"'\$(X_LIBS)'\"'\" ;\\"
3792echotab " echo 'RANLIB='\"'\"'\$(RANLIB)'\"'\" ;\\"
3793echotab " echo 'FILES='\"'\"'${FILES}'\"'\") > makevars"
3794echol
3795for f in clisp-link ; do
3796  echol "${f} : ${SRCDIR}${f}.in"
3797  # On IRIX, clisp-link must be executed through /bin/ksh or bash, not /bin/sh.
3798  case "$host_os" in
3799    irix*) goodshell="$CONFIG_SHELL" ;;
3800    *)     goodshell='/bin/sh' ;;
3801  esac
3802  XCC_CREATESHARED_=`echo "$XCC_CREATESHARED" | sed -e 's,\\$,$$,g'`
3803  echotab "sed -e 's%@''SHELL''@%${goodshell}%' \\"
3804  echotab "    -e 's%@with_dynamic_modules@%${with_dynamic_modules}%' \\"
3805  echotab "    -e 's%@createsharedlib@%$XCC_CREATESHARED_%' \\"
3806  echotab "    -e 's%@LEXE@%${LEXE}%' -e 's%@SHREXT@%${SHREXT}%' \\"
3807  # On Cygwin, "-L$sourcedir$" is not enough for the linker to find
3808  # lisp.def.  So just give the absolute path to lisp.def.
3809  if test -z "${CLISP_DEF}"; then
3810    echotab "    -e 's%@CLISP_DEF@%%' \\"
3811  elif [ "${HSYSOS}" = cygwin ]; then
3812    echotab "    -e 's%@CLISP_DEF@%\$\$absolute_sourcedir/lisp.def%' \\"
3813  else
3814    echotab "    -e 's%@CLISP_DEF@%-L\$\$sourcedir${CLISP_DEF}%' \\"
3815  fi
3816  echotab "  < ${SRCDIR}${f}.in > ${f}"
3817  echotab "chmod a+x ${f}"
3818  echol
3819done
3820echol "boot : modular lispinit.mem"
3821echotab "test -d boot || (mkdir boot && cd boot && for f in ${FILES} modules.h modules.o lisp${LEXE} lispinit.mem; do \$(LN_S) ${PARENT_}\$\$f .; done && (\$(GREP) -v '^FILES=' ${PARENT_}makevars; fl=''; for f in ${FILES}; do fl=\$\$fl' '\`basename \$\$f\`; done; echo 'FILES='\"'\"\$\$fl\"'\") > makevars) || (\$(RMRF) boot ; exit 1)"
3822echol
3823make_modules() {
3824  MODULES_VAR=$1
3825  LINKING_SET=$2
3826  MODULE_NAME=$3         # Some "make"s don't support empty target lists
3827  echol "${MODULE_NAME} \$(${MODULES_VAR}) : ${LINKING_SET} clisp${TEXE} linkkit force"
3828  echotab 'mkdir -p $@'
3829  echotab "m=\`cd ${MODULESDIR_}\$@; pwd\`; \\"
3830  # srcdir has to be passed to ./configure because it must be able to find
3831  # src/build-aux/install-sh _AND_ also its own sources, thus we must
3832  # point it to modules/... in the original source tree.
3833  # The 'if' condition here tests whether $$m/configure is newer than $@/config.status.
3834  echotab "if test -f \$\$m/configure && { test ! -f \$@/config.status || test -n \"\`find \$\$m/configure -prune -newer \$@/config.status\`\"; } ; then ( cd \$@ ;\\"
3835  echotab "    cache="'`'"echo \$@/ | sed -e 's,[^/][^/]*//*,../,g'"'`'"config.cache; \\"
3836  echotab "    if test -f \$\${cache} ; then \\"
3837  echotab "      . \$\${cache}; \\"
3838  for var in ${PRECIOUS_VARS}; do
3839    echotab "      if test \"\$\${ac_cv_env_${var}_set}\" = set; then ${var}=\"\$\${ac_cv_env_${var}_value}\"; export ${var}; fi; \\"
3840  done
3841  # we must use $(SHELL) for sub-configures because when the top CONFIG_SHELL
3842  # is bash, config.cache may be unparsable with sh on Solaris
3843  echotab "      \$(SHELL) \$\$m/configure --with-clisp=\"${HEREP}/clisp -K ${LINKING_SET} ${someflags}\" --cache-file=\$\${cache} --srcdir=\$\$m \$(MODULE_CONFIGURE_FLAGS);\\"
3844  echotab "    else \\"
3845  echotab "      \$(SHELL) \$\$m/configure --srcdir=\$\$m \$(MODULE_CONFIGURE_FLAGS); \\"
3846  echotab "    fi ) ;\\"
3847  echotab "fi; \\"
3848  # srcdir must be correct in Makefile because clisp-link calls link.sh
3849  # which cannot pass srcdir to make on the command line.
3850  # The 'if' condition here tests whether $$m/Makefile is newer than $@/Makefile.
3851  echotab "if test -f \$\$m/Makefile && { test ! -f \$@/Makefile || test -n \"\`find \$\$m/Makefile -prune -newer \$@/Makefile\`\"; } ; then \\"
3852  echotab "  sed \"s,srcdir = .,srcdir = \$\$m,\" \"\$\$m/Makefile\" > \$@/Makefile ; \\"
3853  echotab "fi ; \\"
3854  echotab "CLISP=\"${HEREP}/clisp -K ${LINKING_SET} ${someflags}\" ; \\"
3855  echotab "cd \$@ ; \$(MAKE) clisp-module CC=\"\$(CC)\" CPPFLAGS=\"\$(MODULE_CPPFLAGS)\" CFLAGS=\"\$(${MODULE_CFLAGS_VAR})\" CLFLAGS=\"\$(${MODULE_CLFLAGS_VAR})\" LIBS=\"\$(LIBS)\" RANLIB=\"\$(RANLIB)\" CLISP=\"\$\$CLISP -q\" SHREXT=${SHREXT}"
3856  echol
3857}
3858make_modules BASE_MODULES boot basemodule
3859make_modules MODULES base fullmodule
3860
3861cygwin_finish() {
3862  # make sure no cygwin libraries crept into the mingw distribution
3863  if [ "$host_os" = cygwin -a "${TSYS}" = win32gcc ]; then
3864    # cygcheck can fail with symlinks so resolve them
3865    # 'cyg[^/\\\\]*\$\$' here should look as 'cyg[^/\]*$' for grep
3866    echotab "if cygcheck \`realpath $1/lisp.exe | cygpath --windows -f -\` | grep 'cyg[^/\\\\]*\$\$'; then false; else true; fi"
3867  fi
3868  finish_runtime $1/lisp${LEXE}
3869}
3870
3871# base is always linked statically
3872echol "base : modular boot \$(BASE_MODULES)"
3873echotab "\$(RMRF) base"
3874echotab "MAKE=\$(MAKE) CLISP=\"${HEREP}/clisp -K boot ${someflags}\" with_dynamic_modules=no ${HERE}clisp-link add boot base \$(BASE_MODULES) || (\$(RMRF) base ; exit 1)"
3875cygwin_finish base
3876
3877# full is built dynamically unless explicitly requested otherwise
3878echol "full : modular base \$(MODULES)"
3879echotab "\$(RMRF) full"
3880test "${with_dynamic_modules}" = no || echotab "rm -rf dynmod; mkdir dynmod"
3881echotab "MAKE=\$(MAKE) CLISP=\"${HEREP}/clisp ${someflags}\" ${HERE}clisp-link add base full \$(MODULES) || (\$(RMRF) full ; exit 1)"
3882# show which system supplied functionality is replaced by gnulib
3883test "${verbose}" = true -o "${verbose}" = yes && \
3884  echotab 'grep "^REPLACE_.*='"'1'"'" `find . -name config.log` || true'
3885cygwin_finish full
3886
3887echol "mod-check : base-mod-check full-mod-check"
3888echol
3889modcheck(){                     # $1=clisp command; $2=MODULES variable
3890  echotab 'for m in "" $('$2'); do test -n "$$m" && $(RM) $$m/*.erg; done'
3891  echotab 'z=""; for m in "" $('$2'); do test -n "$$m" && z=$$z" \""$$m/\"; done; '"$1${someflags} -C -i ${TESTSDIR}/tests"' -x "(ext:exit (plusp (or (run-some-tests :dirlist '"'"'($$z) :srcdir \"'${MODULESDIR_}'\" :outdir \"./\") 0)))"'
3892  echol
3893}
3894echol "base-mod-check : clisp${TEXE} ${TESTSDIR} # base"
3895modcheck "./clisp" BASE_MODULES
3896echol "full-mod-check : clisp${TEXE} ${TESTSDIR} # full"
3897if [ "${with_dynamic_modules}" = no ]; then
3898  modcheck "./clisp -K full" MODULES
3899else
3900  modcheck "./clisp" MODULES
3901fi
3902
3903manual_print=''
3904if test -n "$GROFF"; then
3905  for f in ${MANPAGES}; do
3906    manual_print="${manual_print} $f.ps"
3907    test -n "$PS2PDF" && manual_print="$manual_print $f.pdf"
3908  done
3909fi
3910TOP_DOC="ANNOUNCE COPYRIGHT GNU-GPL SUMMARY"
3911READMES="${TOP_DOC} NEWS README README.de README.es"
3912test $TOS = unix && READMES=${READMES}' MAGIC.add'
3913test ${HSYSOS} = cygwin && READMES=${READMES}' cygwin.README'
3914echol "READMES = ${READMES}"
3915IMPNOTES_FILES="impnotes.html impnotes.css clisp.png"
3916test ${HOS} = win32 && IMPNOTES_FILES=${IMPNOTES_FILES}" clisp.ico"
3917echol "IMPNOTES_FILES = ${IMPNOTES_FILES}"
3918manpages1html=''
3919manpages_less=''
3920for f in ${MANPAGES}; do
3921  manpages1html="${manpages1html} $f.1 $f.html";
3922  manpages_less="${manpages_less} $f.man";
3923done
3924echol "MANUALS =${manpages1html} \$(TXTFILES) \$(IMPNOTES_FILES)"
3925echol
3926for f in ${IMPNOTES_FILES} ${TXT_DOCS}; do
3927  link_dep "${f}" "${SRCDOCDIR_M}${f}" "${SRCDOCDIR_}${f}"
3928done
3929EMACS_FILES="clhs.el clisp-coding.el clisp-indent.el clisp-indent.lisp clisp-ffi.el"
3930VIM_FILES="lisp.vim"
3931ACLOCAL_FILES="clisp.m4"
3932
3933# On Unix, clisp.ps & clisp.pdf must be built by "make all",
3934# because "make install" needs it and "make install" must not create files in
3935# the current directory, for compliance with the GNU standards.
3936# On other OSes, clisp.ps & clisp.pdf must be built manually on another
3937# machine, so don't make it part of "make all".
3938if [ $HOS = unix ] ; then
3939  echol "manual : \$(READMES) \$(MANUALS) ${manual_print}"
3940  echodummyrule manual
3941  echol
3942  echol "manualx : manual${manpages_less}"
3943  echodummyrule manualx
3944  echol
3945else
3946  echol "manual : \$(READMES) \$(MANUALS)"
3947  echodummyrule manual
3948  echol
3949  echol "manualx : manual${manpages_less} ${manual_print}"
3950  echodummyrule manualx
3951  echol
3952fi
3953
3954for f in ${TOP_DOC} ; do
3955  link_dep "${f}" "${SRCTOPDIR_M}${f}" "${SRCTOPDIR_}${f}"
3956done
3957
3958if [ -n "${SRCDIR}" ] ; then
3959  for f in NEWS .gdbinit ; do
3960    echol "${f} : ${SRCDIR}${f}"
3961    if [ $f = .gdbinit -a $LEXE != ".run" ]; then
3962      echotab "sed 's/lisp.run/lisp$LEXE/g' ${SRCDIR}${f} > ${f}"
3963    else
3964      echotab "-\$(LN_S) ${SRCDIR}${f} ${f}"
3965    fi
3966    echol
3967  done
3968fi
3969
3970if [ $TOS = unix ] ; then
3971  for f in MAGIC.add ; do
3972    link_dep "${f}" "${SRCTOPDIR}unix${NEXT}${f}"
3973  done
3974fi
3975
3976for f in $TXT_FILES ; do
3977  depends=''
3978  flags=' -I. -DCOMPILE_STANDALONE'
3979  test $f = README && depends=$depends" ${SRCDIR}_${f}.de ${SRCDIR}_${f}.en"
3980  platform_line=""
3981  case $f in
3982    clisp.html | clisp.1 | clisp-1.html | \
3983    clisp-link.html | clisp-link.1 | clisp-link-1.html )
3984      if [ $HOS = win32 ]; then
3985        platform_line=" | sed -e \"s,@PLATFORM@,${TSYS},g\""
3986      else
3987        platform_line=" | sed -e \"s,@PLATFORM@,${host},g\""
3988      fi
3989      sourcedir=${SRCDOCDIR} ;;
3990    *) sourcedir=${SRCDIR} ;;
3991  esac
3992  echol "${f} : ${sourcedir}_${f}${TXT_INCLUDES}${depends} txt2c${HEXE} ${GLLIB_A}"
3993  g="gen-${f}"
3994  # The naïve choice of the executable name g would lead to the error
3995  # "xlc: 1501-218 (S) file gen-clisp.c contains an incorrect file suffix" on AIX.
3996  g=`echo "${g}" | sed -e 's/[.]//g'`
3997  echotab "\$(TXT2C) < ${sourcedir}_${f} > ${g}.c"
3998  echotab_to_HEXE "\$(CC) \$(CPPFLAGS) \$(CFLAGS)${flags} \$(CLFLAGS)${XCC_NOOPTFLAGS}" "${g}.c ${GLLIB_A}" "${g}"
3999  line="${HERE}${g}"
4000  test $f = clisp.1 -o $f = clisp-link.1 && \
4001    line=$line" | \$(GREP) -v ${ARGQ1}^ *\$\$${ARGQ1}"
4002  # *-1.html is for chunked impnotes and does not depend on user hyperspec
4003  test \( $f = clisp.html -o $f = clisp-link.html \) \
4004       -a "${HSDEFAULT}" != "${hyperspec}" && \
4005    line=$line" | sed -e ${ARGQ}s,=${QQUOT}${HSDEFAULT},=${QQUOT}${hyperspec},${ARGQ}"
4006  test $f = distmakefile && line=$line" | sed -e \"s,@@LEXE@@,${LEXE},g\" -e \"s:@@EXPORT_DYNAMIC_FLAG_SPEC@@:${EXPORT_DYNAMIC_FLAG_SPEC}:g\""
4007  line=$line$platform_line
4008  echotab "${line} > ${f}"
4009  echotab "\$($EXERM) ${g}.c $(exefiles ${g})"
4010  echol
4011  OBSOLETE=$OBSOLETE" ${g}.c $(exefiles ${g})"
4012done
4013
4014for f in ${MANPAGES}; do
4015  if test -n "$GROFF"; then
4016    echol "$f.ps : $f.1"
4017    echotab "-\$(ROFF_PS) $f.1 > $f.ps"
4018    echol
4019    if test -n "$PS2PDF"; then
4020      echol "$f.pdf : $f.ps"
4021      echotab "-\$(PS2PDF) $f.ps $f.pdf"
4022      echol
4023    fi
4024  fi
4025  echol "$f.man : $f.1"
4026  echotab "\$(ROFF_MAN) $f.1 > $f.man"
4027  echol
4028done
4029
4030if [ $CROSS = false ] ; then
4031  DRIVER_DEP=''; DRIVER_RES=''
4032  if [ $HOS = win32 ]; then
4033    DRIVER_RES=" clispres${TOBJ}"
4034    DRIVER_DEP=${DRIVER_RES}" ${SRCDIR}w32shell.c ${SRCDIR}execname.c"
4035    echol "clispres${TOBJ} : clisp.rc clisp.ico"
4036    if [ ${TSYS} = win32gcc ]; then
4037      echotab "${WINDRES} -i clisp.rc -o clispres.o"
4038    else
4039      echotab "rc /v /foclisp.res clisp.rc"
4040      echotab "cvtres /verbose /out:clispres.obj clisp.res"
4041      echotab "-\$(RM) clisp.res"
4042    fi
4043    echol
4044    # NB: we link clisp.rc into the driver clisp.exe but _not_ into the
4045    #     run-time lisp.exe because then the latter does not have an icon
4046    #     and the users are less likely to run it without the memory image
4047    echol "clisp.rc : ${SRCDIR}clisp.rc.in Makefile"
4048    PRODUCTVERSION=`echo ${VERSION_NUMBER} | sed -e 's/\./,/g' -e 's/\+//g'`
4049    case "${PRODUCTVERSION}" in
4050      *,*,*,* ) ;;
4051      *,*,* ) PRODUCTVERSION="${PRODUCTVERSION},0" ;;
4052      *,* ) PRODUCTVERSION="${PRODUCTVERSION},0,0" ;;
4053    esac
4054    FILEFLAGS="0"
4055    if [ "${with_debug}" != no ] ; then
4056      FILEFLAGS="${FILEFLAGS}|VS_FF_DEBUG"
4057    fi
4058    case "${VERSION_NUMBER}" in
4059      *++) FILEFLAGS="${FILEFLAGS}|VS_FF_PRERELEASE|VS_FF_PATCHED" ;;
4060      *+)  FILEFLAGS="${FILEFLAGS}|VS_FF_PATCHED" ;;
4061    esac
4062    if [ "${with_unicode}" != no ];
4063    then CHARSET=04B0           # Unicode
4064    else CHARSET=0000           # 7-bit ASCII
4065    fi
4066    echotab "sed -e 's/\@CLISP_PRODUCTVERSION\@/${PRODUCTVERSION}/g' \\"
4067    echotab "    -e 's/\@CLISP_FILEFLAGS\@/${FILEFLAGS}/g' \\"
4068    echotab "    -e 's/\@CLISP_CHARSET\@/${CHARSET}/g' \\"
4069    echotab "    -e 's/\@CLISP_NAME\@/\$(PACKAGE_NAME)/g' \\"
4070    echotab "    -e 's/\@CLISP_VERSION\@/\$(PACKAGE_VERSION)/g' \\"
4071    echotab "    ${SRCDIR}clisp.rc.in > clisp.rc"
4072    echol
4073  fi
4074  DRIVERFLAGS=''
4075  case "$host_os" in
4076    hpux*)
4077      # gcc-2.95.2 on HP-UX 10 miscompiles clisp.c when optimization -O is used.
4078      test $XCC_GCC = true && DRIVERFLAGS=' -O0'
4079      ;;
4080  esac
4081  echol "clisp${TEXE} : clisp.c${DRIVER_DEP}"
4082  echotab "\$(CC) \$(CPPFLAGS) \$(CFLAGS) \$(CLFLAGS)${DRIVERFLAGS} -DENABLE_RELOCATABLE clisp.c${DRIVER_RES} ${LIBS} ${OUT}clisp${TEXE}"
4083  echol
4084  if [ $HOS = unix ] ; then
4085    echol "install : install-bin install-man install-doc"
4086    echodummyrule install
4087    echol
4088    echol "installdirs : force"
4089    echotab "mkdir -p \$(DESTDIR)\$(prefix)"
4090    echotab "mkdir -p \$(DESTDIR)\$(exec_prefix)"
4091    echotab "mkdir -p \$(DESTDIR)\$(libdir)"
4092    echotab "mkdir -p \$(DESTDIR)\$(lisplibdir)"
4093    echotab "mkdir -p \$(DESTDIR)\$(lisplibdir)/data"
4094    echotab "mkdir -p \$(DESTDIR)\$(lisplibdir)/linkkit"
4095    echotab "mkdir -p \$(DESTDIR)\$(lisplibdir)/base"
4096    echotab "mkdir -p \$(DESTDIR)\$(lisplibdir)/full"
4097    echotab "mkdir -p \$(DESTDIR)\$(bindir)"
4098    if test -n "$USE_GETTEXT"; then
4099      echotab "cd po && \$(MAKE) installdirs DESTDIR='\$(DESTDIR)' prefix='\$(prefix)' exec_prefix='\$(exec_prefix)'"
4100      case "$host_os" in
4101        solaris*)
4102          # The non-GNU dgettext() function in Solaris libc needs symbolic links.
4103          # For the list of locale names, see spvw_language:init_language().
4104          for localename in en_US de_DE fr_FR es_ES nl_NL ru_RU da_DK sv_SE; do
4105            ll=`echo "${localename}" | sed -e 's/_.*//'`
4106            echotab "test -d '\$(DESTDIR)\$(prefix)/locale/${localename}.UTF-8/LC_MESSAGES' || ln -s '${ll}' '\$(DESTDIR)\$(prefix)/locale/${localename}.UTF-8'"
4107          done
4108          ;;
4109      esac
4110    fi
4111    echotab "mkdir -p \$(DESTDIR)\$(datarootdir)"
4112    echotab "mkdir -p \$(DESTDIR)\$(elispdir)"
4113    echotab "mkdir -p \$(DESTDIR)\$(vimdir)"
4114    echotab "mkdir -p \$(DESTDIR)\$(aclocaldir)"
4115    echotab "mkdir -p \$(DESTDIR)\$(mandir)"
4116    echotab "mkdir -p \$(DESTDIR)\$(mandir)/man1"
4117    case "$fsstnd" in
4118      gnu_ext)
4119        echotab "mkdir -p \$(DESTDIR)\$(htmldir)"
4120        echotab "mkdir -p \$(DESTDIR)\$(psdir)"
4121        echotab "mkdir -p \$(DESTDIR)\$(pdfdir)"
4122        ;;
4123      *bsd|dragonfly)
4124        echotab "mkdir -p \$(DESTDIR)\$(docdir)"
4125        ;;
4126    esac
4127    echotab "mkdir -p \$(DESTDIR)\$(docdir)"
4128    case "$fsstnd" in
4129      *bsd|dragonfly)
4130        ;;
4131      *)
4132        echotab "mkdir -p \$(DESTDIR)\$(docdir)/doc"
4133        ;;
4134    esac
4135    echol
4136    if [ "${with_dynamic_modules}" != no ]; then
4137      depends="full install-modules force"
4138      line='linkkit base'
4139      echol "install-modules : full force"
4140      echotab "mkdir -p \$(DESTDIR)\$(lisplibdir)/dynmod"
4141      echotab "DESTDIR=\`cd \"\$(DESTDIR)\$(lisplibdir)\"; pwd\` CLISP='./clisp -q -norc' ./clisp-link install \$(MODULES)"
4142      echol
4143    else
4144      depends="full force"
4145      line='linkkit base full'
4146    fi
4147    echol "install-bin : ${depends}"
4148    echotab "mkdir -p \$(DESTDIR)\$(prefix)"
4149    echotab "mkdir -p \$(DESTDIR)\$(exec_prefix)"
4150    echotab "mkdir -p \$(DESTDIR)\$(libdir)"
4151    echotab "mkdir -p \$(DESTDIR)\$(lisplibdir)"
4152    echotab "mkdir -p \$(DESTDIR)\$(lisplibdir)/data"
4153    for f in ${DATA_FILES}; do
4154      echotab "\$(INSTALL_DATA) data/${f} \$(DESTDIR)\$(lisplibdir)/data/${f}"
4155    done
4156    echotab "(cd \$(DESTDIR)\$(lisplibdir) && \$(RMRF) base full)"
4157    echotab "mkdir -p \$(DESTDIR)\$(lisplibdir)/build-aux"
4158    echotab "for f in ${BUILD_AUX}; do \$(INSTALL_DATA) build-aux/\$\$f \$(DESTDIR)\$(lisplibdir)/build-aux/\$\$f; done"
4159    echotab "for d in ${line}; do for f in \$\$d/*; do \\"
4160    echotab "  mkdir -p \$(DESTDIR)\$(lisplibdir)/\$\$d; \\"
4161    echotab "  case \$\$f in \\"
4162    echotab "    */lisp${LEXE}) \$(INSTALL_PROGRAM) \$\$f \$(DESTDIR)\$(lisplibdir)/\$\$f;; \\"
4163    echotab "    *) \$(INSTALL_DATA) \$\$f \$(DESTDIR)\$(lisplibdir)/\$\$f;; \\"
4164    echotab "  esac; \\"
4165    echotab "done; done"
4166    echotab "mkdir -p \$(DESTDIR)\$(bindir)"
4167    echotab "\$(INSTALL_SCRIPT) clisp-link \$(DESTDIR)\$(bindir)/clisp-link"
4168    # Don't strip the executables, otherwise (disassemble #'cons)
4169    # and saveinitmem/:executable won't work.
4170    # echotab "strip \$(DESTDIR)\$(lisplibdir)/base/lisp${LEXE}"
4171    if test -n "$USE_GETTEXT"; then
4172      echotab "cd po && \$(MAKE) install DESTDIR='\$(DESTDIR)' prefix='\$(prefix)' exec_prefix='\$(exec_prefix)'"
4173      case "$host_os" in
4174        solaris*)
4175          # The non-GNU dgettext() function in Solaris libc needs symbolic links.
4176          # For the list of locale names, see spvw_language:init_language().
4177          for localename in en_US de_DE fr_FR es_ES nl_NL ru_RU da_DK sv_SE; do
4178            ll=`echo "${localename}" | sed -e 's/_.*//'`
4179            echotab "test -d '\$(DESTDIR)\$(prefix)/locale/${localename}.UTF-8/LC_MESSAGES' || ln -s '${ll}' '\$(DESTDIR)\$(prefix)/locale/${localename}.UTF-8'"
4180          done
4181          ;;
4182      esac
4183    fi
4184    echotab "\$(CC) \$(CPPFLAGS) \$(CFLAGS) \$(CLFLAGS)${DRIVERFLAGS} -DLISPLIBDIR='\"\$(lisplibdir)\"' -DLOCALEDIR='\"\$(localedir)\"' clisp.c ${GLLIB_A} -o \$(DESTDIR)\$(bindir)/clisp"
4185    echotab "mkdir -p \$(DESTDIR)\$(elispdir)"
4186    for f in ${EMACS_FILES}; do
4187      echotab "\$(INSTALL_DATA) ${SRCTOPDIR}emacs/$f \$(DESTDIR)\$(elispdir)/$f"
4188    done
4189    echotab "mkdir -p \$(DESTDIR)\$(vimdir)"
4190    for f in ${VIM_FILES}; do
4191      echotab "\$(INSTALL_DATA) ${SRCTOPDIR}emacs/$f \$(DESTDIR)\$(vimdir)/$f"
4192    done
4193    echotab "mkdir -p \$(DESTDIR)\$(aclocaldir)"
4194    for f in ${ACLOCAL_FILES}; do
4195      echotab "\$(INSTALL_DATA) ${SRCDIR}m4/$f \$(DESTDIR)\$(aclocaldir)/$f"
4196    done
4197    echol
4198    echol "install-man : ${manpages1html} ${manual_print} force"
4199    echotab "mkdir -p \$(DESTDIR)\$(prefix)"
4200    echotab "mkdir -p \$(DESTDIR)\$(exec_prefix)"
4201    echotab "mkdir -p \$(DESTDIR)\$(datarootdir)"
4202    echotab "mkdir -p \$(DESTDIR)\$(mandir)"
4203    echotab "mkdir -p \$(DESTDIR)\$(mandir)/man1"
4204    for f in ${MANPAGES}; do
4205      echotab "\$(INSTALL_DATA) $f.1 \$(DESTDIR)\$(mandir)/man1/$f.1"
4206    done
4207    case "$fsstnd" in
4208      gnu_ext)
4209        echotab "mkdir -p \$(DESTDIR)\$(htmldir)"
4210        echotab "mkdir -p \$(DESTDIR)\$(psdir)"
4211        echotab "mkdir -p \$(DESTDIR)\$(pdfdir)"
4212        for f in ${MANPAGES}; do
4213          echotab "\$(INSTALL_DATA) $f.html \$(DESTDIR)\$(htmldir)/$f.html"
4214          if test -n "$GROFF"; then
4215            echotab "\$(INSTALL_DATA) $f.ps  \$(DESTDIR)\$(psdir)/$f.ps"
4216            test -n "$PS2PDF" && \
4217              echotab "\$(INSTALL_DATA) $f.pdf \$(DESTDIR)\$(pdfdir)/$f.pdf"
4218          fi
4219        done
4220        ;;
4221      *bsd|dragonfly)
4222        echotab "mkdir -p \$(DESTDIR)\$(docdir)"
4223        for f in ${MANPAGES}; do
4224          echotab "\$(INSTALL_DATA) $f.html \$(DESTDIR)\$(docdir)/$f.html"
4225        done
4226        ;;
4227    esac
4228    echol
4229    echol "install-doc : \$(READMES) \$(MANUALS) ${manual_print} force"
4230    echotab "mkdir -p \$(DESTDIR)\$(prefix)"
4231    echotab "mkdir -p \$(DESTDIR)\$(exec_prefix)"
4232    echotab "mkdir -p \$(DESTDIR)\$(docdir)"
4233    echotab "\$(INSTALL_DATA) \$(READMES) \$(DESTDIR)\$(docdir)/"
4234    case "$fsstnd" in
4235      *bsd|dragonfly)
4236        echotab "\$(INSTALL_DATA) \$(MANUALS) ${manual_print} \$(DESTDIR)\$(docdir)/"
4237        ;;
4238      *)
4239        echotab "mkdir -p \$(DESTDIR)\$(docdir)/doc"
4240        echotab "\$(INSTALL_DATA) \$(MANUALS) ${manual_print} \$(DESTDIR)\$(docdir)/doc/"
4241        ;;
4242    esac
4243    if [ ${HSYSOS} = cygwin ]; then
4244      echotab "mkdir -p \$(DESTDIR)\$(docdir)/../Cygwin"
4245      echotab "\$(INSTALL_DATA) cygwin.README \$(DESTDIR)\$(docdir)/../Cygwin/clisp-\$(VERSION).README"
4246    fi
4247    echol
4248    echol
4249    echol "installcheck : ${TESTSDIR} force"
4250    echotab "cd ${TESTSDIR} && \$(MAKE) LISP=\"\$(bindir)/clisp ${someflags}\""
4251    echol
4252    echol
4253    echol "uninstall : uninstall-bin uninstall-man"
4254    echodummyrule uninstall
4255    echol
4256    echol "uninstall-bin : force"
4257    echotab "\$(RMRF) \$(DESTDIR)\$(lisplibdir)"
4258    if [ ${HSYSOS} = cygwin ]; then
4259      echotab "\$(RM) \$(DESTDIR)\$(docdir)/Cygwin/clisp-\$(VERSION).README"
4260      echotab "\$(RM) \$(DESTDIR)\$(bindir)/clisp.exe"
4261    else
4262      echotab "\$(RM) \$(DESTDIR)\$(bindir)/clisp"
4263    fi
4264    echotab "\$(RM) \$(DESTDIR)\$(bindir)/clisp-link"
4265    test -n "$USE_GETTEXT" && \
4266      echotab "cd po && \$(MAKE) uninstall DESTDIR='\$(DESTDIR)' prefix='\$(prefix)' exec_prefix='\$(exec_prefix)'"
4267    echol
4268    echol "uninstall-man : force"
4269    for f in ${MANPAGES}; do
4270      echotab "\$(RM) \$(DESTDIR)\$(mandir)/man1/$f.1"
4271      case "$fsstnd" in
4272        gnu_ext)
4273          echotab "\$(RM) \$(DESTDIR)\$(htmldir)/$f.html"
4274          echotab "\$(RM) \$(DESTDIR)\$(psdir)/$f.ps"
4275          echotab "\$(RM) \$(DESTDIR)\$(pdfdir)/$f.pdf"
4276          ;;
4277      esac
4278    done
4279    echotab "\$(RMRF) \$(DESTDIR)\$(docdir)"
4280    for f in ${EMACS_FILES}; do
4281      echotab "\$(RMRF) \$(DESTDIR)\$(elispdir)/$f*"
4282    done
4283    for f in ${VIM_FILES}; do
4284      echotab "\$(RMRF) \$(DESTDIR)\$(vimdir)/$f"
4285    done
4286    for f in ${ACLOCAL_FILES}; do
4287      echotab "\$(RMRF) \$(DESTDIR)\$(aclocaldir)/$f"
4288    done
4289    echol
4290    echol
4291  fi
4292fi
4293
4294echo_dist_modules () {
4295  echotab "for module in '' \$(BASE_MODULES) \$(MODULES); do if test -n \"\$\$module\"; then \\"
4296  echotab "  (dir=$1/ ; for subdir in "'`'"echo \$\$module/ | sed -e 's,/, ,g'"'`'" ; do dir=\$\${dir}\$\${subdir} ; test -d \$\${dir} || mkdir \$\${dir} ; dir=\$\${dir}/ ; done ; cd \$\$module ; \$(MAKE) SHREXT=${SHREXT} clisp-module-distrib distribdir=$1/\$\$module/ LN="$2") \\"
4297  echotab "fi; done$3"
4298}
4299if [ ${HSYSOS} = cygwin ]; then
4300  echol "full/lisp.exe : full"
4301  echol
4302  echol "# Makefile: \$(MODULES)"
4303  echol "# full/lisp.exe: dependencies"
4304  echol "setup.hint : SUMMARY # Makefile full/lisp.exe"
4305  echotab "\$(RM) setup.hint"
4306  echol "# normally curr/prev/test are not needed"
4307  echol "# but if one is present, at least curr+prev are required"
4308  echol "# echo 'curr : \$(VERSION)-1' >> setup.hint"
4309  echol "# echo 'prev : \$(VERSION)-1' >> setup.hint"
4310  echol "# echo 'test : \$(VERSION)-1' >> setup.hint"
4311  echotab "echo 'sdesc: \"an ANSI Common Lisp implementation\"' >> setup.hint"
4312  echotab "echo 'category: Devel Interpreters Math Shells' >> setup.hint"
4313  echotab 'REQ=""; for f in `cygcheck full/lisp.exe`; do echo "* "$$f; f=`cygpath -u $$f`; REQ=$${REQ}" "`cygcheck -f $$f|sed "s/-.*//"`; done; REQ=`echo $${REQ} | tr " " "\012" | sort -u`; echo "="$${REQ}; echo "requires: "$${REQ} >> setup.hint'
4314  echotab "echo 'ldesc: \"' >> setup.hint"
4315  echotab "cat SUMMARY >> setup.hint"
4316  echotab "echo >> setup.hint"
4317  echotab "echo 'This binary distribution was built with the following modules:' >> setup.hint"
4318  echotab "echo ' '\$(MODULES) >> setup.hint"
4319  echotab "echo '\"' >> setup.hint"
4320  echol
4321  echol "cygwin.README : setup.hint makemake"
4322  echotab "echo 'CLISP: an ANSI Common Lisp implementation' > cygwin.README"
4323  echotab "echo '' >> cygwin.README"
4324  echotab "grep requires setup.hint >> cygwin.README"
4325  echotab "echo 'recommended: libsigsegv https://www.gnu.org/software/libsigsegv/' >> cygwin.README"
4326  echotab "echo '' >> cygwin.README"
4327  echotab "echo 'builds \"out of the box\" on cygwin:' >> cygwin.README"
4328  echotab "echo './configure$makemake_args --cbc --install build-cygwin' >> cygwin.README"
4329  echotab "echo 'will configure, build and install CLISP' >> cygwin.README"
4330  echotab "echo 'see unix/INSTALL for details' >> cygwin.README"
4331  echotab "echo '' >> cygwin.README"
4332  echotab "cat SUMMARY >> cygwin.README"
4333  echol
4334  echol "CLISP_VR=\$(TOPDIR)-1"
4335  echol "CLISP_SCRIPT=\$(CLISP_VR).sh"
4336  echol "CLISP_CYGWIN=\$(TOPDIR)-cygwin-${UNAME_R}.tar.bz2"
4337  echol "DEST_TMP=/tmp/clisp-install"
4338  echol "distrib : setup.hint cygwin.README force"
4339  echotab "\$(RMRF) \$(DEST_TMP) \$(CLISP_VR).tar.bz2; mkdir -p \$(DEST_TMP)"
4340  echotab "\$(MAKE) install prefix=/usr DESTDIR=\$(DEST_TMP)"
4341  echotab "builddir=\"\`pwd\`\"; cd \$(DEST_TMP); tar cvfj \"\$\$builddir\"/\$(CLISP_CYGWIN) *"
4342  echotab "ln \$(CLISP_CYGWIN) \$(CLISP_VR).tar.bz2"
4343  echotab "\$(RMRF) \$(DEST_TMP)"
4344  echol
4345  echol "TAR_SRC=\"../../archives/\$(VERSION)/\$(TOPDIR).tar.bz2\""
4346  echol "cygwin-src : setup.hint force"
4347  echotab "touch \$(CLISP_VR).patch"
4348  echotab "echo '#!/bin/sh' > \$(CLISP_SCRIPT)"
4349  echotab "echo './configure$makemake_args --cbc build-cygwin' >> \$(CLISP_SCRIPT)"
4350  echotab "echo 'cd build-cygwin' >> \$(CLISP_SCRIPT)"
4351  echotab "echo 'make distrib' >> \$(CLISP_SCRIPT)"
4352  echotab "ln -s \$(TAR_SRC) ."
4353  echotab "tar cvfjh \$(CLISP_VR)-src.tar.bz2 \$(CLISP_SCRIPT) \$(CLISP_VR).patch setup.hint cygwin.README \$(TOPDIR).tar.bz2"
4354  echotab "\$(RMRF) \$(TOPDIR).tar.bz2 \$(CLISP_SCRIPT) \$(CLISP_VR).patch"
4355  echol
4356elif [ ${HOS} = unix ] ; then   # but not cygwin!
4357COMPRESS=@COMPRESS@
4358if [ -z "${COMPRESS}" ]; then
4359  echol "# tar"
4360  echol "PACKEXT=.tar"
4361else
4362  echol "# tar+gzip"
4363  echol "PACKEXT=.tar.gz"
4364  echol "COMPRESS=${COMPRESS}"
4365fi
4366echol
4367echol "# Temporary directory for packing"
4368echol "PACKDIR = ."
4369echol
4370echol "# Distribution file"
4371echol "DISTFILE=\$(PACKDIR)/\$(TOPDIR)-${host}-${UNAME_R}\$(PACKEXT)"
4372echol
4373needs='all'
4374if test "$HLN" != ln; then
4375  needs=$needs' hln'
4376  echol "hln : ${SRCTOPDIR}utils/hln.lisp"
4377  echotab "-\$(RM) hln"
4378  echotab "sed 's,@''CLISP''@,`pwd`/clisp,' ${SRCTOPDIR}utils/hln.lisp > hln"
4379  echotab "chmod +x hln"
4380  echol
4381fi
4382# hln merges pathnames, which means that if the source pathname is absolute,
4383# the destination must be absolute as well!
4384echol "FULLTOPDIR = `pwd`/\$(TOPDIR)"
4385echol "distrib : force $needs modular manualx clisp.c distmakefile"
4386echotab "\$(RMRF) \$(TOPDIR) \$(DISTFILE) clisp\$(PACKEXT)"
4387echotab "mkdir \$(TOPDIR)"
4388# General documentation files.
4389echotab "${HLN} ${READMES} \$(TOPDIR)/"
4390# The linking sets: base and full.
4391for dir in base full; do
4392  echotab "mkdir \$(TOPDIR)/${dir}"
4393  echotab "${HLN} "'`'". ${dir}/makevars ; for f in \$\$FILES modules.h modules.o makevars lispinit.mem ; do echo ${dir}/\$\$f ; done"'`'" \$(TOPDIR)/${dir}/"
4394  # make sure base & full do not link to anything outside
4395  echotab ". ./makevars; for f in \$\$LIBS ; do case \$\$f in -*) ;; \\"
4396  echotab "   *) b=\`basename \$\$f\`; \\"
4397  echotab "      if test ! -f ${dir}/\$\$b; then \\"
4398  if [ "${dir}" = base ]; then
4399    echotab "        ${HLN} \$\$f \$(FULLTOPDIR)/${dir}/; fi; \\"
4400  else
4401    echotab "        if test -f base/\$\$b; then \\"
4402    echotab "          ${HLN} base/\$\$b \$(FULLTOPDIR)/${dir}/; \\"
4403    echotab "        else \\"
4404    echotab "          ${HLN} \$\$f \$(FULLTOPDIR)/${dir}/; fi; \\"
4405    echotab "        fi ;; \\"
4406  fi
4407  echotab "esac ; done"
4408  if test -n "$BINARY_DISTRIB"; then
4409    echotab "cp ${dir}/lisp${LEXE} \$(TOPDIR)/${dir}/lisp${LEXE}"
4410    # Don't strip the executable, otherwise (disassemble #'cons)
4411    # and (saveinitmem ... :executable t) won't work.
4412    # echotab "strip \$(TOPDIR)/${dir}/lisp${LEXE}"
4413    echotab "chmod a+x \$(TOPDIR)/${dir}/lisp${LEXE}"
4414  fi
4415done
4416# The Makefile, generated from distmakefile.
4417if test -z "$BINARY_DISTRIB"; then
4418  echotab "cat distmakefile \\"
4419  for dir in base full; do
4420    DIR=`echo "${dir}" | tr '[a-z]' '[A-Z]'`
4421    echotab "| { . ${dir}/makevars ; ${dir}_files='' ; \\"
4422    echotab " for f in modules.o \$\$FILES ; do \\"
4423    echotab "   ${dir}_files=\"\$\$${dir}_files\"' ${dir}/'\"\$\$f\" ; \\"
4424    echotab " done ; \\"
4425    echotab " ${dir}_libs='' ; \\"
4426    echotab " for f in modules.o \$\$LIBS ; do \\"
4427    echotab "   case \$\$f in \\"
4428    echotab "     -*) ${dir}_libs=\"\$\$${dir}_libs \$\$f\";; \\"
4429    echotab "     *) ${dir}_libs=\"\$\$${dir}_libs\"' ${dir}/'\"\`basename \$\$f\`\";; \\"
4430    echotab "   esac ; \\"
4431    echotab " done ; \\"
4432    echotab " sed_escape_commas='s/,/\\\\,/g' ; \\"
4433    echotab " ${dir}_libs=\`echo \"\$\$${dir}_libs\" | sed -e \"\$\$sed_escape_commas\"\` ; \\"
4434    echotab " sed -e \"s,@@${DIR}_FILES@@,\$\$${dir}_files,\" -e \"s,@@${DIR}_LIBS@@,\$\$${dir}_libs,\"; } \\"
4435  done
4436  echotab "   > \$(TOPDIR)/Makefile"
4437else
4438  echotab "${HLN} distmakefile \$(TOPDIR)/Makefile"
4439fi
4440# Architecture independent data files.
4441if [ -n "$USE_GETTEXT" ] ; then
4442  echotab "for f in \`find locale -type d -print\`; do mkdir \$(TOPDIR)/\$\$f; done"
4443  echotab "for f in \`find locale -type f -print\`; do ${HLN} \$\$f \$(TOPDIR)/\$\$f; done"
4444fi
4445if [ "${with_dynamic_modules}" != no ]; then
4446  echotab "mkdir \$(TOPDIR)/dynmod"
4447  echotab "${HLN} dynmod/* \$(TOPDIR)/dynmod/"
4448fi
4449echotab "mkdir \$(TOPDIR)/data"
4450echotab "${HLN} data/* \$(TOPDIR)/data/"
4451echotab "mkdir \$(TOPDIR)/doc"
4452echotab "${HLN} ${manpages1html} ${manpages_less} ${manual_print} \$(TXTFILES) \$(IMPNOTES_FILES) \$(TOPDIR)/doc/"
4453echotab "mkdir \$(TOPDIR)/emacs"
4454line="${HLN}";
4455for f in ${EMACS_FILES} ${VIM_FILES}; do
4456  line="${line} ${SRCTOPDIR}emacs/${f}"
4457done
4458echotab "${line} \$(FULLTOPDIR)/emacs/"
4459echotab "mkdir \$(TOPDIR)/misc"
4460line="${HLN}";
4461for f in ${ACLOCAL_FILES}; do line="${line} ${SRCDIR}m4/$f"; done
4462echotab "${line} \$(FULLTOPDIR)/misc/"
4463echotab "mkdir \$(TOPDIR)/src"
4464echotab "${HLN} \$(LISPFILES) \$(FASFILES) \$(FULLTOPDIR)/src/"
4465echotab "${HLN} clisp-link \$(TOPDIR)/"
4466echotab "mkdir \$(TOPDIR)/linkkit"
4467echotab "for f in ${LINKKIT}; do ${HLN} linkkit/\$\$f \$(TOPDIR)/linkkit/; done"
4468echotab "mkdir \$(TOPDIR)/build-aux"
4469echotab "cd build-aux && ${HLN} ${BUILD_AUX} \$(FULLTOPDIR)/build-aux"
4470echo_dist_modules "\$(FULLTOPDIR)" ${HLN} ""
4471# For building the `clisp' executable.
4472if test -z "$BINARY_DISTRIB"; then
4473  echotab "${HLN} clisp.c ${SRCDIR}execname.c \$(TOPDIR)/src/"
4474else
4475  echotab_to_HEXE "\$(CC) \$(CPPFLAGS) \$(CFLAGS) \$(CLFLAGS) -DLISPLIBDIR='\"\$(lisplibdir)\"' -DLOCALEDIR='\"\$(localedir)\"'" "clisp.c ${GLLIB_A}" "\$(TOPDIR)/clisp"
4476  echotab_to_HEXE "\$(CC) \$(CPPFLAGS) \$(CFLAGS) \$(CLFLAGS) -I." "${UTILDIR_CC}hardcode.c ${GLLIB_A}" "\$(TOPDIR)/hardcode"
4477fi
4478# Final packing.
4479echotab "chmod a+r \$(TOPDIR) \$(TOPDIR)/* \$(TOPDIR)/*/*"
4480echotab "chmod a+x \$(TOPDIR)/. \$(TOPDIR)/*/."
4481if [ -z "${COMPRESS}" ]; then
4482  echotab "tar cvfh \$(DISTFILE) \$(TOPDIR)"
4483else
4484  echotab "tar cvfh - \$(TOPDIR) | \$(COMPRESS) > \$(DISTFILE)"
4485fi
4486echotab "${HLN} \$(DISTFILE) clisp\$(PACKEXT)"
4487echotab "\$(RMRF) \$(TOPDIR)"
4488echol
4489echol
4490elif [ $HOS = win32 ] ; then
4491  echol "# Distribution, to be executed on a Unix host or using Cygwin."
4492  echol "distrib : install.lisp install.bat config.lisp ${manpages_less} clisp.html COPYRIGHT.rtf env_var_update.nsh install.nsi is_user_admin.nsh force"
4493  echotab "version=\$(VERSION) ; \\"
4494  echotab "distdir=clisp-\$\$version ; \\"
4495  echotab "rm -rf \$\$distdir; \\"
4496  echotab "mkdir \$\$distdir ; \\"
4497  echotab "for f in ${READMES} install.bat ; do \\"
4498  echotab "  if test -f \$\$f ; then cp -p \$\$f \$\$distdir/\$\$f ; else cp -p \`echo \$\$f | tr '[A-Z]' '[a-z]'\` \$\$distdir/\$\$f ; fi ; \\"
4499  echotab "done ; \\"
4500  if [ $TSYS = win32msvc ] ; then
4501    echotab "distfile=clisp-\$\$version-msvc-win32.zip ; \\"
4502    echotab "for f in lisp.exe lispinit.mem install.bat clisp.exe ; do \\"
4503    echotab "  cp -p \$\$f \$\$distdir/\$\$f ; \\"
4504    echotab "done ; \\"
4505  else
4506    echotab "distfile=clisp-\$\$version-win32.zip ; \\"
4507    echotab "installfile=clisp-\$\$version-win32-install.exe ; \\"
4508    echotab "for d in base full ; do \\"
4509    echotab "  mkdir \$\$distdir/\$\$d ; \\"
4510    echotab "  for f in lisp.exe lispinit.mem ; do \\"
4511    echotab "    cp -p \$\$d/\$\$f \$\$distdir/\$\$d/\$\$f ; \\"
4512    echotab "  done ; \\"
4513    echotab "done ; \\"
4514    echotab "mkdir \$\$distdir/linkkit; \\"
4515    echotab "for f in ${LINKKIT}; do \\"
4516    echotab "  cp -p linkkit/\$\$f \$\$distdir/linkkit/\$\$f; \\"
4517    echotab "done ; \\"
4518    echotab "mkdir \$\$distdir/build-aux; \\"
4519    echotab "for f in ${BUILD_AUX}; do \\"
4520    echotab "  cp -p build-aux/\$\$f \$\$distdir/build-aux/\$\$f; \\"
4521    echotab "done ; \\"
4522    echotab "cp clisp-link clisp.exe \$\$distdir/; \\"
4523    echo_dist_modules `pwd`/"\$\$distdir" ln "; \\"
4524  fi
4525  test -n "${USE_GETTEXT}" && echotab "cp -r locale/ \$\$distdir/; \\"
4526  test "${with_dynamic_modules}" != no && \
4527    echotab "cp -r dynmod/ \$\$distdir/; \\"
4528  echotab "mkdir \$\$distdir/data ; \\"
4529  for f in ${DATA_FILES}; do
4530    echotab "cp -p data/${f} \$\$distdir/data/${f} ; \\"
4531  done
4532  echotab "mkdir \$\$distdir/doc ; \\"
4533  echotab "for f in ${manpages1html} ${manpages_less} \$(TXTFILES) \$(IMPNOTES_FILES) ; do \\"
4534  echotab "  if test -f \$\$f ; then cp -p \$\$f \$\$distdir/doc/\$\$f ; else cp -p \`echo \$\$f | tr '[A-Z]' '[a-z]'\` \$\$distdir/doc/\$\$f ; fi ; \\"
4535  echotab "done ; \\"
4536  echotab "mkdir \$\$distdir/emacs; \\"
4537  for f in ${EMACS_FILES} ${VIM_FILES}; do
4538    echotab "cp -p ${SRCTOPDIR}emacs/${f} \$\$distdir/emacs/${f} ; \\"
4539  done
4540  echotab "mkdir \$\$distdir/misc; \\"
4541  for f in ${ACLOCAL_FILES}; do
4542    echotab "cp -p ${SRCDIR}m4/${f} \$\$distdir/misc/${f} ; \\"
4543  done
4544  echotab "mkdir \$\$distdir/src ; \\"
4545  echotab "cp -p \$(LISPFILES) config.lisp install.lisp install.bat \$\$distdir/src/ ; \\"
4546  echotab "chmod 755 \$\$distdir/. \$\$distdir/*/. ; \\"
4547  echotab "find \$\$distdir -type f -exec chmod 664 {} ';' ; \\"
4548  echotab "rm -f \$\$distfile \$\$installfile ; \\"
4549  echotab "(echo \"\$(PACKAGE_NAME) version \$(PACKAGE_VERSION) for Win32.\"; echo \".\") | zip -r -9 -z \$\$distfile \$\$distdir ; \\"
4550  echotab "cd \$\$distdir; cp ../*.ns[hi] ../COPYRIGHT.rtf .; makensis install.nsi; mv \$\$installfile .. ; cd ..; \\"
4551  echotab "rm -rf \$\$distdir"
4552  echol
4553fi
4554
4555cat <<!!
4556# clean0 is harmless: removes only superfluous things: temporary files.
4557clean0 : force
4558	-\$($EXERM) core *.core *.stackdump${OBSOLETE}
4559
4560# clean1 removes everything that becomes obsolete once lisp${LEXE} is recompiled
4561# without changing the bytecode format and the tables in
4562# constobj.d, constpack.d, constsym.d, subr.d, fsubr.d, pseudofun.d.
4563clean1 : clean0
4564	-\$(RM) lispbibl.h clisp.h *.i *.s *${TOBJ} *.a lisp${LEXE} marc.out clisp-link makevars ansi-tests-log ${CLISP_DEF}
4565	for m in "" \$(BASE_MODULES) \$(MODULES); do test -n "\$\$m" && \$(RM) \$\$m/*${TOBJ}; done
4566	-\$(RMRF) ${RECOMPILEDIR}
4567	-\$(RMRF) ${TESTSDIR}
4568	-\$(RMRF) ${ANSITESTSDIR}
4569	-\$(RMRF) ${SACLATESTSDIR}
4570	-\$(RMRF) boot base full linkkit dynmod
4571	-\$(RM) ${TXT_FILES} ${manpages_less} ${manual_print} \$(IMPNOTES_FILES) \$(TXTFILES) COPYRIGHT.rtf install.nsi
4572
4573# clean2 removes everything that becomes obsolete once lisp${LEXE}
4574# is recompiled without changing the bytecode format.
4575clean2 : clean1
4576	-\$(RM) interpreted.mem halfcompiled.mem lispinit.mem lispinit2.mem
4577
4578# clean3 removes everything that becomes obsolete once lisp${LEXE}
4579# is recompiled. It leaves everything generated by "make allc".
4580clean3 : clean2
4581	-\$(RM) \$(FASFILES) *.lib
4582!!
4583line="-\$(RM)"
4584for f in ${LUTILS}; do line=$line" ${f}.fas"; done
4585echotab "$line"
4586echotab 'for m in "" $(BASE_MODULES) $(MODULES); do test -n "$$m" && $(RM) $$m/*.fas $$m/*.lib $$m/*.erg; done'
4587cat <<!!
4588
4589# clean4 removes everything that becomes obsolete
4590# when switching to a new version of the C compiler.
4591# It leaves everything generated by "make init".
4592clean4 : clean3
4593	-\$(RM) cflags.h cflags.h.stamp
4594	-\$(RM) \$(CFILES)
4595!!
4596test -n "$USE_GETTEXT" && \
4597  cat <<!!
4598	cd po && \$(MAKE) clean
4599	-\$(RMRF) locale
4600!!
4601
4602echol '# clean5 even undoes "make init".'
4603echol "clean5 : clean4"
4604echotab "-\$(RM) ${TOP_DOC} modules.h"
4605if [ -n "${SRCDIR}" ] ; then
4606  line="-\$(RM) NEWS clisp.png"
4607  test ${HOS} = win32 && line="$line clisp.ico"
4608  echotab "$line"
4609  test $HOS = unix -a $CROSS = false && echotab "-\$(RM) .gdbinit"
4610  echotab "-\$(RMRF) build-aux"
4611fi
4612test $TOS = unix && echotab "-\$(RM) MAGIC.add"
4613echotab "-\$(RMRF) data"
4614line="$(exefiles clisp) clisp.rc"
4615for f in ${UTILS}; do line=$line" $(exefiles ${f})"; done
4616echotab "-\$($EXERM) ${line}"
4617echol
4618cat <<!!
4619# clean6 lets us go back to "makemake > Makefile".
4620clean6 : clean5
4621	-\$(RM) config.lisp
4622
4623# clean-modules remove the copies of modules, do it if you change modprep and such
4624clean-modules :
4625	-\$(RMRF) \`ls -d ${MODULESDIR_}*/. | sed -e 's,/\.\$\$,,' -e 's,^.*/,,'\`
4626
4627# clean7 lets us go back to the main "configure".
4628clean7 : clean6 clean-modules distclean-subdirs
4629	-\$(RM) config.status config.log config.cache ${PARAMS_H} config.h stamp-h1 libtool makemake Makefile
4630!!
4631test -n "$USE_GETTEXT" && \
4632  cat <<!!
4633	cd po && \$(MAKE) distclean
4634	-\$(RMRF) locale
4635!!
4636echol
4637echol "clean-subdirs :"
4638for dir in ${SUBDIRS}; do
4639  echotab "if test -d ${dir}; then cd ${dir} && \$(MAKE) clean; fi"
4640done
4641echol
4642# this must be run before clean7 because it runs "cd ..; make am--refresh"
4643echol "distclean-subdirs :"
4644for dir in ${SUBDIRS}; do
4645  echotab "if test -d ${dir}; then cd ${dir} && \$(MAKE) distclean; fi"
4646done
4647echol
4648cat <<!!
4649
4650# clean8 moreover cleans up the SRCDIR.
4651clean8 : clean7
4652
4653# The normal "start over" command:
4654mostlyclean : clean4
4655
4656# Clear all files that are built by "make ...":
4657clean : clean5 clean-subdirs
4658
4659# Make "clear for distribution":
4660distclean : clean7
4661
4662# Remove everything that can be generated otherwise:
4663maintainer-clean : clean8
4664
4665!!
4666
4667echol
4668
4669# Without this NeXT's make program tries to compile via c -> s -> o
4670echol ".SUFFIXES:"
4671echodummyrule .SUFFIXES
4672echol
4673
4674echol "force:"
4675echodummyrule force
4676
4677echol
4678