From e9d82dd950cb23e79c3425a636a5ddc95b65f904 Mon Sep 17 00:00:00 2001 From: Marvin Borner Date: Tue, 27 Apr 2021 19:15:45 +0200 Subject: Better makefile debugging structure --- Makefile | 7 ++++--- apps/Makefile | 4 ++++ run | 4 ++-- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/Makefile b/Makefile index 5d8d616..4583234 100644 --- a/Makefile +++ b/Makefile @@ -14,10 +14,11 @@ BUILD = $(PWD)/build/ KERNEL = $(PWD)/kernel/ LIBS = $(PWD)/libs/ -all: compile +ifeq ($(DEBUG), 1) + CFLAGS_DEFAULT += -Wno-error -ggdb3 -s -fsanitize=undefined -fstack-protector-all +endif -debug: CFLAGS_DEFAULT += -Wno-error -ggdb3 -s -fsanitize=undefined -fstack-protector-all -debug: compile +all: compile export diff --git a/apps/Makefile b/apps/Makefile index e4ea24e..98bec47 100644 --- a/apps/Makefile +++ b/apps/Makefile @@ -4,6 +4,10 @@ CFLAGS = $(CFLAGS_DEFAULT) -I$(LIBS)/ -I$(LIBS)/libc/inc/ -pie -fPIE -fPIC -DUSE LDFLAGS = --section-start=.text=0x42000000 -L$(BUILD) DIRS = $(wildcard */.) +ifneq ($(DEBUG), 1) + LDFLAGS += -pie -no-dynamic-linker +endif + export all: $(DIRS) diff --git a/run b/run index 66dbeca..3e41d71 100755 --- a/run +++ b/run @@ -140,9 +140,9 @@ make_build() { printf "\nBuilding...\n" if [ "$mode" = "debug" ] || [ "$MELVIX_DEBUG" = "1" ]; then - $MAKE -j $($NPROC) debug + $MAKE -j $($NPROC) DEBUG=1 else - $MAKE -j $($NPROC) + $MAKE -j $($NPROC) DEBUG=0 fi # Create disk image -- cgit v1.2.3