From 5f153a71d3905ec20b34f1db720441e5c2612890 Mon Sep 17 00:00:00 2001 From: Segcolt <9hmbzr275@mozmail.com> Date: Tue, 15 Oct 2024 22:56:17 -0300 Subject: [PATCH] Create makefile --- makefile | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 makefile diff --git a/makefile b/makefile new file mode 100644 index 0000000..d899f8e --- /dev/null +++ b/makefile @@ -0,0 +1,44 @@ +# Flag para alterar o padrão do compilador +standart = -std=c++11 + +# Flags para otimizar o arquivo executável +optimize_flags = -O3 -pipe -flto + +# Flags para ativar todos os avisos do compilador +warnings = -Wall -Wextra -Werror -Wshadow -Wformat=2 \ + -Wformat-overflow=2 -Wundef -Wconversion -fanalyzer -Wwrite-strings + +# Flags para depurar o código +sanitize = -fsanitize=address,undefined,pointer-compare,pointer-subtract +debug_flags = -ggdb3 -Og -DDEBUG -Wformat-truncation=2 $(sanitize) + +CC := /usr/bin/gcc +CXX := /usr/bin/g++ + +builddir := build +objectname = sabp +objectdir = $(builddir)/$(objectname) + +.PHONY: all debug + +all:set_flags compile + +debug:set_debug_flags compile + +compile:random.o sa.o + $(CXX) $(CPPFLAGS) $(builddir)/random.o $(builddir)/sa.o src/main.cpp -o $(objectdir) + +random.o: + $(CXX) $(CPPFLAGS) src/random.cpp -o $(builddir)/random.o -c + +sa.o: + $(CXX) $(CPPFLAGS) src/sa.cpp -o $(builddir)/sa.o -c + +set_flags: + $(eval override CPPFLAGS += $(warnings) $(optimize_flags) $(standart)) + +set_debug_flags: + $(eval override CPPFLAGS += $(warnings) $(sanitize) $(debug_flags)) + +clean: + rm -rf $(builddir)