+# Determine what linker flags to use to force archive inclusion
+check_linker_flags()
+{
+ w2=
+ if test "$2" ; then
+ w2=-Wl,$2
+ fi
+ compile_prog "" "-Wl,$1 ${w2}"
+}
+
+cat > $TMPC << EOF
+int main(void) { }
+EOF
+if check_linker_flags --whole-archive --no-whole-archive ; then
+ # GNU ld
+ arlibs_begin="-Wl,--whole-archive"
+ arlibs_end="-Wl,--no-whole-archive"
+elif check_linker_flags -z,allextract -z,defaultextract ; then
+ # Solaris ld
+ arlibs_begin"=-Wl,-z,allextract"
+ arlibs_end="-Wl,-z,defaultextract"
+elif check_linker_flags -all_load ; then
+ # Mac OS X
+ arlibs_begin="-all_load"
+ arlibs_end=""
+else
+ echo "Error: your linker does not support --whole-archive or -z."
+ exit 1
+fi
+
+if test "$darwin" != "yes" -a "$mingw32" != "yes" -a "$solaries" != yes -a \
+ "$aix" != "yes" ; then
+ libs_softmmu="-lutil $libs_softmmu"
+fi
+
+# End of CC checks
+# After here, no more $cc or $ld runs
+
+# default flags for all hosts
+QEMU_CFLAGS="-fno-strict-aliasing $QEMU_CFLAGS"
+CFLAGS="-g $CFLAGS"
+if test "$debug" = "no" ; then
+ CFLAGS="-O2 $CFLAGS"
+fi
+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) -MMD -MP -MT \$@ $QEMU_CFLAGS"
+LDFLAGS="-g $LDFLAGS"
+
+# Consult white-list to determine whether to enable werror
+# by default. Only enable by default for git builds
+if test -z "$werror" ; then
+ z_version=`cut -f3 -d. $source_path/VERSION`
+ if test "$z_version" = "50" -a \
+ "$linux" = "yes" ; then
+ werror="yes"
+ else
+ werror="no"
+ 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