Infer qemu path, just like in JOS
This commit is contained in:
parent
0f0456ec53
commit
1e8035be53
1 changed files with 22 additions and 5 deletions
27
Makefile
27
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)
|
echo "***" 1>&2; exit 1; fi)
|
||||||
endif
|
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
|
CC = $(TOOLPREFIX)gcc
|
||||||
AS = $(TOOLPREFIX)gas
|
AS = $(TOOLPREFIX)gas
|
||||||
LD = $(TOOLPREFIX)ld
|
LD = $(TOOLPREFIX)ld
|
||||||
|
@ -159,27 +176,27 @@ bochs : fs.img xv6.img
|
||||||
# try to generate a unique GDB port
|
# try to generate a unique GDB port
|
||||||
GDBPORT = $(shell expr `id -u` % 5000 + 25000)
|
GDBPORT = $(shell expr `id -u` % 5000 + 25000)
|
||||||
# QEMU's gdb stub command line changed in 0.11
|
# 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)"; \
|
then echo "-gdb tcp::$(GDBPORT)"; \
|
||||||
else echo "-s -p $(GDBPORT)"; fi)
|
else echo "-s -p $(GDBPORT)"; fi)
|
||||||
QEMUOPTS = -smp 2 -hdb fs.img xv6.img
|
QEMUOPTS = -smp 2 -hdb fs.img xv6.img
|
||||||
|
|
||||||
qemu: 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-nox: fs.img xv6.img
|
||||||
qemu -nographic $(QEMUOPTS)
|
$(QEMU) -nographic $(QEMUOPTS)
|
||||||
|
|
||||||
.gdbinit: .gdbinit.tmpl
|
.gdbinit: .gdbinit.tmpl
|
||||||
sed "s/localhost:1234/localhost:$(GDBPORT)/" < $^ > $@
|
sed "s/localhost:1234/localhost:$(GDBPORT)/" < $^ > $@
|
||||||
|
|
||||||
qemu-gdb: fs.img xv6.img .gdbinit
|
qemu-gdb: fs.img xv6.img .gdbinit
|
||||||
@echo "*** Now run 'gdb'." 1>&2
|
@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
|
qemu-nox-gdb: fs.img xv6.img .gdbinit
|
||||||
@echo "*** Now run 'gdb'." 1>&2
|
@echo "*** Now run 'gdb'." 1>&2
|
||||||
qemu -nographic $(QEMUOPTS) -S $(QEMUGDB)
|
$(QEMU) -nographic $(QEMUOPTS) -S $(QEMUGDB)
|
||||||
|
|
||||||
# CUT HERE
|
# CUT HERE
|
||||||
# prepare dist for students
|
# prepare dist for students
|
||||||
|
|
Loading…
Reference in a new issue