diff --git a/.gitignore b/.gitignore index ea5b1d9..0a437a2 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ first *.rom make.deps +gmon.out diff --git a/Makefile b/Makefile index b7b0aca..7545a80 100644 --- a/Makefile +++ b/Makefile @@ -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