Add an option to create DEBUG build

This commit is contained in:
Anjia Wang 2024-03-30 12:10:44 -07:00
parent 5b39dc76f1
commit 19896c3515
No known key found for this signature in database
GPG key ID: 22C7D622A8302F5D

View file

@ -27,13 +27,22 @@ ifneq ($(CC), xlc)
CFLAGS_WARN_WALL = -Werror -Wall -Wextra
endif
ifdef DEBUG_BUILD
CFLAGS_DEBUG = -g
else
CFLAGS_DEBUG = -DNDEBUG
ifneq ($(CC), $(CROSS_COMPILE)clang)
LFLAGS_STRIP = -s
endif
endif
# for object file
# -Wa,-aln=test.s
# -save-temps
CFLAGS_BASE_LIST = -c
# CFLAGS_BASE_LIST = -S
CFLAGS_BASE = -O2 $(CFLAGS_BASE_LIST) $(CFLAGS_WARN_WALL) $(CFLAGS_WARN) \
-DNDEBUG -D_REENTRANT -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE \
$(CFLAGS_DEBUG) -D_REENTRANT -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE \
-fPIC
FLAGS_FLTO = -ffunction-sections
@ -207,10 +216,6 @@ $(O):
# LDFLAGS3= -Wl,--gc-sections
# -Wl,--print-gc-sections
ifneq ($(CC), $(CROSS_COMPILE)clang)
LFLAGS_STRIP = -s
endif
LFLAGS_ALL = $(LFLAGS_STRIP) $(MY_ARCH_2) $(LDFLAGS) $(FLAGS_FLTO) $(LD_arch) $(OBJS) $(MY_LIBS) $(LIB2)
# -s : GCC : Remove all symbol table and relocation information from the executable.