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