forked from BenjaminSaldman/CPP_EX1_25
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmakefile
More file actions
52 lines (42 loc) · 1.52 KB
/
makefile
File metadata and controls
52 lines (42 loc) · 1.52 KB
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
49
50
51
52
CC = clang++
CCFLAGS = -Wall -std=c++17 -ggdb
SRCDIR = ./src
INCDIR = ./include
OBJDIR = ./obj
# Instructions
run:
@echo "Please consider the following:\n\tmake Main, \n\tmake valgrind, \n\tmake test \n\tmake clean."
.PHONY: clean valgrind test Main
#compile the main program
Main: $(OBJDIR)/main.o $(OBJDIR)/Graph.o $(OBJDIR)/Algorithms.o $(OBJDIR)/DataStructures.o
$(CC) $(CCFLAGS) -o $@ $^
./Main
#compile source files into object files
$(OBJDIR)/%.o: $(SRCDIR)/%.cpp
mkdir -p $(OBJDIR)
$(CC) $(CCFLAGS) -I$(INCDIR) -c $< -o $@
#compile only the main file
$(OBJDIR)/main.o: $(SRCDIR)/main/main.cpp
mkdir -p $(OBJDIR)
$(CC) $(CCFLAGS) -I$(INCDIR) -c $< -o $@
test: $(OBJDIR)/doctest.o $(OBJDIR)/Graph.o $(OBJDIR)/Algorithms.o $(OBJDIR)/DataStructures.o
$(CC) $(CCFLAGS) -o $@ $^
./test
#compile only the main file
$(OBJDIR)/doctest.o: $(SRCDIR)/doctest.cpp
mkdir -p $(OBJDIR)
$(CC) $(CCFLAGS) -I$(INCDIR) -c $< -o $@
#make sure to run 'ulimit -n 1024' before runing valgrind, thank you
#
#--leak-check=full: "each individual leak will be shown in detail"
#--show-leak-kinds=all: Show all of "definite, indirect, possible,
# reachable" leak kinds in the "full" report.
#--track-origins=yes: Favor useful output over speed. This tracks
# the origins of uninitialized values, which could be very useful
# for memory errors. Consider turning off if Valgrind is unacceptably slow.
#
valgrind:
ulimit -n 1024
valgrind --leak-check=full --show-leak-kinds=all --track-origins=yes ./Main
clean:
rm -rf $(OBJDIR) test Main *.o