Add odxprint, a replacement for FSHOW which can be configured at run-time
[sbcl.git] / make-config.sh
1 #!/bin/sh
2 set -e
3
4 # The make-config.sh script uses information about the target machine
5 # to set things up for compilation. It's vaguely like a stripped-down
6 # version of autoconf. It's intended to be run as part of make.sh. The
7 # only time you'd want to run it by itself is if you're trying to
8 # cross-compile the system or if you're doing some kind of
9 # troubleshooting.
10
11 # This software is part of the SBCL system. See the README file for
12 # more information.
13 #
14 # This software is derived from the CMU CL system, which was
15 # written at Carnegie Mellon University and released into the
16 # public domain. The software is in the public domain and is
17 # provided with absolutely no warranty. See the COPYING and CREDITS
18 # files for more information.
19
20 print_help="no"
21
22 # The classic form here was to use --userinit $DEVNULL --sysinit
23 # $DEVNULL, but that doesn't work on Win32 because SBCL doesn't handle
24 # device names properly. We still need $DEVNULL to be NUL on Win32
25 # because it's used elsewhere (such as canonicalize-whitespace), so we
26 # need an alternate solution for the init file overrides. --no-foos
27 # have now been available long enough that this should not stop anyone
28 # from building.
29 if [ "$OSTYPE" = "cygwin" -o "$OSTYPE" = "msys" ]
30 then
31     SBCL_PREFIX="$PROGRAMFILES/sbcl"
32 else
33     SBCL_PREFIX="/usr/local"
34 fi
35 SBCL_XC_HOST="sbcl --disable-debugger --no-userinit --no-sysinit"
36 export SBCL_XC_HOST
37
38 # Parse command-line options.
39 bad_option() {
40     echo $1
41     echo "Enter \"$0 --help\" for list of valid options."
42     exit 1
43 }
44
45 WITH_FEATURES=""
46 WITHOUT_FEATURES=""
47 FANCY_FEATURES=":sb-core-compression :sb-xref-for-internals :sb-after-xc-core"
48
49 fancy=false
50 some_options=false
51 for option
52 do
53   optarg_ok=true
54   # Split --foo=bar into --foo and bar.
55   case $option in
56       *=*)
57         # For ease of scripting skip valued options with empty
58         # values.
59         optarg=`expr "X$option" : '[^=]*=\(.*\)'` || optarg_ok=false
60         option=`expr "X$option" : 'X\([^=]*=\).*'`
61         ;;
62       --with*)
63         optarg=`expr "X$option" : 'X--[^-]*-\(.*\)'` \
64             || bad_option "Malformed feature toggle: $option"
65         option=`expr "X$option" : 'X\(--[^-]*\).*'`
66         ;;
67       *)
68         optarg=""
69         ;;
70   esac
71
72   case $option in
73       --help | -help | -h)
74         print_help="yes" ;;
75       --prefix=)
76         $optarg_ok && SBCL_PREFIX=$optarg
77         ;;
78       --arch=)
79         $oparg_ok && SBCL_ARCH=$optarg
80         ;;
81       --xc-host=)
82         $optarg_ok && SBCL_XC_HOST=$optarg
83         ;;
84       --dynamic-space-size=)
85         $optarg_ok && SBCL_DYNAMIC_SPACE_SIZE=$optarg
86         ;;
87       --with)
88         WITH_FEATURES="$WITH_FEATURES :$optarg"
89         ;;
90       --without)
91         WITHOUT_FEATURES="$WITHOUT_FEATURES :$optarg"
92         ;;
93       --fancy)
94         WITH_FEATURES="$WITH_FEATURES $FANCY_FEATURES"
95         # Lower down we add :sb-thread for platforms where it can be built.
96         fancy=true
97         ;;
98       -*)
99         bad_option "Unknown command-line option to $0: \"$option\""
100         ;;
101       *)
102         if $some_options
103         then
104             bad_option "Unknown command-line option to $0: \"$option\""
105         else
106             legacy_xc_spec=$option
107         fi
108         ;;
109   esac
110   some_options=true
111 done
112
113 if (test -f customize-target-features.lisp && \
114     (test -n "$WITH_FEATURES" || test -n "$WITHOUT_FEATURES"))
115 then
116     # Actually there's no reason why it would not work, but it would
117     # be confusing to say --with-thread only to have it turned off by
118     # customize-target-features.lisp...
119     echo "ERROR: Both customize-target-features.lisp, and feature-options"
120     echo "to make.sh present -- cannot use both at the same time."
121     exit 1
122 fi
123
124 # Previously XC host was provided as a positional argument. 
125 if test -n "$legacy_xc_spec"
126 then
127     SBCL_XC_HOST="$legacy_xc_spec"
128 fi
129
130 if test "$print_help" = "yes"
131 then
132   cat <<EOF
133 \`make.sh' drives the SBCL build.
134
135 Usage: $0 [OPTION]...
136
137   Important: make.sh does not currently control the entirety of the
138   build: configuration file customize-target-features.lisp and certain
139   environment variables play a role as well. see file INSTALL for
140   details.
141
142 Options:
143   -h, --help           Display this help and exit.
144
145   --prefix=<path>      Specify the install location.
146
147       Script install.sh installs SBCL under the specified prefix
148       path: runtime as prefix/bin/sbcl, additional files under
149       prefix/lib/sbcl, and documentation under prefix/share.
150
151       This option also affects the binaries: built-in default for
152       SBCL_HOME is: prefix/lib/sbcl/
153
154       Default prefix is: /usr/local
155
156   --dynamic-space-size=<size> Default dynamic-space size for target.
157
158       This specifies the default dynamic-space size for the SBCL
159       being built. If you need to control the dynamic-space size
160       of the host SBCL, use the --xc-host option.
161
162       If not provided, the default is platform-specific. <size> is
163       taken to be megabytes unless explicitly suffixed with Gb in
164       order to specify the size in gigabytes.
165
166   --with-<feature>     Build with specified feature.
167   --without-<feature>  Build wihout the specfied feature.
168
169   --fancy              Build with several optional features:
170
171                            $FANCY_FEATURES
172
173                        Plus threading on platforms which support it.
174
175   --arch=<string>      Specify the architecture to build for.
176
177       Mainly for doing x86 builds on x86-64.
178
179   --xc-host=<string>   Specify the Common Lisp compilation host.
180
181       The string provided should be a command to invoke the
182       cross-compilation Lisp system in such a way, that it reads
183       commands from standard input, and terminates when it reaches end
184       of file on standard input.
185
186       Examples:
187
188        "sbcl --disable-debugger --no-sysinit --no-userinit"
189                   Use an existing SBCL binary as a cross-compilation
190                   host even though you have stuff in your
191                   initialization files which makes it behave in such a
192                   non-standard way that it keeps the build from
193                   working. Also disable the debugger instead of
194                   waiting endlessly for a programmer to help it out
195                   with input on *DEBUG-IO*. (This is the default.)
196
197        "sbcl"
198                   Use an existing SBCL binary as a cross-compilation
199                   host, including your initialization files and
200                   building with the debugger enabled. Not recommended
201                   for casual users.
202
203        "lisp -noinit -batch"
204                   Use an existing CMU CL binary as a cross-compilation
205                   host when you have weird things in your .cmucl-init
206                   file.
207 EOF
208   exit 1
209 fi
210
211 mkdir -p output
212 # Save prefix for make and install.sh.
213 echo "SBCL_PREFIX='$SBCL_PREFIX'" > output/prefix.def
214 echo "$SBCL_DYNAMIC_SPACE_SIZE" > output/dynamic-space-size.txt
215
216 # FIXME: Tweak this script, and the rest of the system, to support
217 # a second bootstrapping pass in which the cross-compilation host is
218 # known to be SBCL itself, so that the cross-compiler can do some
219 # optimizations (especially specializable arrays) that it doesn't
220 # know how to implement how in a portable way. (Or maybe that wouldn't
221 # require a second pass, just testing at build-the-cross-compiler time
222 # whether the cross-compilation host returns suitable values from
223 # UPGRADED-ARRAY-ELEMENT-TYPE?)
224
225 if [ "$OSTYPE" = "cygwin" -o "$OSTYPE" = "msys" ] ; then
226     DEVNULL=NUL
227 else
228     DEVNULL=/dev/null
229 fi
230 export DEVNULL
231
232 . ./find-gnumake.sh
233 find_gnumake
234
235 . ./generate-version.sh
236 generate_version
237
238 # Now that we've done our option parsing and found various
239 # dependencies, write them out to a file to be sourced by other
240 # scripts.
241
242 echo "DEVNULL=\"$DEVNULL\"; export DEVNULL" > output/build-config
243 echo "GNUMAKE=\"$GNUMAKE\"; export GNUMAKE" >> output/build-config
244 echo "SBCL_XC_HOST=\"$SBCL_XC_HOST\"; export SBCL_XC_HOST" >> output/build-config
245 echo "legacy_xc_spec=\"$legacy_xc_spec\"; export legacy_xc_spec" >> output/build-config
246
247 # And now, sorting out the per-target dependencies...
248
249 case `uname` in
250     Linux)
251         sbcl_os="linux"
252         ;;
253     OSF1)
254         # it's changed name twice since it was called OSF/1: clearly
255         # the marketers forgot to tell the engineers about Digital Unix
256         # _or_ OSF/1 ...
257         sbcl_os="osf1"
258         ;;
259     *BSD)
260         case `uname` in
261             FreeBSD)
262                 sbcl_os="freebsd"
263                 ;;
264             OpenBSD)
265                 sbcl_os="openbsd"
266                 ;;
267             NetBSD)
268                 sbcl_os="netbsd"
269                 ;;
270             *)
271                 echo unsupported BSD variant: `uname`
272                 exit 1
273                 ;;
274         esac
275         ;;
276     Darwin)
277         sbcl_os="darwin"
278         ;;
279     SunOS)
280         sbcl_os="sunos"
281         ;;
282     CYGWIN* | WindowsNT | MINGW*)
283         sbcl_os="win32"
284         ;;
285     HP-UX)
286         sbcl_os="hpux"
287         ;;
288     *)
289         echo unsupported OS type: `uname`
290         exit 1
291         ;;
292 esac
293
294 link_or_copy() {
295    if [ "$sbcl_os" = "win32" ] ; then
296       # Use preprocessor or makefile includes instead of copying if
297       # possible, to avoid unexpected use of the original, unchanged
298       # files when re-running only make-target-1 during development.
299       if echo "$1" | egrep '[.][ch]$'; then
300          echo "#include \"$1\"" >"$2"
301       elif echo "$1" | egrep '^Config[.]'; then
302          echo "include $1" >"$2"
303       else
304          cp -r "$1" "$2"
305       fi
306    else
307        ln -s "$1" "$2"
308    fi
309 }
310
311 remove_dir_safely() {
312    if [ "$sbcl_os" = "win32" ] ; then
313         if [ -d "$1" ] ; then
314             rm -rf "$1"
315         elif [ -e "$1" ] ; then
316             echo "I'm afraid to remove non-directory $1."
317             exit 1
318         fi
319     else
320         if [ -h "$1" ] ; then
321             rm "$1"
322         elif [ -w "$1" ] ; then
323             echo "I'm afraid to replace non-symlink $1 with a symlink."
324             exit 1
325         fi
326     fi
327 }
328
329 echo //entering make-config.sh
330
331 echo //ensuring the existence of output/ directory
332 if [ ! -d output ] ; then mkdir output; fi
333
334 echo //guessing default target CPU architecture from host architecture
335 case `uname -m` in
336     *86) guessed_sbcl_arch=x86 ;;
337     i86pc) guessed_sbcl_arch=x86 ;;
338     *x86_64) guessed_sbcl_arch=x86-64 ;;
339     amd64) guessed_sbcl_arch=x86-64 ;;
340     [Aa]lpha) guessed_sbcl_arch=alpha ;;
341     sparc*) guessed_sbcl_arch=sparc ;;
342     sun*) guessed_sbcl_arch=sparc ;;
343     *ppc) guessed_sbcl_arch=ppc ;;
344     ppc64) guessed_sbcl_arch=ppc ;;
345     Power*Macintosh) guessed_sbcl_arch=ppc ;;
346     parisc) guessed_sbcl_arch=hppa ;;
347     9000/800) guessed_sbcl_arch=hppa ;;
348     mips*) guessed_sbcl_arch=mips ;;
349     *)
350         # If we're not building on a supported target architecture, we
351         # we have no guess, but it's not an error yet, since maybe
352         # target architecture will be specified explicitly below.
353         guessed_sbcl_arch=''
354         ;;
355 esac
356
357 # Under Solaris, uname -m returns "i86pc" even if CPU is amd64.
358 if [ "$sbcl_os" = "sunos" ] && [ `isainfo -k` = "amd64" ]; then
359     guessed_sbcl_arch=x86-64
360 fi
361
362 # Under Darwin, uname -m returns "i386" even if CPU is x86_64.
363 if [ "$sbcl_os" = "darwin" ] && [ "`/usr/sbin/sysctl -n hw.optional.x86_64`" = "1" ]; then
364     guessed_sbcl_arch=x86-64
365 fi
366
367 echo //setting up CPU-architecture-dependent information
368 if test -n "$SBCL_ARCH"
369 then
370     # Normalize it.
371     SBCL_ARCH=`echo $SBCL_ARCH | tr '[A-Z]' '[a-z]' | tr _ -`
372 fi
373 sbcl_arch=${SBCL_ARCH:-$guessed_sbcl_arch}
374 echo sbcl_arch=\"$sbcl_arch\"
375 if [ "$sbcl_arch" = "" ] ; then
376     echo "can't guess target SBCL architecture, please specify --arch=<name>"
377     exit 1
378 fi
379 if $fancy
380 then
381     # If --fancy, enable threads on platforms where they can be built.
382     case $sbcl_arch in
383         x86|x86-64|ppc)
384             if [ "$sbcl_os" = "sunos" ] && [ "$sbcl_arch" = "x86-64" ]
385             then
386                 echo "No threads on this platform."
387             else
388                 WITH_FEATURES="$WITH_FEATURES :sb-thread"
389                 echo "Enabling threads due to --fancy."
390             fi
391             ;;
392         *)
393             echo "No threads on this platform."
394             ;;
395     esac
396 fi
397
398 ltf=`pwd`/local-target-features.lisp-expr
399 echo //initializing $ltf
400 echo ';;;; This is a machine-generated file.' > $ltf
401 echo ';;;; Please do not edit it by hand.' >> $ltf
402 echo ';;;; See make-config.sh.' >> $ltf
403 echo "((lambda (features) (set-difference features (list$WITHOUT_FEATURES)))" >> $ltf
404 printf " (union (list$WITH_FEATURES) (list " >> $ltf
405
406 printf ":%s" "$sbcl_arch" >> $ltf
407
408 echo //setting up OS-dependent information
409 # Under Darwin x86-64, guess whether Darwin 9+ or below.
410 if [ "$sbcl_os" = "darwin" ] && [ "$sbcl_arch" = "x86-64" ]; then
411     darwin_version=`uname -r`
412     darwin_version_major=${DARWIN_VERSION_MAJOR:-${darwin_version%%.*}}
413     if (( 8 < $darwin_version_major )); then
414         printf ' :inode64 :darwin9-or-better' >> $ltf
415     fi
416 fi
417
418 original_dir=`pwd`
419 cd ./src/runtime/
420 rm -f Config target-arch-os.h target-arch.h target-os.h target-lispregs.h
421 # KLUDGE: these two logically belong in the previous section
422 # ("architecture-dependent"); it seems silly to enforce this in terms
423 # of the shell script, though. -- CSR, 2002-02-03
424 link_or_copy $sbcl_arch-arch.h target-arch.h
425 link_or_copy $sbcl_arch-lispregs.h target-lispregs.h
426 case "$sbcl_os" in
427     linux)
428         printf ' :unix' >> $ltf
429         printf ' :elf' >> $ltf
430         printf ' :linux' >> $ltf
431
432         # If you add other platforms here, don't forget to edit
433         # src/runtime/Config.foo-linux too.
434         case "$sbcl_arch" in
435             mips)
436                 printf ' :largefile' >> $ltf
437                 ;;
438             x86 | x86-64)
439                 printf ' :sb-thread :sb-futex :largefile' >> $ltf
440                 ;;
441             ppc)
442                 printf ' :sb-futex' >> $ltf
443                 ;;
444         esac
445
446         if [ $sbcl_arch = "x86-64" ]; then
447             link_or_copy Config.x86_64-linux Config
448         else
449             link_or_copy Config.$sbcl_arch-linux Config
450         fi
451         link_or_copy $sbcl_arch-linux-os.h target-arch-os.h
452         link_or_copy linux-os.h target-os.h
453         ;;
454     osf1)
455         printf ' :unix' >> $ltf
456         printf ' :elf' >> $ltf
457         printf ' :osf1' >> $ltf
458         link_or_copy Config.$sbcl_arch-osf1 Config
459         link_or_copy $sbcl_arch-osf1-os.h target-arch-os.h
460         link_or_copy osf1-os.h target-os.h
461         ;;
462     hpux)
463         printf ' :unix' >> $ltf
464         printf ' :elf' >> $ltf
465         printf ' :hpux' >> $ltf
466         link_or_copy Config.$sbcl_arch-hpux Config
467         link_or_copy $sbcl_arch-hpux-os.h target-arch-os.h
468         link_or_copy hpux-os.h target-os.h
469         ;;
470     *bsd)
471         printf ' :unix' >> $ltf
472         printf ' :bsd' >> $ltf
473         link_or_copy $sbcl_arch-bsd-os.h target-arch-os.h
474         link_or_copy bsd-os.h target-os.h
475         case "$sbcl_os" in
476             freebsd)
477                 printf ' :elf' >> $ltf
478                 printf ' :freebsd' >> $ltf
479                 printf ' :gcc-tls' >> $ltf
480                 if [ $sbcl_arch = "x86" ]; then
481                     printf ' :restore-tls-segment-register-from-context' >> $ltf
482                 fi
483                 link_or_copy Config.$sbcl_arch-freebsd Config
484                 ;;
485             openbsd)
486                 printf ' :elf' >> $ltf
487                 printf ' :openbsd' >> $ltf
488                 link_or_copy Config.$sbcl_arch-openbsd Config
489                 ;;
490             netbsd)
491                 printf ' :netbsd' >> $ltf
492                 printf ' :elf' >> $ltf
493                 link_or_copy Config.$sbcl_arch-netbsd Config
494                 ;;
495             *)
496                 echo unsupported BSD variant: `uname`
497                 exit 1
498                 ;;
499         esac
500         ;;
501     darwin)
502         printf ' :unix' >> $ltf
503         printf ' :mach-o' >> $ltf
504         printf ' :bsd' >> $ltf
505         printf ' :darwin' >> $ltf
506         if [ $sbcl_arch = "x86" ]; then
507             printf ' :mach-exception-handler :restore-fs-segment-register-from-tls :ud2-breakpoints' >> $ltf
508         fi
509         if [ $sbcl_arch = "x86-64" ]; then
510             printf ' :mach-exception-handler :ud2-breakpoints' >> $ltf
511         fi
512         link_or_copy $sbcl_arch-darwin-os.h target-arch-os.h
513         link_or_copy bsd-os.h target-os.h
514         link_or_copy Config.$sbcl_arch-darwin Config
515         ;;
516     sunos)
517         printf ' :unix' >> $ltf
518         printf ' :elf' >> $ltf
519         printf ' :sunos' >> $ltf
520         if [ $sbcl_arch = "x86-64" ]; then
521             printf ' :largefile' >> $ltf
522         fi
523         link_or_copy Config.$sbcl_arch-sunos Config
524         link_or_copy $sbcl_arch-sunos-os.h target-arch-os.h
525         link_or_copy sunos-os.h target-os.h
526         ;;
527     win32)
528         printf ' :win32' >> $ltf
529         printf ' :sb-qshow' >> $ltf
530         link_or_copy Config.$sbcl_arch-win32 Config
531         link_or_copy $sbcl_arch-win32-os.h target-arch-os.h
532         link_or_copy win32-os.h target-os.h
533         ;;
534     *)
535         echo unsupported OS type: `uname`
536         exit 1
537         ;;
538 esac
539 cd "$original_dir"
540
541 # FIXME: Things like :c-stack-grows-..., etc, should be
542 # *derived-target-features* or equivalent, so that there was a nicer
543 # way to specify them then sprinkling them in this file. They should
544 # still be tweakable by advanced users, though, but probably not
545 # appear in *features* of target. #!+/- should be adjusted to take
546 # them in account as well. At minimum the nicer specification stuff,
547 # though:
548 #
549 # (define-feature :dlopen (features)
550 #   (union '(:bsd :linux :darwin :sunos) features))
551 #
552 # (define-feature :c-stack-grows-downwards-not-upwards (features)
553 #   (member :x86 features))
554
555 # KLUDGE: currently the x86 only works with the generational garbage
556 # collector (indicated by the presence of :GENCGC in *FEATURES*) and
557 # alpha, sparc and ppc with the stop'n'copy collector (indicated by
558 # the absence of :GENCGC in *FEATURES*). This isn't a great
559 # separation, but for now, rather than have :GENCGC in
560 # base-target-features.lisp-expr, we add it into local-target-features
561 # if we're building for x86. -- CSR, 2002-02-21 Then we do something
562 # similar with :STACK-GROWS-FOOWARD, too. -- WHN 2002-03-03
563 if [ "$sbcl_arch" = "x86" ]; then
564     printf ' :gencgc :stack-grows-downward-not-upward :c-stack-is-control-stack' >> $ltf
565     printf ' :compare-and-swap-vops :unwind-to-frame-and-call-vop :raw-instance-init-vops' >> $ltf
566     printf ' :stack-allocatable-closures :stack-allocatable-vectors' >> $ltf
567     printf ' :stack-allocatable-lists :stack-allocatable-fixed-objects' >> $ltf
568     printf ' :alien-callbacks :cycle-counter :inline-constants ' >> $ltf
569     printf ' :memory-barrier-vops :multiply-high-vops' >> $ltf
570     case "$sbcl_os" in
571     linux | freebsd | netbsd | openbsd | sunos | darwin | win32)
572         printf ' :linkage-table' >> $ltf
573     esac
574     if [ "$sbcl_os" = "win32" ]; then
575         # of course it doesn't provide dlopen, but there is
576         # roughly-equivalent magic nevertheless.
577         printf ' :os-provides-dlopen' >> $ltf
578     fi
579     if [ "$sbcl_os" = "openbsd" ]; then
580         rm -f src/runtime/openbsd-sigcontext.h
581         sh tools-for-build/openbsd-sigcontext.sh > src/runtime/openbsd-sigcontext.h
582     fi
583 elif [ "$sbcl_arch" = "x86-64" ]; then
584     printf ' :gencgc :stack-grows-downward-not-upward :c-stack-is-control-stack :linkage-table' >> $ltf
585     printf ' :compare-and-swap-vops :unwind-to-frame-and-call-vop :raw-instance-init-vops' >> $ltf
586     printf ' :stack-allocatable-closures :stack-allocatable-vectors' >> $ltf
587     printf ' :stack-allocatable-lists :stack-allocatable-fixed-objects' >> $ltf
588     printf ' :alien-callbacks :cycle-counter :complex-float-vops' >> $ltf
589     printf ' :float-eql-vops :inline-constants :memory-barrier-vops' >> $ltf
590     printf ' :multiply-high-vops' >> $ltf
591 elif [ "$sbcl_arch" = "mips" ]; then
592     printf ' :cheneygc :linkage-table' >> $ltf
593     printf ' :stack-allocatable-closures :stack-allocatable-vectors' >> $ltf
594     printf ' :stack-allocatable-lists :stack-allocatable-fixed-objects' >> $ltf
595     printf ' :alien-callbacks' >> $ltf
596 elif [ "$sbcl_arch" = "ppc" ]; then
597     printf ' :gencgc :stack-allocatable-closures :stack-allocatable-lists' >> $ltf
598     printf ' :linkage-table :raw-instance-init-vops :memory-barrier-vops' >> $ltf
599     printf ' :compare-and-swap-vops :multiply-high-vops' >> $ltf
600     if [ "$sbcl_os" = "linux" ]; then
601         # Use a C program to detect which kind of glibc we're building on,
602         # to bandage across the break in source compatibility between
603         # versions 2.3.1 and 2.3.2
604         #
605         # FIXME: integrate to grovel-features, mayhaps
606         $GNUMAKE -C tools-for-build where-is-mcontext -I ../src/runtime
607         tools-for-build/where-is-mcontext > src/runtime/ppc-linux-mcontext.h || (echo "error running where-is-mcontext"; exit 1)
608     elif [ "$sbcl_os" = "darwin" ]; then
609         # We provide a dlopen shim, so a little lie won't hurt
610         printf " :os-provides-dlopen :alien-callbacks" >> $ltf
611         # The default stack ulimit under darwin is too small to run PURIFY.
612         # Best we can do is complain and exit at this stage
613         if [ "`ulimit -s`" = "512" ]; then
614             echo "Your stack size limit is too small to build SBCL."
615             echo "See the limit(1) or ulimit(1) commands and the README file."
616             exit 1
617         fi
618     fi
619 elif [ "$sbcl_arch" = "sparc" ]; then
620     # Test the compiler in order to see if we are building on Sun
621     # toolchain as opposed to GNU binutils, and write the appropriate
622     # FUNCDEF macro for assembler. No harm in running this on sparc-linux
623     # as well.
624     sh tools-for-build/sparc-funcdef.sh > src/runtime/sparc-funcdef.h
625     printf ' :cheneygc' >> $ltf
626     if [ "$sbcl_os" = "sunos" ] || [ "$sbcl_os" = "linux" ]; then
627         printf ' :linkage-table' >> $ltf
628     fi
629     printf ' :stack-allocatable-closures :stack-allocatable-lists' >> $ltf
630 elif [ "$sbcl_arch" = "alpha" ]; then
631     printf ' :cheneygc' >> $ltf
632     printf ' :stack-allocatable-closures :stack-allocatable-lists' >> $ltf
633 elif [ "$sbcl_arch" = "hppa" ]; then
634     printf ' :cheneygc' >> $ltf
635     printf ' :stack-allocatable-vectors :stack-allocatable-fixed-objects' >> $ltf
636     printf ' :stack-allocatable-lists' >> $ltf
637 else
638     # Nothing need be done in this case, but sh syntax wants a placeholder.
639     echo > /dev/null
640 fi
641
642 # Use a little C program to try to guess the endianness.  Ware
643 # cross-compilers!
644 #
645 # FIXME: integrate to grovel-features, mayhaps
646 $GNUMAKE -C tools-for-build determine-endianness -I ../src/runtime
647 tools-for-build/determine-endianness >> $ltf
648
649 export sbcl_os sbcl_arch
650 sh tools-for-build/grovel-features.sh >> $ltf
651
652 echo //finishing $ltf
653 echo ')))' >> $ltf
654
655 # FIXME: The version system should probably be redone along these lines:
656 #
657 # echo //setting up version information.
658 # versionfile=version.txt
659 # cp base-version.txt $versionfile
660 # echo " (built `date -u` by `whoami`@`hostname`)" >> $versionfile
661 # echo 'This is a machine-generated file and should not be edited by hand.' >> $versionfile
662
663 # Make a unique ID for this build (to discourage people from
664 # mismatching sbcl and *.core files).
665 if [ `uname` = "SunOS" ] ; then
666   # use /usr/xpg4/bin/id instead of /usr/bin/id
667   PATH=/usr/xpg4/bin:$PATH
668 fi
669 echo '"'`hostname`-`id -un`-`date +%Y-%m-%d-%H-%M-%S`'"' > output/build-id.tmp