blob: 75340eae13e305546ba9550f6a6d4a26bea28fb8 [file] [log] [blame]
bellard7d132992003-03-06 23:23:54 +00001#!/bin/sh
2#
bellard3ef693a2003-03-23 20:17:16 +00003# qemu configure script (c) 2003 Fabrice Bellard
bellard7d132992003-03-06 23:23:54 +00004#
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
bellard3ef693a2003-03-23 20:17:16 +000014TMPC="${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"
bellard7d132992003-03-06 23:23:54 +000018
19# default parameters
20prefix="/usr/local"
bellard1e43adf2003-09-30 20:54:24 +000021interp_prefix="/usr/gnemul/qemu-%M"
bellard43ce4df2003-06-09 19:53:12 +000022static="no"
bellard7d132992003-03-06 23:23:54 +000023cross_prefix=""
24cc="gcc"
25host_cc="gcc"
26ar="ar"
27make="make"
28strip="strip"
29cpu=`uname -m`
bellard67867302003-11-23 17:05:30 +000030target_list="i386-user i386 i386-softmmu arm-user sparc-user ppc-user"
bellard7d132992003-03-06 23:23:54 +000031case "$cpu" in
32 i386|i486|i586|i686|i86pc|BePC)
bellard97a847b2003-08-10 21:36:04 +000033 cpu="i386"
bellard7d132992003-03-06 23:23:54 +000034 ;;
35 armv4l)
36 cpu="armv4l"
37 ;;
38 alpha)
39 cpu="alpha"
40 ;;
bellard295defa2003-04-07 21:31:29 +000041 "Power Macintosh"|ppc|ppc64)
bellard7d132992003-03-06 23:23:54 +000042 cpu="powerpc"
43 ;;
44 mips)
45 cpu="mips"
46 ;;
bellardfb3e5842003-03-29 17:32:36 +000047 s390)
48 cpu="s390"
49 ;;
bellardae228532003-05-13 18:59:59 +000050 sparc)
51 cpu="sparc"
52 ;;
53 sparc64)
54 cpu="sparc64"
55 ;;
bellarda8baa8c2003-04-29 20:53:31 +000056 ia64)
57 cpu="ia64"
58 ;;
bellard38e584a2003-08-10 22:14:22 +000059 m68k)
60 cpu="m68k"
61 ;;
bellardbc51c5c2004-03-17 23:46:04 +000062 x86_64|amd64)
63 cpu="amd64"
64 ;;
bellard7d132992003-03-06 23:23:54 +000065 *)
66 cpu="unknown"
67 ;;
68esac
69gprof="no"
70bigendian="no"
bellard67b915a2004-03-31 23:37:16 +000071mingw32="no"
72EXESUF=""
73gdbstub="yes"
bellard7d132992003-03-06 23:23:54 +000074
75# OS specific
76targetos=`uname -s`
77case $targetos in
bellard67b915a2004-03-31 23:37:16 +000078MINGW32*)
79mingw32="yes"
80;;
bellard7d132992003-03-06 23:23:54 +000081*) ;;
82esac
83
bellard97a847b2003-08-10 21:36:04 +000084##########################################
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
bellard7d132992003-03-06 23:23:54 +0000104# 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 ;;
bellard32ce6332003-04-11 00:16:16 +0000119 --interp-prefix=*) interp_prefix=`echo $opt | cut -d '=' -f 2`
120 ;;
bellard7d132992003-03-06 23:23:54 +0000121 --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 ;;
bellard97a847b2003-08-10 21:36:04 +0000137 --target-list=*) target_list=${opt#--target-list=}
bellardde83cd02003-06-15 20:25:43 +0000138 ;;
bellard7d132992003-03-06 23:23:54 +0000139 --enable-gprof) gprof="yes"
140 ;;
bellard43ce4df2003-06-09 19:53:12 +0000141 --static) static="yes"
142 ;;
bellard97a847b2003-08-10 21:36:04 +0000143 --disable-sdl) sdl="no"
144 ;;
bellard67b915a2004-03-31 23:37:16 +0000145 --enable-mingw32) mingw32="yes" ; cross_prefix="i386-mingw32-"
146 ;;
bellard7d132992003-03-06 23:23:54 +0000147 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
bellard67b915a2004-03-31 23:37:16 +0000159if 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
bellard7d132992003-03-06 23:23:54 +0000167if 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
bellard38e584a2003-08-10 22:14:22 +0000188if test "$cpu" = "powerpc" -o "$cpu" = "mips" -o "$cpu" = "s390" -o "$cpu" = "sparc" -o "$cpu" = "sparc64" -o "$cpu" = "m68k"; then
bellard7d132992003-03-06 23:23:54 +0000189 bigendian="yes"
190fi
191
192fi
193
bellarde8cd23d2003-06-25 16:08:13 +0000194# check gcc options support
bellard04369ff2003-03-20 22:33:23 +0000195cat > $TMPC <<EOF
196int main(void) {
bellard04369ff2003-03-20 22:33:23 +0000197}
198EOF
199
bellarde8cd23d2003-06-25 16:08:13 +0000200have_gcc3_options="no"
201if $cc -fno-reorder-blocks -fno-optimize-sibling-calls -o $TMPO $TMPC 2> /dev/null ; then
202 have_gcc3_options="yes"
bellard04369ff2003-03-20 22:33:23 +0000203fi
bellardca735202003-03-18 20:41:34 +0000204
bellard7d132992003-03-06 23:23:54 +0000205if 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]"
bellard1e43adf2003-09-30 20:54:24 +0000215echo " --interp-prefix=PREFIX where to find shared libraries, etc."
216echo " use %M for cpu name [$interp_prefix]"
bellard97a847b2003-08-10 21:36:04 +0000217echo " --target-list=LIST set target list [$target_list]"
bellard7d132992003-03-06 23:23:54 +0000218echo ""
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]"
bellard43ce4df2003-06-09 19:53:12 +0000224echo " --static enable static build [$static]"
bellard67b915a2004-03-31 23:37:16 +0000225echo " --enable-mingw32 enable Win32 cross compilation with mingw32"
bellard7d132992003-03-06 23:23:54 +0000226echo ""
227echo "NOTE: The object files are build at the place where configure is launched"
228exit 1
229fi
230
bellard5a671352003-10-01 00:13:48 +0000231mandir="$prefix/share/man"
232sharedir="$prefix/share/qemu"
233
bellard43ce4df2003-06-09 19:53:12 +0000234echo "Install prefix $prefix"
bellard5a671352003-10-01 00:13:48 +0000235echo "Manual directory $mandir"
236echo "BIOS directory $sharedir"
bellard43ce4df2003-06-09 19:53:12 +0000237echo "ELF interp prefix $interp_prefix"
bellard5a671352003-10-01 00:13:48 +0000238echo "Source path $source_path"
bellard43ce4df2003-06-09 19:53:12 +0000239echo "C compiler $cc"
240echo "make $make"
241echo "host CPU $cpu"
bellardde83cd02003-06-15 20:25:43 +0000242echo "host big endian $bigendian"
bellard97a847b2003-08-10 21:36:04 +0000243echo "target list $target_list"
bellard43ce4df2003-06-09 19:53:12 +0000244echo "gprof enabled $gprof"
245echo "static build $static"
bellard97a847b2003-08-10 21:36:04 +0000246echo "SDL support $sdl"
bellard67b915a2004-03-31 23:37:16 +0000247echo "mingw32 support $mingw32"
248
bellard97a847b2003-08-10 21:36:04 +0000249if test $sdl_too_old = "yes"; then
250echo "-> Your SDL version is too old - please upgrade to have FFplay/SDL support"
bellarde8cd23d2003-06-25 16:08:13 +0000251fi
bellard97a847b2003-08-10 21:36:04 +0000252
253config_mak="config-host.mak"
254config_h="config-host.h"
255
256echo "Creating $config_mak and $config_h"
257
258echo "# Automatically generated by configure - do not modify" > $config_mak
259echo "/* Automatically generated by configure - do not modify */" > $config_h
260
261echo "prefix=$prefix" >> $config_mak
bellard5a671352003-10-01 00:13:48 +0000262echo "mandir=$mandir" >> $config_mak
263echo "sharedir=$sharedir" >> $config_mak
264echo "#define CONFIG_QEMU_SHAREDIR \"$sharedir\"" >> $config_h
bellard97a847b2003-08-10 21:36:04 +0000265echo "MAKE=$make" >> $config_mak
266echo "CC=$cc" >> $config_mak
267if test "$have_gcc3_options" = "yes" ; then
268 echo "HAVE_GCC3_OPTIONS=yes" >> $config_mak
269fi
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
bellard67b915a2004-03-31 23:37:16 +0000275echo "EXESUF=$EXESUF" >> $config_mak
bellard97a847b2003-08-10 21:36:04 +0000276if test "$cpu" = "i386" ; then
277 echo "ARCH=i386" >> $config_mak
278 echo "#define HOST_I386 1" >> $config_h
bellardbc51c5c2004-03-17 23:46:04 +0000279elif test "$cpu" = "amd64" ; then
280 echo "ARCH=amd64" >> $config_mak
281 echo "#define HOST_AMD64 1" >> $config_h
bellard7d132992003-03-06 23:23:54 +0000282elif test "$cpu" = "armv4l" ; then
bellard97a847b2003-08-10 21:36:04 +0000283 echo "ARCH=arm" >> $config_mak
284 echo "#define HOST_ARM 1" >> $config_h
bellard7d132992003-03-06 23:23:54 +0000285elif test "$cpu" = "powerpc" ; then
bellard97a847b2003-08-10 21:36:04 +0000286 echo "ARCH=ppc" >> $config_mak
287 echo "#define HOST_PPC 1" >> $config_h
bellard7d132992003-03-06 23:23:54 +0000288elif test "$cpu" = "mips" ; then
bellard97a847b2003-08-10 21:36:04 +0000289 echo "ARCH=mips" >> $config_mak
290 echo "#define HOST_MIPS 1" >> $config_h
bellardfb3e5842003-03-29 17:32:36 +0000291elif test "$cpu" = "s390" ; then
bellard97a847b2003-08-10 21:36:04 +0000292 echo "ARCH=s390" >> $config_mak
293 echo "#define HOST_S390 1" >> $config_h
bellard295defa2003-04-07 21:31:29 +0000294elif test "$cpu" = "alpha" ; then
bellard97a847b2003-08-10 21:36:04 +0000295 echo "ARCH=alpha" >> $config_mak
296 echo "#define HOST_ALPHA 1" >> $config_h
bellardae228532003-05-13 18:59:59 +0000297elif test "$cpu" = "sparc" ; then
bellard97a847b2003-08-10 21:36:04 +0000298 echo "ARCH=sparc" >> $config_mak
299 echo "#define HOST_SPARC 1" >> $config_h
bellardae228532003-05-13 18:59:59 +0000300elif test "$cpu" = "sparc64" ; then
bellard97a847b2003-08-10 21:36:04 +0000301 echo "ARCH=sparc64" >> $config_mak
302 echo "#define HOST_SPARC64 1" >> $config_h
bellarda8baa8c2003-04-29 20:53:31 +0000303elif test "$cpu" = "ia64" ; then
bellard97a847b2003-08-10 21:36:04 +0000304 echo "ARCH=ia64" >> $config_mak
305 echo "#define HOST_IA64 1" >> $config_h
bellard38e584a2003-08-10 22:14:22 +0000306elif test "$cpu" = "m68k" ; then
bellard38ca2ab2004-03-13 18:32:13 +0000307 echo "ARCH=m68k" >> $config_mak
308 echo "#define HOST_M68K 1" >> $config_h
bellard7d132992003-03-06 23:23:54 +0000309else
310 echo "Unsupported CPU"
311 exit 1
312fi
313if test "$bigendian" = "yes" ; then
bellard97a847b2003-08-10 21:36:04 +0000314 echo "WORDS_BIGENDIAN=yes" >> $config_mak
315 echo "#define WORDS_BIGENDIAN 1" >> $config_h
316fi
bellard67b915a2004-03-31 23:37:16 +0000317if 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
bellard97a847b2003-08-10 21:36:04 +0000326if 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
bellard50863472003-10-28 23:04:01 +0000332 echo "#define CONFIG_STATIC 1" >> $config_h
bellard97a847b2003-08-10 21:36:04 +0000333fi
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
bellard590b7ee2004-01-04 23:49:02 +0000338 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
bellard97a847b2003-08-10 21:36:04 +0000350fi
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"
bellard1e43adf2003-09-30 20:54:24 +0000368[ "$target_cpu" = "sparc" ] && target_bigendian=yes
bellard67867302003-11-23 17:05:30 +0000369[ "$target_cpu" = "ppc" ] && target_bigendian=yes
bellard97a847b2003-08-10 21:36:04 +0000370target_softmmu="no"
371if expr $target : '.*-softmmu' > /dev/null ; then
372 target_softmmu="yes"
bellard7d132992003-03-06 23:23:54 +0000373fi
bellard997344f2003-10-27 21:10:39 +0000374target_user_only="no"
375if expr $target : '.*-user' > /dev/null ; then
376 target_user_only="yes"
377fi
bellardde83cd02003-06-15 20:25:43 +0000378
bellard97a847b2003-08-10 21:36:04 +0000379echo "Creating $config_mak, $config_h and $target_dir/Makefile"
380
381mkdir -p $target_dir
bellard69de9272004-02-16 21:40:43 +0000382if test "$target" = "arm-user" ; then
383 mkdir -p $target_dir/nwfpe
384fi
385
bellard97a847b2003-08-10 21:36:04 +0000386ln -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
391
392echo "include ../config-host.mak" >> $config_mak
393echo "#include \"../config-host.h\"" >> $config_h
bellard1e43adf2003-09-30 20:54:24 +0000394
395interp_prefix1=`echo "$interp_prefix" | sed "s/%M/$target_cpu/g"`
396echo "#define CONFIG_QEMU_PREFIX \"$interp_prefix1\"" >> $config_h
bellard97a847b2003-08-10 21:36:04 +0000397
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
bellardde83cd02003-06-15 20:25:43 +0000402elif test "$target_cpu" = "arm" ; then
bellard97a847b2003-08-10 21:36:04 +0000403 echo "TARGET_ARCH=arm" >> $config_mak
404 echo "#define TARGET_ARCH \"arm\"" >> $config_h
405 echo "#define TARGET_ARM 1" >> $config_h
bellard1e43adf2003-09-30 20:54:24 +0000406elif 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
bellard67867302003-11-23 17:05:30 +0000410elif 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
bellardde83cd02003-06-15 20:25:43 +0000414else
415 echo "Unsupported target CPU"
416 exit 1
417fi
418if test "$target_bigendian" = "yes" ; then
bellard97a847b2003-08-10 21:36:04 +0000419 echo "TARGET_WORDS_BIGENDIAN=yes" >> $config_mak
420 echo "#define TARGET_WORDS_BIGENDIAN 1" >> $config_h
421fi
422if test "$target_softmmu" = "yes" ; then
423 echo "CONFIG_SOFTMMU=yes" >> $config_mak
424 echo "#define CONFIG_SOFTMMU 1" >> $config_h
bellardde83cd02003-06-15 20:25:43 +0000425fi
bellard997344f2003-10-27 21:10:39 +0000426if test "$target_user_only" = "yes" ; then
427 echo "CONFIG_USER_ONLY=yes" >> $config_mak
428 echo "#define CONFIG_USER_ONLY 1" >> $config_h
429fi
bellardde83cd02003-06-15 20:25:43 +0000430
bellard97a847b2003-08-10 21:36:04 +0000431done # for target in $targets
bellard7d132992003-03-06 23:23:54 +0000432
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
bellard7d132992003-03-06 23:23:54 +0000444
bellard97a847b2003-08-10 21:36:04 +0000445rm -f $TMPO $TMPC $TMPE $TMPS