tools/patchelf: update to 0.18.0
[openwrt/staging/dedeckeh.git] / scripts / qemustart
index 2d1f476dde8be2c4cb00d4dfafbde7679f131a7a..764b0e65afa24bb9f0d25eb19a0ac8b7c5631538 100755 (executable)
@@ -124,6 +124,11 @@ parse_args() {
        o_network=
        o_qemu_extra=()
        while [ "$#" -gt 0 ]; do
+               # Cmdline options for the script itself SHOULD try to be
+               # prefixed with two dashes to distinguish them from those for
+               # qemu executables.
+               #
+               # Also note that qemu accepts both --opt and -opt
                case "$1" in
                        --kernel) o_kernel="$2"; shift 2 ;;
                        --rootfs) o_rootfs="$2"; shift 2 ;;
@@ -153,7 +158,8 @@ parse_args() {
                return 1
        }
        [ -n "$o_subtarget" ] || o_subtarget="generic"
-       o_bindir="bin/targets/$o_target/$o_subtarget"
+       eval "$(grep ^CONFIG_BINARY_FOLDER= .config 2>/dev/null)"
+       o_bindir="${CONFIG_BINARY_FOLDER:-bin}/targets/$o_target/$o_subtarget"
 }
 
 start_qemu_armvirt() {
@@ -207,6 +213,7 @@ start_qemu_malta() {
        local is64
        local isel
        local qemu_exe
+       local cpu
        local rootfs="$o_rootfs"
        local kernel="$o_kernel"
        local mach="${o_mach:-malta}"
@@ -215,6 +222,7 @@ start_qemu_malta() {
        is64="$(echo $o_subtarget | grep -o 64)"
        [ "$(echo "$o_subtarget" | grep -o '^..')" = "le" ] && isel="el"
        qemu_exe="qemu-system-mips$is64$isel"
+       [ -n "$is64" ] && cpu="MIPS64R2-generic" || cpu="24Kc"
 
        [ -n "$kernel" ] || kernel="$o_bindir/openwrt-malta-${o_subtarget%-*}-vmlinux-initramfs.elf"
 
@@ -238,7 +246,7 @@ start_qemu_malta() {
                )
        }
 
-       "$qemu_exe" -machine "$mach" -nographic \
+       "$qemu_exe" -machine "$mach" -cpu "$cpu" -nographic \
                -kernel "$kernel" \
                "${o_qemu_extra[@]}"
 }
@@ -250,7 +258,7 @@ start_qemu_x86() {
        local mach="${o_mach:-pc}"
 
        [ -n "$rootfs" ] || {
-               rootfs="$o_bindir/openwrt-$o_target-${o_subtarget%-*}-combined-ext4.img"
+               rootfs="$o_bindir/openwrt-$o_target-${o_subtarget%-*}-generic-squashfs-combined.img"
                if [ ! -f "$rootfs" -a -s "$rootfs.gz" ]; then
                        gunzip "$rootfs.gz"
                fi