-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
77 lines (59 loc) · 1.25 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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
# Source files directory
S = srcs/
# Object files directory
O = objs/
# Include files directory
I = incs/
# Dependency files directory
D = deps/
# Name of your program
NAME = a_star
# list of your source files
SRCS = main.cpp Map.cpp MapAnalyser.cpp PathFinder.cpp Point.cpp
# Compiler
CC = c++
# Compiler flags
CFLAGS += -Wall -Wextra -g -std=c++98
# Linker flags
LDFLAGS =
# Run command for tests
RUN_COMMAND = ./$(NAME) maps/no_obstacle
# The rest is automatic
CFLAGS += $(addprefix -I,$I)
SRCS := $(addprefix $S,$(SRCS))
OBJS := $(SRCS:$S%=$O%.o)
DEPS := $(SRCS:$S%=$D%.d)
DFLAGS = -MT $(@:$O%.o=$S%) -MMD -MP -MF $(@:$O%.o=$D%.d)
RM = /bin/rm -rf
.PHONY: all
all: $(NAME)
$(NAME): $(OBJS)
@echo "Linking $(NAME)"
$(CC) $^ -o $@
# Object directory generation
$O:
@mkdir $O
# Dependency directory generation
$D:
@mkdir $D
# Object files generation
$(OBJS): $O%.o:$S% | $O $D
@mkdir -p $(@D)
@mkdir -p $(@D:$O%=$D%)
@echo "Compiling $@"
@$(CC) $(CFLAGS) $(DFLAGS) -c $(@:$O%.o=$S%) -o $@
.PHONY: clean
clean:
@echo "Cleaning up..."
@$(RM) $D $O
.PHONY: fclean
fclean: clean
@echo "Everything!"
@$(RM) $(NAME)
.PHONY: re
re: fclean all
.PHONY: run
run: $(NAME)
$(RUN_COMMAND)
valgrind: $(NAME)
valgrind --leak-check=full $(RUN_COMMAND)