]> git.proxmox.com Git - mirror_qemu.git/blame - configure
win32 port (initial patch by kazu)
[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"
7d13299d
FB
18
19# default parameters
20prefix="/usr/local"
1e43adfc 21interp_prefix="/usr/gnemul/qemu-%M"
43ce4dfe 22static="no"
7d13299d
FB
23cross_prefix=""
24cc="gcc"
25host_cc="gcc"
26ar="ar"
27make="make"
28strip="strip"
29cpu=`uname -m`
67867308 30target_list="i386-user i386 i386-softmmu arm-user sparc-user ppc-user"
7d13299d
FB
31case "$cpu" in
32 i386|i486|i586|i686|i86pc|BePC)
97a847bc 33 cpu="i386"
7d13299d
FB
34 ;;
35 armv4l)
36 cpu="armv4l"
37 ;;
38 alpha)
39 cpu="alpha"
40 ;;
295defa5 41 "Power Macintosh"|ppc|ppc64)
7d13299d
FB
42 cpu="powerpc"
43 ;;
44 mips)
45 cpu="mips"
46 ;;
fb3e5849
FB
47 s390)
48 cpu="s390"
49 ;;
ae228531
FB
50 sparc)
51 cpu="sparc"
52 ;;
53 sparc64)
54 cpu="sparc64"
55 ;;
a8baa8c5
FB
56 ia64)
57 cpu="ia64"
58 ;;
38e584a0
FB
59 m68k)
60 cpu="m68k"
61 ;;
bc51c5c9
FB
62 x86_64|amd64)
63 cpu="amd64"
64 ;;
7d13299d
FB
65 *)
66 cpu="unknown"
67 ;;
68esac
69gprof="no"
70bigendian="no"
67b915a5
FB
71mingw32="no"
72EXESUF=""
73gdbstub="yes"
7d13299d
FB
74
75# OS specific
76targetos=`uname -s`
77case $targetos in
67b915a5
FB
78MINGW32*)
79mingw32="yes"
80;;
7d13299d
FB
81*) ;;
82esac
83
97a847bc
FB
84##########################################
85# SDL probe
86
87cat > $TMPC << EOF
88#include <SDL.h>
89#undef main /* We don't want SDL to override our main() */
90int main( void ) { return SDL_Init (SDL_INIT_VIDEO); }
91EOF
92
93sdl_too_old=no
94sdl=no
95if $cc -o $TMPE `sdl-config --cflags` $TMPC `sdl-config --libs` 2> /dev/null ; then
96_sdlversion=`sdl-config --version | sed 's/[^0-9]//g'`
97if test "$_sdlversion" -lt 121 ; then
98sdl_too_old=yes
99else
100sdl=yes
101fi
102fi
103
7d13299d
FB
104# find source path
105# XXX: we assume an absolute path is given when launching configure,
106# except in './configure' case.
107source_path=${0%configure}
108source_path=${source_path%/}
109source_path_used="yes"
110if test -z "$source_path" -o "$source_path" = "." ; then
111 source_path=`pwd`
112 source_path_used="no"
113fi
114
115for opt do
116 case "$opt" in
117 --prefix=*) prefix=`echo $opt | cut -d '=' -f 2`
118 ;;
32ce6337
FB
119 --interp-prefix=*) interp_prefix=`echo $opt | cut -d '=' -f 2`
120 ;;
7d13299d
FB
121 --source-path=*) source_path=`echo $opt | cut -d '=' -f 2`
122 ;;
123 --cross-prefix=*) cross_prefix=`echo $opt | cut -d '=' -f 2`
124 ;;
125 --cc=*) cc=`echo $opt | cut -d '=' -f 2`
126 ;;
127 --make=*) make=`echo $opt | cut -d '=' -f 2`
128 ;;
129 --extra-cflags=*) CFLAGS="${opt#--extra-cflags=}"
130 ;;
131 --extra-ldflags=*) LDFLAGS="${opt#--extra-ldflags=}"
132 ;;
133 --extra-libs=*) extralibs=${opt#--extra-libs=}
134 ;;
135 --cpu=*) cpu=`echo $opt | cut -d '=' -f 2`
136 ;;
97a847bc 137 --target-list=*) target_list=${opt#--target-list=}
de83cd02 138 ;;
7d13299d
FB
139 --enable-gprof) gprof="yes"
140 ;;
43ce4dfe
FB
141 --static) static="yes"
142 ;;
97a847bc
FB
143 --disable-sdl) sdl="no"
144 ;;
67b915a5
FB
145 --enable-mingw32) mingw32="yes" ; cross_prefix="i386-mingw32-"
146 ;;
7d13299d
FB
147 esac
148done
149
150# Checking for CFLAGS
151if test -z "$CFLAGS"; then
152 CFLAGS="-O2"
153fi
154
155cc="${cross_prefix}${cc}"
156ar="${cross_prefix}${ar}"
157strip="${cross_prefix}${strip}"
158
67b915a5
FB
159if test "$mingw32" = "yes" ; then
160 host_cc="$cc"
161 target_list="i386-softmmu"
162 prefix="/c/Program Files/Qemu"
163 EXESUF=".exe"
164 gdbstub="no"
165fi
166
7d13299d
FB
167if test -z "$cross_prefix" ; then
168
169# ---
170# big/little endian test
171cat > $TMPC << EOF
172#include <inttypes.h>
173int main(int argc, char ** argv){
174 volatile uint32_t i=0x01234567;
175 return (*((uint8_t*)(&i))) == 0x67;
176}
177EOF
178
179if $cc -o $TMPE $TMPC 2>/dev/null ; then
180$TMPE && bigendian="yes"
181else
182echo big/little test failed
183fi
184
185else
186
187# if cross compiling, cannot launch a program, so make a static guess
38e584a0 188if test "$cpu" = "powerpc" -o "$cpu" = "mips" -o "$cpu" = "s390" -o "$cpu" = "sparc" -o "$cpu" = "sparc64" -o "$cpu" = "m68k"; then
7d13299d
FB
189 bigendian="yes"
190fi
191
192fi
193
e8cd23de 194# check gcc options support
04369ff2
FB
195cat > $TMPC <<EOF
196int main(void) {
04369ff2
FB
197}
198EOF
199
e8cd23de
FB
200have_gcc3_options="no"
201if $cc -fno-reorder-blocks -fno-optimize-sibling-calls -o $TMPO $TMPC 2> /dev/null ; then
202 have_gcc3_options="yes"
04369ff2 203fi
ca735206 204
7d13299d
FB
205if test x"$1" = x"-h" -o x"$1" = x"--help" ; then
206cat << EOF
207
208Usage: configure [options]
209Options: [defaults in brackets after descriptions]
210
211EOF
212echo "Standard options:"
213echo " --help print this message"
214echo " --prefix=PREFIX install in PREFIX [$prefix]"
1e43adfc
FB
215echo " --interp-prefix=PREFIX where to find shared libraries, etc."
216echo " use %M for cpu name [$interp_prefix]"
97a847bc 217echo " --target-list=LIST set target list [$target_list]"
7d13299d
FB
218echo ""
219echo "Advanced options (experts only):"
220echo " --source-path=PATH path of source code [$source_path]"
221echo " --cross-prefix=PREFIX use PREFIX for compile tools [$cross_prefix]"
222echo " --cc=CC use C compiler CC [$cc]"
223echo " --make=MAKE use specified make [$make]"
43ce4dfe 224echo " --static enable static build [$static]"
67b915a5 225echo " --enable-mingw32 enable Win32 cross compilation with mingw32"
7d13299d
FB
226echo ""
227echo "NOTE: The object files are build at the place where configure is launched"
228exit 1
229fi
230
5a67135a
FB
231mandir="$prefix/share/man"
232sharedir="$prefix/share/qemu"
233
43ce4dfe 234echo "Install prefix $prefix"
5a67135a
FB
235echo "Manual directory $mandir"
236echo "BIOS directory $sharedir"
43ce4dfe 237echo "ELF interp prefix $interp_prefix"
5a67135a 238echo "Source path $source_path"
43ce4dfe
FB
239echo "C compiler $cc"
240echo "make $make"
241echo "host CPU $cpu"
de83cd02 242echo "host big endian $bigendian"
97a847bc 243echo "target list $target_list"
43ce4dfe
FB
244echo "gprof enabled $gprof"
245echo "static build $static"
97a847bc 246echo "SDL support $sdl"
67b915a5
FB
247echo "mingw32 support $mingw32"
248
97a847bc
FB
249if test $sdl_too_old = "yes"; then
250echo "-> Your SDL version is too old - please upgrade to have FFplay/SDL support"
251fi
252
253config_mak="config-host.mak"
254config_h="config-host.h"
7d13299d 255
97a847bc 256echo "Creating $config_mak and $config_h"
7d13299d 257
97a847bc
FB
258echo "# Automatically generated by configure - do not modify" > $config_mak
259echo "/* Automatically generated by configure - do not modify */" > $config_h
7d13299d 260
97a847bc 261echo "prefix=$prefix" >> $config_mak
5a67135a
FB
262echo "mandir=$mandir" >> $config_mak
263echo "sharedir=$sharedir" >> $config_mak
264echo "#define CONFIG_QEMU_SHAREDIR \"$sharedir\"" >> $config_h
97a847bc
FB
265echo "MAKE=$make" >> $config_mak
266echo "CC=$cc" >> $config_mak
e8cd23de 267if test "$have_gcc3_options" = "yes" ; then
97a847bc 268 echo "HAVE_GCC3_OPTIONS=yes" >> $config_mak
e8cd23de 269fi
97a847bc
FB
270echo "HOST_CC=$host_cc" >> $config_mak
271echo "AR=$ar" >> $config_mak
272echo "STRIP=$strip -s -R .comment -R .note" >> $config_mak
273echo "CFLAGS=$CFLAGS" >> $config_mak
274echo "LDFLAGS=$LDFLAGS" >> $config_mak
67b915a5 275echo "EXESUF=$EXESUF" >> $config_mak
97a847bc
FB
276if test "$cpu" = "i386" ; then
277 echo "ARCH=i386" >> $config_mak
278 echo "#define HOST_I386 1" >> $config_h
bc51c5c9
FB
279elif test "$cpu" = "amd64" ; then
280 echo "ARCH=amd64" >> $config_mak
281 echo "#define HOST_AMD64 1" >> $config_h
7d13299d 282elif test "$cpu" = "armv4l" ; then
97a847bc
FB
283 echo "ARCH=arm" >> $config_mak
284 echo "#define HOST_ARM 1" >> $config_h
7d13299d 285elif test "$cpu" = "powerpc" ; then
97a847bc
FB
286 echo "ARCH=ppc" >> $config_mak
287 echo "#define HOST_PPC 1" >> $config_h
7d13299d 288elif test "$cpu" = "mips" ; then
97a847bc
FB
289 echo "ARCH=mips" >> $config_mak
290 echo "#define HOST_MIPS 1" >> $config_h
fb3e5849 291elif test "$cpu" = "s390" ; then
97a847bc
FB
292 echo "ARCH=s390" >> $config_mak
293 echo "#define HOST_S390 1" >> $config_h
295defa5 294elif test "$cpu" = "alpha" ; then
97a847bc
FB
295 echo "ARCH=alpha" >> $config_mak
296 echo "#define HOST_ALPHA 1" >> $config_h
ae228531 297elif test "$cpu" = "sparc" ; then
97a847bc
FB
298 echo "ARCH=sparc" >> $config_mak
299 echo "#define HOST_SPARC 1" >> $config_h
ae228531 300elif test "$cpu" = "sparc64" ; then
97a847bc
FB
301 echo "ARCH=sparc64" >> $config_mak
302 echo "#define HOST_SPARC64 1" >> $config_h
a8baa8c5 303elif test "$cpu" = "ia64" ; then
97a847bc
FB
304 echo "ARCH=ia64" >> $config_mak
305 echo "#define HOST_IA64 1" >> $config_h
38e584a0 306elif test "$cpu" = "m68k" ; then
38ca2abc
FB
307 echo "ARCH=m68k" >> $config_mak
308 echo "#define HOST_M68K 1" >> $config_h
7d13299d
FB
309else
310 echo "Unsupported CPU"
311 exit 1
312fi
313if test "$bigendian" = "yes" ; then
97a847bc
FB
314 echo "WORDS_BIGENDIAN=yes" >> $config_mak
315 echo "#define WORDS_BIGENDIAN 1" >> $config_h
316fi
67b915a5
FB
317if test "$mingw32" = "yes" ; then
318 echo "CONFIG_WIN32=yes" >> $config_mak
319else
320 echo "#define HAVE_BYTESWAP_H 1" >> $config_h
321fi
322if test "$gdbstub" = "yes" ; then
323 echo "CONFIG_GDBSTUB=yes" >> $config_mak
324 echo "#define CONFIG_GDBSTUB 1" >> $config_h
325fi
97a847bc
FB
326if test "$gprof" = "yes" ; then
327 echo "TARGET_GPROF=yes" >> $config_mak
328 echo "#define HAVE_GPROF 1" >> $config_h
329fi
330if test "$static" = "yes" ; then
331 echo "CONFIG_STATIC=yes" >> $config_mak
50863472 332 echo "#define CONFIG_STATIC 1" >> $config_h
7d13299d 333fi
97a847bc
FB
334if test "$sdl" = "yes" ; then
335 echo "CONFIG_SDL=yes" >> $config_mak
336 echo "#define CONFIG_SDL 1" >> $config_h
337 echo "SDL_LIBS=`sdl-config --libs`" >> $config_mak
590b7eed
FB
338 aa="no"
339 `sdl-config --static-libs | grep \\\-laa > /dev/null` && aa="yes"
340 echo -n "SDL_STATIC_LIBS=`sdl-config --static-libs`" >> $config_mak
341 if [ "${aa}" = "yes" ] ; then
342 echo -n " `aalib-config --libs`" >> $config_mak ;
343 fi
344 echo "" >> $config_mak
345 echo -n "SDL_CFLAGS=`sdl-config --cflags`" >> $config_mak
346 if [ "${aa}" = "yes" ] ; then
347 echo -n " `aalib-config --cflags`" >> $config_mak ;
348 fi
349 echo "" >> $config_mak
97a847bc
FB
350fi
351echo -n "VERSION=" >>$config_mak
352head $source_path/VERSION >>$config_mak
353echo "" >>$config_mak
354echo -n "#define QEMU_VERSION \"" >> $config_h
355head $source_path/VERSION >> $config_h
356echo "\"" >> $config_h
357
358echo "SRC_PATH=$source_path" >> $config_mak
359echo "TARGET_DIRS=$target_list" >> $config_mak
360
361for target in $target_list; do
362
363target_dir="$target"
364config_mak=$target_dir/config.mak
365config_h=$target_dir/config.h
366target_cpu=`echo $target | cut -d '-' -f 1`
367target_bigendian="no"
1e43adfc 368[ "$target_cpu" = "sparc" ] && target_bigendian=yes
67867308 369[ "$target_cpu" = "ppc" ] && target_bigendian=yes
97a847bc
FB
370target_softmmu="no"
371if expr $target : '.*-softmmu' > /dev/null ; then
372 target_softmmu="yes"
373fi
997344f3
FB
374target_user_only="no"
375if expr $target : '.*-user' > /dev/null ; then
376 target_user_only="yes"
377fi
97a847bc
FB
378
379echo "Creating $config_mak, $config_h and $target_dir/Makefile"
380
381mkdir -p $target_dir
69de927c
FB
382if test "$target" = "arm-user" ; then
383 mkdir -p $target_dir/nwfpe
384fi
385
97a847bc
FB
386ln -sf $source_path/Makefile.target $target_dir/Makefile
387
388echo "# Automatically generated by configure - do not modify" > $config_mak
389echo "/* Automatically generated by configure - do not modify */" > $config_h
390
de83cd02 391
97a847bc
FB
392echo "include ../config-host.mak" >> $config_mak
393echo "#include \"../config-host.h\"" >> $config_h
1e43adfc
FB
394
395interp_prefix1=`echo "$interp_prefix" | sed "s/%M/$target_cpu/g"`
396echo "#define CONFIG_QEMU_PREFIX \"$interp_prefix1\"" >> $config_h
97a847bc
FB
397
398if test "$target_cpu" = "i386" ; then
399 echo "TARGET_ARCH=i386" >> $config_mak
400 echo "#define TARGET_ARCH \"i386\"" >> $config_h
401 echo "#define TARGET_I386 1" >> $config_h
de83cd02 402elif test "$target_cpu" = "arm" ; then
97a847bc
FB
403 echo "TARGET_ARCH=arm" >> $config_mak
404 echo "#define TARGET_ARCH \"arm\"" >> $config_h
405 echo "#define TARGET_ARM 1" >> $config_h
1e43adfc
FB
406elif test "$target_cpu" = "sparc" ; then
407 echo "TARGET_ARCH=sparc" >> $config_mak
408 echo "#define TARGET_ARCH \"sparc\"" >> $config_h
409 echo "#define TARGET_SPARC 1" >> $config_h
67867308
FB
410elif test "$target_cpu" = "ppc" ; then
411 echo "TARGET_ARCH=ppc" >> $config_mak
412 echo "#define TARGET_ARCH \"ppc\"" >> $config_h
413 echo "#define TARGET_PPC 1" >> $config_h
de83cd02
FB
414else
415 echo "Unsupported target CPU"
416 exit 1
417fi
418if test "$target_bigendian" = "yes" ; then
97a847bc
FB
419 echo "TARGET_WORDS_BIGENDIAN=yes" >> $config_mak
420 echo "#define TARGET_WORDS_BIGENDIAN 1" >> $config_h
de83cd02 421fi
97a847bc
FB
422if test "$target_softmmu" = "yes" ; then
423 echo "CONFIG_SOFTMMU=yes" >> $config_mak
424 echo "#define CONFIG_SOFTMMU 1" >> $config_h
43ce4dfe 425fi
997344f3
FB
426if test "$target_user_only" = "yes" ; then
427 echo "CONFIG_USER_ONLY=yes" >> $config_mak
428 echo "#define CONFIG_USER_ONLY 1" >> $config_h
429fi
97a847bc
FB
430
431done # for target in $targets
7d13299d
FB
432
433# build tree in object directory if source path is different from current one
434if test "$source_path_used" = "yes" ; then
435 DIRS="tests"
436 FILES="Makefile tests/Makefile"
437 for dir in $DIRS ; do
438 mkdir -p $dir
439 done
440 for f in $FILES ; do
441 ln -sf $source_path/$f $f
442 done
443fi
7d13299d 444
97a847bc 445rm -f $TMPO $TMPC $TMPE $TMPS