Adjusted build system to make it more portable
This commit is contained in:
10
Makefile
10
Makefile
@@ -45,22 +45,22 @@ LDFLAGS := $(LDFLAGS) -g
|
||||
ALL_KERNEL_OBJECT_FILES := $(KERNEL_OBJ) $(ARCH_OBJ) $(LIBC_OBJ)
|
||||
|
||||
$(BUILD_DIR)/$(KERNEL_EXEC): $(ALL_KERNEL_OBJECT_FILES)
|
||||
@echo " \033[1;36mLINK\033[0m \033[1m$@\033[0m"
|
||||
@printf " \033[1;36mLD\033[0m \033[1m$@\033[0m\n"
|
||||
@mkdir -p $(@D)
|
||||
@$(LD) $^ -o $@ $(LDFLAGS) $(ARCH_LDFLAGS)
|
||||
|
||||
$(BUILD_DIR)/%.o: %.S
|
||||
@echo " \033[1;32mASM\033[0m $<"
|
||||
@printf " \033[1;32mAS\033[0m $<\n"
|
||||
@mkdir -p $(@D)
|
||||
@$(ASM) $< -o $@ -c $(ASMFLAGS) $(ARCH_ASMFLAGS)
|
||||
|
||||
$(BUILD_DIR)/%.o: %.c
|
||||
@echo " \033[1;32mCC\033[0m $<"
|
||||
@printf " \033[1;32mCC\033[0m $<\n"
|
||||
@mkdir -p $(@D)
|
||||
@$(CC) $< -o $@ -c $(CFLAGS) $(ARCH_CFLAGS)
|
||||
|
||||
clean:
|
||||
@echo " \033[1;93mCLEAN\033[0m Deleting build artefacts."
|
||||
@printf " \033[1;93mRM\033[0m Deleting build artefacts.\n"
|
||||
@rm -rf $(BUILD_DIR)
|
||||
|
||||
|
||||
@@ -69,7 +69,7 @@ all: $(BUILD_DIR)/$(KERNEL_EXEC)
|
||||
$(BUILD_DIR)/compile_commands.json:
|
||||
@$(MAKE) clean
|
||||
|
||||
@echo " \033[1;93mGEN\033[0m Generating compiler database."
|
||||
@printf " \033[1;93mGEN\033[0m Generating compiler database.\n"
|
||||
|
||||
@./tools/make/generate_compile_commands.py
|
||||
|
||||
|
||||
@@ -12,18 +12,16 @@ $(BUILD_DIR)/$(KERNEL_EXEC).elf32: $(BUILD_DIR)/$(KERNEL_EXEC)
|
||||
@printf '\x03\x00' | dd of=$(BUILD_DIR)/$(KERNEL_EXEC).elf32 bs=1 seek=18 count=2 conv=notrunc 2> /dev/null
|
||||
|
||||
run: $(BUILD_DIR)/$(KERNEL_EXEC) $(BUILD_DIR)/$(KERNEL_EXEC).elf32
|
||||
@echo " \033[1;93mBOOT\033[0m $<"
|
||||
@printf " \033[1;93mQEMU\033[0m $<\n"
|
||||
|
||||
@$(QEMU) -kernel $(BUILD_DIR)/$(KERNEL_EXEC).elf32 -monitor stdio
|
||||
|
||||
debug: $(BUILD_DIR)/$(KERNEL_EXEC) $(BUILD_DIR)/$(KERNEL_EXEC).elf32
|
||||
@echo " \033[1;93mDEBUG\033[0m $<"
|
||||
|
||||
@./tools/kernel-debug/debug_session.sh \
|
||||
tools/kernel-debug/gdb_session_init \
|
||||
tools/kernel-debug/lldb_session_init \
|
||||
$(QEMU) \
|
||||
-kernel $(BUILD_DIR)/$(KERNEL_EXEC).elf32 -S -s \
|
||||
-curses -serial file:$(BUILD_DIR)/socks.log $(QEMU_FLAGS)
|
||||
-display curses -serial file:$(BUILD_DIR)/socks.log $(QEMU_FLAGS)
|
||||
|
||||
|
||||
|
||||
@@ -5,19 +5,21 @@ lldb_cfg=$2
|
||||
shift 2
|
||||
|
||||
if command -v gdb &> /dev/null; then
|
||||
printf " \033[93;1mGDB\033[0m boot/socks_kernel\n"
|
||||
tmux \
|
||||
new-session -d -s hz-debug "sleep 0.3; gdb -tui -x $gdb_cfg" \; \
|
||||
split-window -h -l 80 \; \
|
||||
split-window -v -l 25 "$@"\; \
|
||||
select-pane -t 0
|
||||
elif command -v lldb &> /dev/null; then
|
||||
printf " \033[93;1mLLDB\033[0m boot/socks_kernel\n"
|
||||
tmux \
|
||||
new-session -d -s hz-debug "sleep 0.1; lldb --source $lldb_cfg" \; \
|
||||
split-window -h -l 80 \; \
|
||||
split-window -v -l 25 "$@"\; \
|
||||
select-pane -t 0
|
||||
else
|
||||
echo "No debugger available"
|
||||
printf " \033[91;1mERR\033[0m No debugger available\n"
|
||||
exit -1
|
||||
fi
|
||||
|
||||
|
||||
Reference in New Issue
Block a user