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