+# FIXME: Things like :c-stack-grows-..., etc, should be
+# *derived-target-features* or equivalent, so that there was a nicer
+# way to specify them then sprinkling them in this file. They should
+# still be tweakable by advanced users, though, but probably not
+# appear in *features* of target. #!+/- should be adjusted to take
+# them in account as well. At minimum the nicer specification stuff,
+# though:
+#
+# (define-feature :dlopen (features)
+# (union '(:bsd :linux :darwin :sunos) features))
+#
+# (define-feature :c-stack-grows-downwards-not-upwards (features)
+# (member :x86 features))
+
+# KLUDGE: currently the x86 only works with the generational garbage
+# collector (indicated by the presence of :GENCGC in *FEATURES*) and
+# alpha, sparc and ppc with the stop'n'copy collector (indicated by
+# the absence of :GENCGC in *FEATURES*). This isn't a great
+# separation, but for now, rather than have :GENCGC in
+# base-target-features.lisp-expr, we add it into local-target-features
+# if we're building for x86. -- CSR, 2002-02-21 Then we do something
+# similar with :STACK-GROWS-FOOWARD, too. -- WHN 2002-03-03
+if [ "$sbcl_arch" = "x86" ]; then
+ printf ' :gencgc :stack-grows-downward-not-upward :c-stack-is-control-stack' >> $ltf
+ printf ' :stack-allocatable-closures :alien-callbacks' >> $ltf
+ if [ "$sbcl_os" = "linux" ] || [ "$sbcl_os" = "freebsd" ] || [ "$sbcl_os" = "netbsd" ] || [ "$sbcl_os" = "sunos" ]; then
+ printf ' :linkage-table' >> $ltf
+ fi
+ if [ "$sbcl_os" = "win32" ]; then
+ # of course it doesn't provide dlopen, but there is
+ # roughly-equivalent magic nevertheless.
+ printf ' :os-provides-dlopen' >> $ltf
+ fi
+elif [ "$sbcl_arch" = "x86-64" ]; then
+ printf ' :gencgc :stack-grows-downward-not-upward :c-stack-is-control-stack :linkage-table' >> $ltf
+ printf ' :stack-allocatable-closures :alien-callbacks' >> $ltf
+elif [ "$sbcl_arch" = "mips" ]; then
+ printf ' :linkage-table' >> $ltf
+ printf ' :stack-allocatable-closures' >> $ltf
+ # Use a little C program to try to guess the endianness. Ware
+ # cross-compilers!
+ #
+ # FIXME: integrate to grovel-features, mayhaps
+ $GNUMAKE -C tools-for-build determine-endianness -I src/runtime
+ tools-for-build/determine-endianness >> $ltf
+elif [ "$sbcl_arch" = "ppc" -a "$sbcl_os" = "linux" ]; then
+ # Use a C program to detect which kind of glibc we're building on,
+ # to bandage across the break in source compatibility between
+ # versions 2.3.1 and 2.3.2
+ #
+ # FIXME: integrate to grovel-features., maypahps
+ printf ' :gencgc :stack-allocatable-closures :linkage-table' >> $ltf
+ $GNUMAKE -C tools-for-build where-is-mcontext -I src/runtime
+ tools-for-build/where-is-mcontext > src/runtime/ppc-linux-mcontext.h
+elif [ "$sbcl_arch" = "ppc" -a "$sbcl_os" = "darwin" ]; then
+ printf ' :gencgc :stack-allocatable-closures' >> $ltf
+ # We provide a dlopen shim, so a little lie won't hurt
+ printf " :os-provides-dlopen :linkage-table :alien-callbacks" >> $ltf
+ # The default stack ulimit under darwin is too small to run PURIFY.
+ # Best we can do is complain and exit at this stage
+ if [ "`ulimit -s`" = "512" ]; then
+ echo "Your stack size limit is too small to build SBCL."
+ echo "See the limit(1) or ulimit(1) commands and the README file."
+ exit 1
+ fi
+elif [ "$sbcl_arch" = "sparc" ]; then
+ # Test the compiler in order to see if we are building on Sun
+ # toolchain as opposed to GNU binutils, and write the appropriate
+ # FUNCDEF macro for assembler. No harm in running this on sparc-linux
+ # as well.
+ sh tools-for-build/sparc-funcdef.sh > src/runtime/sparc-funcdef.h
+ if [ "$sbcl_os" = "sunos" ] || [ "$sbcl_os" = "linux" ]; then
+ printf ' :linkage-table' >> $ltf
+ fi
+ printf ' :stack-allocatable-closures' >> $ltf
+elif [ "$sbcl_arch" = "alpha" ]; then
+ printf ' :stack-allocatable-closures' >> $ltf
+else
+ # Nothing need be done in this case, but sh syntax wants a placeholder.
+ echo > /dev/null
+fi
+
+export sbcl_os sbcl_arch
+sh tools-for-build/grovel-features.sh >> $ltf
+