Create makefile
This commit is contained in:
parent
901e3a00ff
commit
5f153a71d3
44
makefile
Normal file
44
makefile
Normal file
@ -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)
|
||||
Loading…
x
Reference in New Issue
Block a user