root / configure @ 378180d8
History | View | Annotate | Download (6.1 kB)
1 | 7d13299d | bellard | #!/bin/sh |
---|---|---|---|
2 | 7d13299d | bellard | # |
3 | 3ef693a0 | bellard | # qemu configure script (c) 2003 Fabrice Bellard |
4 | 7d13299d | bellard | # |
5 | 7d13299d | bellard | # set temporary file name |
6 | 7d13299d | bellard | if test ! -z "$TMPDIR" ; then |
7 | 7d13299d | bellard | TMPDIR1="${TMPDIR}" |
8 | 7d13299d | bellard | elif test ! -z "$TEMPDIR" ; then |
9 | 7d13299d | bellard | TMPDIR1="${TEMPDIR}" |
10 | 7d13299d | bellard | else |
11 | 7d13299d | bellard | TMPDIR1="/tmp" |
12 | 7d13299d | bellard | fi |
13 | 7d13299d | bellard | |
14 | 3ef693a0 | bellard | TMPC="${TMPDIR1}/qemu-conf-${RANDOM}-$$-${RANDOM}.c" |
15 | 3ef693a0 | bellard | TMPO="${TMPDIR1}/qemu-conf-${RANDOM}-$$-${RANDOM}.o" |
16 | 3ef693a0 | bellard | TMPE="${TMPDIR1}/qemu-conf-${RANDOM}-$$-${RANDOM}" |
17 | 3ef693a0 | bellard | TMPS="${TMPDIR1}/qemu-conf-${RANDOM}-$$-${RANDOM}.S" |
18 | 3ef693a0 | bellard | TMPH="${TMPDIR1}/qemu-conf-${RANDOM}-$$-${RANDOM}.h" |
19 | 7d13299d | bellard | |
20 | 7d13299d | bellard | # default parameters |
21 | 7d13299d | bellard | prefix="/usr/local" |
22 | 32ce6337 | bellard | interp_prefix="/usr/gnemul/qemu-i386" |
23 | 7d13299d | bellard | cross_prefix="" |
24 | 7d13299d | bellard | cc="gcc" |
25 | 7d13299d | bellard | host_cc="gcc" |
26 | 7d13299d | bellard | ar="ar" |
27 | 7d13299d | bellard | make="make" |
28 | 7d13299d | bellard | strip="strip" |
29 | a98fd896 | bellard | target_cpu="x86" |
30 | 7d13299d | bellard | cpu=`uname -m` |
31 | 7d13299d | bellard | case "$cpu" in |
32 | 7d13299d | bellard | i386|i486|i586|i686|i86pc|BePC) |
33 | 7d13299d | bellard | cpu="x86" |
34 | 7d13299d | bellard | ;; |
35 | 7d13299d | bellard | armv4l) |
36 | 7d13299d | bellard | cpu="armv4l" |
37 | 7d13299d | bellard | ;; |
38 | 7d13299d | bellard | alpha) |
39 | 7d13299d | bellard | cpu="alpha" |
40 | 7d13299d | bellard | ;; |
41 | 295defa5 | bellard | "Power Macintosh"|ppc|ppc64) |
42 | 7d13299d | bellard | cpu="powerpc" |
43 | 7d13299d | bellard | ;; |
44 | 7d13299d | bellard | mips) |
45 | 7d13299d | bellard | cpu="mips" |
46 | 7d13299d | bellard | ;; |
47 | fb3e5849 | bellard | s390) |
48 | fb3e5849 | bellard | cpu="s390" |
49 | fb3e5849 | bellard | ;; |
50 | a8baa8c5 | bellard | ia64) |
51 | a8baa8c5 | bellard | cpu="ia64" |
52 | a8baa8c5 | bellard | ;; |
53 | 7d13299d | bellard | *) |
54 | 7d13299d | bellard | cpu="unknown" |
55 | 7d13299d | bellard | ;; |
56 | 7d13299d | bellard | esac |
57 | 7d13299d | bellard | gprof="no" |
58 | 7d13299d | bellard | bigendian="no" |
59 | 7d13299d | bellard | |
60 | 7d13299d | bellard | # OS specific |
61 | 7d13299d | bellard | targetos=`uname -s` |
62 | 7d13299d | bellard | case $targetos in |
63 | 7d13299d | bellard | *) ;; |
64 | 7d13299d | bellard | esac |
65 | 7d13299d | bellard | |
66 | 7d13299d | bellard | # find source path |
67 | 7d13299d | bellard | # XXX: we assume an absolute path is given when launching configure, |
68 | 7d13299d | bellard | # except in './configure' case. |
69 | 7d13299d | bellard | source_path=${0%configure} |
70 | 7d13299d | bellard | source_path=${source_path%/} |
71 | 7d13299d | bellard | source_path_used="yes" |
72 | 7d13299d | bellard | if test -z "$source_path" -o "$source_path" = "." ; then |
73 | 7d13299d | bellard | source_path=`pwd` |
74 | 7d13299d | bellard | source_path_used="no" |
75 | 7d13299d | bellard | fi |
76 | 7d13299d | bellard | |
77 | 7d13299d | bellard | for opt do |
78 | 7d13299d | bellard | case "$opt" in |
79 | 7d13299d | bellard | --prefix=*) prefix=`echo $opt | cut -d '=' -f 2` |
80 | 7d13299d | bellard | ;; |
81 | 32ce6337 | bellard | --interp-prefix=*) interp_prefix=`echo $opt | cut -d '=' -f 2` |
82 | 32ce6337 | bellard | ;; |
83 | 7d13299d | bellard | --source-path=*) source_path=`echo $opt | cut -d '=' -f 2` |
84 | 7d13299d | bellard | ;; |
85 | 7d13299d | bellard | --cross-prefix=*) cross_prefix=`echo $opt | cut -d '=' -f 2` |
86 | 7d13299d | bellard | ;; |
87 | 7d13299d | bellard | --cc=*) cc=`echo $opt | cut -d '=' -f 2` |
88 | 7d13299d | bellard | ;; |
89 | 7d13299d | bellard | --make=*) make=`echo $opt | cut -d '=' -f 2` |
90 | 7d13299d | bellard | ;; |
91 | 7d13299d | bellard | --extra-cflags=*) CFLAGS="${opt#--extra-cflags=}" |
92 | 7d13299d | bellard | ;; |
93 | 7d13299d | bellard | --extra-ldflags=*) LDFLAGS="${opt#--extra-ldflags=}" |
94 | 7d13299d | bellard | ;; |
95 | 7d13299d | bellard | --extra-libs=*) extralibs=${opt#--extra-libs=} |
96 | 7d13299d | bellard | ;; |
97 | 7d13299d | bellard | --cpu=*) cpu=`echo $opt | cut -d '=' -f 2` |
98 | 7d13299d | bellard | ;; |
99 | 7d13299d | bellard | --enable-gprof) gprof="yes" |
100 | 7d13299d | bellard | ;; |
101 | 7d13299d | bellard | esac |
102 | 7d13299d | bellard | done |
103 | 7d13299d | bellard | |
104 | 7d13299d | bellard | # Checking for CFLAGS |
105 | 7d13299d | bellard | if test -z "$CFLAGS"; then |
106 | 7d13299d | bellard | CFLAGS="-O2" |
107 | 7d13299d | bellard | fi |
108 | 7d13299d | bellard | |
109 | 7d13299d | bellard | cc="${cross_prefix}${cc}" |
110 | 7d13299d | bellard | ar="${cross_prefix}${ar}" |
111 | 7d13299d | bellard | strip="${cross_prefix}${strip}" |
112 | 7d13299d | bellard | |
113 | 7d13299d | bellard | if test -z "$cross_prefix" ; then |
114 | 7d13299d | bellard | |
115 | 7d13299d | bellard | # --- |
116 | 7d13299d | bellard | # big/little endian test |
117 | 7d13299d | bellard | cat > $TMPC << EOF |
118 | 7d13299d | bellard | #include <inttypes.h> |
119 | 7d13299d | bellard | int main(int argc, char ** argv){ |
120 | 7d13299d | bellard | volatile uint32_t i=0x01234567; |
121 | 7d13299d | bellard | return (*((uint8_t*)(&i))) == 0x67; |
122 | 7d13299d | bellard | } |
123 | 7d13299d | bellard | EOF |
124 | 7d13299d | bellard | |
125 | 7d13299d | bellard | if $cc -o $TMPE $TMPC 2>/dev/null ; then |
126 | 7d13299d | bellard | $TMPE && bigendian="yes" |
127 | 7d13299d | bellard | else |
128 | 7d13299d | bellard | echo big/little test failed |
129 | 7d13299d | bellard | fi |
130 | 7d13299d | bellard | |
131 | 7d13299d | bellard | else |
132 | 7d13299d | bellard | |
133 | 7d13299d | bellard | # if cross compiling, cannot launch a program, so make a static guess |
134 | fb3e5849 | bellard | if test "$cpu" = "powerpc" -o "$cpu" = "mips" -o "$cpu" = "s390" ; then |
135 | 7d13299d | bellard | bigendian="yes" |
136 | 7d13299d | bellard | fi |
137 | 7d13299d | bellard | |
138 | 7d13299d | bellard | fi |
139 | 7d13299d | bellard | |
140 | ca735206 | bellard | # check gcc version |
141 | 04369ff2 | bellard | cat > $TMPC <<EOF |
142 | 04369ff2 | bellard | int main(void) { |
143 | 04369ff2 | bellard | #if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 2) |
144 | 04369ff2 | bellard | return 0; |
145 | 04369ff2 | bellard | #else |
146 | 04369ff2 | bellard | #error gcc < 3.2 |
147 | 04369ff2 | bellard | #endif |
148 | 04369ff2 | bellard | } |
149 | 04369ff2 | bellard | EOF |
150 | 04369ff2 | bellard | |
151 | ca735206 | bellard | gcc_major="2" |
152 | 04369ff2 | bellard | if $cc -o $TMPO $TMPC 2> /dev/null ; then |
153 | 04369ff2 | bellard | gcc_major="3" |
154 | 04369ff2 | bellard | fi |
155 | ca735206 | bellard | |
156 | 7d13299d | bellard | if test x"$1" = x"-h" -o x"$1" = x"--help" ; then |
157 | 7d13299d | bellard | cat << EOF |
158 | 7d13299d | bellard | |
159 | 7d13299d | bellard | Usage: configure [options] |
160 | 7d13299d | bellard | Options: [defaults in brackets after descriptions] |
161 | 7d13299d | bellard | |
162 | 7d13299d | bellard | EOF |
163 | 7d13299d | bellard | echo "Standard options:" |
164 | 7d13299d | bellard | echo " --help print this message" |
165 | 7d13299d | bellard | echo " --prefix=PREFIX install in PREFIX [$prefix]" |
166 | 32ce6337 | bellard | echo " --interp-prefix=PREFIX where to find shared libraries, etc. [$interp_prefix]" |
167 | 7d13299d | bellard | echo "" |
168 | 7d13299d | bellard | echo "Advanced options (experts only):" |
169 | 7d13299d | bellard | echo " --source-path=PATH path of source code [$source_path]" |
170 | 7d13299d | bellard | echo " --cross-prefix=PREFIX use PREFIX for compile tools [$cross_prefix]" |
171 | 7d13299d | bellard | echo " --cc=CC use C compiler CC [$cc]" |
172 | 7d13299d | bellard | echo " --make=MAKE use specified make [$make]" |
173 | 7d13299d | bellard | echo "" |
174 | 7d13299d | bellard | echo "NOTE: The object files are build at the place where configure is launched" |
175 | 7d13299d | bellard | exit 1 |
176 | 7d13299d | bellard | fi |
177 | 7d13299d | bellard | |
178 | 7d13299d | bellard | echo "Install prefix $prefix" |
179 | 7d13299d | bellard | echo "Source path $source_path" |
180 | 7d13299d | bellard | echo "C compiler $cc" |
181 | 7d13299d | bellard | echo "make $make" |
182 | a98fd896 | bellard | echo "host CPU $cpu" |
183 | 7d13299d | bellard | echo "Big Endian $bigendian" |
184 | a98fd896 | bellard | echo "target CPU $target_cpu" |
185 | 7d13299d | bellard | echo "gprof enabled $gprof" |
186 | 7d13299d | bellard | |
187 | 7d13299d | bellard | echo "Creating config.mak and config.h" |
188 | 7d13299d | bellard | |
189 | 7d13299d | bellard | echo "# Automatically generated by configure - do not modify" > config.mak |
190 | 7d13299d | bellard | echo "/* Automatically generated by configure - do not modify */" > $TMPH |
191 | 7d13299d | bellard | |
192 | 7d13299d | bellard | echo "prefix=$prefix" >> config.mak |
193 | 32ce6337 | bellard | echo "#define CONFIG_QEMU_PREFIX \"$interp_prefix\"" >> $TMPH |
194 | 7d13299d | bellard | echo "MAKE=$make" >> config.mak |
195 | 7d13299d | bellard | echo "CC=$cc" >> config.mak |
196 | ca735206 | bellard | echo "GCC_MAJOR=$gcc_major" >> config.mak |
197 | 7d13299d | bellard | echo "HOST_CC=$host_cc" >> config.mak |
198 | 7d13299d | bellard | echo "AR=$ar" >> config.mak |
199 | 7d13299d | bellard | echo "STRIP=$strip -s -R .comment -R .note" >> config.mak |
200 | 7d13299d | bellard | echo "CFLAGS=$CFLAGS" >> config.mak |
201 | 7d13299d | bellard | echo "LDFLAGS=$LDFLAGS" >> config.mak |
202 | 7d13299d | bellard | if test "$cpu" = "x86" ; then |
203 | 7d13299d | bellard | echo "ARCH=i386" >> config.mak |
204 | 295defa5 | bellard | echo "#define HOST_I386 1" >> $TMPH |
205 | 7d13299d | bellard | elif test "$cpu" = "armv4l" ; then |
206 | 7d13299d | bellard | echo "ARCH=arm" >> config.mak |
207 | 295defa5 | bellard | echo "#define HOST_ARM 1" >> $TMPH |
208 | 7d13299d | bellard | elif test "$cpu" = "powerpc" ; then |
209 | 04369ff2 | bellard | echo "ARCH=ppc" >> config.mak |
210 | 295defa5 | bellard | echo "#define HOST_PPC 1" >> $TMPH |
211 | 7d13299d | bellard | elif test "$cpu" = "mips" ; then |
212 | 04369ff2 | bellard | echo "ARCH=mips" >> config.mak |
213 | 295defa5 | bellard | echo "#define HOST_MIPS 1" >> $TMPH |
214 | fb3e5849 | bellard | elif test "$cpu" = "s390" ; then |
215 | fb3e5849 | bellard | echo "ARCH=s390" >> config.mak |
216 | 295defa5 | bellard | echo "#define HOST_S390 1" >> $TMPH |
217 | 295defa5 | bellard | elif test "$cpu" = "alpha" ; then |
218 | 295defa5 | bellard | echo "ARCH=alpha" >> config.mak |
219 | 295defa5 | bellard | echo "#define HOST_ALPHA 1" >> $TMPH |
220 | a8baa8c5 | bellard | elif test "$cpu" = "ia64" ; then |
221 | a8baa8c5 | bellard | echo "ARCH=ia64" >> config.mak |
222 | a8baa8c5 | bellard | echo "#define HOST_IA64 1" >> $TMPH |
223 | 7d13299d | bellard | else |
224 | 7d13299d | bellard | echo "Unsupported CPU" |
225 | 7d13299d | bellard | exit 1 |
226 | 7d13299d | bellard | fi |
227 | 7d13299d | bellard | if test "$bigendian" = "yes" ; then |
228 | 7d13299d | bellard | echo "WORDS_BIGENDIAN=yes" >> config.mak |
229 | 7d13299d | bellard | echo "#define WORDS_BIGENDIAN 1" >> $TMPH |
230 | 7d13299d | bellard | fi |
231 | 7d13299d | bellard | if test "$gprof" = "yes" ; then |
232 | 7d13299d | bellard | echo "TARGET_GPROF=yes" >> config.mak |
233 | 7d13299d | bellard | echo "#define HAVE_GPROF 1" >> $TMPH |
234 | 7d13299d | bellard | fi |
235 | 7d13299d | bellard | echo -n "VERSION=" >>config.mak |
236 | 7d13299d | bellard | head $source_path/VERSION >>config.mak |
237 | 7d13299d | bellard | echo "" >>config.mak |
238 | 3ef693a0 | bellard | echo -n "#define QEMU_VERSION \"" >> $TMPH |
239 | 7d13299d | bellard | head $source_path/VERSION >> $TMPH |
240 | 7d13299d | bellard | echo "\"" >> $TMPH |
241 | 7d13299d | bellard | |
242 | 7d13299d | bellard | # build tree in object directory if source path is different from current one |
243 | 7d13299d | bellard | if test "$source_path_used" = "yes" ; then |
244 | 7d13299d | bellard | DIRS="tests" |
245 | 7d13299d | bellard | FILES="Makefile tests/Makefile" |
246 | 7d13299d | bellard | for dir in $DIRS ; do |
247 | 7d13299d | bellard | mkdir -p $dir |
248 | 7d13299d | bellard | done |
249 | 7d13299d | bellard | for f in $FILES ; do |
250 | 7d13299d | bellard | ln -sf $source_path/$f $f |
251 | 7d13299d | bellard | done |
252 | 7d13299d | bellard | fi |
253 | 7d13299d | bellard | echo "SRC_PATH=$source_path" >> config.mak |
254 | 7d13299d | bellard | |
255 | 7d13299d | bellard | diff $TMPH config.h >/dev/null 2>&1 |
256 | 7d13299d | bellard | if test $? -ne 0 ; then |
257 | 7d13299d | bellard | mv -f $TMPH config.h |
258 | 7d13299d | bellard | else |
259 | 7d13299d | bellard | echo "config.h is unchanged" |
260 | 7d13299d | bellard | fi |
261 | 7d13299d | bellard | |
262 | 1eb87257 | bellard | rm -f $TMPO $TMPC $TMPE $TMPS $TMPH |