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
11 # This software is part of the SBCL system. See the README file for
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.
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
29 if [ "$OSTYPE" = "cygwin" -o "$OSTYPE" = "msys" ]
31 SBCL_PREFIX="$PROGRAMFILES/sbcl"
33 SBCL_PREFIX="/usr/local"
35 SBCL_XC_HOST="sbcl --disable-debugger --no-userinit --no-sysinit"
38 # Parse command-line options.
41 echo "Enter \"$0 --help\" for list of valid options."
49 # Split --foo=bar into --foo and bar.
52 # For ease of scripting treat skip valued options with empty
54 optarg=`expr "X$option" : '[^=]*=\(.*\)'` || optarg_ok=false
55 option=`expr "X$option" : 'X\([^=]*=\).*'`
66 $optarg_ok && SBCL_PREFIX=$optarg
69 $optarg_ok && SBCL_XC_HOST=$optarg
71 --dynamic-space-size=)
72 $optarg_ok && SBCL_DYNAMIC_SPACE_SIZE=$optarg
75 bad_option "Unknown command-line option to $0: \"$option\""
80 bad_option "Unknown command-line option to $0: \"$option\""
82 legacy_xc_spec=$option
89 # Previously XC host was provided as a positional argument.
90 if test -n "$legacy_xc_spec"
92 SBCL_XC_HOST="$legacy_xc_spec"
95 if test "$print_help" = "yes"
98 \`make.sh' drives the SBCL build.
100 Usage: $0 [OPTION]...
102 Important: make.sh does not currently control the entirety of the
103 build: configuration file customize-target-features.lisp and certain
104 environment variables play a role as well. see file INSTALL for
108 -h, --help Display this help and exit.
110 --prefix=<path> Specify the install location.
112 Script install.sh installs SBCL under the specified prefix
113 path: runtime as prefix/bin/sbcl, additional files under
114 prefix/lib/sbcl, and documentation under prefix/share.
116 This option also affects the binaries: built-in default for
117 SBCL_HOME is: prefix/lib/sbcl/
119 Default prefix is: /usr/local
121 --dynamic-space-size=<size> Default dynamic-space size for target.
123 This specifies the default dynamic-space size for the SBCL
124 being built. If you need to control the dynamic-space size
125 of the host SBCL, use the --xc-host option.
127 If not provided, the default is platform-specific. <size> is
128 taken to be megabytes unless explicitly suffixed with Gb in
129 order to specify the size in gigabytes.
131 --xc-host=<string> Specify the Common Lisp compilation host.
133 The string provided should be a command to invoke the
134 cross-compilation Lisp system in such a way, that it reads
135 commands from standard input, and terminates when it reaches end
136 of file on standard input.
140 "sbcl --disable-debugger --no-sysinit --no-userinit"
141 Use an existing SBCL binary as a cross-compilation
142 host even though you have stuff in your
143 initialization files which makes it behave in such a
144 non-standard way that it keeps the build from
145 working. Also disable the debugger instead of
146 waiting endlessly for a programmer to help it out
147 with input on *DEBUG-IO*. (This is the default.)
150 Use an existing SBCL binary as a cross-compilation
151 host, including your initialization files and
152 building with the debugger enabled. Not recommended
155 "lisp -noinit -batch"
156 Use an existing CMU CL binary as a cross-compilation
157 host when you have weird things in your .cmucl-init
164 # Save prefix for make and install.sh.
165 echo "SBCL_PREFIX='$SBCL_PREFIX'" > output/prefix.def
166 echo "$SBCL_DYNAMIC_SPACE_SIZE" > output/dynamic-space-size.txt
168 # FIXME: Tweak this script, and the rest of the system, to support
169 # a second bootstrapping pass in which the cross-compilation host is
170 # known to be SBCL itself, so that the cross-compiler can do some
171 # optimizations (especially specializable arrays) that it doesn't
172 # know how to implement how in a portable way. (Or maybe that wouldn't
173 # require a second pass, just testing at build-the-cross-compiler time
174 # whether the cross-compilation host returns suitable values from
175 # UPGRADED-ARRAY-ELEMENT-TYPE?)
177 if [ "$OSTYPE" = "cygwin" -o "$OSTYPE" = "msys" ] ; then
187 . ./generate-version.sh
190 # Now that we've done our option parsing and found various
191 # dependencies, write them out to a file to be sourced by other
194 echo "DEVNULL=\"$DEVNULL\"; export DEVNULL" > output/build-config
195 echo "GNUMAKE=\"$GNUMAKE\"; export GNUMAKE" >> output/build-config
196 echo "SBCL_XC_HOST=\"$SBCL_XC_HOST\"; export SBCL_XC_HOST" >> output/build-config
197 echo "legacy_xc_spec=\"$legacy_xc_spec\"; export legacy_xc_spec" >> output/build-config
199 # And now, sorting out the per-target dependencies...
206 # it's changed name twice since it was called OSF/1: clearly
207 # the marketers forgot to tell the engineers about Digital Unix
223 echo unsupported BSD variant: `uname`
234 CYGWIN* | WindowsNT | MINGW*)
241 echo unsupported OS type: `uname`
247 if [ "$sbcl_os" = "win32" ] ; then
254 remove_dir_safely() {
255 if [ "$sbcl_os" = "win32" ] ; then
256 if [ -d "$1" ] ; then
258 elif [ -e "$1" ] ; then
259 echo "I'm afraid to remove non-directory $1."
263 if [ -h "$1" ] ; then
265 elif [ -w "$1" ] ; then
266 echo "I'm afraid to replace non-symlink $1 with a symlink."
272 echo //entering make-config.sh
274 echo //ensuring the existence of output/ directory
275 if [ ! -d output ] ; then mkdir output; fi
277 ltf=`pwd`/local-target-features.lisp-expr
278 echo //initializing $ltf
279 echo ';;;; This is a machine-generated file.' > $ltf
280 echo ';;;; Please do not edit it by hand.' >> $ltf
281 echo ';;;; See make-config.sh.' >> $ltf
284 echo //guessing default target CPU architecture from host architecture
286 *86) guessed_sbcl_arch=x86 ;;
287 i86pc) guessed_sbcl_arch=x86 ;;
288 *x86_64) guessed_sbcl_arch=x86-64 ;;
289 amd64) guessed_sbcl_arch=x86-64 ;;
290 [Aa]lpha) guessed_sbcl_arch=alpha ;;
291 sparc*) guessed_sbcl_arch=sparc ;;
292 sun*) guessed_sbcl_arch=sparc ;;
293 *ppc) guessed_sbcl_arch=ppc ;;
294 ppc64) guessed_sbcl_arch=ppc ;;
295 Power*Macintosh) guessed_sbcl_arch=ppc ;;
296 parisc) guessed_sbcl_arch=hppa ;;
297 9000/800) guessed_sbcl_arch=hppa ;;
298 mips*) guessed_sbcl_arch=mips ;;
300 # If we're not building on a supported target architecture, we
301 # we have no guess, but it's not an error yet, since maybe
302 # target architecture will be specified explicitly below.
307 # Under Solaris, uname -m returns "i86pc" even if CPU is amd64.
308 if [ "$sbcl_os" = "sunos" ] && [ `isainfo -k` = "amd64" ]; then
309 guessed_sbcl_arch=x86-64
312 # Under Darwin, uname -m returns "i386" even if CPU is x86_64.
313 if [ "$sbcl_os" = "darwin" ] && [ "`/usr/sbin/sysctl -n hw.optional.x86_64`" = "1" ]; then
314 guessed_sbcl_arch=x86-64
317 echo //setting up CPU-architecture-dependent information
318 sbcl_arch=${SBCL_ARCH:-$guessed_sbcl_arch}
319 echo sbcl_arch=\"$sbcl_arch\"
320 if [ "$sbcl_arch" = "" ] ; then
321 echo "can't guess target SBCL architecture, need SBCL_ARCH environment var"
324 printf ":%s" "$sbcl_arch" >> $ltf
326 echo //setting up OS-dependent information
328 # Under Darwin x86-64, guess whether Darwin 9+ or below.
329 if [ "$sbcl_os" = "darwin" ] && [ "$sbcl_arch" = "x86-64" ]; then
330 darwin_version=`uname -r`
331 darwin_version_major=${DARWIN_VERSION_MAJOR:-${darwin_version%%.*}}
332 if (( 8 < $darwin_version_major )); then
333 printf ' :inode64 :darwin9-or-better' >> $ltf
339 rm -f Config target-arch-os.h target-arch.h target-os.h target-lispregs.h
340 # KLUDGE: these two logically belong in the previous section
341 # ("architecture-dependent"); it seems silly to enforce this in terms
342 # of the shell script, though. -- CSR, 2002-02-03
343 link_or_copy $sbcl_arch-arch.h target-arch.h
344 link_or_copy $sbcl_arch-lispregs.h target-lispregs.h
347 printf ' :unix' >> $ltf
348 printf ' :elf' >> $ltf
349 printf ' :linux' >> $ltf
351 # If you add other platforms here, don't forget to edit
352 # src/runtime/Config.foo-linux too.
355 printf ' :largefile' >> $ltf
358 printf ' :sb-thread :sb-futex :largefile' >> $ltf
361 printf ' :sb-futex' >> $ltf
365 if [ $sbcl_arch = "x86-64" ]; then
366 link_or_copy Config.x86_64-linux Config
368 link_or_copy Config.$sbcl_arch-linux Config
370 link_or_copy $sbcl_arch-linux-os.h target-arch-os.h
371 link_or_copy linux-os.h target-os.h
374 printf ' :unix' >> $ltf
375 printf ' :elf' >> $ltf
376 printf ' :osf1' >> $ltf
377 link_or_copy Config.$sbcl_arch-osf1 Config
378 link_or_copy $sbcl_arch-osf1-os.h target-arch-os.h
379 link_or_copy osf1-os.h target-os.h
382 printf ' :unix' >> $ltf
383 printf ' :elf' >> $ltf
384 printf ' :hpux' >> $ltf
385 link_or_copy Config.$sbcl_arch-hpux Config
386 link_or_copy $sbcl_arch-hpux-os.h target-arch-os.h
387 link_or_copy hpux-os.h target-os.h
390 printf ' :unix' >> $ltf
391 printf ' :bsd' >> $ltf
392 link_or_copy $sbcl_arch-bsd-os.h target-arch-os.h
393 link_or_copy bsd-os.h target-os.h
396 printf ' :elf' >> $ltf
397 printf ' :freebsd' >> $ltf
398 printf ' :gcc-tls' >> $ltf
399 if [ $sbcl_arch = "x86" ]; then
400 printf ' :restore-tls-segment-register-from-context' >> $ltf
402 link_or_copy Config.$sbcl_arch-freebsd Config
405 printf ' :elf' >> $ltf
406 printf ' :openbsd' >> $ltf
407 link_or_copy Config.$sbcl_arch-openbsd Config
410 printf ' :netbsd' >> $ltf
411 printf ' :elf' >> $ltf
412 link_or_copy Config.$sbcl_arch-netbsd Config
415 echo unsupported BSD variant: `uname`
421 printf ' :unix' >> $ltf
422 printf ' :mach-o' >> $ltf
423 printf ' :bsd' >> $ltf
424 printf ' :darwin' >> $ltf
425 if [ $sbcl_arch = "x86" ]; then
426 printf ' :mach-exception-handler :restore-fs-segment-register-from-tls :ud2-breakpoints' >> $ltf
428 if [ $sbcl_arch = "x86-64" ]; then
429 printf ' :mach-exception-handler :ud2-breakpoints' >> $ltf
431 link_or_copy $sbcl_arch-darwin-os.h target-arch-os.h
432 link_or_copy bsd-os.h target-os.h
433 link_or_copy Config.$sbcl_arch-darwin Config
436 printf ' :unix' >> $ltf
437 printf ' :elf' >> $ltf
438 printf ' :sunos' >> $ltf
439 if [ $sbcl_arch = "x86-64" ]; then
440 printf ' :largefile' >> $ltf
442 link_or_copy Config.$sbcl_arch-sunos Config
443 link_or_copy $sbcl_arch-sunos-os.h target-arch-os.h
444 link_or_copy sunos-os.h target-os.h
447 printf ' :win32' >> $ltf
448 link_or_copy Config.$sbcl_arch-win32 Config
449 link_or_copy $sbcl_arch-win32-os.h target-arch-os.h
450 link_or_copy win32-os.h target-os.h
453 echo unsupported OS type: `uname`
459 # FIXME: Things like :c-stack-grows-..., etc, should be
460 # *derived-target-features* or equivalent, so that there was a nicer
461 # way to specify them then sprinkling them in this file. They should
462 # still be tweakable by advanced users, though, but probably not
463 # appear in *features* of target. #!+/- should be adjusted to take
464 # them in account as well. At minimum the nicer specification stuff,
467 # (define-feature :dlopen (features)
468 # (union '(:bsd :linux :darwin :sunos) features))
470 # (define-feature :c-stack-grows-downwards-not-upwards (features)
471 # (member :x86 features))
473 # KLUDGE: currently the x86 only works with the generational garbage
474 # collector (indicated by the presence of :GENCGC in *FEATURES*) and
475 # alpha, sparc and ppc with the stop'n'copy collector (indicated by
476 # the absence of :GENCGC in *FEATURES*). This isn't a great
477 # separation, but for now, rather than have :GENCGC in
478 # base-target-features.lisp-expr, we add it into local-target-features
479 # if we're building for x86. -- CSR, 2002-02-21 Then we do something
480 # similar with :STACK-GROWS-FOOWARD, too. -- WHN 2002-03-03
481 if [ "$sbcl_arch" = "x86" ]; then
482 printf ' :gencgc :stack-grows-downward-not-upward :c-stack-is-control-stack' >> $ltf
483 printf ' :compare-and-swap-vops :unwind-to-frame-and-call-vop :raw-instance-init-vops' >> $ltf
484 printf ' :stack-allocatable-closures :stack-allocatable-vectors' >> $ltf
485 printf ' :stack-allocatable-lists :stack-allocatable-fixed-objects' >> $ltf
486 printf ' :alien-callbacks :cycle-counter :inline-constants ' >> $ltf
487 printf ' :memory-barrier-vops :multiply-high-vops' >> $ltf
489 linux | freebsd | netbsd | openbsd | sunos | darwin | win32)
490 printf ' :linkage-table' >> $ltf
492 if [ "$sbcl_os" = "win32" ]; then
493 # of course it doesn't provide dlopen, but there is
494 # roughly-equivalent magic nevertheless.
495 printf ' :os-provides-dlopen' >> $ltf
497 if [ "$sbcl_os" = "openbsd" ]; then
498 rm -f src/runtime/openbsd-sigcontext.h
499 sh tools-for-build/openbsd-sigcontext.sh > src/runtime/openbsd-sigcontext.h
501 elif [ "$sbcl_arch" = "x86-64" ]; then
502 printf ' :gencgc :stack-grows-downward-not-upward :c-stack-is-control-stack :linkage-table' >> $ltf
503 printf ' :compare-and-swap-vops :unwind-to-frame-and-call-vop :raw-instance-init-vops' >> $ltf
504 printf ' :stack-allocatable-closures :stack-allocatable-vectors' >> $ltf
505 printf ' :stack-allocatable-lists :stack-allocatable-fixed-objects' >> $ltf
506 printf ' :alien-callbacks :cycle-counter :complex-float-vops' >> $ltf
507 printf ' :float-eql-vops :inline-constants :memory-barrier-vops' >> $ltf
508 printf ' :multiply-high-vops' >> $ltf
509 elif [ "$sbcl_arch" = "mips" ]; then
510 printf ' :linkage-table' >> $ltf
511 printf ' :stack-allocatable-closures :stack-allocatable-vectors' >> $ltf
512 printf ' :stack-allocatable-lists :stack-allocatable-fixed-objects' >> $ltf
513 printf ' :alien-callbacks' >> $ltf
514 # Use a little C program to try to guess the endianness. Ware
517 # FIXME: integrate to grovel-features, mayhaps
518 $GNUMAKE -C tools-for-build determine-endianness -I ../src/runtime
519 tools-for-build/determine-endianness >> $ltf
520 elif [ "$sbcl_arch" = "ppc" ]; then
521 printf ' :gencgc :stack-allocatable-closures :stack-allocatable-lists' >> $ltf
522 printf ' :linkage-table :raw-instance-init-vops :memory-barrier-vops' >> $ltf
523 printf ' :compare-and-swap-vops :multiply-high-vops' >> $ltf
524 if [ "$sbcl_os" = "linux" ]; then
525 # Use a C program to detect which kind of glibc we're building on,
526 # to bandage across the break in source compatibility between
527 # versions 2.3.1 and 2.3.2
529 # FIXME: integrate to grovel-features, mayhaps
530 $GNUMAKE -C tools-for-build where-is-mcontext -I ../src/runtime
531 tools-for-build/where-is-mcontext > src/runtime/ppc-linux-mcontext.h || (echo "error running where-is-mcontext"; exit 1)
532 elif [ "$sbcl_os" = "darwin" ]; then
533 # We provide a dlopen shim, so a little lie won't hurt
534 printf " :os-provides-dlopen :alien-callbacks" >> $ltf
535 # The default stack ulimit under darwin is too small to run PURIFY.
536 # Best we can do is complain and exit at this stage
537 if [ "`ulimit -s`" = "512" ]; then
538 echo "Your stack size limit is too small to build SBCL."
539 echo "See the limit(1) or ulimit(1) commands and the README file."
543 elif [ "$sbcl_arch" = "sparc" ]; then
544 # Test the compiler in order to see if we are building on Sun
545 # toolchain as opposed to GNU binutils, and write the appropriate
546 # FUNCDEF macro for assembler. No harm in running this on sparc-linux
548 sh tools-for-build/sparc-funcdef.sh > src/runtime/sparc-funcdef.h
549 if [ "$sbcl_os" = "sunos" ] || [ "$sbcl_os" = "linux" ]; then
550 printf ' :linkage-table' >> $ltf
552 printf ' :stack-allocatable-closures :stack-allocatable-lists' >> $ltf
553 elif [ "$sbcl_arch" = "alpha" ]; then
554 printf ' :stack-allocatable-closures :stack-allocatable-lists' >> $ltf
555 elif [ "$sbcl_arch" = "hppa" ]; then
556 printf ' :stack-allocatable-vectors :stack-allocatable-fixed-objects' >> $ltf
557 printf ' :stack-allocatable-lists' >> $ltf
559 # Nothing need be done in this case, but sh syntax wants a placeholder.
563 export sbcl_os sbcl_arch
564 sh tools-for-build/grovel-features.sh >> $ltf
566 echo //finishing $ltf
569 # FIXME: The version system should probably be redone along these lines:
571 # echo //setting up version information.
572 # versionfile=version.txt
573 # cp base-version.txt $versionfile
574 # echo " (built `date -u` by `whoami`@`hostname`)" >> $versionfile
575 # echo 'This is a machine-generated file and should not be edited by hand.' >> $versionfile
577 # Make a unique ID for this build (to discourage people from
578 # mismatching sbcl and *.core files).
579 if [ `uname` = "SunOS" ] ; then
580 # use /usr/xpg4/bin/id instead of /usr/bin/id
581 PATH=/usr/xpg4/bin:$PATH
583 echo '"'`hostname`-`id -un`-`date +%Y-%m-%d-%H-%M-%S`'"' > output/build-id.tmp