#!/bin/sh # # qemu configure script (c) 2003 Fabrice Bellard # # set temporary file name if test ! -z "$TMPDIR" ; then TMPDIR1="${TMPDIR}" elif test ! -z "$TEMPDIR" ; then TMPDIR1="${TEMPDIR}" else TMPDIR1="/tmp" fi TMPC="${TMPDIR1}/qemu-conf-${RANDOM}-$$-${RANDOM}.c" TMPO="${TMPDIR1}/qemu-conf-${RANDOM}-$$-${RANDOM}.o" TMPE="${TMPDIR1}/qemu-conf-${RANDOM}-$$-${RANDOM}.exe" trap "rm -f $TMPC $TMPO $TMPE ; exit" 0 2 3 15 compile_object() { $cc $QEMU_CFLAGS -c -o $TMPO $TMPC > /dev/null 2> /dev/null } compile_prog() { local_cflags="$1" local_ldflags="$2" $cc $QEMU_CFLAGS $local_cflags -o $TMPE $TMPC $LDFLAGS $local_ldflags > /dev/null 2> /dev/null } # default parameters cpu="" static="no" sparc_cpu="" cross_prefix="" cc="gcc" block_drv_whitelist="" host_cc="gcc" ar="ar" make="make" ld="ld" helper_cflags="" libs_softmmu="" # parse CC options first for opt do optarg=`expr "x$opt" : 'x[^=]*=\(.*\)'` case "$opt" in --cross-prefix=*) cross_prefix="$optarg" ;; --cc=*) cc="$optarg" ;; --cpu=*) cpu="$optarg" ;; --extra-cflags=*) QEMU_CFLAGS="$optarg $QEMU_CFLAGS" ;; --extra-ldflags=*) LDFLAGS="$optarg $LDFLAGS" ;; --sparc_cpu=*) sparc_cpu="$optarg" case $sparc_cpu in v7|v8|v8plus|v8plusa) cpu="sparc" ;; v9) cpu="sparc64" ;; *) echo "undefined SPARC architecture. Exiting"; exit 1 ;; esac ;; esac done # OS specific # Using uname is really, really broken. Once we have the right set of checks # we can eliminate it's usage altogether cc="${cross_prefix}${cc}" ar="${cross_prefix}${ar}" ld="${cross_prefix}${ld}" # default flags for all hosts QEMU_CFLAGS="-fno-strict-aliasing $QEMU_CFLAGS" CFLAGS="-g $CFLAGS" QEMU_CFLAGS="-Wall -Wundef -Wendif-labels -Wwrite-strings -Wmissing-prototypes $QEMU_CFLAGS" QEMU_CFLAGS="-Wstrict-prototypes -Wredundant-decls $QEMU_CFLAGS" QEMU_CFLAGS="-D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE $QEMU_CFLAGS" QEMU_CFLAGS="-U_FORTIFY_SOURCE $QEMU_CFLAGS" QEMU_CFLAGS="-I. -I\$(SRC_PATH) $QEMU_CFLAGS" LDFLAGS="-g $LDFLAGS" gcc_flags="-Wold-style-declaration -Wold-style-definition" cat > $TMPC << EOF int main(void) { } EOF for flag in $gcc_flags; do if compile_prog "$QEMU_CFLAGS" "$flag" ; then QEMU_CFLAGS="$flag $QEMU_CFLAGS" fi done # check that the C compiler works. cat > $TMPC < $TMPC < /dev/null | /usr/bin/grep -v "no ar in"` if test -z "$sol_ar" ; then echo "Error: No path includes ar" if test -f /usr/ccs/bin/ar ; then echo "Add /usr/ccs/bin to your path and rerun configure" fi exit 1 fi fi feature_not_found() { feature=$1 echo "ERROR" echo "ERROR: User requested feature $feature" echo "ERROR: configure was not able to find it" echo "ERROR" exit 1; } if test -z "$cross_prefix" ; then # --- # big/little endian test cat > $TMPC << EOF #include int main(int argc, char ** argv){ volatile uint32_t i=0x01234567; return (*((uint8_t*)(&i))) == 0x67; } EOF if compile_prog "" "" ; then $TMPE && bigendian="yes" else echo big/little test failed fi else # if cross compiling, cannot launch a program, so make a static guess case "$cpu" in armv4b|hppa|m68k|mips|mips64|ppc|ppc64|s390|s390x|sparc|sparc64) bigendian=yes ;; esac fi # host long bits test hostlongbits="32" case "$cpu" in x86_64|alpha|ia64|sparc64|ppc64|s390x) hostlongbits=64 ;; esac ########################################## # zlib check cat > $TMPC << EOF #include int main(void) { zlibVersion(); return 0; } EOF if compile_prog "" "-lz" ; then : else echo echo "Error: zlib check failed" echo "Make sure to have the zlib libs and headers installed." echo exit 1 fi ########################################## # Sparse probe if test "$sparse" != "no" ; then if test -x "$(which cgcc 2>/dev/null)"; then sparse=yes else if test "$sparse" = "yes" ; then feature_not_found "sparse" fi sparse=no fi fi ########################################## # fnmatch() probe, used for ACL routines fnmatch="no" cat > $TMPC << EOF #include int main(void) { fnmatch("foo", "foo", 0); return 0; } EOF if compile_prog "" "" ; then fnmatch="yes" fi ########################################## # pthread probe PTHREADLIBS_LIST="-lpthread -lpthreadGC2" pthread=no cat > $TMPC << EOF #include int main(void) { pthread_create(0,0,0,0); return 0; } EOF for pthread_lib in $PTHREADLIBS_LIST; do if compile_prog "" "$pthread_lib" ; then pthread=yes LIBS="$pthread_lib $LIBS" break fi done if test "$mingw32" != yes -a "$pthread" = no; then echo echo "Error: pthread check failed" echo "Make sure to have the pthread libs and headers installed." echo exit 1 fi ########################################## # iovec probe cat > $TMPC < #include #include int main(void) { struct iovec iov; return 0; } EOF iovec=no if compile_prog "" "" ; then iovec=yes fi ########################################## # preadv probe cat > $TMPC < #include #include int main(void) { preadv; } EOF preadv=no if compile_prog "" "" ; then preadv=yes fi # check if pipe2 is there pipe2=no cat > $TMPC << EOF #define _GNU_SOURCE #include #include int main(void) { int pipefd[2]; pipe2(pipefd, O_CLOEXEC); return 0; } EOF if compile_prog "" "" ; then pipe2=yes fi # check if accept4 is there accept4=no cat > $TMPC << EOF #define _GNU_SOURCE #include #include int main(void) { accept4(0, NULL, NULL, SOCK_CLOEXEC); return 0; } EOF if compile_prog "" "" ; then accept4=yes fi # Search for bswap_32 function byteswap_h=no cat > $TMPC << EOF #include int main(void) { return bswap_32(0); } EOF if compile_prog "" "" ; then byteswap_h=yes fi # Search for bswap_32 function bswap_h=no cat > $TMPC << EOF #include #include #include int main(void) { return bswap32(0); } EOF if compile_prog "" "" ; then bswap_h=yes fi ########################################## # Do we need librt cat > $TMPC < #include int main(void) { clockid_t id; return clock_gettime(id, NULL); } EOF if compile_prog "" "" ; then : elif compile_prog "" "-lrt" ; then LIBS="-lrt $LIBS" fi if test "$darwin" != "yes" -a "$mingw32" != "yes" -a "$solaris" != yes -a \ "$aix" != "yes" ; then libs_softmmu="-lutil $libs_softmmu" fi ########################################## # check if the compiler defines offsetof need_offsetof=yes cat > $TMPC << EOF #include int main(void) { struct s { int f; }; return offsetof(struct s, f); } EOF if compile_prog "" "" ; then need_offsetof=no fi ########################################## # check if the compiler understands attribute warn_unused_result # # This could be smarter, but gcc -Werror does not error out even when warning # about attribute warn_unused_result gcc_attribute_warn_unused_result=no cat > $TMPC << EOF #if defined(__GNUC__) && (__GNUC__ < 4) && defined(__GNUC_MINOR__) && (__GNUC__ < 4) #error gcc 3.3 or older #endif int main(void) { return 0;} EOF if compile_prog "" ""; then gcc_attribute_warn_unused_result=yes fi ########################################## # check if we have fdatasync fdatasync=no cat > $TMPC << EOF #include int main(void) { return fdatasync(0); } EOF if compile_prog "" "" ; then fdatasync=yes fi # End of CC checks # After here, no more $cc or $ld runs if test "$debug" = "no" ; then CFLAGS="-O2 $CFLAGS" fi # Consult white-list to determine whether to enable werror # by default. Only enable by default for git builds z_version=`cut -f3 -d. $source_path/VERSION` if test -z "$werror" ; then if test "$z_version" = "50" -a \ "$linux" = "yes" ; then werror="yes" else werror="no" fi fi # Disable zero malloc errors for official releases unless explicitly told to # enable/disable if test -z "$zero_malloc" ; then if test "$z_version" = "50" ; then zero_malloc="no" else zero_malloc="yes" fi fi if test "$werror" = "yes" ; then QEMU_CFLAGS="-Werror $QEMU_CFLAGS" fi if test "$solaris" = "no" ; then if $ld --version 2>/dev/null | grep "GNU ld" >/dev/null 2>/dev/null ; then LDFLAGS="-Wl,--warn-common $LDFLAGS" fi fi echo "Source path $source_path" echo "C compiler $cc" echo "Host C compiler $host_cc" echo "CFLAGS $CFLAGS" echo "QEMU_CFLAGS $QEMU_CFLAGS" echo "LDFLAGS $LDFLAGS" echo "make $make" echo "host CPU $cpu" echo "host big endian $bigendian" echo "target list arm-softmmu" echo "tcg debug enabled $debug_tcg" echo "gprof enabled $gprof" echo "sparse enabled $sparse" echo "strip binaries $strip_opt" echo "profiler $profiler" echo "static build $static" echo "-Werror enabled $werror" echo "mingw32 support $mingw32" echo "Block whitelist $block_drv_whitelist" if test -n "$sparc_cpu"; then echo "Target Sparc Arch $sparc_cpu" fi echo "preadv support $preadv" echo "fdatasync $fdatasync" config_host_mak="config-host.mak" config_host_ld="config-host.ld" echo "# Automatically generated by configure - do not modify" > $config_host_mak printf "# Configured with:" >> $config_host_mak printf " '%s'" "$0" "$@" >> $config_host_mak echo >> $config_host_mak case "$cpu" in i386|x86_64|alpha|cris|hppa|ia64|m68k|microblaze|mips|mips64|ppc|ppc64|s390|s390x|sparc|sparc64) ARCH=$cpu ;; armv4b|armv4l) ARCH=arm ;; *) echo "Unsupported CPU = $cpu" exit 1 ;; esac echo "ARCH=$ARCH" >> $config_host_mak if test "$debug_tcg" = "yes" ; then echo "CONFIG_DEBUG_TCG=y" >> $config_host_mak fi if test "$debug" = "yes" ; then echo "CONFIG_DEBUG_EXEC=y" >> $config_host_mak fi if test "$strip_opt" = "yes" ; then echo "STRIP_OPT=-s" >> $config_host_mak fi if test "$bigendian" = "yes" ; then echo "HOST_WORDS_BIGENDIAN=y" >> $config_host_mak fi echo "HOST_LONG_BITS=$hostlongbits" >> $config_host_mak if test "$mingw32" = "yes" ; then echo "CONFIG_WIN32=y" >> $config_host_mak else echo "CONFIG_POSIX=y" >> $config_host_mak fi if test "$linux" = "yes" ; then echo "CONFIG_LINUX=y" >> $config_host_mak fi if test "$darwin" = "yes" ; then echo "CONFIG_DARWIN=y" >> $config_host_mak fi if test "$aix" = "yes" ; then echo "CONFIG_AIX=y" >> $config_host_mak fi if test "$solaris" = "yes" ; then echo "CONFIG_SOLARIS=y" >> $config_host_mak echo "CONFIG_SOLARIS_VERSION=$solarisrev" >> $config_host_mak if test "$needs_libsunmath" = "yes" ; then echo "CONFIG_NEEDS_LIBSUNMATH=y" >> $config_host_mak fi fi if test "$static" = "yes" ; then echo "CONFIG_STATIC=y" >> $config_host_mak LDFLAGS="-static $LDFLAGS" fi if test $profiler = "yes" ; then echo "CONFIG_PROFILER=y" >> $config_host_mak fi echo "CONFIG_BDRV_WHITELIST=$block_drv_whitelist" >> $config_host_mak if test "$fnmatch" = "yes" ; then echo "CONFIG_FNMATCH=y" >> $config_host_mak fi qemu_version=`head $source_path/VERSION` echo "VERSION=$qemu_version" >>$config_host_mak echo "PKGVERSION=$pkgversion" >>$config_host_mak echo "SRC_PATH=$source_path" >> $config_host_mak if test "$pipe2" = "yes" ; then echo "CONFIG_PIPE2=y" >> $config_host_mak fi if test "$accept4" = "yes" ; then echo "CONFIG_ACCEPT4=y" >> $config_host_mak fi if test "$byteswap_h" = "yes" ; then echo "CONFIG_BYTESWAP_H=y" >> $config_host_mak fi if test "$bswap_h" = "yes" ; then echo "CONFIG_MACHINE_BSWAP_H=y" >> $config_host_mak fi if test "$iovec" = "yes" ; then echo "CONFIG_IOVEC=y" >> $config_host_mak fi if test "$preadv" = "yes" ; then echo "CONFIG_PREADV=y" >> $config_host_mak fi if test "$need_offsetof" = "yes" ; then echo "CONFIG_NEED_OFFSETOF=y" >> $config_host_mak fi if test "$gcc_attribute_warn_unused_result" = "yes" ; then echo "CONFIG_GCC_ATTRIBUTE_WARN_UNUSED_RESULT=y" >> $config_host_mak fi if test "$fdatasync" = "yes" ; then echo "CONFIG_FDATASYNC=y" >> $config_host_mak fi # XXX: suppress that if [ "$bsd" = "yes" ] ; then echo "CONFIG_BSD=y" >> $config_host_mak fi if test "$zero_malloc" = "yes" ; then echo "CONFIG_ZERO_MALLOC=y" >> $config_host_mak fi echo "MAKE=$make" >> $config_host_mak echo "CC=$cc" >> $config_host_mak echo "HOST_CC=$host_cc" >> $config_host_mak if test "$sparse" = "yes" ; then echo "CC := REAL_CC=\"\$(CC)\" cgcc" >> $config_host_mak echo "HOST_CC := REAL_CC=\"\$(HOST_CC)\" cgcc" >> $config_host_mak echo "QEMU_CFLAGS += -Wbitwise -Wno-transparent-union -Wno-old-initializer -Wno-non-pointer-null" >> $config_host_mak fi echo "AR=$ar" >> $config_host_mak echo "LD=$ld" >> $config_host_mak echo "CFLAGS=$CFLAGS" >> $config_host_mak echo "QEMU_CFLAGS=$QEMU_CFLAGS" >> $config_host_mak echo "HELPER_CFLAGS=$helper_cflags" >> $config_host_mak echo "LDFLAGS=$LDFLAGS" >> $config_host_mak echo "ARLIBS_BEGIN=$arlibs_begin" >> $config_host_mak echo "ARLIBS_END=$arlibs_end" >> $config_host_mak echo "LIBS+=$LIBS" >> $config_host_mak echo "EXESUF=$EXESUF" >> $config_host_mak # generate list of library paths for linker script $ld --verbose -v 2> /dev/null | grep SEARCH_DIR > ${config_host_ld} if test -f ${config_host_ld}~ ; then if cmp -s $config_host_ld ${config_host_ld}~ ; then mv ${config_host_ld}~ $config_host_ld else rm ${config_host_ld}~ fi fi config_target_mak=arm-softmmu/config-target.mak mkdir -p arm-softmmu mkdir -p arm-softmmu/fpu mkdir -p arm-softmmu/tcg # # don't use ln -sf as not all "ln -sf" over write the file/link # rm -f arm-softmmu/Makefile ln -s $source_path/Makefile-small.target arm-softmmu/Makefile echo "# Automatically generated by configure - do not modify" > $config_target_mak gdb_xml_files="arm-core.xml arm-vfp.xml arm-vfp3.xml arm-neon.xml" target_phys_bits=32 echo "TARGET_ARCH=arm" >> $config_target_mak echo "TARGET_ARM=y" >> $config_target_mak echo "TARGET_BASE_ARCH=arm" >> $config_target_mak if [ $target_phys_bits -lt $hostlongbits ] ; then target_phys_bits=$hostlongbits fi echo "TARGET_PHYS_ADDR_BITS=$target_phys_bits" >> $config_target_mak echo "CONFIG_SOFTMMU=y" >> $config_target_mak echo "LIBS+=$libs_softmmu" >> $config_target_mak echo "HWDIR=../libhw$target_phys_bits" >> $config_target_mak echo "subdir-arm-softmmu: subdir-libhw$target_phys_bits" >> $config_host_mak list="" if test ! -z "$gdb_xml_files" ; then for x in $gdb_xml_files; do list="$list $source_path/gdb-xml/$x" done echo "TARGET_XML_FILES=$list" >> $config_target_mak fi echo "CONFIG_SOFTFLOAT=y" >> $config_target_mak #echo "CONFIG_NOSOFTFLOAT=y" >> $config_target_mak # generate QEMU_CFLAGS/LDFLAGS for targets cflags="" ldflags="" if test "$ARCH" = "sparc64" ; then cflags="-I\$(SRC_PATH)/tcg/sparc $cflags" elif test "$ARCH" = "s390x" ; then cflags="-I\$(SRC_PATH)/tcg/s390 $cflags" else cflags="-I\$(SRC_PATH)/tcg/\$(ARCH) $cflags" fi cflags="-I\$(SRC_PATH)/tcg $cflags" cflags="-I\$(SRC_PATH)/fpu $cflags" for i in $ARCH arm ; do case "$i" in alpha) echo "CONFIG_ALPHA_DIS=y" >> $config_target_mak ;; arm) echo "CONFIG_ARM_DIS=y" >> $config_target_mak ;; cris) echo "CONFIG_CRIS_DIS=y" >> $config_target_mak ;; hppa) echo "CONFIG_HPPA_DIS=y" >> $config_target_mak ;; i386|x86_64) echo "CONFIG_I386_DIS=y" >> $config_target_mak ;; m68k) echo "CONFIG_M68K_DIS=y" >> $config_target_mak ;; microblaze) echo "CONFIG_MICROBLAZE_DIS=y" >> $config_target_mak ;; mips*) echo "CONFIG_MIPS_DIS=y" >> $config_target_mak ;; ppc*) echo "CONFIG_PPC_DIS=y" >> $config_target_mak ;; s390*) echo "CONFIG_S390_DIS=y" >> $config_target_mak ;; sh4) echo "CONFIG_SH4_DIS=y" >> $config_target_mak ;; sparc*) echo "CONFIG_SPARC_DIS=y" >> $config_target_mak ;; esac done case "$ARCH" in alpha) # Ensure there's only a single GP cflags="-msmall-data $cflags" ;; ia64) cflags="-mno-sdata $cflags" ;; esac if test "$gprof" = "yes" ; then echo "TARGET_GPROF=yes" >> $config_target_mak ldflags="-p $ldflags" echo "GPROF_CFLAGS=-p" >> $config_target_mak fi linker_script="-Wl,-T../config-host.ld -Wl,-T,\$(SRC_PATH)/\$(ARCH).ld" case "$ARCH" in ia64) ldflags="-Wl,-G0 $linker_script -static $ldflags" ;; esac echo "LDFLAGS+=$ldflags" >> $config_target_mak echo "QEMU_CFLAGS+=$cflags" >> $config_target_mak # build tree in object directory if source path is different from current one if test "$source_path_used" = "yes" ; then FILES="Makefile-small" # remove the link and recreate it, as not all "ln -sf" overwrite the link for f in $FILES ; do rm -f $f ln -s $source_path/$f $f done fi for hwlib in 32 64; do d=libhw$hwlib mkdir -p $d rm -f $d/Makefile ln -s $source_path/Makefile-small.hw $d/Makefile echo "QEMU_CFLAGS+=-DTARGET_PHYS_ADDR_BITS=$hwlib" >> $d/config.mak done