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
*)
57 echo unsupported OS
type: `uname`
63 if [ "$sbcl_os" = "win32" ] ; then
71 if [ "$sbcl_os" = "win32" ] ; then
74 elif [ -e "$1" ] ; then
75 echo "I'm afraid to remove non-directory $1."
81 elif [ -w "$1" ] ; then
82 echo "I'm afraid to replace non-symlink $1 with a symlink."
88 echo //entering make-config.sh
90 echo //ensuring the existence of output
/ directory
91 if [ ! -d output
] ; then mkdir output
; fi
93 ltf
=`pwd`/local-target-features.lisp-expr
94 echo //initializing
$ltf
95 echo ';;;; This is a machine-generated file.' > $ltf
96 echo ';;;; Please do not edit it by hand.' >> $ltf
97 echo ';;;; See make-config.sh.' >> $ltf
100 echo //guessing default target CPU architecture from
host architecture
102 *86) guessed_sbcl_arch
=x86
;;
103 i86pc
) guessed_sbcl_arch
=x86
;;
104 *x86_64
) guessed_sbcl_arch
=x86-64
;;
105 amd64
) guessed_sbcl_arch
=x86-64
;;
106 [Aa
]lpha
) guessed_sbcl_arch
=alpha
;;
107 sparc
*) guessed_sbcl_arch
=sparc
;;
108 sun
*) guessed_sbcl_arch
=sparc
;;
109 *ppc
) guessed_sbcl_arch
=ppc
;;
110 ppc64
) guessed_sbcl_arch
=ppc
;;
111 Power
*Macintosh
) guessed_sbcl_arch
=ppc
;;
112 parisc
) guessed_sbcl_arch
=hppa
;;
113 mips
*) guessed_sbcl_arch
=mips
;;
115 # If we're not building on a supported target architecture, we
116 # we have no guess, but it's not an error yet, since maybe
117 # target architecture will be specified explicitly below.
122 echo //setting up CPU-architecture-dependent information
123 sbcl_arch
=${SBCL_ARCH:-$guessed_sbcl_arch}
124 echo sbcl_arch
=\"$sbcl_arch\"
125 if [ "$sbcl_arch" = "" ] ; then
126 echo "can't guess target SBCL architecture, need SBCL_ARCH environment var"
129 printf ":%s" "$sbcl_arch" >> $ltf
131 for d
in src
/compiler src
/assembly
; do
132 echo //setting up symlink
$d/target
134 remove_dir_safely
"$d/target"
136 if [ -d $sbcl_arch ] ; then
137 link_or_copy
$sbcl_arch target
139 echo "missing sbcl_arch directory $PWD/$sbcl_arch"
145 echo //setting up symlink src
/compiler
/assembly
146 remove_dir_safely src
/compiler
/assembly
149 link_or_copy ..
/assembly assembly
152 echo //setting up OS-dependent information
155 rm -f Config target-arch-os.h target-arch.h target-os.h target-lispregs.h
156 # KLUDGE: these two logically belong in the previous section
157 # ("architecture-dependent"); it seems silly to enforce this in terms
158 # of the shell script, though. -- CSR, 2002-02-03
159 link_or_copy
$sbcl_arch-arch.h target-arch.h
160 link_or_copy
$sbcl_arch-lispregs.h target-lispregs.h
163 printf ' :elf' >> $ltf
164 printf ' :linux' >> $ltf
166 # If you add other platforms here, don't forget to edit
167 # src/runtime/Config.foo-linux too.
168 if [ $sbcl_arch = "x86" ]; then
169 printf ' :largefile' >> $ltf
172 if [ $sbcl_arch = "x86-64" ]; then
173 link_or_copy Config.x86_64-linux Config
175 link_or_copy Config.
$sbcl_arch-linux Config
177 link_or_copy
$sbcl_arch-linux-os.h target-arch-os.h
178 link_or_copy linux-os.h target-os.h
181 printf ' :elf' >> $ltf
182 printf ' :osf1' >> $ltf
183 link_or_copy Config.
$sbcl_arch-osf1 Config
184 link_or_copy
$sbcl_arch-osf1-os.h target-arch-os.h
185 link_or_copy osf1-os.h target-os.h
188 printf ' :bsd' >> $ltf
189 link_or_copy
$sbcl_arch-bsd-os.h target-arch-os.h
190 link_or_copy bsd-os.h target-os.h
193 printf ' :elf' >> $ltf
194 printf ' :freebsd' >> $ltf
195 printf ' :sb-pthread-futex' >> $ltf
196 if [ $sbcl_arch = "x86" ]; then
197 printf ' :restore-tls-segment-register-from-tls' >> $ltf
199 link_or_copy Config.
$sbcl_arch-freebsd Config
202 printf ' :elf' >> $ltf
203 printf ' :openbsd' >> $ltf
204 link_or_copy Config.
$sbcl_arch-openbsd Config
207 printf ' :netbsd' >> $ltf
208 printf ' :elf' >> $ltf
209 link_or_copy Config.
$sbcl_arch-netbsd Config
212 echo unsupported BSD variant
: `uname`
218 printf ' :mach-o' >> $ltf
219 printf ' :bsd' >> $ltf
220 printf ' :darwin' >> $ltf
221 if [ $sbcl_arch = "x86" ]; then
222 printf ' :mach-exception-handler :sb-lutex :restore-fs-segment-register-from-tls' >> $ltf
224 if [ $sbcl_arch = "x86-64" ]; then
225 printf ' :mach-exception-handler :sb-lutex' >> $ltf
227 link_or_copy
$sbcl_arch-darwin-os.h target-arch-os.h
228 link_or_copy bsd-os.h target-os.h
229 link_or_copy Config.
$sbcl_arch-darwin Config
232 printf ' :elf' >> $ltf
233 printf ' :sunos' >> $ltf
234 if [ $sbcl_arch = "x86" ]; then
235 printf ' :sb-lutex' >> $ltf
237 link_or_copy Config.
$sbcl_arch-sunos Config
238 link_or_copy
$sbcl_arch-sunos-os.h target-arch-os.h
239 link_or_copy sunos-os.h target-os.h
242 printf ' :win32' >> $ltf
243 link_or_copy Config.
$sbcl_arch-win32 Config
244 link_or_copy
$sbcl_arch-win32-os.h target-arch-os.h
245 link_or_copy win32-os.h target-os.h
248 echo unsupported OS
type: `uname`
254 # FIXME: Things like :c-stack-grows-..., etc, should be
255 # *derived-target-features* or equivalent, so that there was a nicer
256 # way to specify them then sprinkling them in this file. They should
257 # still be tweakable by advanced users, though, but probably not
258 # appear in *features* of target. #!+/- should be adjusted to take
259 # them in account as well. At minimum the nicer specification stuff,
262 # (define-feature :dlopen (features)
263 # (union '(:bsd :linux :darwin :sunos) features))
265 # (define-feature :c-stack-grows-downwards-not-upwards (features)
266 # (member :x86 features))
268 # KLUDGE: currently the x86 only works with the generational garbage
269 # collector (indicated by the presence of :GENCGC in *FEATURES*) and
270 # alpha, sparc and ppc with the stop'n'copy collector (indicated by
271 # the absence of :GENCGC in *FEATURES*). This isn't a great
272 # separation, but for now, rather than have :GENCGC in
273 # base-target-features.lisp-expr, we add it into local-target-features
274 # if we're building for x86. -- CSR, 2002-02-21 Then we do something
275 # similar with :STACK-GROWS-FOOWARD, too. -- WHN 2002-03-03
276 if [ "$sbcl_arch" = "x86" ]; then
277 printf ' :gencgc :stack-grows-downward-not-upward :c-stack-is-control-stack' >> $ltf
278 printf ' :stack-allocatable-closures :alien-callbacks' >> $ltf
279 if [ "$sbcl_os" = "linux" ] ||
[ "$sbcl_os" = "freebsd" ] ||
[ "$sbcl_os" = "netbsd" ] ||
[ "$sbcl_os" = "sunos" ] ||
[ "$sbcl_os" = "darwin" ] ||
[ "$sbcl_os" = "win32" ]; then
280 printf ' :linkage-table' >> $ltf
282 if [ "$sbcl_os" = "win32" ]; then
283 # of course it doesn't provide dlopen, but there is
284 # roughly-equivalent magic nevertheless.
285 printf ' :os-provides-dlopen' >> $ltf
287 elif [ "$sbcl_arch" = "x86-64" ]; then
288 printf ' :gencgc :stack-grows-downward-not-upward :c-stack-is-control-stack :linkage-table' >> $ltf
289 printf ' :stack-allocatable-closures :alien-callbacks' >> $ltf
290 elif [ "$sbcl_arch" = "mips" ]; then
291 printf ' :linkage-table' >> $ltf
292 printf ' :stack-allocatable-closures' >> $ltf
293 # Use a little C program to try to guess the endianness. Ware
296 # FIXME: integrate to grovel-features, mayhaps
297 $GNUMAKE -C tools-for-build determine-endianness
-I ..
/src
/runtime
298 tools-for-build
/determine-endianness
>> $ltf
299 elif [ "$sbcl_arch" = "ppc" -a "$sbcl_os" = "linux" ]; then
300 # Use a C program to detect which kind of glibc we're building on,
301 # to bandage across the break in source compatibility between
302 # versions 2.3.1 and 2.3.2
304 # FIXME: integrate to grovel-features., maypahps
305 printf ' :gencgc :stack-allocatable-closures :linkage-table' >> $ltf
306 $GNUMAKE -C tools-for-build where-is-mcontext
-I ..
/src
/runtime
307 tools-for-build
/where-is-mcontext
> src
/runtime
/ppc-linux-mcontext.h ||
(echo "error running where-is-mcontext"; exit 1)
308 elif [ "$sbcl_arch" = "ppc" -a "$sbcl_os" = "darwin" ]; then
309 printf ' :gencgc :stack-allocatable-closures' >> $ltf
310 # We provide a dlopen shim, so a little lie won't hurt
311 printf " :os-provides-dlopen :linkage-table :alien-callbacks" >> $ltf
312 # The default stack ulimit under darwin is too small to run PURIFY.
313 # Best we can do is complain and exit at this stage
314 if [ "`ulimit -s`" = "512" ]; then
315 echo "Your stack size limit is too small to build SBCL."
316 echo "See the limit(1) or ulimit(1) commands and the README file."
319 elif [ "$sbcl_arch" = "ppc" -a "$sbcl_os" = "netbsd" ]; then
320 printf ' :gencgc :stack-allocatable-closures :linkage-table' >> $ltf
321 elif [ "$sbcl_arch" = "sparc" ]; then
322 # Test the compiler in order to see if we are building on Sun
323 # toolchain as opposed to GNU binutils, and write the appropriate
324 # FUNCDEF macro for assembler. No harm in running this on sparc-linux
326 sh tools-for-build
/sparc-funcdef.sh
> src
/runtime
/sparc-funcdef.h
327 if [ "$sbcl_os" = "sunos" ] ||
[ "$sbcl_os" = "linux" ]; then
328 printf ' :linkage-table' >> $ltf
330 printf ' :stack-allocatable-closures' >> $ltf
331 elif [ "$sbcl_arch" = "alpha" ]; then
332 printf ' :stack-allocatable-closures' >> $ltf
334 # Nothing need be done in this case, but sh syntax wants a placeholder.
338 export sbcl_os sbcl_arch
339 sh tools-for-build
/grovel-features.sh
>> $ltf
341 echo //finishing
$ltf
344 # FIXME: The version system should probably be redone along these lines:
346 # echo //setting up version information.
347 # versionfile=version.txt
348 # cp base-version.txt $versionfile
349 # echo " (built `date -u` by `whoami`@`hostname`)" >> $versionfile
350 # echo 'This is a machine-generated file and should not be edited by hand.' >> $versionfile
352 # Make a unique ID for this build (to discourage people from
353 # mismatching sbcl and *.core files).
354 if [ `uname` = "SunOS" ] ; then
355 # use /usr/xpg4/bin/id instead of /usr/bin/id
356 PATH
=/usr
/xpg
4/bin
:$PATH
358 echo '"'`hostname`-`id -un`-`date +%Y-%m-%d-%H-%M-%S`'"' > output
/build-id.tmp