-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
60 lines (47 loc) · 1.17 KB
/
Makefile
File metadata and controls
60 lines (47 loc) · 1.17 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
53
54
55
56
57
58
59
60
# Compiler
CC := g++
# Compiler flags
CFLAGS := -Wall -Wextra -std=c++11
# Include directories
INC_DIR := include
# Source directories
SRC_DIR := src
# Object directories
OBJ_DIR := obj
# Binary directories
BIN_DIR := bin
# Source files
SRC := $(wildcard $(SRC_DIR)/*.cpp)
# Object files
OBJ := $(SRC:$(SRC_DIR)/%.cpp=$(OBJ_DIR)/%.o)
# Output executable
TARGET := $(BIN_DIR)/test_controller
# Library name
LIB_NAME := aiplayercontroller
# Library file
LIB := $(BIN_DIR)/lib$(LIB_NAME).a
# Compiler flags for building the library
LIB_FLAGS := -c
# Include directories for compilation
INC := -I$(INC_DIR)
# Main target
all: $(TARGET)
# Rule to build the executable
$(TARGET): $(OBJ) $(LIB)
@mkdir -p $(BIN_DIR)
$(CC) $(CFLAGS) $(INC) $(OBJ) -o $@ -L$(BIN_DIR) -l$(LIB_NAME)
# Rule to build the object files
$(OBJ_DIR)/%.o: $(SRC_DIR)/%.cpp
@mkdir -p $(OBJ_DIR)
$(CC) $(CFLAGS) $(INC) $(LIB_FLAGS) $< -o $@
# Rule to build the library
$(LIB): $(OBJ)
@mkdir -p $(BIN_DIR)
ar rcs $@ $^
# Phony target to clean the project
clean:
$(RM) -r $(OBJ_DIR) $(BIN_DIR)
# Phony target to clean and build the project
rebuild: clean all
# Declare the phony targets
.PHONY: all clean rebuild