xv6

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

commit fa7208ce8ed31932a8738fbbecd46e29f55a3c6c
parent 0ee8ff4d83f8a744b00c7e589b31dc0aadb6afe6
Author: Brian Swetland <swetland@frotz.net>
Date:   Sat, 21 Sep 2019 22:42:19 -0700

Fix stuff to work better out of the box

- remove QEMU and TOOLPREFIX guessing goop
- default to 64bit build
- happy now on my ubuntu 18.04.2 lts machine

Todo (someday):
- really overhaul the makefile
- allow building of 32bit/64bit side-by-side

Diffstat:
MMakefile | 43+++++++------------------------------------
1 file changed, 7 insertions(+), 36 deletions(-)

diff --git a/Makefile b/Makefile @@ -1,13 +1,17 @@ -include local.mk -ifneq ("$(X64)","") +X64 ?= yes + +ifeq ("$(X64)","yes") BITS = 64 XOBJS = kobj/vm64.o XFLAGS = -m64 -DX64 -mcmodel=kernel -mtls-direct-seg-refs -mno-red-zone LDFLAGS = -m elf_x86_64 -nodefaultlibs +QEMU ?= qemu-system-x86_64 else XFLAGS = -m32 LDFLAGS = -m elf_i386 -nodefaultlibs +QEMU ?= qemu-system-i386 endif OPT ?= -O0 @@ -57,39 +61,6 @@ endif # Using native tools (e.g., on X86 Linux) #TOOLPREFIX = -# Try to infer the correct TOOLPREFIX if not set -ifndef TOOLPREFIX -TOOLPREFIX := $(shell if i386-jos-elf-objdump -i 2>&1 | grep '^elf32-i386$$' >/dev/null 2>&1; \ - then echo 'i386-jos-elf-'; \ - elif objdump -i 2>&1 | grep 'elf32-i386' >/dev/null 2>&1; \ - then echo ''; \ - else echo "***" 1>&2; \ - echo "*** Error: Couldn't find an i386-*-elf version of GCC/binutils." 1>&2; \ - echo "*** Is the directory with i386-jos-elf-gcc in your PATH?" 1>&2; \ - echo "*** If your i386-*-elf toolchain is installed with a command" 1>&2; \ - echo "*** prefix other than 'i386-jos-elf-', set your TOOLPREFIX" 1>&2; \ - echo "*** environment variable to that prefix and run 'make' again." 1>&2; \ - echo "*** To turn off this error, run 'gmake TOOLPREFIX= ...'." 1>&2; \ - 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 @@ -98,7 +69,7 @@ OBJDUMP = $(TOOLPREFIX)objdump CFLAGS = -fno-pic -static -fno-builtin -fno-strict-aliasing -Wall -MD -ggdb -fno-omit-frame-pointer CFLAGS += -ffreestanding -fno-common -nostdlib -Iinclude -gdwarf-2 $(XFLAGS) $(OPT) CFLAGS += $(shell $(CC) -fno-stack-protector -E -x c /dev/null >/dev/null 2>&1 && echo -fno-stack-protector) -ASFLAGS = -gdwarf-2 -Wa,-divide -Iinclude $(XFLAGS) +ASFLAGS = -fno-pic -gdwarf-2 -Wa,-divide -Iinclude $(XFLAGS) xv6.img: out/bootblock out/kernel.elf fs.img dd if=/dev/zero of=xv6.img count=10000 @@ -236,7 +207,7 @@ QEMUGDB = $(shell if $(QEMU) -help | grep -q '^-gdb'; \ ifndef CPUS CPUS := 2 endif -QEMUOPTS = -net none -hdb fs.img xv6.img -smp $(CPUS) -m 512 $(QEMUEXTRA) +QEMUOPTS = -net none -hda xv6.img -hdb fs.img -smp $(CPUS) -m 512 $(QEMUEXTRA) qemu: fs.img xv6.img $(QEMU) -serial mon:stdio $(QEMUOPTS)