diff --git a/aux/devel.sh b/aux/devel.sh index d6a748e..8dd31b5 100755 --- a/aux/devel.sh +++ b/aux/devel.sh @@ -2,21 +2,22 @@ set -xe +debugopt="" + if [ "$1" = "debug" ]; then - make -B all_kernel buildtype=debug -else - make -B all_kernel + debugopt="buildtype=debug" fi -make -B all_libsystem -make -B all_liballoc -make -B all_libprocess -make -B all_libterminal -make -B all_libstring -make -B all_libkb -make -B all_libaux -make -B all_libarena -make -B all_libioutil -make -B all_apps +make -B all_kernel "$debugopt" +make -B all_libsystem "$debugopt" +make -B all_liballoc "$debugopt" +make -B all_libprocess "$debugopt" +make -B all_libterminal "$debugopt" +make -B all_libstring "$debugopt" +make -B all_libkb "$debugopt" +make -B all_libaux "$debugopt" +make -B all_libarena "$debugopt" +make -B all_libioutil "$debugopt" +make -B all_apps "$debugopt" make -B all_dist ./aux/limine_iso_amd64.sh diff --git a/generic/flags.mk b/generic/flags.mk index d525f21..54a6658 100644 --- a/generic/flags.mk +++ b/generic/flags.mk @@ -5,9 +5,15 @@ cflags += -nostdinc \ -std=c11 \ -pedantic \ -Wall \ - -Wextra \ - -ffunction-sections \ - -fdata-sections + -Wextra + +ifeq ($(buildtype),debug) + cflags += -O0 -g +endif + +ifeq ($(buildtype),release) + cflags += -ffunction-sections -fdata-sections -Oz +endif cflags += -isystem ../include @@ -15,6 +21,14 @@ ldflags += -ffreestanding \ -nostdlib \ -fno-builtin \ -fuse-ld=lld \ - -static \ - -Wl,--gc-sections \ - -flto + -static + +ifeq ($(buildtype),debug) + ldflags += -g +endif + +ifeq ($(buildtype),release) + ldflags += -Wl,--gc-sections \ + -Wl,--strip-all \ + -flto +endif