0.8.8.23:
[sbcl/lichteblau.git] / make-config.sh
blobff693d1e2abb4439125307a98eb38509c173f1b7
1 #!/bin/sh
3 # The make-config.sh script uses information about the target machine
4 # to set things up for compilation. It's vaguely like a stripped-down
5 # version of autoconf. It's intended to be run as part of make.sh. The
6 # only time you'd want to run it by itself is if you're trying to
7 # cross-compile the system or if you're doing some kind of
8 # troubleshooting.
10 # This software is part of the SBCL system. See the README file for
11 # more information.
13 # This software is derived from the CMU CL system, which was
14 # written at Carnegie Mellon University and released into the
15 # public domain. The software is in the public domain and is
16 # provided with absolutely no warranty. See the COPYING and CREDITS
17 # files for more information.
19 echo //entering make-config.sh
21 echo //ensuring the existence of output/ directory
22 if [ ! -d output ] ; then mkdir output; fi
24 ltf=`pwd`/local-target-features.lisp-expr
25 echo //initializing $ltf
26 echo ';;;; This is a machine-generated file.' > $ltf
27 echo ';;;; Please do not edit it by hand.' >> $ltf
28 echo ';;;; See make-config.sh.' >> $ltf
29 printf '(' >> $ltf
31 echo //guessing default target CPU architecture from host architecture
32 case `uname -m` in
33 *86|x86_64) guessed_sbcl_arch=x86 ;;
34 [Aa]lpha) guessed_sbcl_arch=alpha ;;
35 sparc*) guessed_sbcl_arch=sparc ;;
36 sun*) guessed_sbcl_arch=sparc ;;
37 ppc) guessed_sbcl_arch=ppc ;;
38 Power*Macintosh) guessed_sbcl_arch=ppc ;;
39 parisc) guessed_sbcl_arch=hppa ;;
40 mips) guessed_sbcl_arch=mips ;;
42 # If we're not building on a supported target architecture, we
43 # we have no guess, but it's not an error yet, since maybe
44 # target architecture will be specified explicitly below.
45 guessed_sbcl_arch=''
47 esac
49 echo //setting up CPU-architecture-dependent information
50 sbcl_arch=${SBCL_ARCH:-$guessed_sbcl_arch}
51 echo sbcl_arch=\"$sbcl_arch\"
52 if [ "$sbcl_arch" = "" ] ; then
53 echo "can't guess target SBCL architecture, need SBCL_ARCH environment var"
54 exit 1
56 printf ":%s" "$sbcl_arch" >> $ltf
58 for d in src/compiler src/assembly; do
59 echo //setting up symlink $d/target
60 original_dir=`pwd`
61 cd $d
62 if [ -h target ] ; then
63 rm target
64 elif [ -w target ] ; then
65 echo "I'm afraid to replace non-symlink $d/target with a symlink."
66 exit 1
68 if [ -d $sbcl_arch ] ; then
69 ln -s $sbcl_arch target
70 else
71 echo "missing sbcl_arch directory $PWD/$sbcl_arch"
72 exit 1
74 cd $original_dir
75 done
77 echo //setting up symlink src/compiler/assembly
78 if [ -h src/compiler/assembly ] ; then
79 rm src/compiler/assembly
80 elif [ -w src/compiler/assembly ] ; then
81 echo "I'm afraid to replace non-symlink compiler/assembly with a symlink."
82 exit 1
84 ln -s ../assembly src/compiler/assembly
86 echo //setting up OS-dependent information
87 original_dir=`pwd`
88 cd src/runtime/
89 rm -f Config target-arch-os.h target-arch.h target-os.h target-lispregs.h
90 # KLUDGE: these two logically belong in the previous section
91 # ("architecture-dependent"); it seems silly to enforce this in terms
92 # of the shell script, though. -- CSR, 2002-02-03
93 ln -s $sbcl_arch-arch.h target-arch.h
94 ln -s $sbcl_arch-lispregs.h target-lispregs.h
95 case `uname` in
96 Linux)
97 printf ' :linux' >> $ltf
98 sbcl_os="linux"
99 if [ "`uname -m`" = "x86_64" ]; then
100 ln -s Config.x86_64-linux Config
101 else
102 ln -s Config.$sbcl_arch-linux Config
104 ln -s $sbcl_arch-linux-os.h target-arch-os.h
105 ln -s linux-os.h target-os.h
107 OSF1)
108 # it's changed name twice since it was called OSF/1: clearly
109 # the marketers forgot to tell the engineers about Digital Unix
110 # _or_ OSF/1 ...
111 printf ' :osf1' >> $ltf
112 sbcl_os="osf1"
113 ln -s Config.$sbcl_arch-osf1 Config
114 ln -s $sbcl_arch-osf1-os.h target-arch-os.h
115 ln -s osf1-os.h target-os.h
117 *BSD)
118 printf ' :bsd' >> $ltf
119 ln -s $sbcl_arch-bsd-os.h target-arch-os.h
120 ln -s bsd-os.h target-os.h
121 case `uname` in
122 FreeBSD)
123 printf ' :freebsd' >> $ltf
124 sbcl_os="freebsd"
125 ln -s Config.$sbcl_arch-freebsd Config
127 OpenBSD)
128 printf ' :openbsd' >> $ltf
129 sbcl_os="openbsd"
130 ln -s Config.$sbcl_arch-openbsd Config
133 echo unsupported BSD variant: `uname`
134 exit 1
136 esac
138 Darwin)
139 printf ' :bsd' >> $ltf
140 sbcl_os="darwin"
141 ln -s $sbcl_arch-darwin-os.h target-arch-os.h
142 ln -s bsd-os.h target-os.h
143 printf ' :darwin' >> $ltf
144 ln -s Config.$sbcl_arch-darwin Config
146 SunOS)
147 printf ' :sunos' >> $ltf
148 sbcl_os="sunos"
149 ln -s Config.$sbcl_arch-sunos Config
150 ln -s $sbcl_arch-sunos-os.h target-arch-os.h
151 ln -s sunos-os.h target-os.h
154 echo unsupported OS type: `uname`
155 exit 1
157 esac
158 cd $original_dir
160 # KLUDGE: currently the x86 only works with the generational garbage
161 # collector (indicated by the presence of :GENCGC in *FEATURES*) and
162 # alpha, sparc and ppc with the stop'n'copy collector (indicated by
163 # the absence of :GENCGC in *FEATURES*). This isn't a great
164 # separation, but for now, rather than have :GENCGC in
165 # base-target-features.lisp-expr, we add it into local-target-features
166 # if we're building for x86. -- CSR, 2002-02-21 Then we do something
167 # similar with :STACK-GROWS-FOOWARD, too. -- WHN 2002-03-03
168 if [ "$sbcl_arch" = "x86" ] ; then
169 printf ' :gencgc :stack-grows-downward-not-upward :c-stack-is-control-stack' >> $ltf
170 elif [ "$sbcl_arch" = "mips" ] ; then
171 # Use a little C program to try to guess the endianness. Ware
172 # cross-compilers!
173 $GNUMAKE -C tools-for-build determine-endianness
174 tools-for-build/determine-endianness >> $ltf
175 elif [ "$sbcl_arch" = "ppc" -a "$sbcl_os" = "linux" ]; then
176 # Use a C program to detect which kind of glibc we're building on,
177 # to bandage across the break in source compatibility between
178 # versions 2.3.1 and 2.3.2
179 $GNUMAKE -C tools-for-build where-is-mcontext
180 tools-for-build/where-is-mcontext > src/runtime/ppc-linux-mcontext.h
181 elif [ "$sbcl_arch" = "ppc" -a "$sbcl_os" = "darwin" ]; then
182 # The default stack ulimit under darwin is too small to run PURIFY.
183 # Best we can do is complain and exit at this stage
184 if [ "`ulimit -s`" = "512" ]; then
185 echo "Your stack size limit is too small to build SBCL."
186 echo "See the limit(1) or ulimit(1) commands and the README file."
187 exit 1
189 elif [ "$sbcl_arch" = "sparc" ]; then
190 # Test the compiler in order to see if we are building on Sun
191 # toolchain as opposed to GNU binutils, and write the appropriate
192 # FUNCDEF macro for assembler. No harm in running this on sparc-linux
193 # as well.
194 sh tools-for-build/sparc-funcdef.sh > src/runtime/sparc-funcdef.h
195 else
196 # Nothing need be done in this case, but sh syntax wants a placeholder.
197 echo > /dev/null
200 echo //finishing $ltf
201 echo ')' >> $ltf
203 # FIXME: The version system should probably be redone along these lines:
205 # echo //setting up version information.
206 # versionfile=version.txt
207 # cp base-version.txt $versionfile
208 # echo " (built `date -u` by `whoami`@`hostname`)" >> $versionfile
209 # echo 'This is a machine-generated file and should not be edited by hand.' >> $versionfile
211 # Make a unique ID for this build (to discourage people from
212 # mismatching sbcl and *.core files).
213 echo '"'`hostname`-`whoami`-`date +%F-%H-%M-%S`'"' > output/build-id.tmp