Transform %find-position for strings when item is not a character.
[sbcl.git] / make-config.sh
blobc19bda4497fc14cbd124f8989ced6e11bce9cffb
1 #!/bin/sh
2 set -e
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.
11 # This software is part of the SBCL system. See the README file for
12 # more information.
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.
20 print_help="no"
22 if [ "$OSTYPE" = "cygwin" -o "$OSTYPE" = "msys" ]
23 then
24 SBCL_PREFIX="$PROGRAMFILES/sbcl"
25 else
26 SBCL_PREFIX="/usr/local"
28 SBCL_XC_HOST="sbcl --no-userinit --no-sysinit"
30 # Parse command-line options.
31 bad_option() {
32 echo $1
33 echo "Enter \"$0 --help\" for list of valid options."
34 exit 1
37 WITH_FEATURES=""
38 WITHOUT_FEATURES=""
39 FANCY_FEATURES=":sb-core-compression :sb-xref-for-internals :sb-after-xc-core"
40 CONTRIBS=""
41 for dir in `cd contrib ; echo *`; do
42 if [ -d "contrib/$dir" -a -f "contrib/$dir/Makefile" ]; then
43 CONTRIBS="$CONTRIBS ${dir}"
45 done
46 SBCL_CONTRIB_BLOCKLIST=${SBCL_CONTRIB_BLOCKLIST:-""}
48 perform_host_lisp_check=no
49 fancy=false
50 some_options=false
51 android=false
52 if [ -z "$ANDROID_API" ]; then
53 ANDROID_API=21
55 for option
57 optarg_ok=true
58 # Split --foo=bar into --foo and bar.
59 case $option in
60 *=*)
61 # For ease of scripting skip valued options with empty
62 # values.
63 optarg=`expr "X$option" : '[^=]*=\(.*\)'` || optarg_ok=false
64 option=`expr "X$option" : 'X\([^=]*=\).*'`
66 --with*)
67 optarg=`expr "X$option" : 'X--[^-]*-\(.*\)'` \
68 || bad_option "Malformed feature toggle: $option"
69 option=`expr "X$option" : 'X\(--[^-]*\).*'`
72 optarg=""
74 esac
76 case $option in
77 --help | -help | -h)
78 print_help="yes" ;;
79 --prefix=)
80 $optarg_ok && SBCL_PREFIX=$optarg
82 --arch=)
83 $oparg_ok && SBCL_ARCH=$optarg
85 --xc-host=)
86 $optarg_ok && SBCL_XC_HOST=$optarg
88 --host-location=)
89 $optarg_ok && SBCL_HOST_LOCATION=$optarg
91 --target-location=)
92 $optarg_ok && SBCL_TARGET_LOCATION=$optarg
94 --dynamic-space-size=)
95 $optarg_ok && SBCL_DYNAMIC_SPACE_SIZE=$optarg
97 --with)
98 WITH_FEATURES="$WITH_FEATURES :$optarg"
99 if [ "$optarg" = "android" ]
100 then
101 android=true
104 --without)
105 WITHOUT_FEATURES="$WITHOUT_FEATURES :$optarg"
106 case $CONTRIBS
107 in *"$optarg"*)
108 SBCL_CONTRIB_BLOCKLIST="$SBCL_CONTRIB_BLOCKLIST $optarg"
109 ;; esac
111 --android-api=)
112 $optarg_ok && ANDROID_API=$optarg
114 --ndk=)
115 $optarg_ok && NDK=$optarg
117 --fancy)
118 WITH_FEATURES="$WITH_FEATURES $FANCY_FEATURES"
119 # Lower down we add :sb-thread for platforms where it can be built.
120 fancy=true
122 --check-host-lisp)
123 perform_host_lisp_check=yes
126 bad_option "Unknown command-line option to $0: \"$option\""
129 if $some_options
130 then
131 bad_option "Unknown command-line option to $0: \"$option\""
132 else
133 SBCL_XC_HOST=$option
136 esac
137 some_options=true
138 done
140 if (test -f customize-target-features.lisp && \
141 (test -n "$WITH_FEATURES" || test -n "$WITHOUT_FEATURES"))
142 then
143 # Actually there's no reason why it would not work, but it would
144 # be confusing to say --with-thread only to have it turned off by
145 # customize-target-features.lisp...
146 echo "ERROR: Both customize-target-features.lisp, and feature-options"
147 echo "to make.sh present -- cannot use both at the same time."
148 exit 1
151 if test "$print_help" = "yes"
152 then
153 cat <<EOF
154 \`make.sh' drives the SBCL build.
156 Usage: $0 [OPTION]...
158 Important: make.sh does not currently control the entirety of the
159 build: configuration file customize-target-features.lisp and certain
160 environment variables play a role as well. see file INSTALL for
161 details.
163 Options:
164 -h, --help Display this help and exit.
166 --prefix=<path> Specify the install location.
168 Script install.sh installs SBCL under the specified prefix
169 path: runtime as prefix/bin/sbcl, additional files under
170 prefix/lib/sbcl, and documentation under prefix/share.
172 This option also affects the binaries: built-in default for
173 SBCL_HOME is: prefix/lib/sbcl/
175 Default prefix is: /usr/local
177 --dynamic-space-size=<size> Default dynamic-space size for target.
179 This specifies the default dynamic-space size for the SBCL
180 being built. If you need to control the dynamic-space size
181 of the host SBCL, use the --xc-host option.
183 If not provided, the default is platform-specific. <size> is
184 taken to be megabytes unless explicitly suffixed with Gb in
185 order to specify the size in gigabytes.
187 --with-<feature> Build with specified feature.
188 --without-<feature> Build wihout the specfied feature.
190 --fancy Build with several optional features:
192 $FANCY_FEATURES
194 Plus threading on platforms which support it.
196 --arch=<string> Specify the architecture to build for.
198 Mainly for doing x86 builds on x86-64.
200 --xc-host=<string> Specify the Common Lisp compilation host.
202 The string provided should be a command to invoke the
203 cross-compilation Lisp system in such a way, that it reads
204 commands from standard input, and terminates when it reaches end
205 of file on standard input.
207 Examples:
209 "sbcl --disable-debugger --no-sysinit --no-userinit"
210 Use an existing SBCL binary as a cross-compilation
211 host even though you have stuff in your
212 initialization files which makes it behave in such a
213 non-standard way that it keeps the build from
214 working. Also disable the debugger instead of
215 waiting endlessly for a programmer to help it out
216 with input on *DEBUG-IO*. (This is the default.)
218 "sbcl"
219 Use an existing SBCL binary as a cross-compilation
220 host, including your initialization files and
221 building with the debugger enabled. Not recommended
222 for casual users.
224 "lisp -noinit -batch"
225 Use an existing CMU CL binary as a cross-compilation
226 host when you have weird things in your .cmucl-init
227 file.
229 --host-location=<string> Location of the source directory on compilation host
231 The string is passed to the command rsync to transfer the
232 necessary files between the target and host directories during
233 the make-target-*.sh steps of cross-compilation (cf. make.sh)
235 Examples:
237 user@host-machine:/home/user/sbcl
238 Transfer the files to/from directory /home/user/sbcl
239 on host-machine.
242 exit 1
245 mkdir -p output
246 echo "SBCL_TEST_HOST=\"$SBCL_XC_HOST\"" > output/build-config
247 . output/build-config # may come out differently due to escaping
249 if [ $perform_host_lisp_check = yes ]
250 then
251 if echo '(lisp-implementation-type)' | $SBCL_TEST_HOST; then
253 else
254 echo "No working host Common Lisp implementation."
255 echo 'See ./INSTALL, the "SOURCE DISTRIBUTION" section'
256 exit 1
260 # Running make.sh with different options without clean.sh in the middle
261 # can break things.
262 sh clean.sh
264 # Save prefix for make and install.sh.
265 echo "SBCL_PREFIX='$SBCL_PREFIX'" > output/prefix.def
266 echo "$SBCL_DYNAMIC_SPACE_SIZE" > output/dynamic-space-size.txt
268 # FIXME: Tweak this script, and the rest of the system, to support
269 # a second bootstrapping pass in which the cross-compilation host is
270 # known to be SBCL itself, so that the cross-compiler can do some
271 # optimizations (especially specializable arrays) that it doesn't
272 # know how to implement how in a portable way. (Or maybe that wouldn't
273 # require a second pass, just testing at build-the-cross-compiler time
274 # whether the cross-compilation host returns suitable values from
275 # UPGRADED-ARRAY-ELEMENT-TYPE?)
277 . ./find-gnumake.sh
278 find_gnumake
280 ./generate-version.sh
282 # Now that we've done our option parsing and found various
283 # dependencies, write them out to a file to be sourced by other
284 # scripts.
286 echo "GNUMAKE=\"$GNUMAKE\"; export GNUMAKE" >> output/build-config
287 echo "SBCL_XC_HOST=\"$SBCL_XC_HOST\"; export SBCL_XC_HOST" >> output/build-config
288 if [ -n "$SBCL_HOST_LOCATION" ]; then
289 echo "SBCL_HOST_LOCATION=\"$SBCL_HOST_LOCATION\"; export SBCL_HOST_LOCATION" >> output/build-config
291 if [ -n "$SBCL_TARGET_LOCATION" ]; then
292 echo "SBCL_TARGET_LOCATION=\"$SBCL_TARGET_LOCATION\"; export SBCL_TARGET_LOCATION" >> output/build-config
294 echo "android=$android; export android" >> output/build-config
296 # And now, sorting out the per-target dependencies...
298 case `uname` in
299 Linux)
300 sbcl_os="linux"
302 *BSD)
303 case `uname` in
304 FreeBSD)
305 sbcl_os="freebsd"
307 GNU/kFreeBSD)
308 sbcl_os="gnu-kfreebsd"
310 OpenBSD)
311 sbcl_os="openbsd"
313 NetBSD)
314 sbcl_os="netbsd"
317 echo unsupported BSD variant: `uname`
318 exit 1
320 esac
322 DragonFly)
323 sbcl_os="dragonflybsd"
325 Darwin)
326 sbcl_os="darwin"
328 SunOS)
329 sbcl_os="sunos"
331 CYGWIN* | WindowsNT | MINGW* | MSYS*)
332 sbcl_os="win32"
334 Haiku)
335 sbcl_os="haiku"
338 echo unsupported OS type: `uname`
339 exit 1
341 esac
343 link_or_copy() {
344 if [ "$sbcl_os" = "win32" ] ; then
345 # Use preprocessor or makefile includes instead of copying if
346 # possible, to avoid unexpected use of the original, unchanged
347 # files when re-running only make-target-1 during development.
348 if echo "$1" | egrep '[.][ch]$'; then
349 echo "#include \"$1\"" >"$2"
350 elif echo "$1" | egrep '^Config[.]'; then
351 echo "include $1" >"$2"
352 else
353 cp -r "$1" "$2"
355 elif $android ; then
356 # adb push doesn't like symlinks on unrooted devices.
357 cp -r "$1" "$2"
358 else
359 ln -s "$1" "$2"
363 remove_dir_safely() {
364 if [ "$sbcl_os" = "win32" ] ; then
365 if [ -d "$1" ] ; then
366 rm -rf "$1"
367 elif [ -e "$1" ] ; then
368 echo "I'm afraid to remove non-directory $1."
369 exit 1
371 else
372 if [ -h "$1" ] ; then
373 rm "$1"
374 elif [ -w "$1" ] ; then
375 echo "I'm afraid to replace non-symlink $1 with a symlink."
376 exit 1
381 echo //entering make-config.sh
383 echo //ensuring the existence of output/ directory
384 if [ ! -d output ] ; then mkdir output; fi
386 echo //guessing default target CPU architecture from host architecture
387 if $android
388 then
389 uname_arch=`adb shell uname -m`
390 else
391 uname_arch=`uname -m`
394 case $uname_arch in
395 *86) guessed_sbcl_arch=x86 ;;
396 i86pc) guessed_sbcl_arch=x86 ;;
397 *x86_64) guessed_sbcl_arch=x86-64 ;;
398 amd64) guessed_sbcl_arch=x86-64 ;;
399 sparc*) guessed_sbcl_arch=sparc ;;
400 sun*) guessed_sbcl_arch=sparc ;;
401 *ppc) guessed_sbcl_arch=ppc ;;
402 ppc64) guessed_sbcl_arch=ppc ;;
403 ppc64le) guessed_sbcl_arch=ppc64 ;; # is ok because there was never 32-bit LE
404 Power*Macintosh) guessed_sbcl_arch=ppc ;;
405 ibmnws) guessed_sbcl_arch=ppc ;;
406 mips*) guessed_sbcl_arch=mips ;;
407 arm64) guessed_sbcl_arch=arm64 ;;
408 *arm*) guessed_sbcl_arch=arm ;;
409 aarch64) guessed_sbcl_arch=arm64 ;;
410 riscv32) guessed_sbcl_arch=riscv xlen=32;;
411 riscv64) guessed_sbcl_arch=riscv xlen=64;;
413 # If we're not building on a supported target architecture, we
414 # we have no guess, but it's not an error yet, since maybe
415 # target architecture will be specified explicitly below.
416 guessed_sbcl_arch=''
418 esac
420 # Under Solaris, uname -m returns "i86pc" even if CPU is amd64.
421 if [ "$sbcl_os" = "sunos" ] && [ `isainfo -k` = "amd64" ]; then
422 guessed_sbcl_arch=x86-64
425 # Under Darwin, uname -m returns "i386" even if CPU is x86_64.
426 # (I suspect this is not true any more - it reports "x86_64 for me)
427 if [ "$sbcl_os" = "darwin" ] && [ "`/usr/sbin/sysctl -n hw.optional.x86_64`" = "1" ]; then
428 guessed_sbcl_arch=x86-64
431 # Under NetBSD, uname -m returns "evbarm" even if CPU is arm64.
432 if [ "$sbcl_os" = "netbsd" ] && [ `uname -p` = "aarch64" ]; then
433 guessed_sbcl_arch=arm64
436 echo //setting up CPU-architecture-dependent information
437 if test -n "$SBCL_ARCH"
438 then
439 # Normalize it.
440 SBCL_ARCH=`echo $SBCL_ARCH | tr '[A-Z]' '[a-z]' | tr _ -`
441 case $SBCL_ARCH in
442 riscv*)
443 case $SBCL_ARCH in
444 riscv32) SBCL_ARCH=riscv xlen=32;;
445 riscv64) SBCL_ARCH=riscv xlen=64;;
447 echo "Please choose between riscv32 and riscv64."
448 exit 1
449 esac
450 esac
452 sbcl_arch=${SBCL_ARCH:-$guessed_sbcl_arch}
453 echo sbcl_arch=\"$sbcl_arch\"
454 if [ "$sbcl_arch" = "" ] ; then
455 echo "can't guess target SBCL architecture, please specify --arch=<name>"
456 exit 1
459 if $android
460 then
461 case $sbcl_arch in
462 arm64) TARGET_TAG=aarch64-linux-android ;;
463 arm) TARGET_TAG=armv7a-linux-androideabi
464 echo "Unsupported configuration"
465 exit 1
467 x86) TARGET_TAG=i686-linux-android
468 echo "Unsupported configuration"
469 exit 1
471 x86-64) TARGET_TAG=x86_64-linux-android ;;
472 esac
473 HOST_TAG=$sbcl_os-x86_64
474 TOOLCHAIN=$NDK/toolchains/llvm/prebuilt/$HOST_TAG
475 export CC=$TOOLCHAIN/bin/$TARGET_TAG$ANDROID_API-clang
476 echo "CC=$CC; export CC" >> output/build-config
477 echo "NDK=$NDK" > output/ndk-config
478 echo "HOST_TAG=$HOST_TAG" >> output/ndk-config
479 echo "TARGET_TAG=$TARGET_TAG" >> output/ndk-config
480 echo "TOOLCHAIN=$TOOLCHAIN" >> output/ndk-config
481 echo "ANDROID_API=$ANDROID_API" >> output/ndk-config
484 if $fancy
485 then
486 # If --fancy, enable threads on platforms where they can be built.
487 case $sbcl_arch in
488 x86|x86-64|ppc|arm64|riscv)
489 if [ "$sbcl_os" = "dragonflybsd" ]
490 then
491 echo "No threads on this platform."
492 else
493 WITH_FEATURES="$WITH_FEATURES :sb-thread"
494 echo "Enabling threads due to --fancy."
498 echo "No threads on this platform."
500 esac
501 else
502 case $sbcl_arch in
503 x86|x86-64)
504 case $sbcl_os in
505 linux|darwin)
506 WITH_FEATURES="$WITH_FEATURES :sb-thread"
507 esac
508 esac
509 case $sbcl_arch in
510 arm64|riscv)
511 WITH_FEATURES="$WITH_FEATURES :sb-thread"
512 esac
515 case "$sbcl_os" in
516 netbsd)
517 # default to using paxctl to disable mprotect restrictions
518 if [ "x$(sysctl -n security.pax.mprotect.enabled 2>/dev/null)" = x1 -a \
519 "x$SBCL_PAXCTL" = x ]; then
520 echo "SBCL_PAXCTL=\"/usr/sbin/paxctl +m\"; export SBCL_PAXCTL" \
521 >> output/build-config
524 openbsd)
525 # openbsd 6.0 and newer restrict mmap of RWX pages
526 if [ `uname -r | tr -d .` -gt 60 ]; then
527 rm -f tools-for-build/mmap-rwx
528 LDFLAGS="$LDFLAGS -Wl,-zwxneeded" $GNUMAKE -C tools-for-build mmap-rwx -I ../src/runtime
529 if ! ./tools-for-build/mmap-rwx; then
530 echo "Can't mmap() RWX pages!"
531 echo "Is the current filesystem mounted with wxallowed?"
532 exit 1
536 esac
538 ltf=`pwd`/local-target-features.lisp-expr
539 echo //initializing $ltf
540 echo ';;;; This is a machine-generated file.' > $ltf
541 echo ';;;; Please do not edit it by hand.' >> $ltf
542 echo ';;;; See make-config.sh.' >> $ltf
543 echo "(lambda (features) (set-difference (union features (list :${sbcl_arch}$WITH_FEATURES" >> $ltf
545 # Automatically block sb-simd on non-x86 platforms, at least for now.
546 case "$sbcl_arch" in
547 x86-64) ;; *) SBCL_CONTRIB_BLOCKLIST="$SBCL_CONTRIB_BLOCKLIST sb-simd" ;;
548 esac
549 case "$sbcl_os" in
550 linux) ;; *) SBCL_CONTRIB_BLOCKLIST="$SBCL_CONTRIB_BLOCKLIST sb-perf" ;;
551 esac
553 echo //setting up OS-dependent information
555 original_dir=`pwd`
556 cd ./src/runtime/
557 rm -f Config target-arch-os.h target-arch.h target-os.h target-lispregs.h
558 rm -f sbcl.mk sbcl.o libsbcl.a
559 # KLUDGE: these two logically belong in the previous section
560 # ("architecture-dependent"); it seems silly to enforce this in terms
561 # of the shell script, though. -- CSR, 2002-02-03
562 link_or_copy $sbcl_arch-arch.h target-arch.h
563 link_or_copy $sbcl_arch-lispregs.h target-lispregs.h
564 case "$sbcl_os" in
565 linux)
566 printf ' :unix :linux :elf' >> $ltf
567 case "$sbcl_arch" in
568 arm64 | ppc64 | x86 | x86-64)
569 printf ' :gcc-tls' >> $ltf
570 esac
571 case "$sbcl_arch" in
572 arm | arm64 | ppc | ppc64 | x86 | x86-64)
573 printf ' :use-sys-mmap' >> $ltf
574 esac
576 # If you add other platforms here, don't forget to edit
577 # src/runtime/Config.foo-linux too.
578 case "$sbcl_arch" in
579 mips | arm | x86 | x86-64)
580 printf ' :largefile' >> $ltf
582 esac
583 if $android
584 then
585 link_or_copy Config.$sbcl_arch-android Config
586 link_or_copy $sbcl_arch-android-os.h target-arch-os.h
587 link_or_copy android-os.h target-os.h
588 else
589 link_or_copy Config.$sbcl_arch-linux Config
590 link_or_copy $sbcl_arch-linux-os.h target-arch-os.h
591 link_or_copy linux-os.h target-os.h
594 haiku)
595 printf ' :unix :haiku :elf :int4-breakpoints' >> $ltf
596 link_or_copy Config.$sbcl_arch-haiku Config
597 link_or_copy $sbcl_arch-haiku-os.h target-arch-os.h
598 link_or_copy haiku-os.h target-os.h
600 *bsd)
601 printf ' :unix :bsd :elf' >> $ltf
602 # FIXME: can we enable :gcc-tls across all variants?
603 link_or_copy $sbcl_arch-bsd-os.h target-arch-os.h
604 link_or_copy bsd-os.h target-os.h
605 case "$sbcl_os" in
606 *freebsd)
607 printf ' :freebsd' >> $ltf
608 printf ' :gcc-tls' >> $ltf
609 if [ $sbcl_os = "gnu-kfreebsd" ]; then
610 printf ' :gnu-kfreebsd' >> $ltf
612 link_or_copy Config.$sbcl_arch-$sbcl_os Config
614 openbsd)
615 printf ' :openbsd' >> $ltf
616 case "$sbcl_arch" in
617 arm64 | x86 | x86-64)
618 printf ' :gcc-tls' >> $ltf
619 esac
620 link_or_copy Config.$sbcl_arch-openbsd Config
622 netbsd)
623 printf ' :netbsd' >> $ltf
624 link_or_copy Config.$sbcl_arch-netbsd Config
626 dragonflybsd)
627 printf ' :dragonfly' >> $ltf
628 link_or_copy Config.$sbcl_arch-dragonfly Config
631 echo unsupported BSD variant: `uname`
632 exit 1
634 esac
636 darwin)
637 printf ' :unix :bsd :darwin :mach-o' >> $ltf
638 darwin_version=`uname -r`
639 darwin_version_major=${DARWIN_VERSION_MAJOR:-${darwin_version%%.*}}
640 if (( 10 > $darwin_version_major )) || [ $sbcl_arch = "ppc" ]; then
641 printf ' :use-darwin-posix-semaphores :avoid-pthread-setname-np' >> $ltf
643 if (( 15 > $darwin_version_major )); then
644 printf ' :avoid-clock-gettime' >> $ltf
646 if [ $sbcl_arch = "x86-64" ]; then
647 if (( 8 < $darwin_version_major )); then
648 printf ' :inode64' >> $ltf
650 printf ' :gcc-tls' >> $ltf
652 if [ $sbcl_arch = "arm64" ]; then
653 printf ' :darwin-jit :gcc-tls' >> $ltf
655 if $android; then
656 echo "Android build is unsupported on darwin"
658 link_or_copy $sbcl_arch-darwin-os.h target-arch-os.h
659 link_or_copy bsd-os.h target-os.h
660 link_or_copy Config.$sbcl_arch-darwin Config
662 sunos)
663 printf ' :unix :sunos :elf' >> $ltf
664 link_or_copy Config.$sbcl_arch-sunos Config
665 link_or_copy $sbcl_arch-sunos-os.h target-arch-os.h
666 link_or_copy sunos-os.h target-os.h
668 win32)
669 printf ' :win32' >> $ltf
671 # Required features -- Some of these used to be optional, but
672 # building without them is no longer considered supported:
674 # (Of course it doesn't provide dlopen, but there is
675 # roughly-equivalent magic nevertheless:)
676 printf ' :os-provides-dlopen' >> $ltf
677 printf ' :sb-thread :sb-safepoint' >> $ltf
679 link_or_copy Config.$sbcl_arch-win32 Config
680 link_or_copy $sbcl_arch-win32-os.h target-arch-os.h
681 link_or_copy win32-os.h target-os.h
684 echo unsupported OS type: `uname`
685 exit 1
687 esac
688 cd "$original_dir"
690 if $android
691 then
692 . tools-for-build/android_run.sh
695 case "$sbcl_arch" in
696 x86)
697 if [ "$sbcl_os" = "win32" ]; then
698 # of course it doesn't provide dlopen, but there is
699 # roughly-equivalent magic nevertheless.
700 printf ' :os-provides-dlopen' >> $ltf
702 if [ "$sbcl_os" = "openbsd" ]; then
703 rm -f src/runtime/openbsd-sigcontext.h
704 sh tools-for-build/openbsd-sigcontext.sh > src/runtime/openbsd-sigcontext.h
707 x86-64)
708 printf ' :sb-simd-pack :sb-simd-pack-256 :avx2' >> $ltf # not mandatory
710 if $android; then
711 $GNUMAKE -C tools-for-build avx2 2> /dev/null
712 if ! android_run tools-for-build/avx2 ; then
713 SBCL_CONTRIB_BLOCKLIST="$SBCL_CONTRIB_BLOCKLIST sb-simd"
715 else
716 if ! $GNUMAKE -C tools-for-build avx2 2> /dev/null || tools-for-build/avx2 ; then
717 SBCL_CONTRIB_BLOCKLIST="$SBCL_CONTRIB_BLOCKLIST sb-simd"
721 case "$sbcl_os" in
722 linux | darwin | *bsd | win32)
723 printf ' :immobile-space' >> $ltf
724 esac
726 ppc)
727 if [ "$sbcl_os" = "linux" ]; then
728 # Use a C program to detect which kind of glibc we're building on,
729 # to bandage across the break in source compatibility between
730 # versions 2.3.1 and 2.3.2
732 # FIXME: integrate to grovel-features, mayhaps
733 $GNUMAKE -C tools-for-build where-is-mcontext -I ../src/runtime
734 tools-for-build/where-is-mcontext > src/runtime/ppc-linux-mcontext.h || (echo "error running where-is-mcontext"; exit 1)
735 elif [ "$sbcl_os" = "darwin" ]; then
736 # We provide a dlopen shim, so a little lie won't hurt
737 printf ' :os-provides-dlopen' >> $ltf
738 # The default stack ulimit under darwin is too small to run PURIFY.
739 # Best we can do is complain and exit at this stage
740 if [ "`ulimit -s`" = "512" ]; then
741 echo "Your stack size limit is too small to build SBCL."
742 echo "See the limit(1) or ulimit(1) commands and the README file."
743 exit 1
747 ppc64)
748 # there is no glibc bug that requires the 'where-is-mcontext' hack.
749 # (Sufficiently new glibc uses the correct definition, which is the same as
750 # 2.3.1, so define our constant for that)
751 echo '#define GLIBC231_STYLE_UCONTEXT 1' > src/runtime/ppc-linux-mcontext.h
753 riscv)
754 if [ "$xlen" = "64" ]; then
755 printf ' :64-bit' >> $ltf
756 elif [ "$xlen" = "32" ]; then
758 else
759 echo 'Architecture word width unspecified. (Either 32-bit or 64-bit.)'
760 exit 1
763 esac
765 if [ "$sbcl_os" = darwin -a "$sbcl_arch" = arm64 ]
766 then
767 # Launching new executables is pretty slow on macOS, but this configuration is pretty uniform
768 echo ' :little-endian :os-provides-dlopen :os-provides-dladdr' >> $ltf
769 echo ' :os-provides-blksize-t :os-provides-suseconds-t :os-provides-posix-spawn' >> $ltf
770 else
771 # Use a little C program to try to guess the endianness. Ware
772 # cross-compilers!
774 # FIXME: integrate to grovel-features, mayhaps
775 if $android
776 then
777 $CC tools-for-build/determine-endianness.c -o tools-for-build/determine-endianness
778 android_run tools-for-build/determine-endianness >> $ltf
779 else
780 $GNUMAKE -C tools-for-build determine-endianness -I ../src/runtime
781 tools-for-build/determine-endianness >> $ltf
783 export sbcl_os sbcl_arch android
784 sh tools-for-build/grovel-features.sh >> $ltf
788 echo //finishing $ltf
789 printf " %s" "`cat crossbuild-runner/backends/${sbcl_arch}/features`" >> $ltf
790 echo ")) (list$WITHOUT_FEATURES)))" >> $ltf
792 echo "SBCL_CONTRIB_BLOCKLIST=\"$SBCL_CONTRIB_BLOCKLIST\"; export SBCL_CONTRIB_BLOCKLIST" >> output/build-config
794 # FIXME: The version system should probably be redone along these lines:
796 # echo //setting up version information.
797 # versionfile=version.txt
798 # cp base-version.txt $versionfile
799 # echo " (built `date -u` by `whoami`@`hostname`)" >> $versionfile
800 # echo 'This is a machine-generated file and should not be edited by hand.' >> $versionfile
802 # Make a unique ID for this build (to discourage people from
803 # mismatching sbcl and *.core files).
804 if [ `uname` = "SunOS" ] ; then
805 # use /usr/xpg4/bin/id instead of /usr/bin/id
806 PATH=/usr/xpg4/bin:$PATH
809 if [ -n "$SOURCE_DATE_EPOCH" ]; then
810 echo '"'hostname-id-"$SOURCE_DATE_EPOCH"'"' > output/build-id.inc
811 else
812 echo '"'`hostname`-`id -un`-`date +%Y-%m-%d-%H-%M-%S`'"' > output/build-id.inc
815 if [ -n "$SBCL_HOST_LOCATION" ]; then
816 echo //setting up host configuration
817 rsync --delete-after -a output/ "$SBCL_HOST_LOCATION/output/"
818 rsync -a local-target-features.lisp-expr version.lisp-expr "$SBCL_HOST_LOCATION/"