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