summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAustin Clements <[email protected]>2010-08-31 15:05:27 -0400
committerAustin Clements <[email protected]>2010-08-31 15:05:27 -0400
commit1e8035be535781e2b317881ab421ac33c7de0299 (patch)
tree025de1080b2f011c642a3254f152f6350347548f
parent0f0456ec53d2739282eccf62b22f7c933d7cbae5 (diff)
downloadxv6-labs-1e8035be535781e2b317881ab421ac33c7de0299.tar.gz
xv6-labs-1e8035be535781e2b317881ab421ac33c7de0299.tar.bz2
xv6-labs-1e8035be535781e2b317881ab421ac33c7de0299.zip
Infer qemu path, just like in JOS
-rw-r--r--Makefile27
1 files changed, 22 insertions, 5 deletions
diff --git a/Makefile b/Makefile
index 71f28b9..11b78c3 100644
--- 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