0.7.10.3:
[sbcl/lichteblau.git] / make-config.sh
blob720cf141ca36941939f1672c1f930a5b6b26b99b
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) 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 parisc) guessed_sbcl_arch=hppa ;;
39 mips) guessed_sbcl_arch=mips ;;
41 # If we're not building on a supported target architecture, we
42 # we have no guess, but it's not an error yet, since maybe
43 # target architecture will be specified explicitly below.
44 guessed_sbcl_arch=''
46 esac
48 echo //setting up CPU-architecture-dependent information
49 sbcl_arch=${SBCL_ARCH:-$guessed_sbcl_arch}
50 echo sbcl_arch=\"$sbcl_arch\"
51 if [ "$sbcl_arch" = "" ] ; then
52 echo "can't guess target SBCL architecture, need SBCL_ARCH environment var"
53 exit 1
55 printf ":%s" "$sbcl_arch" >> $ltf
56 # KLUDGE: currently the x86 only works with the generational garbage
57 # collector (indicated by the presence of :GENCGC in *FEATURES*) and
58 # alpha, sparc and ppc with the stop'n'copy collector (indicated by
59 # the absence of :GENCGC in *FEATURES*). This isn't a great
60 # separation, but for now, rather than have :GENCGC in
61 # base-target-features.lisp-expr, we add it into local-target-features
62 # if we're building for x86. -- CSR, 2002-02-21 Then we do something
63 # similar with :STACK-GROWS-FOOWARD, too. -- WHN 2002-03-03
64 if [ "$sbcl_arch" = "x86" ] ; then
65 printf ' :gencgc :stack-grows-downward-not-upward :c-stack-is-control-stack' >> $ltf
66 elif [ "$sbcl_arch" = "mips" ] ; then
67 # Use a little C program to try to guess the endianness. Ware
68 # cross-compilers!
69 gnumake=${GNUMAKE:-gmake}
70 $gnumake -C tools-for-build determine-endianness
71 tools-for-build/determine-endianness >> $ltf
72 else
73 # Nothing need be done in this case, but sh syntax wants a placeholder.
74 echo > /dev/null
76 for d in src/compiler src/assembly; do
77 echo //setting up symlink $d/target
78 original_dir=`pwd`
79 cd $d
80 if [ -h target ] ; then
81 rm target
82 elif [ -w target ] ; then
83 echo "I'm afraid to replace non-symlink $d/target with a symlink."
84 exit 1
86 if [ -d $sbcl_arch ] ; then
87 ln -s $sbcl_arch target
88 else
89 echo "missing sbcl_arch directory $PWD/$sbcl_arch"
90 exit 1
92 cd $original_dir
93 done
95 echo //setting up OS-dependent information
96 original_dir=`pwd`
97 cd src/runtime/
98 rm -f Config target-arch-os.h target-arch.h target-os.h target-lispregs.h
99 # KLUDGE: these two logically belong in the previous section
100 # ("architecture-dependent"); it seems silly to enforce this in terms
101 # of the shell script, though. -- CSR, 2002-02-03
102 ln -s $sbcl_arch-arch.h target-arch.h
103 ln -s $sbcl_arch-lispregs.h target-lispregs.h
104 case `uname` in
105 Linux)
106 printf ' :linux' >> $ltf
107 ln -s Config.$sbcl_arch-linux Config
108 ln -s $sbcl_arch-linux-os.h target-arch-os.h
109 ln -s linux-os.h target-os.h
111 OSF1)
112 # it's changed name twice since it was called OSF/1: clearly
113 # the marketers forgot to tell the engineers about Digital Unix
114 # _or_ OSF/1 ...
115 printf ' :osf1' >> $ltf
116 ln -s Config.$sbcl_arch-osf1 Config
117 ln -s $sbcl_arch-osf1-os.h target-arch-os.h
118 ln -s osf1-os.h target-os.h
120 *BSD)
121 printf ' :bsd' >> $ltf
122 ln -s $sbcl_arch-bsd-os.h target-arch-os.h
123 ln -s bsd-os.h target-os.h
124 case `uname` in
125 FreeBSD)
126 printf ' :freebsd' >> $ltf
127 ln -s Config.$sbcl_arch-freebsd Config
129 OpenBSD)
130 printf ' :openbsd' >> $ltf
131 ln -s Config.$sbcl_arch-openbsd Config
134 echo unsupported BSD variant: `uname`
135 exit 1
137 esac
139 SunOS)
140 printf ' :sunos' >> $ltf
141 ln -s Config.$sbcl_arch-sunos Config
142 ln -s $sbcl_arch-sunos-os.h target-arch-os.h
143 ln -s sunos-os.h target-os.h
146 echo unsupported OS type: `uname`
147 exit 1
149 esac
150 cd $original_dir
152 echo //finishing $ltf
153 echo ')' >> $ltf
155 # FIXME: The version system should probably be redone along these lines:
157 # echo //setting up version information.
158 # versionfile=version.txt
159 # cp base-version.txt $versionfile
160 # echo " (built `date -u` by `whoami`@`hostname`)" >> $versionfile
161 # echo 'This is a machine-generated file and should not be edited by hand.' >> $versionfile
163 # Make a unique ID for this build (to discourage people from
164 # mismatching sbcl and *.core files).
165 echo '"'`hostname -s`-`whoami`-`date +%F-%H-%M-%S`'"' > output/build-id.tmp