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.
25 # it's changed name twice since it was called OSF/1: clearly
26 # the marketers forgot to tell the engineers about Digital Unix
42 echo unsupported BSD variant
: `uname`
53 CYGWIN
* | WindowsNT | MINGW
*)
60 echo unsupported OS
type: `uname`
66 if [ "$sbcl_os" = "win32" ] ; then
74 if [ "$sbcl_os" = "win32" ] ; then
77 elif [ -e "$1" ] ; then
78 echo "I'm afraid to remove non-directory $1."
84 elif [ -w "$1" ] ; then
85 echo "I'm afraid to replace non-symlink $1 with a symlink."
91 echo //entering make-config.sh
93 echo //ensuring the existence of output
/ directory
94 if [ ! -d output
] ; then mkdir output
; fi
96 ltf
=`pwd`/local-target-features.lisp-expr
97 echo //initializing
$ltf
98 echo ';;;; This is a machine-generated file.' > $ltf
99 echo ';;;; Please do not edit it by hand.' >> $ltf
100 echo ';;;; See make-config.sh.' >> $ltf
103 echo //guessing default target CPU architecture from
host architecture
105 *86) guessed_sbcl_arch
=x86
;;
106 i86pc
) guessed_sbcl_arch
=x86
;;
107 *x86_64
) guessed_sbcl_arch
=x86-64
;;
108 amd64
) guessed_sbcl_arch
=x86-64
;;
109 [Aa
]lpha
) guessed_sbcl_arch
=alpha
;;
110 sparc
*) guessed_sbcl_arch
=sparc
;;
111 sun
*) guessed_sbcl_arch
=sparc
;;
112 *ppc
) guessed_sbcl_arch
=ppc
;;
113 ppc64
) guessed_sbcl_arch
=ppc
;;
114 Power
*Macintosh
) guessed_sbcl_arch
=ppc
;;
115 parisc
) guessed_sbcl_arch
=hppa
;;
116 9000/800) guessed_sbcl_arch
=hppa
;;
117 mips
*) guessed_sbcl_arch
=mips
;;
119 # If we're not building on a supported target architecture, we
120 # we have no guess, but it's not an error yet, since maybe
121 # target architecture will be specified explicitly below.
126 # Under Solaris, uname -m returns "i86pc" even if CPU is amd64.
127 if [ "$sbcl_os" = "sunos" ] && [ `isainfo -k` = "amd64" ]; then
128 guessed_sbcl_arch
=x86-64
131 # Under Darwin, uname -m returns "i386" even if CPU is x86_64.
132 if [ "$sbcl_os" = "darwin" ] && [ "`/usr/sbin/sysctl -n hw.optional.x86_64`" = "1" ]; then
133 guessed_sbcl_arch
=x86-64
136 echo //setting up CPU-architecture-dependent information
137 sbcl_arch
=${SBCL_ARCH:-$guessed_sbcl_arch}
138 echo sbcl_arch
=\"$sbcl_arch\"
139 if [ "$sbcl_arch" = "" ] ; then
140 echo "can't guess target SBCL architecture, need SBCL_ARCH environment var"
143 printf ":%s" "$sbcl_arch" >> $ltf
145 echo //setting up OS-dependent information
147 # Under Darwin x86-64, guess whether Darwin 9+ or below.
148 if [ "$sbcl_os" = "darwin" ] && [ "$sbcl_arch" = "x86-64" ]; then
149 darwin_version
=`uname -r`
150 darwin_version_major
=${DARWIN_VERSION_MAJOR:-${darwin_version%%.*}}
151 if (( 8 < $darwin_version_major )); then
152 printf ' :inode64 :darwin9-or-better' >> $ltf
158 rm -f Config target-arch-os.h target-arch.h target-os.h target-lispregs.h
159 # KLUDGE: these two logically belong in the previous section
160 # ("architecture-dependent"); it seems silly to enforce this in terms
161 # of the shell script, though. -- CSR, 2002-02-03
162 link_or_copy
$sbcl_arch-arch.h target-arch.h
163 link_or_copy
$sbcl_arch-lispregs.h target-lispregs.h
166 printf ' :unix' >> $ltf
167 printf ' :elf' >> $ltf
168 printf ' :linux' >> $ltf
170 # If you add other platforms here, don't forget to edit
171 # src/runtime/Config.foo-linux too.
174 printf ' :largefile' >> $ltf
177 printf ' :sb-thread :largefile' >> $ltf
181 if [ $sbcl_arch = "x86-64" ]; then
182 link_or_copy Config.x86_64-linux Config
184 link_or_copy Config.
$sbcl_arch-linux Config
186 link_or_copy
$sbcl_arch-linux-os.h target-arch-os.h
187 link_or_copy linux-os.h target-os.h
190 printf ' :unix' >> $ltf
191 printf ' :elf' >> $ltf
192 printf ' :osf1' >> $ltf
193 link_or_copy Config.
$sbcl_arch-osf1 Config
194 link_or_copy
$sbcl_arch-osf1-os.h target-arch-os.h
195 link_or_copy osf1-os.h target-os.h
198 printf ' :unix' >> $ltf
199 printf ' :elf' >> $ltf
200 printf ' :hpux' >> $ltf
201 link_or_copy Config.
$sbcl_arch-hpux Config
202 link_or_copy
$sbcl_arch-hpux-os.h target-arch-os.h
203 link_or_copy hpux-os.h target-os.h
206 printf ' :unix' >> $ltf
207 printf ' :bsd' >> $ltf
208 link_or_copy
$sbcl_arch-bsd-os.h target-arch-os.h
209 link_or_copy bsd-os.h target-os.h
212 printf ' :elf' >> $ltf
213 printf ' :freebsd' >> $ltf
214 printf ' :gcc-tls' >> $ltf
215 if [ $sbcl_arch = "x86" ]; then
216 printf ' :restore-tls-segment-register-from-context' >> $ltf
218 link_or_copy Config.
$sbcl_arch-freebsd Config
221 printf ' :elf' >> $ltf
222 printf ' :openbsd' >> $ltf
223 link_or_copy Config.
$sbcl_arch-openbsd Config
226 printf ' :netbsd' >> $ltf
227 printf ' :elf' >> $ltf
228 link_or_copy Config.
$sbcl_arch-netbsd Config
231 echo unsupported BSD variant
: `uname`
237 printf ' :unix' >> $ltf
238 printf ' :mach-o' >> $ltf
239 printf ' :bsd' >> $ltf
240 printf ' :darwin' >> $ltf
241 if [ $sbcl_arch = "x86" ]; then
242 printf ' :mach-exception-handler :sb-lutex :restore-fs-segment-register-from-tls :ud2-breakpoints' >> $ltf
244 if [ $sbcl_arch = "x86-64" ]; then
245 printf ' :mach-exception-handler :sb-lutex :ud2-breakpoints' >> $ltf
247 link_or_copy
$sbcl_arch-darwin-os.h target-arch-os.h
248 link_or_copy bsd-os.h target-os.h
249 link_or_copy Config.
$sbcl_arch-darwin Config
252 printf ' :unix' >> $ltf
253 printf ' :elf' >> $ltf
254 printf ' :sunos' >> $ltf
255 if [ $sbcl_arch = "x86" ] ||
[ $sbcl_arch = "amd64" ]; then
256 printf ' :sb-lutex' >> $ltf
258 link_or_copy Config.
$sbcl_arch-sunos Config
259 link_or_copy
$sbcl_arch-sunos-os.h target-arch-os.h
260 link_or_copy sunos-os.h target-os.h
263 printf ' :win32' >> $ltf
264 link_or_copy Config.
$sbcl_arch-win32 Config
265 link_or_copy
$sbcl_arch-win32-os.h target-arch-os.h
266 link_or_copy win32-os.h target-os.h
269 echo unsupported OS
type: `uname`
275 # FIXME: Things like :c-stack-grows-..., etc, should be
276 # *derived-target-features* or equivalent, so that there was a nicer
277 # way to specify them then sprinkling them in this file. They should
278 # still be tweakable by advanced users, though, but probably not
279 # appear in *features* of target. #!+/- should be adjusted to take
280 # them in account as well. At minimum the nicer specification stuff,
283 # (define-feature :dlopen (features)
284 # (union '(:bsd :linux :darwin :sunos) features))
286 # (define-feature :c-stack-grows-downwards-not-upwards (features)
287 # (member :x86 features))
289 # KLUDGE: currently the x86 only works with the generational garbage
290 # collector (indicated by the presence of :GENCGC in *FEATURES*) and
291 # alpha, sparc and ppc with the stop'n'copy collector (indicated by
292 # the absence of :GENCGC in *FEATURES*). This isn't a great
293 # separation, but for now, rather than have :GENCGC in
294 # base-target-features.lisp-expr, we add it into local-target-features
295 # if we're building for x86. -- CSR, 2002-02-21 Then we do something
296 # similar with :STACK-GROWS-FOOWARD, too. -- WHN 2002-03-03
297 if [ "$sbcl_arch" = "x86" ]; then
298 printf ' :gencgc :stack-grows-downward-not-upward :c-stack-is-control-stack' >> $ltf
299 printf ' :compare-and-swap-vops :unwind-to-frame-and-call-vop :raw-instance-init-vops' >> $ltf
300 printf ' :stack-allocatable-closures :stack-allocatable-vectors' >> $ltf
301 printf ' :stack-allocatable-lists :stack-allocatable-fixed-objects' >> $ltf
302 printf ' :alien-callbacks :cycle-counter :inline-constants ' >> $ltf
303 printf ' :memory-barrier-vops' >> $ltf
305 linux | freebsd | netbsd | openbsd | sunos | darwin | win32
)
306 printf ' :linkage-table' >> $ltf
308 if [ "$sbcl_os" = "win32" ]; then
309 # of course it doesn't provide dlopen, but there is
310 # roughly-equivalent magic nevertheless.
311 printf ' :os-provides-dlopen' >> $ltf
313 elif [ "$sbcl_arch" = "x86-64" ]; then
314 printf ' :gencgc :stack-grows-downward-not-upward :c-stack-is-control-stack :linkage-table' >> $ltf
315 printf ' :compare-and-swap-vops :unwind-to-frame-and-call-vop :raw-instance-init-vops' >> $ltf
316 printf ' :stack-allocatable-closures :stack-allocatable-vectors' >> $ltf
317 printf ' :stack-allocatable-lists :stack-allocatable-fixed-objects' >> $ltf
318 printf ' :alien-callbacks :cycle-counter :complex-float-vops' >> $ltf
319 printf ' :float-eql-vops :inline-constants :memory-barrier-vops' >> $ltf
320 elif [ "$sbcl_arch" = "mips" ]; then
321 printf ' :linkage-table' >> $ltf
322 printf ' :stack-allocatable-closures :stack-allocatable-vectors' >> $ltf
323 printf ' :stack-allocatable-lists :stack-allocatable-fixed-objects' >> $ltf
324 printf ' :alien-callbacks' >> $ltf
325 # Use a little C program to try to guess the endianness. Ware
328 # FIXME: integrate to grovel-features, mayhaps
329 $GNUMAKE -C tools-for-build determine-endianness
-I ..
/src
/runtime
330 tools-for-build
/determine-endianness
>> $ltf
331 elif [ "$sbcl_arch" = "ppc" ]; then
332 printf ' :gencgc :stack-allocatable-closures :stack-allocatable-lists' >> $ltf
333 printf ' :linkage-table :raw-instance-init-vops :memory-barrier-vops' >> $ltf
334 printf ' :compare-and-swap-vops' >> $ltf
335 if [ "$sbcl_os" = "linux" ]; then
336 # Use a C program to detect which kind of glibc we're building on,
337 # to bandage across the break in source compatibility between
338 # versions 2.3.1 and 2.3.2
340 # FIXME: integrate to grovel-features, mayhaps
341 $GNUMAKE -C tools-for-build where-is-mcontext
-I ..
/src
/runtime
342 tools-for-build
/where-is-mcontext
> src
/runtime
/ppc-linux-mcontext.h ||
(echo "error running where-is-mcontext"; exit 1)
343 elif [ "$sbcl_os" = "darwin" ]; then
344 # We provide a dlopen shim, so a little lie won't hurt
345 printf " :os-provides-dlopen :alien-callbacks" >> $ltf
346 # The default stack ulimit under darwin is too small to run PURIFY.
347 # Best we can do is complain and exit at this stage
348 if [ "`ulimit -s`" = "512" ]; then
349 echo "Your stack size limit is too small to build SBCL."
350 echo "See the limit(1) or ulimit(1) commands and the README file."
354 elif [ "$sbcl_arch" = "sparc" ]; then
355 # Test the compiler in order to see if we are building on Sun
356 # toolchain as opposed to GNU binutils, and write the appropriate
357 # FUNCDEF macro for assembler. No harm in running this on sparc-linux
359 sh tools-for-build
/sparc-funcdef.sh
> src
/runtime
/sparc-funcdef.h
360 if [ "$sbcl_os" = "sunos" ] ||
[ "$sbcl_os" = "linux" ]; then
361 printf ' :linkage-table' >> $ltf
363 printf ' :stack-allocatable-closures :stack-allocatable-lists' >> $ltf
364 elif [ "$sbcl_arch" = "alpha" ]; then
365 printf ' :stack-allocatable-closures :stack-allocatable-lists' >> $ltf
366 elif [ "$sbcl_arch" = "hppa" ]; then
367 printf ' :stack-allocatable-vectors :stack-allocatable-fixed-objects' >> $ltf
368 printf ' :stack-allocatable-lists' >> $ltf
370 # Nothing need be done in this case, but sh syntax wants a placeholder.
374 export sbcl_os sbcl_arch
375 sh tools-for-build
/grovel-features.sh
>> $ltf
377 echo //finishing
$ltf
380 # FIXME: The version system should probably be redone along these lines:
382 # echo //setting up version information.
383 # versionfile=version.txt
384 # cp base-version.txt $versionfile
385 # echo " (built `date -u` by `whoami`@`hostname`)" >> $versionfile
386 # echo 'This is a machine-generated file and should not be edited by hand.' >> $versionfile
388 # Make a unique ID for this build (to discourage people from
389 # mismatching sbcl and *.core files).
390 if [ `uname` = "SunOS" ] ; then
391 # use /usr/xpg4/bin/id instead of /usr/bin/id
392 PATH
=/usr
/xpg
4/bin
:$PATH
394 echo '"'`hostname`-`id -un`-`date +%Y-%m-%d-%H-%M-%S`'"' > output
/build-id.tmp