0.7.1.1:
[sbcl.git] / make-config.sh
1 #!/bin/sh
2
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.
9
10 # This software is part of the SBCL system. See the README file for
11 # more information.
12 #
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.
18
19 echo //entering make-config.sh
20
21 echo //ensuring the existence of output/ directory
22 if [ ! -d output ] ; then mkdir output; fi
23
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
30
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     *)
39         # If we're not building on a supported target architecture, we
40         # we have no guess, but it's not an error yet, since maybe
41         # target architecture will be specified explicitly below.
42         guessed_sbcl_arch=''
43         ;;
44 esac
45
46 echo //setting up CPU-architecture-dependent information
47 sbcl_arch=${SBCL_ARCH:-$guessed_sbcl_arch}
48 echo sbcl_arch=\"$sbcl_arch\"
49 if [ "$sbcl_arch" = "" ] ; then
50     echo "can't guess target SBCL architecture, need SBCL_ARCH environment var"
51     exit 1
52 fi
53 printf ":%s" "$sbcl_arch" >> $ltf 
54 # KLUDGE: currently the x86 only works with the generational garbage
55 # collector (indicated by the presence of :GENCGC in *FEATURES*) and
56 # alpha, sparc and ppc with the stop'n'copy collector (indicated by
57 # the absence of :GENCGC in *FEATURES*). This isn't a great
58 # separation, but for now, rather than have :GENCGC in
59 # base-target-features.lisp-expr, we add it into local-target-features
60 # if we're building for x86. -- CSR, 2002-02-21 Then we do something
61 # similar with :STACK-GROWS-FOOWARD, too. -- WHN 2002-03-03
62 if [ "$sbcl_arch" = "x86" ] ; then
63     printf ' :gencgc :stack-grows-downward-not-upward' >> $ltf
64 else
65     # Nothing need be done in this case, but sh syntax wants a placeholder.
66     echo > /dev/null
67 fi
68 for d in src/compiler src/assembly; do
69     echo //setting up symlink $d/target
70     original_dir=`pwd`
71     cd $d
72     if [ -h target ] ; then
73         rm target
74     elif [ -w target ] ; then
75         echo "I'm afraid to replace non-symlink $d/target with a symlink."
76         exit 1
77     fi
78     if [ -d $sbcl_arch ] ; then
79         ln -s $sbcl_arch target
80     else
81         echo "missing sbcl_arch directory $PWD/$sbcl_arch"
82         exit 1
83     fi
84     cd $original_dir
85 done
86
87 echo //setting up OS-dependent information
88 original_dir=`pwd`
89 cd src/runtime/
90 rm -f Config target-arch-os.h target-arch.h target-os.h target-lispregs.h
91 # KLUDGE: these two logically belong in the previous section
92 # ("architecture-dependent"); it seems silly to enforce this in terms
93 # of the shell script, though. -- CSR, 2002-02-03
94 ln -s $sbcl_arch-arch.h target-arch.h
95 ln -s $sbcl_arch-lispregs.h target-lispregs.h
96 case `uname` in 
97     Linux)
98         printf ' :linux' >> $ltf
99         ln -s Config.$sbcl_arch-linux Config
100         ln -s $sbcl_arch-linux-os.h target-arch-os.h
101         ln -s linux-os.h target-os.h
102         ;;
103     *BSD)
104         printf ' :bsd' >> $ltf
105         ln -s $sbcl_arch-bsd-os.h target-arch-os.h
106         ln -s bsd-os.h target-os.h
107         case `uname` in
108             FreeBSD)
109                 printf ' :freebsd' >> $ltf
110                 ln -s Config.$sbcl_arch-freebsd Config
111                 ;;
112             OpenBSD)
113                 printf ' :openbsd' >> $ltf
114                 ln -s Config.$sbcl_arch-openbsd Config
115                 ;;
116             *)
117                 echo unsupported BSD variant: `uname`
118                 exit 1
119                 ;;
120         esac
121         ;;
122     SunOS)
123         printf ' :sunos' >> $ltf
124         ln -s Config.$sbcl_arch-sunos Config
125         ln -s $sbcl_arch-sunos-os.h target-arch-os.h
126         ln -s sunos-os.h target-os.h
127         ;;
128     *)
129         echo unsupported OS type: `uname`
130         exit 1
131         ;;
132 esac
133 cd $original_dir
134
135 echo //finishing $ltf
136 echo ')' >> $ltf
137
138 # FIXME: The version system should probably be redone along these lines:
139 #
140 # echo //setting up version information.
141 # versionfile=version.txt
142 # cp base-version.txt $versionfile
143 # echo " (built `date -u` by `whoami`@`hostname`)" >> $versionfile
144 # echo 'This is a machine-generated file and should not be edited by hand.' >> $versionfile