+glob() {
+ eval test -z '"${1#'"$2"'}"'
+}
+
+supported_hax_target() {
+ test "$hax" = "yes" || return 1
+ glob "$1" "*-softmmu" || return 1
+ case "${1%-softmmu}" in
+ i386|x86_64)
+ return 0
+ ;;
+ esac
+ return 1
+}
+
+supported_kvm_target() {
+ test "$kvm" = "yes" || return 1
+ glob "$1" "*-softmmu" || return 1
+ case "${1%-softmmu}:$cpu" in
+ arm:arm | aarch64:aarch64 | \
+ i386:i386 | i386:x86_64 | i386:x32 | \
+ x86_64:i386 | x86_64:x86_64 | x86_64:x32 | \
+ mips:mips | mipsel:mips | \
+ ppc:ppc | ppcemb:ppc | ppc64:ppc | \
+ ppc:ppc64 | ppcemb:ppc64 | ppc64:ppc64 | \
+ s390x:s390x)
+ return 0
+ ;;
+ esac
+ return 1
+}
+
+supported_xen_target() {
+ test "$xen" = "yes" || return 1
+ glob "$1" "*-softmmu" || return 1
+ # Only i386 and x86_64 provide the xenpv machine.
+ case "${1%-softmmu}" in
+ i386|x86_64)
+ return 0
+ ;;
+ esac
+ return 1
+}
+
+supported_target() {
+ case "$1" in
+ *-softmmu)
+ ;;
+ *-linux-user)
+ if test "$linux" != "yes"; then
+ print_error "Target '$target' is only available on a Linux host"
+ return 1
+ fi
+ ;;
+ *-bsd-user)
+ if test "$bsd" != "yes"; then
+ print_error "Target '$target' is only available on a BSD host"
+ return 1
+ fi
+ ;;
+ *)
+ print_error "Invalid target name '$target'"
+ return 1
+ ;;
+ esac
+ test "$tcg" = "yes" && return 0
+ supported_kvm_target "$1" && return 0
+ supported_xen_target "$1" && return 0
+ supported_hax_target "$1" && return 0
+ print_error "TCG disabled, but hardware accelerator not available for '$target'"
+ return 1
+}
+