-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmakefile
53 lines (42 loc) · 1.14 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
# To build the program (which is called golf-sim by default), simply type:
# make
#
# To clean up and remove the compiled binary and other generated files, type:
# make clean
#
# To build AND run the program, type:
# make run
#
# The name of your binary.
NAME = golf-sim
# Flags passed to the preprocessor.
CPPFLAGS += -Wall -MMD -MP -Isrc -g -std=c++11
# ALL .cpp files.
SRCS = $(shell find src -name '*.cpp')
OBJS = $(SRCS:src/%.cpp=bin/%.o)
DEPS = $(SRCS:src/%.cpp=bin/%.d)
# Libraries needed by the binary.
ifeq ($(shell uname),Darwin)
LIBS = -lboost_thread-mt -lboost_system
else
LIBS = -lboost_thread -lboost_system
endif
# Default target, which builds your binary.
$(NAME): $(OBJS)
$(CXX) $(CPP_FLAGS) $^ -o $(NAME) $(LIBS)
# Build and run the program.
run: $(NAME)
./$(NAME) input_files/easy
# Remove all generated files.
clean:
rm -rf $(NAME)* bin/
# Ensure the bin/ directories are created.
$(SRCS): | bin
# Mirror the directory structure of src/ under bin/
bin:
mkdir -p $(shell find src -type d | sed "s/src/bin/")
# Build objects.
bin/%.o: src/%.cpp
$(CXX) $(CPPFLAGS) $< -c -o $@
# Auto dependency management.
-include $(DEPS)