-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
54 lines (40 loc) · 1.27 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
# Define the compiler
CXX=g++
# Define the compiler flags
CXXFLAGS=-std=c++11 -Wall -Werror=vla
# Define the debugging flags
DEBUGFLAGS=-g -O0
# Define the target executable
TARGET=main
TARGET_DEBUG=main_debug
# Define the source files
SRCS=main.cpp environment.cpp frame.cpp body.cpp kinematic.cpp odeSolver.cpp dynamic.cpp
# Define the object files from the source files
OBJS=$(SRCS:.cpp=.o)
OBJS_DEBUG=$(SRCS:.cpp=_debug.o)
# Define the build rule for the target
$(TARGET): $(OBJS)
$(CXX) $(CXXFLAGS) -o $(TARGET) $(OBJS)
# Define the build rule for the debug target
$(TARGET_DEBUG): $(OBJS_DEBUG)
$(CXX) $(CXXFLAGS) $(DEBUGFLAGS) -o $(TARGET_DEBUG) $(OBJS_DEBUG)
# Define the rule for compiling the source files into object files
%.o: %.cpp
$(CXX) $(CXXFLAGS) -c $< -o $@
# Define the rule for compiling the source files into debug object files
%_debug.o: %.cpp
$(CXX) $(CXXFLAGS) $(DEBUGFLAGS) -c $< -o $@
# Define the clean rule
clean:
del -f $(TARGET) $(TARGET_DEBUG) $(OBJS) $(OBJS_DEBUG)
# Define the rule for making the target
all: $(TARGET)
# Define the rule for running the executable
run: $(TARGET)
./$(TARGET)
make clean
# Define the rule for running the debug executable
rungdb: $(TARGET_DEBUG)
gdb ./$(TARGET_DEBUG)
make clean
.PHONY: clean all run rungdb