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