-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmakefile
48 lines (41 loc) · 1.26 KB
/
makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# Variaveis
CC=g++
CFLAGS=-Wall -g
EXEC=./tp3 # nome do executavel que sera gerado, nao troque
BUILD=./build/
SRC=./src/
INCLUDE=./include/
COMP=Computador/
# Expansoes de variaveis
OBJETOS:=$(patsubst $(SRC)%cpp, $(BUILD)%o, $(wildcard $(SRC)$(COMP)*.cpp))
OBJ_COMPIL_COMMAND=$(CC) $(CFLAGS) -I $(INCLUDE)$(COMP) -c $< -o $@
# Regras
$(EXEC): $(BUILD)main.o
$(CC) $(CFLAGS) -o $(EXEC) $(BUILD)main.o $(BUILD)$(COMP)*.o
$(BUILD)$(COMP) ::
@-mkdir --parents $@
$(BUILD)main.o: $(BUILD)$(COMP) $(SRC)main.cpp $(OBJETOS)
$(CC) $(CFLAGS) -I $(INCLUDE)$(COMP) -c $(SRC)main.cpp -o $(BUILD)main.o
$(BUILD)%.o :: $(SRC)%.cpp $(INCLUDE)%.hpp
$(OBJ_COMPIL_COMMAND)
.PHONY: clean mem
clean ::
$(info Deleting all the directories and subfolders:)
$(info $(BUILD))
@echo
@echo Are you sure? \(Y/N\)
@read choice && \
if [[ "$$choice" = "y" ]] || [[ "$$choice" = "Y" ]]; then \
{ rm --verbose --preserve-root --recursive $(BUILD) && \
rm --verbose --preserve-root $(EXEC) && \
echo Cleaning successful.; } || \
{ let "status = $$?"; \
echo Cleaning of some directory failed; \
echo Shell exit status: $$status; \
exit $$status; \
} \
else \
echo No cleaning was performed.; \
fi
mem:
valgrind --leak-check=full --show-leak-kinds=all $(EXEC) ./testcases/EX1.txt