Build system: Added basic support for profiling

This commit is contained in:
(Tim) Efthimis Kritikos 2024-02-20 02:12:57 +00:00
parent af71b6e75e
commit 783a8bac23
2 changed files with 18 additions and 3 deletions

1
.gitignore vendored
View File

@ -2,3 +2,4 @@
first
*.rom
make.deps
gmon.out

View File

@ -1,4 +1,6 @@
QUIET=1
PROFILING=1
ADDRESS_SANITIZE=1
all:first
@ -22,11 +24,23 @@ else
Q =
endif
ifeq "${PROFILING}" "1"
CFLAGS += -pg
LDFLAGS += -pg
endif
ifeq "${ADDRESS_SANITIZE}" "1"
CFLAGS += -fsanitize=address -ggdb
LDFLAGS += -fsanitize=address -fsanitize=undefined -fsanitize=leak
endif
all:${MAIN_ROM}
first: ${OBJECT_FILES}
${QUIET_LINK}
${Q}gcc -ggdb $^ -fsanitize=address -fsanitize=undefined -fsanitize=leak -lncursesw -ltinfow -lm -o $@
${Q}gcc -ggdb $^ -lncursesw -ltinfow -lm -o $@ ${LDFLAGS}
gprof:
gprof first -b|less
%.rom:%.asm first
$(QUIET_FAS)
@ -34,9 +48,9 @@ first: ${OBJECT_FILES}
%.o:%.c
${QUIET_CC}
${Q}gcc -ggdb -c $< -Wall -Wextra -Werror -fsanitize=address
${Q}gcc -c $< -Wall -Wextra -Werror ${CFLAGS}
.PHONY: clean
clean:
${QUIET_CLEAN}
${Q} rm -f ${OBJECT_FILES} first ${ROMS}
${Q} rm -f ${OBJECT_FILES} first ${ROMS} gmon.out