fb0349020172cf6c30ce581260f7e599e7f22647
[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 echo -n '(' >> $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     *)
36         # If we're not building on a supported target architecture, we
37         # we have no guess, but it's not an error yet, since maybe
38         # target architecture will be specified explicitly below.
39         guessed_sbcl_arch=''
40         ;;
41 esac
42
43 echo //setting up CPU-architecture-dependent information
44 sbcl_arch=${SBCL_ARCH:-$guessed_sbcl_arch}
45 echo sbcl_arch=\"$sbcl_arch\"
46 if [ "$sbcl_arch" = "" ] ; then
47     echo "can't guess target SBCL architecture, need SBCL_ARCH environment var"
48     exit 1
49 fi
50 echo -n ":$sbcl_arch" >> $ltf 
51 for d in src/compiler src/assembly; do
52     echo //setting up symlink $d/target
53     original_dir=`pwd`
54     cd $d
55     if [ -L target ] ; then
56         rm target
57     elif [ -e target ] ; then
58         echo "I'm afraid to replace non-symlink $d/target with a symlink."
59         exit 1
60     fi
61     if [ -d $sbcl_arch ] ; then
62         ln -s $sbcl_arch target
63     else
64         echo "missing sbcl_arch directory $PWD/$sbcl_arch"
65         exit 1
66     fi
67     cd $original_dir
68 done
69
70 echo //setting up OS-dependent information
71 original_dir=`pwd`
72 cd src/runtime/
73 rm -f Config
74 case `uname` in 
75     Linux)
76         echo -n ' :linux' >> $ltf
77         ln -s Config.$sbcl_arch-linux Config
78         ;;
79     *BSD)
80         echo -n ' :bsd' >> $ltf
81         case `uname` in
82             FreeBSD)
83                 echo -n ' :freebsd' >> $ltf
84                 ln -s Config.$sbcl_arch-freebsd Config
85                 ;;
86             OpenBSD)
87                 echo -n ' :openbsd' >> $ltf
88                 ln -s Config.$sbcl_arch-openbsd Config
89                 ;;
90             *)
91                 echo unsupported BSD variant: `uname`
92                 exit 1
93                 ;;
94         esac
95         ;;
96     *)
97         echo unsupported OS type: `uname`
98         exit 1
99         ;;
100 esac
101 cd $original_dir
102
103 echo //finishing $ltf
104 echo ')' >> $ltf
105
106 # FIXME: The version system should probably be redone along these lines:
107 #
108 # echo //setting up version information.
109 # versionfile=version.txt
110 # cp base-version.txt $versionfile
111 # echo " (built `date -u` by `whoami`@`hostname`)" >> $versionfile
112 # echo 'This is a machine-generated file and should not be edited by hand.' >> $versionfile