Improved build commands

This commit is contained in:
Thomas Lovén 2022-01-02 20:19:53 +01:00
parent e0979ed357
commit 271ab8860f
8 changed files with 54 additions and 29 deletions

3
.gitignore vendored
View File

@ -1,5 +1,4 @@
dist/
build/
mittos.iso
sysroot/
*.d

View File

@ -2,23 +2,27 @@ ifeq ($(BUILDROOT),)
$(error BUILDROOT IS NOT SET!)
endif
TARGET := x86_64-elf
KERNELMAKE := TARGET=${TARGET} $(MAKE) -C src/kernel
DIST := $(BUILDROOT)/mittos.iso
SYSROOT := $(BUILDROOT)/sysroot
DIST := $(BUILDROOT)/dist/mittos.iso
$(DIST):
setup-grub.sh
$(DIST): $(SYSROOT)/kernel
$(BUILDROOT)/toolchain/setup-grub.sh
grub-mkrescue -o $@ $(SYSROOT)
kernel:
$(SYSROOT)/kernel: FORCE
ifeq ($(shell make -sqC src/kernel || echo 1), 1)
$(MAKE) -C src/kernel install
$(KERNELMAKE) install
endif
install: $(DIST)
.PHONY: FORCE
clean:
rm -rf $(DIST)
$(MAKE) -C src/kernel clean
$(KERNELMAKE) clean
.PHONY: install
distclean:
$(MAKE) clean
rm -rf $(SYSROOT)

11
dbg
View File

@ -1,3 +1,12 @@
#!/usr/bin/env bash
docker-compose -f toolchain/docker-compose.yml run --rm dbg "$@"
default="gdb -q -x /opt/toolchain/gdbinit"
if [[ "$1" == "-" ]]; then
shift
cmd="$@"
else
cmd="${default} $@"
fi
docker-compose -f toolchain/docker-compose.yml run --rm -u $(id -u):$(id -g) run ${cmd}

11
emu
View File

@ -1,3 +1,12 @@
#!/usr/bin/env bash
docker-compose -f toolchain/docker-compose.yml run --rm --name emul emul "$@"
default="qemu-system-x86_64 -s -S -cdrom /opt/mittos.iso -curses"
if [[ "$1" == "-" ]]; then
shift
cmd="$@"
else
cmd="${default} $@"
fi
docker-compose -f toolchain/docker-compose.yml run --rm --name emul -u $(id -u):$(id -g) run ${cmd}

11
make
View File

@ -1,3 +1,12 @@
#!/usr/bin/env bash
docker-compose -f toolchain/docker-compose.yml run --rm -u $(id -u):$(id -g) make make "$@"
default="make"
if [[ "$1" == "-" ]]; then
shift
cmd="$@"
else
cmd="${default} $@"
fi
docker-compose -f toolchain/docker-compose.yml run --rm -u $(id -u):$(id -g) build ${cmd}

View File

@ -1,5 +1,8 @@
ifeq ($(BUILDROOT),)
$(error BUILDROOT IS NOT SET!)
endif
CC := x86_64-elf-gcc
CC := ${TARGET}-gcc
SRC := $(wildcard **/*.[cS])
OBJ := $(patsubst %, %.o, $(basename $(SRC)))
@ -13,6 +16,7 @@ LDFLAGS := -n -nostdlib -lgcc -T Link.ld
kernel: $(OBJ)
$(LINK.c) $^ -o $@
# Automatic dependency tracking
DEP := $(OBJ:.o=.d)
DEPFLAGS = -MT $@ -MMD -MP -MF $*.d
$(OBJ): CPPFLAGS += $(DEPFLAGS)
@ -30,4 +34,5 @@ clean:
.PHONY: install
# Include automatic dependency rules
include $(DEP)

View File

@ -1,29 +1,18 @@
version: "3.5"
services:
make:
build:
image: thomasloven/mittos-build
build:
context: .
dockerfile: Dockerfile.build
volumes:
- ..:/opt
command: make
emul:
run:
image: thomasloven/mittos-run
build:
context: .
dockerfile: Dockerfile.run
volumes:
- ..:/opt
command: qemu-system-x86_64 -s -S -cdrom /opt/dist/mittos.iso -curses
dbg:
image: thomasloven/mittos-run
build:
context: .
dockerfile: Dockerfile.run
volumes:
- ..:/opt
command: gdb -q -x /opt/toolchain/gdbinit

View File

@ -5,6 +5,7 @@ target remote emul:1234
define q
monitor quit
quit
end
define reg