From 0cc3900e8854dc394922d3eea9ddbad06627fd6e Mon Sep 17 00:00:00 2001 From: apio Date: Wed, 7 Sep 2022 15:05:57 +0200 Subject: [PATCH] Make building with debug symbols conditional in the Makefile --- kernel/Makefile | 6 +++++- tools/debug.sh | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/kernel/Makefile b/kernel/Makefile index fce3a997..ea544c30 100644 --- a/kernel/Makefile +++ b/kernel/Makefile @@ -8,7 +8,7 @@ CXX := x86_64-elf-g++ AS := x86_64-elf-as NASM := nasm -CFLAGS := -g -Wall -Wextra -Werror -Os -ffreestanding -mno-red-zone -mno-mmx -mno-sse -mno-sse2 -fshort-wchar -mcmodel=kernel -I$(MOON_DIR)/include -isystem $(MOON_DIR)/include/std +CFLAGS := -Wall -Wextra -Werror -Os -ffreestanding -mno-red-zone -mno-mmx -mno-sse -mno-sse2 -fshort-wchar -mcmodel=kernel -I$(MOON_DIR)/include -isystem $(MOON_DIR)/include/std CXXFLAGS := -fno-rtti -fno-exceptions NASMFLAGS := -felf64 ASFLAGS := @@ -18,6 +18,10 @@ ifneq ($(MOON_BUILD_STABLE), 1) CFLAGS := ${CFLAGS} -D_MOON_SUFFIX="$(shell git rev-parse --short HEAD)" endif +ifeq ($(MOON_BUILD_DEBUG), 1) +CFLAGS := -ggdb ${CFLAGS} +endif + rwildcard=$(foreach d,$(wildcard $(1:=/*)),$(call rwildcard,$d,$2) $(filter $(subst *,%,$2),$d)) CXX_SRC = $(call rwildcard,$(MOON_SRC),*.cpp) diff --git a/tools/debug.sh b/tools/debug.sh index 81648bd6..71090fe6 100755 --- a/tools/debug.sh +++ b/tools/debug.sh @@ -3,6 +3,6 @@ set -e source $(dirname $0)/env.sh -tools/build-iso.sh +MOON_BUILD_DEBUG=1 tools/rebuild-iso.sh qemu-system-x86_64 -cdrom Luna.iso -smp 1 -m 256M -serial stdio -d int,cpu_reset -s -no-reboot $@ \ No newline at end of file