]> Devi Nivas Git - cs3210-lab0.git/commitdiff
Infer qemu path, just like in JOS
authorAustin Clements <amdragon@mit.edu>
Tue, 31 Aug 2010 19:05:27 +0000 (15:05 -0400)
committerAustin Clements <amdragon@mit.edu>
Tue, 31 Aug 2010 19:05:27 +0000 (15:05 -0400)
Makefile

index 71f28b96de3fc13a0a1422e993469c17d3f21217..11b78c38b90175dc748b16d21532e73398759ea4 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -49,6 +49,23 @@ TOOLPREFIX := $(shell if i386-jos-elf-objdump -i 2>&1 | grep '^elf32-i386$$' >/d
        echo "***" 1>&2; exit 1; fi)
 endif
 
+# If the makefile can't find QEMU, specify its path here
+#QEMU = 
+
+# Try to infer the correct QEMU
+ifndef QEMU
+QEMU = $(shell if which qemu > /dev/null; \
+       then echo qemu; exit; \
+       else \
+       qemu=/Applications/Q.app/Contents/MacOS/i386-softmmu.app/Contents/MacOS/i386-softmmu; \
+       if test -x $$qemu; then echo $$qemu; exit; fi; fi; \
+       echo "***" 1>&2; \
+       echo "*** Error: Couldn't find a working QEMU executable." 1>&2; \
+       echo "*** Is the directory containing the qemu binary in your PATH" 1>&2; \
+       echo "*** or have you tried setting the QEMU variable in Makefile?" 1>&2; \
+       echo "***" 1>&2; exit 1)
+endif
+
 CC = $(TOOLPREFIX)gcc
 AS = $(TOOLPREFIX)gas
 LD = $(TOOLPREFIX)ld
@@ -159,27 +176,27 @@ bochs : fs.img xv6.img
 # try to generate a unique GDB port
 GDBPORT = $(shell expr `id -u` % 5000 + 25000)
 # QEMU's gdb stub command line changed in 0.11
-QEMUGDB = $(shell if qemu -help | grep -q '^-gdb'; \
+QEMUGDB = $(shell if $(QEMU) -help | grep -q '^-gdb'; \
        then echo "-gdb tcp::$(GDBPORT)"; \
        else echo "-s -p $(GDBPORT)"; fi)
 QEMUOPTS = -smp 2 -hdb fs.img xv6.img
 
 qemu: fs.img xv6.img
-       qemu -serial mon:stdio $(QEMUOPTS)
+       $(QEMU) -serial mon:stdio $(QEMUOPTS)
 
 qemu-nox: fs.img xv6.img
-       qemu -nographic $(QEMUOPTS)
+       $(QEMU) -nographic $(QEMUOPTS)
 
 .gdbinit: .gdbinit.tmpl
        sed "s/localhost:1234/localhost:$(GDBPORT)/" < $^ > $@
 
 qemu-gdb: fs.img xv6.img .gdbinit
        @echo "*** Now run 'gdb'." 1>&2
-       qemu -serial mon:stdio $(QEMUOPTS) -S $(QEMUGDB)
+       $(QEMU) -serial mon:stdio $(QEMUOPTS) -S $(QEMUGDB)
 
 qemu-nox-gdb: fs.img xv6.img .gdbinit
        @echo "*** Now run 'gdb'." 1>&2
-       qemu -nographic $(QEMUOPTS) -S $(QEMUGDB)
+       $(QEMU) -nographic $(QEMUOPTS) -S $(QEMUGDB)
 
 # CUT HERE
 # prepare dist for students