1.0.26.1: Modify uploading instructions in release checklist
[sbcl/nikodemus.git] / make-config.sh
blob2a70efe8e502af3f426c4dcbfa39f80c1c4b91d9
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 case `uname` in
21 Linux)
22 sbcl_os="linux"
24 OSF1)
25 # it's changed name twice since it was called OSF/1: clearly
26 # the marketers forgot to tell the engineers about Digital Unix
27 # _or_ OSF/1 ...
28 sbcl_os="osf1"
30 *BSD)
31 case `uname` in
32 FreeBSD)
33 sbcl_os="freebsd"
35 OpenBSD)
36 sbcl_os="openbsd"
38 NetBSD)
39 sbcl_os="netbsd"
42 echo unsupported BSD variant: `uname`
43 exit 1
45 esac
47 Darwin)
48 sbcl_os="darwin"
50 SunOS)
51 sbcl_os="sunos"
53 CYGWIN* | WindowsNT | MINGW*)
54 sbcl_os="win32"
56 HP-UX)
57 sbcl_os="hpux"
60 echo unsupported OS type: `uname`
61 exit 1
63 esac
65 link_or_copy() {
66 if [ "$sbcl_os" = "win32" ] ; then
67 cp -r "$1" "$2"
68 else
69 ln -s "$1" "$2"
73 remove_dir_safely() {
74 if [ "$sbcl_os" = "win32" ] ; then
75 if [ -d "$1" ] ; then
76 rm -rf "$1"
77 elif [ -e "$1" ] ; then
78 echo "I'm afraid to remove non-directory $1."
79 exit 1
81 else
82 if [ -h "$1" ] ; then
83 rm "$1"
84 elif [ -w "$1" ] ; then
85 echo "I'm afraid to replace non-symlink $1 with a symlink."
86 exit 1
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
101 printf '(' >> $ltf
103 echo //guessing default target CPU architecture from host architecture
104 case `uname -m` in
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.
122 guessed_sbcl_arch=''
124 esac
126 echo //setting up CPU-architecture-dependent information
127 sbcl_arch=${SBCL_ARCH:-$guessed_sbcl_arch}
128 echo sbcl_arch=\"$sbcl_arch\"
129 if [ "$sbcl_arch" = "" ] ; then
130 echo "can't guess target SBCL architecture, need SBCL_ARCH environment var"
131 exit 1
133 printf ":%s" "$sbcl_arch" >> $ltf
135 for d in src/compiler src/assembly; do
136 echo //setting up symlink $d/target
137 original_dir=`pwd`
138 remove_dir_safely "$d/target"
139 cd ./$d
140 if [ -d $sbcl_arch ] ; then
141 link_or_copy $sbcl_arch target
142 else
143 echo "missing sbcl_arch directory $PWD/$sbcl_arch"
144 exit 1
146 cd "$original_dir"
147 done
149 echo //setting up symlink src/compiler/assembly
150 remove_dir_safely src/compiler/assembly
151 original_dir=`pwd`
152 cd src/compiler
153 link_or_copy ../assembly assembly
154 cd "$original_dir"
156 echo //setting up OS-dependent information
157 original_dir=`pwd`
158 cd ./src/runtime/
159 rm -f Config target-arch-os.h target-arch.h target-os.h target-lispregs.h
160 # KLUDGE: these two logically belong in the previous section
161 # ("architecture-dependent"); it seems silly to enforce this in terms
162 # of the shell script, though. -- CSR, 2002-02-03
163 link_or_copy $sbcl_arch-arch.h target-arch.h
164 link_or_copy $sbcl_arch-lispregs.h target-lispregs.h
165 case "$sbcl_os" in
166 linux)
167 printf ' :unix' >> $ltf
168 printf ' :elf' >> $ltf
169 printf ' :linux' >> $ltf
171 # If you add other platforms here, don't forget to edit
172 # src/runtime/Config.foo-linux too.
173 case "$sbcl_arch" in
174 x86 | mips)
175 printf ' :largefile' >> $ltf
177 esac
179 if [ $sbcl_arch = "x86-64" ]; then
180 link_or_copy Config.x86_64-linux Config
181 else
182 link_or_copy Config.$sbcl_arch-linux Config
184 link_or_copy $sbcl_arch-linux-os.h target-arch-os.h
185 link_or_copy linux-os.h target-os.h
187 osf1)
188 printf ' :unix' >> $ltf
189 printf ' :elf' >> $ltf
190 printf ' :osf1' >> $ltf
191 link_or_copy Config.$sbcl_arch-osf1 Config
192 link_or_copy $sbcl_arch-osf1-os.h target-arch-os.h
193 link_or_copy osf1-os.h target-os.h
195 hpux)
196 printf ' :unix' >> $ltf
197 printf ' :elf' >> $ltf
198 printf ' :hpux' >> $ltf
199 link_or_copy Config.$sbcl_arch-hpux Config
200 link_or_copy $sbcl_arch-hpux-os.h target-arch-os.h
201 link_or_copy hpux-os.h target-os.h
203 *bsd)
204 printf ' :unix' >> $ltf
205 printf ' :bsd' >> $ltf
206 link_or_copy $sbcl_arch-bsd-os.h target-arch-os.h
207 link_or_copy bsd-os.h target-os.h
208 case "$sbcl_os" in
209 freebsd)
210 printf ' :elf' >> $ltf
211 printf ' :freebsd' >> $ltf
212 printf ' :gcc-tls' >> $ltf
213 if [ $sbcl_arch = "x86" ]; then
214 printf ' :restore-tls-segment-register-from-context' >> $ltf
216 link_or_copy Config.$sbcl_arch-freebsd Config
218 openbsd)
219 printf ' :elf' >> $ltf
220 printf ' :openbsd' >> $ltf
221 link_or_copy Config.$sbcl_arch-openbsd Config
223 netbsd)
224 printf ' :netbsd' >> $ltf
225 printf ' :elf' >> $ltf
226 link_or_copy Config.$sbcl_arch-netbsd Config
229 echo unsupported BSD variant: `uname`
230 exit 1
232 esac
234 darwin)
235 printf ' :unix' >> $ltf
236 printf ' :mach-o' >> $ltf
237 printf ' :bsd' >> $ltf
238 printf ' :darwin' >> $ltf
239 if [ $sbcl_arch = "x86" ]; then
240 printf ' :mach-exception-handler :sb-lutex :restore-fs-segment-register-from-tls' >> $ltf
242 if [ $sbcl_arch = "x86-64" ]; then
243 printf ' :mach-exception-handler :sb-lutex' >> $ltf
245 link_or_copy $sbcl_arch-darwin-os.h target-arch-os.h
246 link_or_copy bsd-os.h target-os.h
247 link_or_copy Config.$sbcl_arch-darwin Config
249 sunos)
250 printf ' :unix' >> $ltf
251 printf ' :elf' >> $ltf
252 printf ' :sunos' >> $ltf
253 if [ $sbcl_arch = "x86" ]; then
254 printf ' :sb-lutex' >> $ltf
256 link_or_copy Config.$sbcl_arch-sunos Config
257 link_or_copy $sbcl_arch-sunos-os.h target-arch-os.h
258 link_or_copy sunos-os.h target-os.h
260 win32)
261 printf ' :win32' >> $ltf
262 link_or_copy Config.$sbcl_arch-win32 Config
263 link_or_copy $sbcl_arch-win32-os.h target-arch-os.h
264 link_or_copy win32-os.h target-os.h
267 echo unsupported OS type: `uname`
268 exit 1
270 esac
271 cd "$original_dir"
273 # FIXME: Things like :c-stack-grows-..., etc, should be
274 # *derived-target-features* or equivalent, so that there was a nicer
275 # way to specify them then sprinkling them in this file. They should
276 # still be tweakable by advanced users, though, but probably not
277 # appear in *features* of target. #!+/- should be adjusted to take
278 # them in account as well. At minimum the nicer specification stuff,
279 # though:
281 # (define-feature :dlopen (features)
282 # (union '(:bsd :linux :darwin :sunos) features))
284 # (define-feature :c-stack-grows-downwards-not-upwards (features)
285 # (member :x86 features))
287 # KLUDGE: currently the x86 only works with the generational garbage
288 # collector (indicated by the presence of :GENCGC in *FEATURES*) and
289 # alpha, sparc and ppc with the stop'n'copy collector (indicated by
290 # the absence of :GENCGC in *FEATURES*). This isn't a great
291 # separation, but for now, rather than have :GENCGC in
292 # base-target-features.lisp-expr, we add it into local-target-features
293 # if we're building for x86. -- CSR, 2002-02-21 Then we do something
294 # similar with :STACK-GROWS-FOOWARD, too. -- WHN 2002-03-03
295 if [ "$sbcl_arch" = "x86" ]; then
296 printf ' :gencgc :stack-grows-downward-not-upward :c-stack-is-control-stack' >> $ltf
297 printf ' :compare-and-swap-vops :unwind-to-frame-and-call-vop :raw-instance-init-vops' >> $ltf
298 printf ' :stack-allocatable-closures :alien-callbacks :cycle-counter' >> $ltf
299 case "$sbcl_os" in
300 linux | freebsd | netbsd | openbsd | sunos | darwin | win32)
301 printf ' :linkage-table' >> $ltf
302 esac
303 if [ "$sbcl_os" = "win32" ]; then
304 # of course it doesn't provide dlopen, but there is
305 # roughly-equivalent magic nevertheless.
306 printf ' :os-provides-dlopen' >> $ltf
308 elif [ "$sbcl_arch" = "x86-64" ]; then
309 printf ' :gencgc :stack-grows-downward-not-upward :c-stack-is-control-stack :linkage-table' >> $ltf
310 printf ' :compare-and-swap-vops :unwind-to-frame-and-call-vop :raw-instance-init-vops' >> $ltf
311 printf ' :stack-allocatable-closures :alien-callbacks :cycle-counter' >> $ltf
312 elif [ "$sbcl_arch" = "mips" ]; then
313 printf ' :linkage-table' >> $ltf
314 printf ' :stack-allocatable-closures' >> $ltf
315 printf ' :alien-callbacks' >> $ltf
316 # Use a little C program to try to guess the endianness. Ware
317 # cross-compilers!
319 # FIXME: integrate to grovel-features, mayhaps
320 $GNUMAKE -C tools-for-build determine-endianness -I ../src/runtime
321 tools-for-build/determine-endianness >> $ltf
322 elif [ "$sbcl_arch" = "ppc" -a "$sbcl_os" = "linux" ]; then
323 # Use a C program to detect which kind of glibc we're building on,
324 # to bandage across the break in source compatibility between
325 # versions 2.3.1 and 2.3.2
327 # FIXME: integrate to grovel-features, mayhaps
328 printf ' :gencgc :stack-allocatable-closures :linkage-table' >> $ltf
329 $GNUMAKE -C tools-for-build where-is-mcontext -I ../src/runtime
330 tools-for-build/where-is-mcontext > src/runtime/ppc-linux-mcontext.h || (echo "error running where-is-mcontext"; exit 1)
331 elif [ "$sbcl_arch" = "ppc" -a "$sbcl_os" = "darwin" ]; then
332 printf ' :gencgc :stack-allocatable-closures' >> $ltf
333 # We provide a dlopen shim, so a little lie won't hurt
334 printf " :os-provides-dlopen :linkage-table :alien-callbacks" >> $ltf
335 # The default stack ulimit under darwin is too small to run PURIFY.
336 # Best we can do is complain and exit at this stage
337 if [ "`ulimit -s`" = "512" ]; then
338 echo "Your stack size limit is too small to build SBCL."
339 echo "See the limit(1) or ulimit(1) commands and the README file."
340 exit 1
342 elif [ "$sbcl_arch" = "ppc" -a "$sbcl_os" = "netbsd" ]; then
343 printf ' :gencgc :stack-allocatable-closures :linkage-table' >> $ltf
344 elif [ "$sbcl_arch" = "sparc" ]; then
345 # Test the compiler in order to see if we are building on Sun
346 # toolchain as opposed to GNU binutils, and write the appropriate
347 # FUNCDEF macro for assembler. No harm in running this on sparc-linux
348 # as well.
349 sh tools-for-build/sparc-funcdef.sh > src/runtime/sparc-funcdef.h
350 if [ "$sbcl_os" = "sunos" ] || [ "$sbcl_os" = "linux" ]; then
351 printf ' :linkage-table' >> $ltf
353 printf ' :stack-allocatable-closures' >> $ltf
354 elif [ "$sbcl_arch" = "alpha" ]; then
355 printf ' :stack-allocatable-closures' >> $ltf
356 else
357 # Nothing need be done in this case, but sh syntax wants a placeholder.
358 echo > /dev/null
361 export sbcl_os sbcl_arch
362 sh tools-for-build/grovel-features.sh >> $ltf
364 echo //finishing $ltf
365 echo ')' >> $ltf
367 # FIXME: The version system should probably be redone along these lines:
369 # echo //setting up version information.
370 # versionfile=version.txt
371 # cp base-version.txt $versionfile
372 # echo " (built `date -u` by `whoami`@`hostname`)" >> $versionfile
373 # echo 'This is a machine-generated file and should not be edited by hand.' >> $versionfile
375 # Make a unique ID for this build (to discourage people from
376 # mismatching sbcl and *.core files).
377 if [ `uname` = "SunOS" ] ; then
378 # use /usr/xpg4/bin/id instead of /usr/bin/id
379 PATH=/usr/xpg4/bin:$PATH
381 echo '"'`hostname`-`id -un`-`date +%Y-%m-%d-%H-%M-%S`'"' > output/build-id.tmp